]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - HLT/PHOS/AliHLTPHOSDigitMakerComponent.cxx
Changes for #64259 Request for including the new class AliTRDresponse in STEER and...
[u/mrichter/AliRoot.git] / HLT / PHOS / AliHLTPHOSDigitMakerComponent.cxx
index c35bc8c71b6525bc744737f56124e124129568ec..7474f5966a669e4aab35d9814b0d4e0a229a2e08 100644 (file)
@@ -1,3 +1,5 @@
+ // $Id$
+
  /**************************************************************************
  * This file is property of and copyright by the ALICE HLT Project        *
  * All rights reserved.                                                   *
  **************************************************************************/
 
 #include "AliHLTPHOSDigitMakerComponent.h"
-#include "AliHLTPHOSDigitMaker.h"
-#include "TTree.h"
-#include "AliHLTPHOSProcessor.h"
-#include "AliHLTPHOSRcuCellEnergyDataStruct.h"
-#include "AliHLTPHOSDigitContainerDataStruct.h"
+#include "AliHLTCaloDigitMaker.h"
+#include "AliHLTCaloDigitDataStruct.h"
+#include "AliHLTPHOSMapper.h"
 #include "AliHLTPHOSChannelDataHeaderStruct.h"
-#include "TClonesArray.h"
+#include "AliHLTPHOSChannelDataStruct.h"
 #include "TFile.h"
 #include <sys/stat.h>
 #include <sys/types.h>
 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
 
 
-const AliHLTComponentDataType AliHLTPHOSDigitMakerComponent::fgkInputDataTypes[]={kAliHLTVoidDataType,{0,"",""}};
-
 AliHLTPHOSDigitMakerComponent gAliHLTPHOSDigitMakerComponent;
 
 AliHLTPHOSDigitMakerComponent::AliHLTPHOSDigitMakerComponent() :
   AliHLTPHOSProcessor(),
   fDigitMakerPtr(0),
   fDigitContainerPtr(0)
-  //  fEvtCnt(0)
 {
   //see header file for documentation
 }
 
