ALIROOT-5433 Transition to CDHv3 in HLT
[u/mrichter/AliRoot.git] / HLT / EMCAL / AliHLTEMCALDigitMakerComponent.cxx
index 7f68953..ddcb261 100644 (file)
@@ -14,7 +14,6 @@
  * about the suitability of this software for any purpose. It is          *
  * provided "as is" without express or implied warranty.                  *
  **************************************************************************/
-
 #include "AliHLTEMCALDigitMakerComponent.h"
 #include "AliHLTCaloDigitMaker.h"
 #include "AliHLTCaloDigitDataStruct.h"
 #include <sys/stat.h>
 #include <sys/types.h>
 
+//#include "AliHLTEMCALConstant.h"
+#include "AliHLTCaloConstants.h"
+
+using EMCAL::NZROWSMOD;
+using EMCAL::NXCOLUMNSMOD;  
+using CALO::HGLGFACTOR;
 
 /** 
  * @file   AliHLTEMCALDigitMakerComponent.cxx
 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
 
 
+ClassImp(AliHLTEMCALDigitMakerComponent)
+
 AliHLTEMCALDigitMakerComponent gAliHLTEMCALDigitMakerComponent;
 
 AliHLTEMCALDigitMakerComponent::AliHLTEMCALDigitMakerComponent() :
   AliHLTCaloProcessor(),
-  AliHLTCaloConstantsHandler("EMCAL"),
+  //  AliHLTCaloConstantsHandler("EMCAL"),
   fDigitMakerPtr(0),
   fDigitContainerPtr(0),
   fPedestalData(0),
@@ -58,6 +65,7 @@ AliHLTEMCALDigitMakerComponent::AliHLTEMCALDigitMakerComponent() :
   fBCMInitialised(true),
   fGainsInitialised(true)
 {
+  
   //see header file for documentation
 }
 
@@ -112,29 +120,33 @@ AliHLTEMCALDigitMakerComponent::GetOutputDataSize(unsigned long& constBase, doub
   inputMultiplier = (float)sizeof(AliHLTCaloDigitDataStruct)/sizeof(AliHLTCaloChannelDataStruct) + 1;
 }
 
+
+
 int 
 AliHLTEMCALDigitMakerComponent::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)
 {
+
+  //patch in order to skip calib events
+  if(! IsDataEvent()) return 0;
+
   //see header file for documentation
   UInt_t offset           = 0; 
   UInt_t mysize           = 0;
   Int_t digitCount        = 0;
   Int_t ret               = 0;
-
-  AliHLTUInt8_t* outBPtr;
-  outBPtr = outputPtr;
+  
   const AliHLTComponentBlockData* iter = 0; 
   unsigned long ndx; 
-
+  
   UInt_t specification = 0;
   AliHLTCaloChannelDataHeaderStruct* tmpChannelData = 0;
   
   //  fDigitMakerPtr->SetDigitHeaderPtr(reinterpret_cast<AliHLTCaloDigitHeaderStruct*>(outputPtr));
-
+  
   fDigitMakerPtr->SetDigitDataPtr(reinterpret_cast<AliHLTCaloDigitDataStruct*>(outputPtr));
-
+  
   for( ndx = 0; ndx < evtData.fBlockCnt; ndx++ )
     {
       iter = blocks+ndx;
@@ -143,38 +155,52 @@ AliHLTEMCALDigitMakerComponent::DoEvent(const AliHLTComponentEventData& evtData,
        {
          continue;
        }
+      
+      Int_t module = 0;
+      
       if(!fBCMInitialised)
-      {
-        AliHLTEMCALMapper mapper(iter->fSpecification);
-        Int_t module = mapper.GetModuleFromSpec(iter->fSpecification);
-        for(Int_t x = 0; x < fCaloConstants->GetNXCOLUMNSMOD(); x++)
-        {
-           for(Int_t z = 0; z < fCaloConstants->GetNZROWSMOD(); z++)
-           {
-              fDigitMakerPtr->SetBadChannel(x, z, fPedestalData->IsBadChannel(module, z+1, x+1));
-           }
-        }
-        //delete fBadChannelMap;
-        fBCMInitialised = true;
-      }
+       {
+         AliHLTEMCALMapper mapper(iter->fSpecification);
+         module = mapper.GetModuleFromSpec(iter->fSpecification);
+         
+         if (module>=0) {
+         
+           for(Int_t x = 0; x < NXCOLUMNSMOD ; x++) // PTH  
+             for(Int_t z = 0; z <  NZROWSMOD ; z++) // PTH
+        // FR 
+               fDigitMakerPtr->SetBadChannel(x, z, fPedestalData->IsBadChannel(module, z, x));
+           //delete fBadChannelMap;  
+           fBCMInitialised = true;
+         }
+         else 
+           HLTError("Error setting pedestal with module value of %d", module);
+         
+       }
+      
       if(!fGainsInitialised)
-      {
-        AliHLTEMCALMapper mapper(iter->fSpecification);;
-        Int_t module = mapper.GetModuleFromSpec(iter->fSpecification);
-        for(Int_t x = 0; x < fCaloConstants->GetNXCOLUMNSMOD(); x++)
-        {
-           for(Int_t z = 0; z < fCaloConstants->GetNZROWSMOD(); z++)
-           {
-              module = 0; //removing warning
-               //fDigitMakerPtr->SetGain(x, z, fCalibData->GE(module, z+1, x+1), fCalibData->GetADCchannelEmc(module, z+1, x+1));
+       {
+         
+         AliHLTEMCALMapper mapper(iter->fSpecification);
+         module = mapper.GetModuleFromSpec(iter->fSpecification);
+           
+           if (module>=0) {
+             
+             for(Int_t x = 0; x < NXCOLUMNSMOD; x++)   //PTH
+               for(Int_t z = 0; z < NZROWSMOD; z++)   //PTH
+                 // FR setting gains 
+                 fDigitMakerPtr->SetGain(x, z, HGLGFACTOR, fCalibData->GetADCchannel(module, z, x));
+             
+             fGainsInitialised = true;
            }
-        }
-        fGainsInitialised = true;
-      }
+           else
+             HLTError("Error setting gains with module value of %d", module);
+       }
+      
       specification |= iter->fSpecification;
       tmpChannelData = reinterpret_cast<AliHLTCaloChannelDataHeaderStruct*>(iter->fPtr);
     
       ret = fDigitMakerPtr->MakeDigits(tmpChannelData, size-(digitCount*sizeof(AliHLTCaloDigitDataStruct)));
+      
       if(ret == -1) 
        {
          HLTError("Trying to write over buffer size");
@@ -226,21 +252,28 @@ AliHLTEMCALDigitMakerComponent::DoInit(int argc, const char** argv )
        {
          fDigitMakerPtr->SetGlobalHighGainFactor(atof(argv[i+1]));
        }
+
     }
- GetBCMFromCDB();
+
+  
+  if (GetBCMFromCDB()) 
+    return -1;
+  
+  if (GetGainsFromCDB()) 
+    return -1; 
+
+  //GetBCMFromCDB();
   //fDigitMakerPtr->SetDigitThreshold(2);
 
   return 0;
 }
 
+
 int AliHLTEMCALDigitMakerComponent::GetBCMFromCDB()
 {
    // See header file for class documentation
-   
-     fBCMInitialised = false;
-   
-//   HLTInfo("Getting bad channel map...");
-
+  fBCMInitialised = false;
+  //   HLTInfo("Getting bad channel map...");
   AliCDBPath path("EMCAL","Calib","Pedestals");
   if(path.GetPath())
     {
@@ -264,13 +297,12 @@ int AliHLTEMCALDigitMakerComponent::GetBCMFromCDB()
    return 0;
 }
 
+
 int AliHLTEMCALDigitMakerComponent::GetGainsFromCDB()
 {
    // See header file for class documentation
-   
-     fGainsInitialised = false;
-   
-//   HLTInfo("Getting bad channel map...");
+  fGainsInitialised = false;
+  //  HLTInfo("Getting bad channel map...");
 
   AliCDBPath path("EMCAL","Calib","Data");
   if(path.GetPath())
@@ -288,14 +320,10 @@ int AliHLTEMCALDigitMakerComponent::GetGainsFromCDB()
        }
     }
    if(!fCalibData) return -1;
-
-
-
    return 0;
 }
 
 
-
 AliHLTComponent*
 AliHLTEMCALDigitMakerComponent::Spawn()
 {