]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - HLT/CALO/AliHLTCaloClusterizerComponent.cxx
- adding use of associated cluster for digits
[u/mrichter/AliRoot.git] / HLT / CALO / AliHLTCaloClusterizerComponent.cxx
index 139062bc3c694543dccb02351d4244f736612292..794cf492f8c60c47082ba6864d2b6a1ea20c70bd 100644 (file)
@@ -16,7 +16,7 @@
 
 #include "AliHLTCaloClusterizerComponent.h"
 #include "AliHLTCaloClusterizer.h"
-#include "AliHLTCaloClusterAnalyser.h" 
+#include "AliHLTCaloClusterAnalyser.h"
 #include "AliHLTCaloRecPointDataStruct.h"
 #include "AliHLTCaloRecPointHeaderStruct.h"
 #include "AliHLTCaloDigitDataStruct.h"
@@ -28,7 +28,7 @@
 
 /** @file   AliHLTCaloClusterizerComponent.cxx
     @author Oystein Djuvsland
-    @date   
+    @date
     @brief  A clusterizer component for PHOS HLT
 */
 
 
 ClassImp(AliHLTCaloClusterizerComponent);
 
-AliHLTCaloClusterizerComponent::AliHLTCaloClusterizerComponent(TString det): 
-  AliHLTCaloProcessor(),
-  AliHLTCaloConstantsHandler(det),
-  fDataOrigin('\0'),
-  fAnalyserPtr(0),
-  fRecoParamsPtr(0),
-  fDigitsPointerArray(0), 
-  fOutputDigitsArray(0),
-  fClusterizerPtr(0),
-  fDigitCount(0)
+AliHLTCaloClusterizerComponent::AliHLTCaloClusterizerComponent(TString det):
+        AliHLTCaloProcessor(),
+        AliHLTCaloConstantsHandler(det),
+        fDataOrigin('\0'),
+        fAnalyserPtr(0),
+        fRecoParamsPtr(0),
+        fDigitsPointerArray(0),
+        fOutputDigitsArray(0),
+        fClusterizerPtr(0),
+        fDigitCount(0),
+        fCopyDigitsToOuput(kTRUE)
 {
-  //See headerfile for documentation
-  
-  
+    //See headerfile for documentation
+
+
+
 }
 
 AliHLTCaloClusterizerComponent::~AliHLTCaloClusterizerComponent()
 {
-  //See headerfile for documentation
-delete fAnalyserPtr;
-  if(fClusterizerPtr)
+    //See headerfile for documentation
+    delete fAnalyserPtr;
+    if (fClusterizerPtr)
     {
-      delete fClusterizerPtr;
-      fClusterizerPtr = 0;
+        delete fClusterizerPtr;
+        fClusterizerPtr = 0;
     }
 }
 