+
 AliHLTPHOSDigitMakerComponent::~AliHLTPHOSDigitMakerComponent()
 {
   //see header file for documentation
@@ -84,12 +82,6 @@ AliHLTPHOSDigitMakerComponent::GetInputDataTypes(vector<AliHLTComponentDataType>
   //see header file for documentation
   list.clear();
   list.push_back(AliHLTPHOSDefinitions::fgkChannelDataType);
-
-//   const AliHLTComponentDataType* pType=fgkInputDataTypes;
-//   while (pType->fID!=0) {
-//     list.push_back(*pType); 
-//     pType++;
-//   }
 }
 
 AliHLTComponentDataType 
@@ -104,8 +96,8 @@ void
 AliHLTPHOSDigitMakerComponent::GetOutputDataSize(unsigned long& constBase, double& inputMultiplier)
 {
   //see header file for documentation
-  constBase = sizeof(AliHLTPHOSDigitContainerDataStruct);
-  inputMultiplier = 1;
+  constBase = 0;
+  inputMultiplier = (float)sizeof(AliHLTCaloDigitDataStruct)/sizeof(AliHLTPHOSChannelDataStruct) + 1;
 }
 
 int 
@@ -114,10 +106,10 @@ AliHLTPHOSDigitMakerComponent::DoEvent(const AliHLTComponentEventData& evtData,
                                        std::vector<AliHLTComponentBlockData>& outputBlocks)
 {
   //see header file for documentation
-  UInt_t tSize            = 0;
   UInt_t offset           = 0; 
   UInt_t mysize           = 0;
-  Int_t digitCount = 0;
+  Int_t digitCount        = 0;
+  Int_t ret               = 0;
 
   AliHLTUInt8_t* outBPtr;
   outBPtr = outputPtr;
@@ -125,9 +117,11 @@ AliHLTPHOSDigitMakerComponent::DoEvent(const AliHLTComponentEventData& evtData,
   unsigned long ndx; 
 
   UInt_t specification = 0;
-  AliHLTPHOSChannelDataHeaderStruct* tmpChannelData = 0;
+  AliHLTCaloChannelDataHeaderStruct* tmpChannelData = 0;
   
-  fDigitMakerPtr->SetDigitContainerStruct(reinterpret_cast<AliHLTPHOSDigitContainerDataStruct*>(outputPtr));
+  //  fDigitMakerPtr->SetDigitHeaderPtr(reinterpret_cast<AliHLTCaloDigitHeaderStruct*>(outputPtr));
+
+  fDigitMakerPtr->SetDigitDataPtr(reinterpret_cast<AliHLTCaloDigitDataStruct*>(outputPtr));
 
   for( ndx = 0; ndx < evtData.fBlockCnt; ndx++ )
     {
@@ -138,34 +132,32 @@ AliHLTPHOSDigitMakerComponent::DoEvent(const AliHLTComponentEventData& evtData,
          HLTDebug("Data block is not of type fgkChannelDataType");
          continue;
        }
-      if(iter == 0) continue;
-      if((reinterpret_cast<AliHLTPHOSChannelDataHeaderStruct*>(iter->fPtr))->fNChannels == 0) continue;
-      specification = specification|iter->fSpecification;
-      tmpChannelData = reinterpret_cast<AliHLTPHOSChannelDataHeaderStruct*>(iter->fPtr);
+
+      specification |= iter->fSpecification;
+      tmpChannelData = reinterpret_cast<AliHLTCaloChannelDataHeaderStruct*>(iter->fPtr);
     
-      digitCount += fDigitMakerPtr->MakeDigits(tmpChannelData);
+      ret = fDigitMakerPtr->MakeDigits(tmpChannelData, size-(digitCount*sizeof(AliHLTCaloDigitDataStruct)));
+      if(ret == -1) 
+       {
+         HLTError("Trying to write over buffer size");
+         return -ENOBUFS;
+       }
+      digitCount += ret; 
     }
   
-  //  mysize = 0;
-  //offset = tSize;
-      
-  mysize += sizeof(AliHLTPHOSDigitContainerDataStruct);
-  (reinterpret_cast<AliHLTPHOSDigitContainerDataStruct*>(outputPtr))->fNDigits = digitCount;
-  AliHLTComponentBlockData bd;
-  FillBlockData( bd );
-  bd.fOffset = offset;
-  bd.fSize = mysize;
-  bd.fDataType = AliHLTPHOSDefinitions::fgkDigitDataType;
-  bd.fSpecification = specification;
-  outputBlocks.push_back(bd);
-       
-//   tSize += mysize;
-//   outputPtr += mysize;
-
-  if( tSize > size )
+  mysize += digitCount*sizeof(AliHLTCaloDigitDataStruct);
+
+  HLTDebug("# of digits: %d, used memory size: %d, available size: %d", digitCount, mysize, size);
+
+  if(mysize > 0) 
     {
-      Logging( kHLTLogFatal, "HLT::AliHLTPHOSDigitMakerComponent::DoEvent", "Too much data", "Data written over allowed buffer. Amount written: %lu, allowed amount: %lu.", tSize, size );
-      return EMSGSIZE;
+      AliHLTComponentBlockData bd;
+      FillBlockData( bd );
+      bd.fOffset = offset;
+      bd.fSize = mysize;
+      bd.fDataType = AliHLTPHOSDefinitions::fgkDigitDataType;
+      bd.fSpecification = specification;
+      outputBlocks.push_back(bd);
     }
 
   fDigitMakerPtr->Reset();
@@ -181,14 +173,13 @@ AliHLTPHOSDigitMakerComponent::DoInit(int argc, const char** argv )
 {
   //see header file for documentation
 
-  fDigitMakerPtr = new AliHLTPHOSDigitMaker();
+  fDigitMakerPtr = new AliHLTCaloDigitMaker("PHOS");
+
+  AliHLTCaloMapper *mapper = new AliHLTPHOSMapper();
+  fDigitMakerPtr->SetMapper(mapper);
   
   for(int i = 0; i < argc; i++)
     {
-      if(!strcmp("-rmsfilepath", argv[i]))
-       {
-         fDigitMakerPtr->SetDigitThresholds(argv[i+1], 3);
-       }
       if(!strcmp("-lowgainfactor", argv[i]))
        {
          fDigitMakerPtr->SetGlobalLowGainFactor(atof(argv[i+1]));
@@ -197,10 +188,6 @@ AliHLTPHOSDigitMakerComponent::DoInit(int argc, const char** argv )
        {
          fDigitMakerPtr->SetGlobalHighGainFactor(atof(argv[i+1]));
        }
-      if(!strcmp("-digitthresholds", argv[i]))
-       {
-         fDigitMakerPtr->SetDigitThresholds(atof(argv[i+1]), atof(argv[i+2]));
-       }
     }
  
   //fDigitMakerPtr->SetDigitThreshold(2);