]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - HLT/PHOS/AliHLTPHOSClusterizerComponent.cxx
Selectiv readout and writing to FXS (oystein)
[u/mrichter/AliRoot.git] / HLT / PHOS / AliHLTPHOSClusterizerComponent.cxx
index 1b67a86e8f1a5e123ef34545d516d565b9cb70d4..bfe4b7f6063fc7f364038773bedede331a723df0 100644 (file)
@@ -1,7 +1,7 @@
 /**************************************************************************
  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
  *                                                                        *
- * Authors: Ã\98ystein Djuvsland <oysteind@ift.uib.no>                       *
+ * Authors: Oystein Djuvsland <oysteind@ift.uib.no>                       *
  *                                                                        *
  * Permission to use, copy, modify and distribute this software and its   *
  * documentation strictly for non-commercial purposes is hereby granted   *
  * provided "as is" without express or implied warranty.                  *
  **************************************************************************/
 
-
-
+#include <iostream>
 
 #include "AliHLTPHOSClusterizerComponent.h"
 #include "AliHLTPHOSClusterizer.h"
-//#include "AliHLTPHOSPhysicsDefinitions.h"
-//#include "AliHLTPHOSDefinitions.h"
 #include "AliHLTPHOSRecPointDataStruct.h"
-#include "AliHLTPHOSClusterDataStruct.h"
-#include "AliHLTPHOSRecPointListDataStruct.h"
 #include "AliHLTPHOSDigitContainerDataStruct.h"
 
