]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - HLT/PHOS/AliHLTPHOSClusterizerComponent.cxx
- adding new component for the new clusterizer.
[u/mrichter/AliRoot.git] / HLT / PHOS / AliHLTPHOSClusterizerComponent.cxx
index a3a8d5b83d73e44eea0be3051a1354e889f8c8da..d4254652f837ba588e29027646369cc79a8cd4eb 100644 (file)
 #include <iostream>
 
 #include "AliHLTPHOSClusterizerComponent.h"
-#include "AliHLTPHOSClusterizer.h"
-#include "AliHLTPHOSRecPointDataStruct.h"
-#include "AliHLTPHOSRecPointHeaderStruct.h"
-#include "AliHLTPHOSDigitDataStruct.h"
-#include "AliHLTPHOSDigitContainerDataStruct.h"
+#include "AliHLTCaloRecPointDataStruct.h"
+#include "AliHLTCaloRecPointHeaderStruct.h"
+#include "AliHLTPHOSGeometry.h"
+#include "AliHLTCaloClusterAnalyser.h"
+
 
 
 
 // refer to README to build package
 // or
 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
-
-#if __GNUC__>= 3
-using namespace std;
-#endif
-
-// const AliHLTComponentDataType AliHLTPHOSClusterizerComponent::fgkInputDataTypes[]=
-//   {
-//     kAliHLTVoidDataType,{0,"",""}
-//   };
+#include "AliHLTCaloDefinitions.h"
+#include "AliHLTPHOSGeometry.h"
+#include "AliHLTPHOSRecoParamHandler.h"
+#include "AliHLTCaloClusterizer.h"
 
 AliHLTPHOSClusterizerComponent gAliHLTPHOSClusterizerComponent;
 
-
 AliHLTPHOSClusterizerComponent::AliHLTPHOSClusterizerComponent(): 
-  AliHLTPHOSProcessor(), 
-  fAllDigitsPtr(0),
-  fClusterizerPtr(0),
-  fRecPointStructArrayPtr(0),
-  fDigitCount(0),
-  fModuleClusterizationMode(true),
-  fNoCrazyness(0)
-{
-  //See headerfile for documentation
-}
-
-AliHLTPHOSClusterizerComponent::~AliHLTPHOSClusterizerComponent()
-{
-  //See headerfile for documentation
-
-  if(fClusterizerPtr)
-    {
-      delete fClusterizerPtr;
-      fClusterizerPtr = 0;
-    }
-  if(fRecPointStructArrayPtr)
-    {
-      for (int i = 0; i < 1000; i++)
-        {
-          //     fRecPointStructArrayPtr[i].Del();
-        }
-      delete fRecPointStructArrayPtr;
-      fRecPointStructArrayPtr = 0;
-    }
-  if(fAllDigitsPtr)
-    {
-      delete fAllDigitsPtr;
-      fAllDigitsPtr = 0;
-    }
-}
-
-
-int
-AliHLTPHOSClusterizerComponent::Deinit()
+  AliHLTCaloClusterizerComponent("PHOS")
 {
   //See headerfile for documentation
 
-  if (fClusterizerPtr)
-    {
-      delete fClusterizerPtr;
-      fClusterizerPtr = 0;
-    }
-  for (int i = 0; i < 1000; i++)
-    {
-      //    fRecPointStructArrayPtr[i].Del();
-    }
-
-  if (fRecPointStructArrayPtr)
-    {
-      for (int i = 0; i < 1000; i++)
-        {
-          //     fRecPointStructArrayPtr[i].Del();
-        }
-      delete fRecPointStructArrayPtr;
-      fRecPointStructArrayPtr = 0;
-    }
+  fDataOrigin = const_cast<char*>(kAliHLTDataOriginPHOS);
 
-  return 0;
+  //AliHLTPHOSGeometry *geom = new AliHLTPHOSGeometry;
+  
 }
 
-const Char_t*
-AliHLTPHOSClusterizerComponent::GetComponentID()
+AliHLTPHOSClusterizerComponent::~AliHLTPHOSClusterizerComponent()
 {
   //See headerfile for documentation
-  return "PhosClusterizer";
 }
 
 void
