LCOV - code coverage report
Current view: top level - HLT/CALO - AliHLTCaloClusterizerComponent.cxx (source / functions) Hit Total Coverage
Test: coverage.info Lines: 18 141 12.8 %
Date: 2016-06-14 17:26:59 Functions: 3 13 23.1 %

          Line data    Source code
       1             : // $Id: AliHLTCaloClusterizerComponent.cxx 36709 2009-11-12 16:57:55Z odjuvsla $
       2             : 
       3             : /**************************************************************************
       4             :  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
       5             :  *                                                                        *
       6             :  * Authors: Oystein Djuvsland <oysteind@ift.uib.no>                       *
       7             :  *                                                                        *
       8             :  * Permission to use, copy, modify and distribute this software and its   *
       9             :  * documentation strictly for non-commercial purposes is hereby granted   *
      10             :  * without fee, provided that the above copyright notice appears in all   *
      11             :  * copies and that both the copyright notice and this permission notice   *
      12             :  * appear in the supporting documentation. The authors make no claims     *
      13             :  * about the suitability of this software for any purpose. It is          *
      14             :  * provided "as is" without express or implied warranty.                  *
      15             :  **************************************************************************/
      16             : 
      17             : #include "AliHLTCaloClusterizerComponent.h"
      18             : #include "AliHLTCaloClusterizer.h"
      19             : #include "AliHLTCaloClusterAnalyser.h"
      20             : #include "AliHLTCaloRecPointDataStruct.h"
      21             : #include "AliHLTCaloRecPointHeaderStruct.h"
      22             : #include "AliHLTCaloDigitDataStruct.h"
      23             : #include "AliHLTCaloDigitContainerDataStruct.h"
      24             : #include "AliHLTCaloDefinitions.h"
      25             : #include "AliHLTCaloClusterDataStruct.h"
      26             : #include "AliHLTCaloRecoParamHandler.h"
      27             : #include "TString.h"
      28             : 
      29             : /** @file   AliHLTCaloClusterizerComponent.cxx
      30             :     @author Oystein Djuvsland
      31             :     @date
      32             :     @brief  A clusterizer component for PHOS HLT
      33             :  */
      34             : 
      35             : // see header file for class documentation
      36             : // or
      37             : // refer to README to build package
      38             : // or
      39             : // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
      40             : 
      41           6 : ClassImp(AliHLTCaloClusterizerComponent);
      42             : 
      43             : AliHLTCaloClusterizerComponent::AliHLTCaloClusterizerComponent(TString det):
      44           6 :             AliHLTCaloProcessor(),
      45          18 :             AliHLTCaloConstantsHandler(det),
      46           6 :             fDataOrigin(0),
      47           6 :             fAnalyserPtr(0),
      48           6 :             fRecoParamsPtr(0),
      49           6 :             fClusterizerPtr(0),
      50           6 :             fDigitsPointerArray(0),
      51           6 :             fOutputDigitsArray(0),
      52           6 :             fDigitCount(0),
      53           6 :             fCopyDigitsToOuput(kTRUE),
      54           6 :             fUseInputSpec(kFALSE)
      55          24 : {
      56             :   //See headerfile for documentation
      57          12 :   fUseInputSpec = det=="EMCAL";
      58             : 
      59             : 
      60           6 : }
      61             : 
      62           0 : AliHLTCaloClusterizerComponent::~AliHLTCaloClusterizerComponent()
      63          12 : {
      64             :   //See headerfile for documentation
      65           6 :   if(fAnalyserPtr)
      66             :   {
      67           0 :     delete fAnalyserPtr;
      68           0 :     fAnalyserPtr = 0;
      69           0 :   }
      70           6 : }
      71             : 
      72             : int
      73             : AliHLTCaloClusterizerComponent::DoEvent(const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks,
      74             :     AliHLTComponentTriggerData& /*trigData*/, AliHLTUInt8_t* outputPtr, AliHLTUInt32_t& size,
      75             :     std::vector<AliHLTComponentBlockData>& outputBlocks)
      76             : {
      77             :   //See headerfile for documentation
      78             : 
      79           0 :   if (blocks == 0) return 0;
      80             : 
      81             :   UInt_t offset           = 0;
      82           0 :   UInt_t mysize           = 0;
      83             :   Int_t nRecPoints        = 0;
      84             :   Int_t nDigits           = 0;
      85             :   Int_t digCount          = 0;
      86             : 
      87           0 :   UInt_t availableSize = size;
      88             :   AliHLTUInt8_t* outBPtr;
      89             :   outBPtr = outputPtr;
      90             :   const AliHLTComponentBlockData* iter = 0;
      91             :   unsigned long ndx;
      92             : 
      93             :   UInt_t specification = 0;
      94             : 
      95             :   AliHLTCaloDigitDataStruct *digitDataPtr = 0;
      96             : 
      97             :   // Adding together all the digits, should be put in standalone method
      98           0 :   for ( ndx = 0; ndx < evtData.fBlockCnt; ndx++ )
      99             :   {
     100           0 :     iter = blocks+ndx;
     101             : 
     102           0 :     if (iter->fDataType == (AliHLTCaloDefinitions::fgkDigitDataType|fDataOrigin))
     103             :     {
     104             : 
     105             :       // Update the number of digits
     106           0 :       nDigits = iter->fSize/sizeof(AliHLTCaloDigitDataStruct);
     107           0 :       availableSize -= iter->fSize;
     108             : 
     109           0 :       if(fUseInputSpec)
     110           0 :         specification = iter->fSpecification;
     111             :       else
     112           0 :         specification = specification|iter->fSpecification;
     113             : 
     114           0 :       digitDataPtr = reinterpret_cast<AliHLTCaloDigitDataStruct*>(iter->fPtr);
     115             : 
     116             :       // We copy the digits to the digit buffer used by the clusterizer
     117             :       // This is convinient since we want the digits from all DDLs before starting
     118             :       // Could be changed if this is a bottle neck.
     119           0 :       for (Int_t i = 0; i < nDigits; i++)
     120             :       {
     121             :         // If we have a digit based on a low gain channel, but there has been no high gain channel,
     122             :         // we shouldn't use it since we are then very sensitive to noise (e.g. for PHOS 1 LG ADC count = 40 MeV)
     123           0 :         if(digitDataPtr->fHgPresent)
     124             :         {
     125           0 :           fDigitsPointerArray[digCount] = digitDataPtr;
     126           0 :           digCount++;
     127           0 :           digitDataPtr++;
     128           0 :         }
     129             :       }
     130           0 :     }
     131             :   }
     132             : 
     133           0 :   if (digCount > 0)
     134             :   {
     135             : 
     136           0 :     AliHLTCaloClusterHeaderStruct* caloClusterHeaderPtr = reinterpret_cast<AliHLTCaloClusterHeaderStruct*>(outBPtr);
     137           0 :     caloClusterHeaderPtr->fNDigits = digCount;
     138             : 
     139           0 :     outBPtr += sizeof(AliHLTCaloClusterHeaderStruct);
     140           0 :     mysize += sizeof(AliHLTCaloClusterHeaderStruct);
     141             : 
     142             :     // Sort the digit pointers
     143             :     //      qsort(fDigitsPointerArray, digCount, sizeof(AliHLTCaloDigitDataStruct*), CompareDigits);
     144             : 
     145             : 
     146           0 :     if (fCopyDigitsToOuput)
     147             :     {
     148             :       // Copy the digits to the output
     149           0 :       fOutputDigitsArray = reinterpret_cast<AliHLTCaloDigitDataStruct*>(outBPtr);
     150             : 
     151           0 :       for (Int_t n = 0; n < digCount; n++)
     152             :       {
     153           0 :         memcpy(outBPtr, fDigitsPointerArray[n], sizeof(AliHLTCaloDigitDataStruct));
     154             :         //fOutputDigitsArray[n] = reinterpret_cast<AliHLTCaloDigitDataStruct*>(outBPtr);
     155           0 :         outBPtr = outBPtr + sizeof(AliHLTCaloDigitDataStruct);
     156             :       }
     157           0 :     }
     158             : 
     159             :     // Update the size of the output we have used, needs to be removed if we don't push the digits
     160           0 :     mysize += digCount*sizeof(AliHLTCaloDigitDataStruct);
     161             : 
     162             :     // Do the clusterisation
     163           0 :     nRecPoints = fClusterizerPtr->ClusterizeEvent(digCount);
     164             : 
     165             :     HLTDebug("Number of rec points found: %d", nRecPoints);
     166             : 
     167             :     // Give the cluster output to the analyser
     168           0 :     fAnalyserPtr->SetCaloClusterData(reinterpret_cast<AliHLTCaloClusterDataStruct*>(outBPtr));
     169             : 
     170             :     // Give the rec points to the analyser (input)
     171           0 :     fAnalyserPtr->SetRecPointArray(fClusterizerPtr->GetRecPoints(), nRecPoints);
     172             : 
     173             :     // Give the digits to the analyser
     174             :     //fAnalyserPtr->SetDigitDataArray(fOutputDigitsArray);
     175           0 :     fAnalyserPtr->SetDigitDataArray(fDigitsPointerArray);
     176             : 
     177             :     // Then we create the clusters
     178           0 :     Int_t nClusters = fAnalyserPtr->CreateClusters(nRecPoints, size, mysize);
     179             : 
     180           0 :     if (nClusters < 0)
     181             :     {
     182           0 :       HLTError("Error in clusterisation");
     183           0 :       caloClusterHeaderPtr->fNClusters = 0;
     184           0 :     }
     185             :     else
     186             :     {
     187           0 :       caloClusterHeaderPtr->fNClusters = nClusters;
     188             :     }
     189             : 
     190             :     HLTDebug("Number of clusters: %d", nRecPoints);
     191             : 
     192           0 :     AliHLTComponentBlockData bd;
     193           0 :     FillBlockData( bd );
     194           0 :     bd.fOffset = offset;
     195           0 :     bd.fSize = mysize;
     196           0 :     bd.fDataType = kAliHLTDataTypeCaloCluster | fDataOrigin;
     197           0 :     bd.fSpecification = specification;
     198           0 :     outputBlocks.push_back( bd );
     199           0 :   }
     200             : 
     201           0 :   size = mysize;
     202             : 
     203             :   return 0;
     204           0 : }
     205             : 
     206             : int
     207             : AliHLTCaloClusterizerComponent::Reconfigure(const char* cdbEntry, const char* /*chainId*/)
     208             : {
     209             :   // see header file for class documentation
     210             : 
     211             :   const char* path="HLT/ConfigPHOS/ClusterizerComponent";
     212             : 
     213           0 :   if (cdbEntry) path = cdbEntry;
     214             : 
     215           0 :   return ConfigureFromCDBTObjString(path);
     216             : }
     217             : 
     218             : int
     219             : AliHLTCaloClusterizerComponent::ScanConfigurationArgument(int argc, const char **argv)
     220             : {
     221             :   //See header file for documentation
     222             : 
     223           0 :   if (argc <= 0) return 0;
     224             : 
     225           0 :   for(int i=0;i<argc;i++){
     226           0 :     TString argument=argv[i];
     227             : 
     228           0 :     if (argument.CompareTo("-digitthreshold") == 0)
     229             :     {
     230           0 :       if (++i >= argc) return -EPROTO;
     231           0 :       argument = argv[i];
     232           0 :       fClusterizerPtr->SetEmcMinEnergyThreshold(argument.Atof());
     233           0 :     }
     234             : 
     235           0 :     if (argument.CompareTo("-recpointthreshold") == 0)
     236             :     {
     237           0 :       if (++i >= argc) return -EPROTO;
     238           0 :       argument = argv[i];
     239           0 :       fClusterizerPtr->SetEmcClusteringThreshold(argument.Atof());
     240           0 :     }
     241             : 
     242           0 :     if (argument.CompareTo("-cutonsinglecell") == 0)
     243             :     {
     244           0 :       if (++i >= argc) return -EPROTO;
     245           0 :       argument = argv[i];
     246           0 :       fAnalyserPtr->SetCutOnSingleCellClusters(true, argument.Atof());
     247           0 :     }
     248             : 
     249           0 :     if (argument.CompareTo("-emctimegate") == 0)
     250             :     {
     251           0 :       if (++i >= argc) return -EPROTO;
     252           0 :       argument = argv[i];
     253           0 :       fClusterizerPtr->SetEmcTimeGate(argument.Atof());
     254           0 :     }
     255             : 
     256           0 :     if (argument.CompareTo("-sortbyposition") == 0)
     257             :     {
     258           0 :       fClusterizerPtr->SetSortDigitsByPosition();
     259             :     }
     260           0 :   }
     261             : 
     262           0 :   return 0;
     263           0 : }
     264             : 
     265             : int
     266             : AliHLTCaloClusterizerComponent::DoInit(int argc, const char** argv )
     267             : {
     268             :   //See headerfile for documentation
     269             : 
     270           0 :   if (fCaloConstants->GetDETNAME() == "EMCAL") 
     271             : 
     272           0 :     fDigitsPointerArray = new AliHLTCaloDigitDataStruct*[2*fCaloConstants->GetNXCOLUMNSMOD()*fCaloConstants->GetNZROWSMOD()];
     273             :   else 
     274           0 :     fDigitsPointerArray = new AliHLTCaloDigitDataStruct*[fCaloConstants->GetNXCOLUMNSMOD()*fCaloConstants->GetNZROWSMOD()];
     275             : 
     276           0 :   fClusterizerPtr->SetDigitArray(fDigitsPointerArray);
     277             : 
     278           0 :   fClusterizerPtr->SetSortDigitsByEnergy();
     279             : 
     280           0 :   fClusterizerPtr->SetDetector(TString(fCaloConstants->GetDETNAME()));
     281             : 
     282           0 :   fAnalyserPtr = new AliHLTCaloClusterAnalyser();
     283             : 
     284           0 :   if (fCaloConstants->GetDETNAME() == "PHOS")
     285             :   {
     286           0 :     fAnalyserPtr->SetClusterType(kPHOSCluster);
     287           0 :   }
     288           0 :   else if (fCaloConstants->GetDETNAME() == "EMCAL")
     289             :   {
     290           0 :     fAnalyserPtr->SetClusterType(kEMCALClusterv1);
     291           0 :   }
     292             :   else
     293             :   {
     294           0 :     fAnalyserPtr->SetClusterType(kUndef);
     295             :   }
     296           0 :   InitialiseGeometry();
     297           0 :   if (fRecoParamsPtr)
     298             :   {
     299           0 :     if (!fRecoParamsPtr->GetParametersFromCDB())
     300             :     {
     301           0 :       fAnalyserPtr->SetRecoParamHandler(fRecoParamsPtr);
     302           0 :       fClusterizerPtr->SetEmcClusteringThreshold(fRecoParamsPtr->GetRecPointThreshold());
     303           0 :       fClusterizerPtr->SetEmcMinEnergyThreshold(fRecoParamsPtr->GetRecPointMemberThreshold());
     304           0 :       HLTInfo("Setting thresholds for clusterizer: %f, %f", fRecoParamsPtr->GetRecPointThreshold(), fRecoParamsPtr->GetRecPointMemberThreshold());
     305             :     }
     306             :   }
     307             :   //
     308             : 
     309             :   //  const char *path = "HLT/ConfigPHOS/ClusterizerComponent";
     310             : 
     311             :   //  ConfigureFromCDBTObjString(path);
     312             : 
     313           0 :   ScanConfigurationArgument(argc, argv);
     314             : 
     315           0 :   return 0;
     316           0 : }
     317             : int AliHLTCaloClusterizerComponent::DoDeinit()
     318             : {
     319             :   // See header file for documentation
     320           0 :   if (fDigitsPointerArray)
     321             :   {
     322           0 :     delete []  fDigitsPointerArray;
     323           0 :     fDigitsPointerArray = 0;
     324           0 :   }
     325           0 :   if (fClusterizerPtr)
     326             :   {
     327           0 :     delete fClusterizerPtr;
     328           0 :     fClusterizerPtr = 0;
     329           0 :   }
     330           0 :   if (fAnalyserPtr)
     331             :   {
     332           0 :     delete fAnalyserPtr;
     333           0 :     fAnalyserPtr = 0;
     334           0 :   }
     335           0 :   return 0;
     336             : }
     337             : 
     338             : Int_t
     339             : AliHLTCaloClusterizerComponent::CompareDigits(const void *dig0, const void *dig1)
     340             : {
     341             :   // See header file for documentation
     342           0 :   return (*((AliHLTCaloDigitDataStruct**)(dig0)))->fID - (*((AliHLTCaloDigitDataStruct**)(dig1)))->fID;
     343             : 
     344             :   //return (*((AliHLTCaloDigitDataStruct**)(dig0)))->fID - (*((AliHLTCaloDigitDataStruct**)(dig1)))->fID;
     345             : }

Generated by: LCOV version 1.11