]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - HLT/PHOS/AliHLTPHOSClusterizerComponent.cxx
- cleaning up debug output
[u/mrichter/AliRoot.git] / HLT / PHOS / AliHLTPHOSClusterizerComponent.cxx
index e7b4c411e192f2a7d3d97e2521de2fdb9812e0c8..47ccdf4995e3156353a6358b30fe91eca22ad77a 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
+#include "AliHLTCaloDefinitions.h"
+#include "AliHLTPHOSGeometry.h"
 
 AliHLTPHOSClusterizerComponent gAliHLTPHOSClusterizerComponent;
 
 AliHLTPHOSClusterizerComponent::AliHLTPHOSClusterizerComponent(): 
-  AliHLTPHOSProcessor(), 
-  fAllDigitsPtr(0),
-  fClusterizerPtr(0),
-  fDigitCount(0),
-  fNoCrazyness(0)
+  AliHLTCaloClusterizerComponent("PHOS")
 {
   //See headerfile for documentation
-}
 
-AliHLTPHOSClusterizerComponent::~AliHLTPHOSClusterizerComponent()
-{
-  //See headerfile for documentation
+  fDataOrigin = const_cast<char*>(kAliHLTDataOriginPHOS);
 
-  if(fClusterizerPtr)
-    {
-      delete fClusterizerPtr;
-      fClusterizerPtr = 0;
-    }
-  if(fAllDigitsPtr)
-    {
-      delete fAllDigitsPtr;
-      fAllDigitsPtr = 0;
-    }
-}
-
-
-int
-AliHLTPHOSClusterizerComponent::Deinit()
-{
-  //See headerfile for documentation
-
-  if (fClusterizerPtr)
-    {
-      delete fClusterizerPtr;
-      fClusterizerPtr = 0;
-    }
-
-  return 0;
+  //AliHLTPHOSGeometry *geom = new AliHLTPHOSGeometry;
+  
+  fAnalyserPtr->SetGeometry(new AliHLTPHOSGeometry);
+  
 }
 
-const Char_t*
-AliHLTPHOSClusterizerComponent::GetComponentID()
+AliHLTPHOSClusterizerComponent::~AliHLTPHOSClusterizerComponent()
 {
   //See headerfile for documentation
-  return "PhosClusterizer";
 }
 
 void
@@ -92,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 AliHLTCaloDefinitions::fgkRecPointDataType|kAliHLTDataOriginPHOS;
 }
 
 void