@@ -73,253 +74,258 @@ AliHLTCaloClusterizerComponent::DoEvent(const AliHLTComponentEventData& evtData,
                                         AliHLTComponentTriggerData& /*trigData*/, AliHLTUInt8_t* outputPtr, AliHLTUInt32_t& size,
                                         std::vector<AliHLTComponentBlockData>& outputBlocks)
 {
-  //See headerfile for documentation
-
-  if(blocks == 0) return 0;
-  
-  UInt_t offset           = 0;
-  UInt_t mysize           = 0;
-  Int_t nRecPoints        = 0;
-  Int_t nDigits           = 0;
-  Int_t digCount          = 0;
-
-  UInt_t availableSize = size;
-  AliHLTUInt8_t* outBPtr;
-  outBPtr = outputPtr;
-  const AliHLTComponentBlockData* iter = 0;
-  unsigned long ndx;
-  
-  UInt_t specification = 0;
-  
-  AliHLTCaloDigitDataStruct *digitDataPtr = 0;
-
-  // Adding together all the digits, should be put in standalone method  
-  for ( ndx = 0; ndx < evtData.fBlockCnt; ndx++ )
+    //See headerfile for documentation
+
+    if (blocks == 0) return 0;
+
+    UInt_t offset           = 0;
+    UInt_t mysize           = 0;
+    Int_t nRecPoints        = 0;
+    Int_t nDigits           = 0;
+    Int_t digCount          = 0;
+
+    UInt_t availableSize = size;
+    AliHLTUInt8_t* outBPtr;
+    outBPtr = outputPtr;
+    const AliHLTComponentBlockData* iter = 0;
+    unsigned long ndx;
+
+    UInt_t specification = 0;
+
+    AliHLTCaloDigitDataStruct *digitDataPtr = 0;
+
+    // Adding together all the digits, should be put in standalone method
+    for ( ndx = 0; ndx < evtData.fBlockCnt; ndx++ )
     {
-      iter = blocks+ndx;
-      //            HLTError("Got block");
-      if (iter->fDataType == (AliHLTCaloDefinitions::fgkDigitDataType|fDataOrigin))
-       {
-
-          // Update the number of digits
-         nDigits = iter->fSize/sizeof(AliHLTCaloDigitDataStruct);
-         availableSize -= iter->fSize;
-         
-         specification = specification|iter->fSpecification;
-
-         digitDataPtr = reinterpret_cast<AliHLTCaloDigitDataStruct*>(iter->fPtr);
-         
-         // We copy the digits to the digit buffer used by the clusterizer
-         // This is convinient since we want the digits from all DDLs before starting
-         // Could be changed if this is a bottle neck. 
-         for (Int_t i = 0; i < nDigits; i++)
-           {
-             fDigitsPointerArray[digCount] = digitDataPtr;
-             digCount++;
-             digitDataPtr++;
-           }
-       }
+        iter = blocks+ndx;
+
+       if (iter->fDataType == (AliHLTCaloDefinitions::fgkDigitDataType|fDataOrigin))
+        {
+
+            // Update the number of digits
+            nDigits = iter->fSize/sizeof(AliHLTCaloDigitDataStruct);
+            availableSize -= iter->fSize;
+
+            specification = specification|iter->fSpecification;
+
+            digitDataPtr = reinterpret_cast<AliHLTCaloDigitDataStruct*>(iter->fPtr);
+
+            // We copy the digits to the digit buffer used by the clusterizer
+            // This is convinient since we want the digits from all DDLs before starting
+            // Could be changed if this is a bottle neck.
+            for (Int_t i = 0; i < nDigits; i++)
+            {
+                fDigitsPointerArray[digCount] = digitDataPtr;
+                digCount++;
+                digitDataPtr++;
+            }
+        }
     }
 
-  if(digCount > 0)
+    if (digCount > 0)
     {
-       
-      AliHLTCaloClusterHeaderStruct* caloClusterHeaderPtr = reinterpret_cast<AliHLTCaloClusterHeaderStruct*>(outBPtr);
-      caloClusterHeaderPtr->fNDigits = digCount;
-      
-      outBPtr += sizeof(AliHLTCaloClusterHeaderStruct);
-      mysize += sizeof(AliHLTCaloClusterHeaderStruct);
-      
-      // Sort the digit pointers
+
+        AliHLTCaloClusterHeaderStruct* caloClusterHeaderPtr = reinterpret_cast<AliHLTCaloClusterHeaderStruct*>(outBPtr);
+        caloClusterHeaderPtr->fNDigits = digCount;
+
+        outBPtr += sizeof(AliHLTCaloClusterHeaderStruct);
+        mysize += sizeof(AliHLTCaloClusterHeaderStruct);
+
+        // Sort the digit pointers
 //      qsort(fDigitsPointerArray, digCount, sizeof(AliHLTCaloDigitDataStruct*), CompareDigits);
 
-      // Copy the digits to the output
-      // If we don't want the digits in the output we currently need to copy them to another buffer
-      // The reason is that the clusterizer sets the energy of the digits in the input buffer to 0,
-      // but we want to use the digits in the cluster analyser. 
-      fOutputDigitsArray = reinterpret_cast<AliHLTCaloDigitDataStruct*>(outBPtr);
-      for(Int_t n = 0; n < digCount; n++)
-       {
-         memcpy(outBPtr, fDigitsPointerArray[n], sizeof(AliHLTCaloDigitDataStruct));
-         //fOutputDigitsArray[n] = reinterpret_cast<AliHLTCaloDigitDataStruct*>(outBPtr);
-         outBPtr = outBPtr + sizeof(AliHLTCaloDigitDataStruct);
-       }
-      
-      // Update the size of the output we have used, needs to be removed if we don't push the digits 
-      mysize += digCount*sizeof(AliHLTCaloDigitDataStruct);
-
-      // Do the clusterisation
-      nRecPoints = fClusterizerPtr->ClusterizeEvent(digCount);
-
-      // Give the cluster output to the analyser
-      fAnalyserPtr->SetCaloClusterData(reinterpret_cast<AliHLTCaloClusterDataStruct*>(outBPtr));
-      
-      // Give the rec points to the analyser (input)
-      fAnalyserPtr->SetRecPointArray(fClusterizerPtr->GetRecPoints(), nRecPoints);
-
-      // Give the digits to the analyser 
-      fAnalyserPtr->SetDigitDataArray(fOutputDigitsArray);
-      
-      // Then we create the clusters
-      Int_t nClusters = fAnalyserPtr->CreateClusters(nRecPoints, size, mysize);
-      
-      if (nClusters < 0) 
-       {
-          HLTError("Error in clusterisation");
-         caloClusterHeaderPtr->fNClusters = 0;
-       } 
-      else 
-       {
-         caloClusterHeaderPtr->fNClusters = nClusters;
-       }
-     
-      HLTDebug("Number of clusters: %d", nRecPoints);
-      
-      AliHLTComponentBlockData bd;
-      FillBlockData( bd );
-      bd.fOffset = offset;
-      bd.fSize = mysize;
-      bd.fDataType = kAliHLTDataTypeCaloCluster | fDataOrigin;
-      bd.fSpecification = specification;
-      outputBlocks.push_back( bd );
+
+        if (fCopyDigitsToOuput)
+        {
+            // Copy the digits to the output
+            fOutputDigitsArray = reinterpret_cast<AliHLTCaloDigitDataStruct*>(outBPtr);
+
+            for (Int_t n = 0; n < digCount; n++)
+            {
+                memcpy(outBPtr, fDigitsPointerArray[n], sizeof(AliHLTCaloDigitDataStruct));
+                //fOutputDigitsArray[n] = reinterpret_cast<AliHLTCaloDigitDataStruct*>(outBPtr);
+                outBPtr = outBPtr + sizeof(AliHLTCaloDigitDataStruct);
+            }
+        }
+        
+        // Update the size of the output we have used, needs to be removed if we don't push the digits
+        mysize += digCount*sizeof(AliHLTCaloDigitDataStruct);
+
+        // Do the clusterisation
+        nRecPoints = fClusterizerPtr->ClusterizeEvent(digCount);
+
+        HLTDebug("Number of rec points found: %d", nRecPoints);
+
+        // Give the cluster output to the analyser
+        fAnalyserPtr->SetCaloClusterData(reinterpret_cast<AliHLTCaloClusterDataStruct*>(outBPtr));
+
+        // Give the rec points to the analyser (input)
+        fAnalyserPtr->SetRecPointArray(fClusterizerPtr->GetRecPoints(), nRecPoints);
+
+        // Give the digits to the analyser
+        //fAnalyserPtr->SetDigitDataArray(fOutputDigitsArray);
+        fAnalyserPtr->SetDigitDataArray(fDigitsPointerArray);
+
+        // Then we create the clusters
+        Int_t nClusters = fAnalyserPtr->CreateClusters(nRecPoints, size, mysize);
+
+        if (nClusters < 0)
+        {
+            HLTError("Error in clusterisation");
+            caloClusterHeaderPtr->fNClusters = 0;
+        }
+        else
+        {
+            caloClusterHeaderPtr->fNClusters = nClusters;
+        }
+
+        HLTDebug("Number of clusters: %d", nRecPoints);
+
+        AliHLTComponentBlockData bd;
+        FillBlockData( bd );
+        bd.fOffset = offset;
+        bd.fSize = mysize;
+        bd.fDataType = kAliHLTDataTypeCaloCluster | fDataOrigin;
+        bd.fSpecification = specification;
+        outputBlocks.push_back( bd );
     }
 
-  size = mysize;
-  
-  return 0;
+    size = mysize;
+
+    return 0;
 }
 