-using namespace std;
 
 
+/** @file   AliHLTPHOSClusterizerComponent.cxx
+    @author Oystein Djuvsland
+    @date   
+    @brief  A clusterizer component for PHOS HLT
+*/
+
+// see header file for class documentation
+// or
+// 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,"",""}
@@ -34,31 +44,29 @@ const AliHLTComponentDataType AliHLTPHOSClusterizerComponent::fgkInputDataTypes[
 
 AliHLTPHOSClusterizerComponent gAliHLTPHOSClusterizerComponent;
 
-//AliHLTPHOSClusterizerComponent::AliHLTPHOSClusterizerComponent(): AliHLTPHOSBase(), AliHLTProcessor(), fClusterizerPtr(0), fOutPtr(0),
-//                                                              fRecPointStructArrayPtr(0), fRecPointListPtr(0)
-AliHLTPHOSClusterizerComponent::AliHLTPHOSClusterizerComponent(): AliHLTPHOSProcessor(), fClusterizerPtr(0), fOutPtr(0),
-    fRecPointStructArrayPtr(0), fRecPointListPtr(0)
+
+AliHLTPHOSClusterizerComponent::AliHLTPHOSClusterizerComponent(): 
+  AliHLTPHOSProcessor(), 
+  fAllDigitsPtr(0),
+  fClusterizerPtr(0),
+  fRecPointStructArrayPtr(0),
+  fDigitCount(0),
+  fModuleClusterizationMode(false),
+  fNoCrazyness(0)
 {
-  //Constructor
+  //See headerfile for documentation
 }
 
 AliHLTPHOSClusterizerComponent::~AliHLTPHOSClusterizerComponent()
 {
-  //Destructor
+  //See headerfile for documentation
 
-  if (fClusterizerPtr)
+  if(fClusterizerPtr)
     {
       delete fClusterizerPtr;
       fClusterizerPtr = 0;
     }
-
-  if (fRecPointListPtr)
-    {
-      delete fRecPointListPtr;
-      fRecPointListPtr = 0;
-    }
-
-  if (fRecPointStructArrayPtr)
+  if(fRecPointStructArrayPtr)
     {
       for (int i = 0; i < 1000; i++)
         {
@@ -67,43 +75,24 @@ AliHLTPHOSClusterizerComponent::~AliHLTPHOSClusterizerComponent()
       delete fRecPointStructArrayPtr;
       fRecPointStructArrayPtr = 0;
     }
-
-}
-
-/*
-int
-AliHLTPHOSClusterizerComponent::AliHLTPHOSClusterizerComponent::Deinit()
-{
-  ////////// PTH WARNING you should Define a class AliHLTPHOSModuleProcessor
+  if(fAllDigitsPtr)
+    {
+      delete fAllDigitsPtr;
+      fAllDigitsPtr = 0;
+    }
 }
-*/
 
-// PTH AliHLTPHOSClusterizerComponent::AliHLTPHOSClusterizerComponent(const AliHLTPHOSClusterizerComponent &):AliHLTProcessor(),
-//                                                                                                    fClusterizerPtr(0),
-//                                                                                                    fOutPtr(0),
-//                                                                                                    fRecPointStructArrayPtr(0),
-//                                                                                                    fRecPointListPtr(0)
-//{
-//Copy constructor, not implemented
-//}
 
 int
 AliHLTPHOSClusterizerComponent::Deinit()
 {
-  //Deinitialization
+  //See headerfile for documentation
 
   if (fClusterizerPtr)
     {
       delete fClusterizerPtr;
       fClusterizerPtr = 0;
     }
-
-  if (fRecPointListPtr)
-    {
-      delete fRecPointListPtr;
-      fRecPointListPtr = 0;
-    }
-
   for (int i = 0; i < 1000; i++)
     {
       //    fRecPointStructArrayPtr[i].Del();
@@ -122,63 +111,48 @@ AliHLTPHOSClusterizerComponent::Deinit()
   return 0;
 }
 
-int
-AliHLTPHOSClusterizerComponent::DoDeinit()
-{
-  //Do deinitialization
-  Logging(kHLTLogInfo, "HLT", "PHOS", ",AliHLTPHOSClusterizerComponent DoDeinit");
-
-  return 0;
-}
-
-
 const Char_t*
 AliHLTPHOSClusterizerComponent::GetComponentID()
 {
-  //comment
-  return "AliHltPhosClusterizer";
+  //See headerfile for documentation
+
+  return "PhosClusterizer";
 }
 
 void
 AliHLTPHOSClusterizerComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list)
 {
-  //Get datatypes for input
-  const AliHLTComponentDataType* pType=fgkInputDataTypes;
-  while (pType->fID!=0)
-    {
-      list.push_back(*pType);
-      pType++;
-    }
+  list.clear();
+  list.push_back(AliHLTPHOSDefinitions::fgkDigitDataType);
 }
 
 AliHLTComponentDataType
 AliHLTPHOSClusterizerComponent::GetOutputDataType()
 {
-  //  return AliHLTPHOSPhysicsDefinitions::fgkAliHLTClusterDataType;
-  return AliHLTPHOSDefinitions::fgkAliHLTClusterDataType;
+  //See headerfile for documentation
+  return AliHLTPHOSDefinitions::fgkClusterDataType;
 }
 
 void
 AliHLTPHOSClusterizerComponent::GetOutputDataSize(unsigned long& constBase, double& inputMultiplier )
 
 {
+  //See headerfile for documentation
   constBase = 30;
-  inputMultiplier = 0.2;
+  inputMultiplier = 1;
 }
 
 int
 AliHLTPHOSClusterizerComponent::DoEvent(const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks,
-                                        AliHLTComponentTriggerData& /*trigData*/, AliHLTUInt8_t* outputPtr, AliHLTUInt32_t& size,
+                                        AliHLTComponentTriggerData& trigData, AliHLTUInt8_t* outputPtr, AliHLTUInt32_t& size,
                                         std::vector<AliHLTComponentBlockData>& outputBlocks)
 {
-  //Do event
+  //See headerfile for documentation
 
   UInt_t tSize            = 0;
   UInt_t offset           = 0;
   UInt_t mysize           = 0;
   Int_t nRecPoints        = 0;
-  Int_t nDigits           = 0;
-  //Int_t index             = 0;
   Int_t j =0;
 
   AliHLTUInt8_t* outBPtr;
@@ -186,61 +160,62 @@ AliHLTPHOSClusterizerComponent::DoEvent(const AliHLTComponentEventData& evtData,
   const AliHLTComponentBlockData* iter = 0;
   unsigned long ndx;
 
+  UInt_t specification = 0;
+
   AliHLTPHOSDigitContainerDataStruct *digitContainerPtr = 0;
-  
-  //AliHLTPHOSRecPointContainerStruct *recPointContainerPtr = (AliHLTPHOSRecPointContainerStruct*)outBPtr;
   fClusterizerPtr->SetRecPointContainer((AliHLTPHOSRecPointContainerStruct*)outBPtr);
+  
   for ( ndx = 0; ndx < evtData.fBlockCnt; ndx++ )
     {
       iter = blocks+ndx;
-      digitContainerPtr = reinterpret_cast<AliHLTPHOSDigitContainerDataStruct*>(iter->fPtr);
-      if (iter->fDataType != AliHLTPHOSDefinitions::fgkAliHLTDigitDataType)
+      if (iter->fDataType == AliHLTPHOSDefinitions::fgkDigitDataType)
         {
-          //     cout << "Warning: data type is not fgkAliHLTDigitDataType " << endl;
-          continue;
-        }
-      for (UInt_t i = 0; i < digitContainerPtr->fNDigits; i++)
-        {
-         if(fNoCrazyness && digitContainerPtr->fDigitDataStruct[i].fCrazyness)
-           continue;
-           
-          fAllDigitsPtr->fDigitDataStruct[j+nDigits].fX = digitContainerPtr->fDigitDataStruct[i].fX;
-          fAllDigitsPtr->fDigitDataStruct[j+nDigits].fZ = digitContainerPtr->fDigitDataStruct[i].fZ;
-          fAllDigitsPtr->fDigitDataStruct[j+nDigits].fAmplitude = digitContainerPtr->fDigitDataStruct[i].fAmplitude;
-          fAllDigitsPtr->fDigitDataStruct[j+nDigits].fTime = digitContainerPtr->fDigitDataStruct[i].fTime;
-         // fAllDigitsPtr->fDigitDataStruct[i+nDigits].fCrazyness = digitContainerPtr->fDigitDataStruct[i].fCrazyness;
-         j++;
-        }
-      nDigits++;
+         specification = specification|iter->fSpecification;
+         digitContainerPtr = reinterpret_cast<AliHLTPHOSDigitContainerDataStruct*>(iter->fPtr);
+         if(fModuleClusterizationMode)
+           {
+             for (UInt_t i = 0; i < digitContainerPtr->fNDigits; i++)
+               {
+                 fAllDigitsPtr->fDigitDataStruct[j].fX = digitContainerPtr->fDigitDataStruct[i].fX;
+                 fAllDigitsPtr->fDigitDataStruct[j].fZ = digitContainerPtr->fDigitDataStruct[i].fZ;
+                 fAllDigitsPtr->fDigitDataStruct[j].fAmplitude = digitContainerPtr->fDigitDataStruct[i].fAmplitude;
+                 fAllDigitsPtr->fDigitDataStruct[j].fTime = digitContainerPtr->fDigitDataStruct[i].fTime;
+                 fAllDigitsPtr->fDigitDataStruct[j].fCrazyness = digitContainerPtr->fDigitDataStruct[i].fCrazyness;
+                 j++;
+               }
+         
+           }
+       }
     }
-
-// nRecPoints = fClusterizerPtr->CreateRecPointStructArray(fRecPointStructArrayPtr, fRecPointListPtr, index);
-
-  fOutPtr =  (AliHLTPHOSRecPointContainerStruct*)outBPtr;
-  nRecPoints = fClusterizerPtr->ClusterizeEvent();
-  //nRecPoints = fClusterizerPtr->CalculateCenterOfGravity(&fRecPointStructArrayPtr[i]);
-  cout << "Number of clusters found: " << nRecPoints << " extracted from " << nDigits << " digits" << endl;
-
-  mysize = 0;
-  offset = tSize;
-
-  //      fClusterizerPtr->CalculateMoments(&fRecPointStructArrayPtr[i], 0);
-  //     fClusterizerPtr->ClusterizeStruct(&fRecPointStructArrayPtr[i], fOutPtr);
-
-  mysize += sizeof(AliHLTPHOSClusterDataStruct);
-
-  AliHLTComponentBlockData bd;
-  FillBlockData( bd );
-  bd.fOffset = offset;
-  bd.fSize = mysize;
-  // PTH      bd.fDataType = AliHLTPHOSPhysicsDefinitions::fgkAliHLTClusterDataType;
-  bd.fDataType = AliHLTPHOSDefinitions::fgkAliHLTClusterDataType;
-  bd.fSpecification = 0xFFFFFFFF;
-  outputBlocks.push_back( bd );
-
-  tSize += mysize;
-  outBPtr += mysize;
-
+  if(fModuleClusterizationMode && fAllDigitsPtr != 0)
+    {
+      fClusterizerPtr->SetDigitContainer(fAllDigitsPtr);
+    }
+  else if(digitContainerPtr != 0)
+    {
+      fClusterizerPtr->SetDigitContainer(digitContainerPtr);
+    }      
+  if(digitContainerPtr != 0)
+    {
+      nRecPoints = fClusterizerPtr->ClusterizeEvent();
+      
+      mysize = 0;
+      offset = tSize;
+
+      mysize += sizeof(AliHLTPHOSRecPointContainerStruct);
+      
+      AliHLTComponentBlockData bd;
+      FillBlockData( bd );
+      bd.fOffset = offset;
+      bd.fSize = mysize;
+      bd.fDataType = AliHLTPHOSDefinitions::fgkClusterDataType;
+      bd.fSpecification = specification;
+      outputBlocks.push_back( bd );
+      tSize += mysize;
+      outBPtr += mysize;
+  
+    }
+  
   if ( tSize > size )
     {
       Logging( kHLTLogFatal, "HLT::AliHLTPHOSClusterizerComponent::DoEvent", "Too much data",
@@ -248,59 +223,47 @@ AliHLTPHOSClusterizerComponent::DoEvent(const AliHLTComponentEventData& evtData,
                , tSize, size );
       return EMSGSIZE;
     }
-
-
-  size = tSize;
-// fClusterizerPtr->ResetCellEnergyArray();
-
+  
   return 0;
 
+
 }
 
 int
 AliHLTPHOSClusterizerComponent::DoInit(int argc, const char** argv )
 {
-  //Do initialization
+  //See headerfile for documentation
+
   fAllDigitsPtr = new AliHLTPHOSDigitContainerDataStruct();
   fClusterizerPtr = new AliHLTPHOSClusterizer();
-  //fClusterizerPtr->SetNoCrazyness(true);
+  fClusterizerPtr->SetDigitContainer(fAllDigitsPtr);
+  fNoCrazyness = false;
   //
+
+  ScanArguments(argc, argv);
   for (int i = 0; i < argc; i++)
     {
-      /*
-      if(!strcmp("-threshold", argv[i]))
-      fClusterizerPtr->SetThreshold(atof(argv[i+1]));
-      if(!strcmp("-clusterthreshold", argv[i]))
-      fClusterizerPtr->SetClusterThreshold(atof(argv[i+1]));
-      if(!strcmp("-highgain", argv[i]))
-      fClusterizerPtr->SetHighGainFactor(atof(argv[i+1]));
-      if(!strcmp("-lowgain", argv[i]))
-      fClusterizerPtr->SetLowGainFactor(atof(argv[i+1]));
-      if(!strcmp("-arraysize", argv[i]))
-      fClusterizerPtr->SetArraySize(atoi(argv[i+1]));*/
-    }
-  //  fClusterizerPtr->ResetCellEnergyArray();
-  fRecPointListPtr = new AliHLTPHOSRecPointListDataStruct[N_ZROWS_MOD*N_XCOLUMNS_MOD];
-  fRecPointStructArrayPtr = new AliHLTPHOSRecPointDataStruct[1000];
-  for (int i = 0; i < 1000; i++)
-    {
-      fRecPointStructArrayPtr[i].fMultiplicity = atoi(argv[4])* atoi(argv[4]);
-      // fRecPointStructArrayPtr[i].New();
+      if(!strcmp("-digitthreshold", argv[i]))
+       {
+         fClusterizerPtr->SetEmcMinEnergyThreshold(atof(argv[i+1]));
+       }
+      if(!strcmp("-recpointthreshold", argv[i]))
+       {
+         fClusterizerPtr->SetEmcClusteringThreshold(atof(argv[i+1]));
+       }
+      if(!strcmp("-modulemode", argv[i]))
+       {
+         fModuleClusterizationMode = true;
+       }
     }
-  /*
-  printf("Clusterizer component started with:\n");
-  printf(" Cell threshold:     %f\n", fClusterizerPtr->GetThreshold());
-  printf(" Cluster threshold:  %f\n", fClusterizerPtr->GetClusterThreshold());
-  printf(" High gain factor:   %f\n", fClusterizerPtr->GetHighGainFactor());
-  printf(" Low gain factor:    %f\n", fClusterizerPtr->GetLowGainFactor());
-  printf(" Cluster array size: %d\n\n", fClusterizerPtr->GetArraySize());
-  */
+
   return 0;
 }
 
 AliHLTComponent*
 AliHLTPHOSClusterizerComponent::Spawn()
 {
-  //Spawn a new AliHLTPHOSClusterizerComponent, for HLT framework
+  //See headerfile for documentation
+
   return new AliHLTPHOSClusterizerComponent();
 }