@@ -127,14 +64,14 @@ AliHLTPHOSClusterizerComponent::GetInputDataTypes( vector<AliHLTComponentDataTyp
 {
   //See headerfile for documentation
   list.clear();
-  list.push_back(AliHLTPHOSDefinitions::fgkDigitDataType);
+  list.push_back(AliHLTCaloDefinitions::fgkDigitDataType|kAliHLTDataOriginPHOS);
 }
 
 AliHLTComponentDataType
 AliHLTPHOSClusterizerComponent::GetOutputDataType()
 {
   //See headerfile for documentation
-  return AliHLTPHOSDefinitions::fgkRecPointDataType;
+  return kAliHLTDataTypeCaloCluster|kAliHLTDataOriginPHOS;
 }
 
 void
@@ -142,134 +79,50 @@ AliHLTPHOSClusterizerComponent::GetOutputDataSize(unsigned long& constBase, doub
 
 {
   //See headerfile for documentation
-  constBase = sizeof(AliHLTPHOSRecPointHeaderStruct) + sizeof(AliHLTPHOSRecPointDataStruct) + (sizeof(AliHLTPHOSDigitDataStruct) << 7); //Reasonable estimate... ;
-  inputMultiplier = 1.5;
+  constBase = sizeof(AliHLTCaloRecPointHeaderStruct) + sizeof(AliHLTCaloRecPointDataStruct) + (sizeof(AliHLTCaloDigitDataStruct) << 7); //Reasonable estimate... ;
+  inputMultiplier = 2.0;
 }
 
-int
-AliHLTPHOSClusterizerComponent::DoEvent(const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks,
-                                        AliHLTComponentTriggerData& /*trigData*/, AliHLTUInt8_t* outputPtr, AliHLTUInt32_t& size,
-                                        std::vector<AliHLTComponentBlockData>& outputBlocks)
+const Char_t*
+AliHLTPHOSClusterizerComponent::GetComponentID()
 {
   //See headerfile for documentation
-  
-  UInt_t offset           = 0;
-  UInt_t mysize           = 0;
-  Int_t nRecPoints        = 0;
-  Int_t nDigits           = 0;
-  Int_t j                 = 0;
-  
-  AliHLTUInt8_t* outBPtr;
-  outBPtr = outputPtr;
-  const AliHLTComponentBlockData* iter = 0;
-  unsigned long ndx;
-  
-  UInt_t specification = 0;
-  
-  AliHLTPHOSDigitDataStruct *digitDataPtr = 0;
-  
-  AliHLTPHOSRecPointHeaderStruct* recPointHeaderPtr = reinterpret_cast<AliHLTPHOSRecPointHeaderStruct*>(outBPtr);
-
-  fClusterizerPtr->SetRecPointDataPtr(reinterpret_cast<AliHLTPHOSRecPointDataStruct*>(outBPtr+sizeof(AliHLTPHOSRecPointHeaderStruct)));
-  
-  for ( ndx = 0; ndx < evtData.fBlockCnt; ndx++ )
-    {
-      iter = blocks+ndx;
-      if (iter->fDataType == AliHLTPHOSDefinitions::fgkDigitDataType)
-       {
-         specification = specification|iter->fSpecification;
-         nDigits = iter->fSize/sizeof(AliHLTPHOSDigitDataStruct);
-         //HLTDebug("Number of digits in block: %d", nDigits);
-         digitDataPtr = reinterpret_cast<AliHLTPHOSDigitDataStruct*>(iter->fPtr);
-         for (Int_t i = 0; i < nDigits; i++)
-           {
-             fAllDigitsPtr->fDigitDataStruct[j].fX = digitDataPtr->fX;
-             fAllDigitsPtr->fDigitDataStruct[j].fZ = digitDataPtr->fZ;
-             fAllDigitsPtr->fDigitDataStruct[j].fEnergy = digitDataPtr->fEnergy;
-             //HLTDebug("Digit energy: %f", digitDataPtr->fEnergy);
-             fAllDigitsPtr->fDigitDataStruct[j].fTime = digitDataPtr->fTime;
-             fAllDigitsPtr->fDigitDataStruct[j].fCrazyness = digitDataPtr->fCrazyness;
-             fAllDigitsPtr->fDigitDataStruct[j].fModule = digitDataPtr->fModule;
-             j++;
-             digitDataPtr++;
-           }
-       }
-    }
-
-  fAllDigitsPtr->fNDigits = j;
-  HLTDebug("Number of digits: %d", j);
-  nRecPoints = fClusterizerPtr->ClusterizeEvent(size, mysize);
-
-  if(nRecPoints == -1)
-    {
-      HLTError("Running out of buffer, exiting for safety.");
-      return -ENOBUFS;
-    }
-
-  recPointHeaderPtr->fNRecPoints = nRecPoints;
-  mysize += sizeof(AliHLTPHOSRecPointHeaderStruct);
-  
-  HLTDebug("Number of clusters: %d", nRecPoints);
-
-//   if(nRecPoints > 0)
-//     {
-
-      AliHLTComponentBlockData clusterBd;
-      FillBlockData( clusterBd );
-      clusterBd.fOffset = offset;
-      clusterBd.fSize = mysize;
-      clusterBd.fDataType = AliHLTPHOSDefinitions::fgkRecPointDataType;
-      clusterBd.fSpecification = specification;
-      outputBlocks.push_back( clusterBd );
-//     }
-
-  // if(fAllDigitsPtr->fNDigits)
-  if(false)
-    {
-      AliHLTComponentBlockData digitBd;
-      FillBlockData(digitBd);
-    }
-  
-       
-  size = mysize;
-  
-  return 0;
+  return "PhosClusterizer";
 }
 
-int
-AliHLTPHOSClusterizerComponent::DoInit(int argc, const char** argv )
+AliHLTComponent*
+AliHLTPHOSClusterizerComponent::Spawn()
 {
   //See headerfile for documentation
 
-  fAllDigitsPtr = new AliHLTPHOSDigitContainerDataStruct();
-  fClusterizerPtr = new AliHLTPHOSClusterizer();
-  fClusterizerPtr->SetDigitContainer(fAllDigitsPtr);
-  fNoCrazyness = false;
-  //
+  return new AliHLTPHOSClusterizerComponent();
+}
+
+int AliHLTPHOSClusterizerComponent::DoInit(int argc, const char** argv)
+{
+   
+   fClusterizerPtr = new AliHLTCaloClusterizer("PHOS");
+   
+   fRecoParamsPtr = new AliHLTPHOSRecoParamHandler(); 
+    
+    return AliHLTCaloClusterizerComponent::DoInit(argc, argv);
+}
 
-  ScanArgumentsModule(argc, argv);
-  for (int i = 0; i < argc; i++)
+int AliHLTPHOSClusterizerComponent::DoDeinit()
+{
+    if(fRecoParamsPtr) 
     {
-      if(!strcmp("-digitthreshold", argv[i]))
-       {
-         fClusterizerPtr->SetEmcMinEnergyThreshold(atof(argv[i+1]));
-       }
-      if(!strcmp("-recpointthreshold", argv[i]))
-       {
-         fClusterizerPtr->SetEmcClusteringThreshold(atof(argv[i+1]));
-       }
-      if(!strcmp("-partitionmode", argv[i]))
-       {
-         fModuleClusterizationMode = false;
-       }
+       delete fRecoParamsPtr;
+       fRecoParamsPtr = 0;
     }
-  return 0;
+    return AliHLTCaloClusterizerComponent::DoDeinit();
 }
 
-AliHLTComponent*
-AliHLTPHOSClusterizerComponent::Spawn()
-{
-  //See headerfile for documentation
 
-  return new AliHLTPHOSClusterizerComponent();
+Int_t AliHLTPHOSClusterizerComponent::InitialiseGeometry()
+{
+  fAnalyserPtr->SetGeometry(new AliHLTPHOSGeometry);
+  return 0;
 }