-int 
+int
 AliHLTCaloClusterizerComponent::Reconfigure(const char* cdbEntry, const char* /*chainId*/)
-{  
-  // see header file for class documentation
+{
+    // see header file for class documentation
 
-  const char* path="HLT/ConfigPHOS/ClusterizerComponent";
+    const char* path="HLT/ConfigPHOS/ClusterizerComponent";
 
-  if (cdbEntry) path = cdbEntry;
+    if (cdbEntry) path = cdbEntry;
 
-  return ConfigureFromCDBTObjString(cdbEntry);
+    return ConfigureFromCDBTObjString(cdbEntry);
 }
 
-int 
+int
 AliHLTCaloClusterizerComponent::ScanConfigurationArgument(int argc, const char **argv)
 {
-  //See header file for documentation
+    //See header file for documentation
 
-  if(argc <= 0) return 0;
+    if (argc <= 0) return 0;
 
-  int i=0;
+    int i=0;
 
-  TString argument=argv[i];
+    TString argument=argv[i];
 
-  if (argument.CompareTo("-digitthreshold") == 0)
+    if (argument.CompareTo("-digitthreshold") == 0)
     {
-      if (++i >= argc) return -EPROTO;
-      argument = argv[i];
-      fClusterizerPtr->SetEmcMinEnergyThreshold(argument.Atof());
-      return 1;
+        if (++i >= argc) return -EPROTO;
+        argument = argv[i];
+        fClusterizerPtr->SetEmcMinEnergyThreshold(argument.Atof());
+        return 1;
     }
 
-  if (argument.CompareTo("-recpointthreshold") == 0)
+    if (argument.CompareTo("-recpointthreshold") == 0)
     {
-      if (++i >= argc) return -EPROTO;
-      argument = argv[i];
-      fClusterizerPtr->SetEmcClusteringThreshold(argument.Atof());
-      return 1;
+        if (++i >= argc) return -EPROTO;
+        argument = argv[i];
+        fClusterizerPtr->SetEmcClusteringThreshold(argument.Atof());
+        return 1;
     }
-  
-  if (argument.CompareTo("-cutonsinglecell") == 0)
+
+    if (argument.CompareTo("-cutonsinglecell") == 0)
     {
-      if (++i >= argc) return -EPROTO;
-      argument = argv[i];
-      fAnalyserPtr->SetCutOnSingleCellClusters(true, argument.Atof());
-      return 1;
+        if (++i >= argc) return -EPROTO;
+        argument = argv[i];
+        fAnalyserPtr->SetCutOnSingleCellClusters(true, argument.Atof());
+        return 1;
     }
-  if (argument.CompareTo("-sortbyposition") == 0)
+    if (argument.CompareTo("-sortbyposition") == 0)
     {
-      fClusterizerPtr->SetSortDigitsByPosition();
-       return 1;
+        fClusterizerPtr->SetSortDigitsByPosition();
+        return 1;
     }
-    
-  return 0;
+
+    return 0;
 }
 
 int
 AliHLTCaloClusterizerComponent::DoInit(int argc, const char** argv )
 {
-  //See headerfile for documentation
-
-  fDigitsPointerArray = new AliHLTCaloDigitDataStruct*[fCaloConstants->GetNXCOLUMNSMOD()*fCaloConstants->GetNZROWSMOD()];
-
-  fClusterizerPtr = new AliHLTCaloClusterizer(fCaloConstants->GetDETNAME());
-
-  fClusterizerPtr->SetDigitArray(fDigitsPointerArray);
-  
-  fClusterizerPtr->SetSortDigitsByEnergy();
-   
-  fAnalyserPtr = new AliHLTCaloClusterAnalyser();
-  
-  if(fCaloConstants->GetDETNAME() == "PHOS")
-  {
-     fAnalyserPtr->SetClusterType(kPHOSCluster);
-  }
-  else if(fCaloConstants->GetDETNAME() == "EMCAL")
-  {
-     fAnalyserPtr->SetClusterType(kEMCALClusterv1);
-  }
-  else
-  {
-     fAnalyserPtr->SetClusterType(kUndef);
-  }
-   InitialiseGeometry();
-  if(fRecoParamsPtr)
-  {
-     if(!fRecoParamsPtr->GetParametersFromCDB())
-     {
-        fAnalyserPtr->SetRecoParamHandler(fRecoParamsPtr);
-        fClusterizerPtr->SetEmcClusteringThreshold(fRecoParamsPtr->GetRecPointThreshold());
-        fClusterizerPtr->SetEmcMinEnergyThreshold(fRecoParamsPtr->GetRecPointMemberThreshold());
-     }
-  }
-  //
-
-  //  const char *path = "HLT/ConfigPHOS/ClusterizerComponent";
-
-  //  ConfigureFromCDBTObjString(path);
-
-  for (int i = 0; i < argc; i++)
+    //See headerfile for documentation
+
+    fDigitsPointerArray = new AliHLTCaloDigitDataStruct*[fCaloConstants->GetNXCOLUMNSMOD()*fCaloConstants->GetNZROWSMOD()];
+
+    fClusterizerPtr = new AliHLTCaloClusterizer(fCaloConstants->GetDETNAME());
+
+    fClusterizerPtr->SetDigitArray(fDigitsPointerArray);
+
+    fClusterizerPtr->SetSortDigitsByEnergy();
+
+    fAnalyserPtr = new AliHLTCaloClusterAnalyser();
+
+    if (fCaloConstants->GetDETNAME() == "PHOS")
+    {
+        fAnalyserPtr->SetClusterType(kPHOSCluster);
+    }
+    else if (fCaloConstants->GetDETNAME() == "EMCAL")
+    {
+        fAnalyserPtr->SetClusterType(kEMCALClusterv1);
+    }
+    else
+    {
+        fAnalyserPtr->SetClusterType(kUndef);
+    }
+    InitialiseGeometry();
+    if (fRecoParamsPtr)
     {
-      ScanConfigurationArgument(i, argv);
+        if (!fRecoParamsPtr->GetParametersFromCDB())
+        {
+            fAnalyserPtr->SetRecoParamHandler(fRecoParamsPtr);
+            fClusterizerPtr->SetEmcClusteringThreshold(fRecoParamsPtr->GetRecPointThreshold());
+            fClusterizerPtr->SetEmcMinEnergyThreshold(fRecoParamsPtr->GetRecPointMemberThreshold());
+        }
     }
+    //
 
-  return 0;
+    //  const char *path = "HLT/ConfigPHOS/ClusterizerComponent";
+
+    //  ConfigureFromCDBTObjString(path);
+
+    for (int i = 0; i < argc; i++)
+    {
+        ScanConfigurationArgument(i, argv);
+    }
+
+    return 0;
 }
 int AliHLTCaloClusterizerComponent::DoDeinit()
 {
-   // See header file for documentation
-   if(fDigitsPointerArray)
-   {
-      delete []  fDigitsPointerArray;
-      fDigitsPointerArray = 0;
-   }
-   if(fClusterizerPtr)
-   {
-      delete fClusterizerPtr;
-      fClusterizerPtr = 0;
-   }
-   if(fAnalyserPtr)
-   {
-      delete fAnalyserPtr;
-      fAnalyserPtr = 0;
-   }
-   return 0;
+    // See header file for documentation
+    if (fDigitsPointerArray)
+    {
+        delete []  fDigitsPointerArray;
+        fDigitsPointerArray = 0;
+    }
+    if (fClusterizerPtr)
+    {
+        delete fClusterizerPtr;
+        fClusterizerPtr = 0;
+    }
+    if (fAnalyserPtr)
+    {
+        delete fAnalyserPtr;
+        fAnalyserPtr = 0;
+    }
+    return 0;
 }
 
-Int_t 
+Int_t
 AliHLTCaloClusterizerComponent::CompareDigits(const void *dig0, const void *dig1)
 {
-  // See header file for documentation
-  return (*((AliHLTCaloDigitDataStruct**)(dig0)))->fID - (*((AliHLTCaloDigitDataStruct**)(dig1)))->fID;
+    // See header file for documentation
+    return (*((AliHLTCaloDigitDataStruct**)(dig0)))->fID - (*((AliHLTCaloDigitDataStruct**)(dig1)))->fID;
 
-  //return (*((AliHLTCaloDigitDataStruct**)(dig0)))->fID - (*((AliHLTCaloDigitDataStruct**)(dig1)))->fID;
+    //return (*((AliHLTCaloDigitDataStruct**)(dig0)))->fID - (*((AliHLTCaloDigitDataStruct**)(dig1)))->fID;
 }