@@ -107,213 +79,16 @@ 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)
-{
-  //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;
 
-  UInt_t availableSize = size;
-  AliHLTUInt8_t* outBPtr;
-  outBPtr = outputPtr;
-  const AliHLTComponentBlockData* iter = 0;
-  unsigned long ndx;
-  
-  UInt_t specification = 0;
-  
-  AliHLTPHOSDigitHeaderStruct *digitHeaderPtr = 0;
-  AliHLTPHOSDigitHeaderStruct *outputDigitHeaderPtr = reinterpret_cast<AliHLTPHOSDigitHeaderStruct*>(outBPtr);
-
-  AliHLTPHOSDigitDataStruct *firstDigitPtr = 0;
-  AliHLTPHOSDigitDataStruct *lastDigitPtr = 0;
-  
-  // Adding together all the digits, should be put in standalone method  
-  for ( ndx = 0; ndx < evtData.fBlockCnt; ndx++ )
-    {
-      iter = blocks+ndx;
-      if (iter->fDataType == AliHLTPHOSDefinitions::fgkDigitDataType)
-       {
-         // Update the number of digits
-         nDigits += digitHeaderPtr->fNDigits;
-
-         // Get the specification
-         specification = specification|iter->fSpecification;
-         
-         // Get the digit header
-         digitHeaderPtr = reinterpret_cast<AliHLTPHOSDigitHeaderStruct*>(iter->fPtr);
-         
-         // Check if we have the first buffer in the event
-         if(!firstDigitPtr)
-           {
-             if(availableSize < digitHeaderPtr->fNDigits*sizeof(AliHLTPHOSDigitDataStruct) + sizeof(AliHLTPHOSDigitHeaderStruct))
-               {
-                 // HLTError("Buffer overflow: Trying to write data of size: %d bytes. Output buffer available: %d bytes.", totSize, size);
-                 HLTError("Buffer overflow: Trying to write data of size: %d bytes. Output buffer available: %d bytes.", mysize, size);
-                 return -1;
-               }
-             // If so, lets copy the header and the corresponding digits to the output
-             memcpy(outBPtr, iter->fPtr, digitHeaderPtr->fNDigits*sizeof(AliHLTPHOSDigitDataStruct) + sizeof(AliHLTPHOSDigitHeaderStruct));
-
-             // Set the pointer to the first digit in the list
-             firstDigitPtr = reinterpret_cast<AliHLTPHOSDigitDataStruct*>(outBPtr + sizeof(AliHLTPHOSDigitHeaderStruct) + digitHeaderPtr->fFirstDigitOffset);
-
-             lastDigitPtr = reinterpret_cast<AliHLTPHOSDigitDataStruct*>(outBPtr + sizeof(AliHLTPHOSDigitHeaderStruct) + digitHeaderPtr->fLastDigitOffset);
-             
-             // Update the amount of the output buffer we have used
-             mysize += digitHeaderPtr->fNDigits*sizeof(AliHLTPHOSDigitDataStruct) + sizeof(AliHLTPHOSDigitHeaderStruct);
-           }
-         else
-           {
-             // Check if we have space for 
-             if(availableSize < digitHeaderPtr->fNDigits*sizeof(AliHLTPHOSDigitDataStruct))
-               {
-                 HLTError("Buffer overflow: Trying to write data of size: %d bytes. Output buffer available: %d bytes.", mysize, size);
-                 return -1;
-               }
-
-             // If we already have copied the first buffer to the output copy only the digits
-             memcpy(outBPtr, reinterpret_cast<const void*>(reinterpret_cast<Long_t>(iter->fPtr)+sizeof(AliHLTPHOSDigitHeaderStruct)), digitHeaderPtr->fNDigits*sizeof(AliHLTPHOSDigitDataStruct));
-
-             // Check if the first digit in this buffer has a ID less than the first digit in the previous
-             if(firstDigitPtr->fID > reinterpret_cast<AliHLTPHOSDigitDataStruct*>(reinterpret_cast<Long_t>(iter->fPtr) + sizeof(AliHLTPHOSDigitDataStruct) + digitHeaderPtr->fFirstDigitOffset)->fID)
-               {
-                 // If that is the case we have to take care of the ordering
-                                 
-                 // The last digit in the current buffer has to link to the first digit in the previous buffer
-                 lastDigitPtr->fMemOffsetNext = reinterpret_cast<Long_t>(outBPtr) + digitHeaderPtr->fFirstDigitOffset - reinterpret_cast<Long_t>(lastDigitPtr);
-
-                 // Setting the pointer to the new first digit
-                 firstDigitPtr = reinterpret_cast<AliHLTPHOSDigitDataStruct*>(outBPtr + digitHeaderPtr->fFirstDigitOffset);
-               }
-             else
-               {
-                 // Previous last digit need to link to the current first digit
-                 lastDigitPtr->fMemOffsetNext = reinterpret_cast<Long_t>(outBPtr) + digitHeaderPtr->fFirstDigitOffset;           
-                 
-                 // We need to change the last digit pointer
-                 lastDigitPtr = reinterpret_cast<AliHLTPHOSDigitDataStruct*>(reinterpret_cast<Long_t>(outBPtr) + digitHeaderPtr->fLastDigitOffset);
-               }
-             // Update the amount of the output buffer we have used
-             mysize += digitHeaderPtr->fNDigits*sizeof(AliHLTPHOSDigitDataStruct);
-           }
-
-         outBPtr += mysize;
-       }
-    }
-  
-  // The digit header in the output needs to know about the position of the new first digit (the last digit is still the same)
-  outputDigitHeaderPtr->fFirstDigitOffset = reinterpret_cast<Long_t>(firstDigitPtr) - reinterpret_cast<Long_t>(outputDigitHeaderPtr) + sizeof(AliHLTPHOSDigitHeaderStruct);
-  
-  // The digit header in the output needs to know about the position of the new last digit (the first digit is still the same)
-  outputDigitHeaderPtr->fLastDigitOffset = reinterpret_cast<Long_t>(lastDigitPtr) - reinterpret_cast<Long_t>(outputDigitHeaderPtr) + sizeof(AliHLTPHOSDigitHeaderStruct);
-                 
-
-  HLTDebug("Number of digits: %d", nDigits);
-
-  AliHLTPHOSRecPointHeaderStruct* recPointHeaderPtr = reinterpret_cast<AliHLTPHOSRecPointHeaderStruct*>(outBPtr);
-
-  fClusterizerPtr->SetRecPointDataPtr(reinterpret_cast<AliHLTPHOSRecPointDataStruct*>(outBPtr+sizeof(AliHLTPHOSRecPointHeaderStruct)));
-
-  nRecPoints = fClusterizerPtr->ClusterizeEvent(outputDigitHeaderPtr, availableSize, mysize);
-  recPointHeaderPtr->fNRecPoints = nRecPoints;
-
-  mysize += sizeof(AliHLTPHOSRecPointHeaderStruct);
-  
-  HLTDebug("Number of clusters: %d", nRecPoints);
-
-  AliHLTComponentBlockData clusterBd;
-  FillBlockData( clusterBd );
-  clusterBd.fOffset = offset;
-  clusterBd.fSize = mysize;
-  clusterBd.fDataType = AliHLTPHOSDefinitions::fgkRecPointDataType;
-  clusterBd.fSpecification = specification;
-  outputBlocks.push_back( clusterBd );
-
-  if(false)
-    {
-      AliHLTComponentBlockData digitBd;
-      FillBlockData(digitBd);
-    }
-       
-  size = mysize;
-  
-  return 0;
-}
-
-int 
-AliHLTPHOSClusterizerComponent::Reconfigure(const char* cdbEntry, const char* /*chainId*/)
-{  
-  // see header file for class documentation
-
-  const char* path="HLT/ConfigPHOS/ClusterizerComponent";
-
-  if (cdbEntry) path = cdbEntry;
-
-  return ConfigureFromCDBTObjString(cdbEntry);
-}
-
-int 
-AliHLTPHOSClusterizerComponent::ScanConfigurationArgument(int argc, const char **argv)
-{
-  //See header file for documentation
-
-  if(argc <= 0) return 0;
-
-  int i=0;
-
-  TString argument=argv[i];
-
-  if (argument.CompareTo("-digitthreshold") == 0)
-    {
-      if (++i >= argc) return -EPROTO;
-      argument = argv[i];
-      fClusterizerPtr->SetEmcMinEnergyThreshold(argument.Atof());
-      return 1;
-    }
-
-  if (argument.CompareTo("-recpointthreshold") == 0)
-    {
-      if (++i >= argc) return -EPROTO;
-      argument = argv[i];
-      fClusterizerPtr->SetEmcClusteringThreshold(argument.Atof());
-      return 1;
-    }
-  return 0;
-}
-
-int
-AliHLTPHOSClusterizerComponent::DoInit(int argc, const char** argv )
+const Char_t*
+AliHLTPHOSClusterizerComponent::GetComponentID()
 {
   //See headerfile for documentation
-
-  fAllDigitsPtr = new AliHLTPHOSDigitContainerDataStruct();
-  fClusterizerPtr = new AliHLTPHOSClusterizer();
-  fClusterizerPtr->SetDigitContainer(fAllDigitsPtr);
-  fNoCrazyness = false;
-  //
-
-  //  const char *path = "HLT/ConfigPHOS/ClusterizerComponent";
-
-  //  ConfigureFromCDBTObjString(path);
-
-  for (int i = 0; i < argc; i++)
-    {
-      ScanConfigurationArgument(i, argv);
-    }
-
-  return 0;
+  return "PhosClusterizer";
 }
 
 AliHLTComponent*