]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - HLT/PHOS/AliHLTPHOSDigitMakerComponent.cxx
ALIROOT-5600 - skip non-participating detector modules
[u/mrichter/AliRoot.git] / HLT / PHOS / AliHLTPHOSDigitMakerComponent.cxx
index 0712ab062182f443ac674ade2fbf151b509adec9..997a499094317630a0a8e2d606ec90b85a6980fc 100644 (file)
 #include "AliHLTCaloDigitMaker.h"
 #include "AliHLTCaloDigitDataStruct.h"
 #include "AliHLTPHOSMapper.h"
-#include "AliHLTPHOSChannelDataHeaderStruct.h"
-#include "AliHLTPHOSChannelDataStruct.h"
+#include "AliHLTCaloChannelDataHeaderStruct.h"
+#include "AliHLTCaloChannelDataStruct.h"
+#include "AliPHOSEmcBadChannelsMap.h"
+#include "AliPHOSEmcCalibData.h"
 #include "TFile.h"
+#include "AliCDBEntry.h"
+#include "AliCDBPath.h"
+#include "AliCDBManager.h"
 #include <sys/stat.h>
 #include <sys/types.h>
 
 
 /** 
- * @file   AliHLTCaloDigitMakerComponent.cxx
+ * @file   AliHLTPHOSDigitMakerComponent.cxx
  * @author Oystein Djuvsland
  * @date   
  * @brief  A digit maker component for PHOS HLT
 // or
 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
 
-
-AliHLTPHOSDigitMakerComponent gAliHLTPHOSDigitMakerComponent;
+ClassImp(AliHLTPHOSDigitMakerComponent);
 
 AliHLTPHOSDigitMakerComponent::AliHLTPHOSDigitMakerComponent() :
-  AliHLTPHOSProcessor(),
+  AliHLTCaloProcessor(),
+  AliHLTCaloConstantsHandler("PHOS"),
   fDigitMakerPtr(0),
-  fDigitContainerPtr(0)
+  fDigitContainerPtr(0),
+  fBadChannelMap(0),
+  fCalibData(0),
+  fBCMInitialised(true),
+  fGainsInitialised(true)
 {
   //see header file for documentation
 }
@@ -97,7 +106,7 @@ AliHLTPHOSDigitMakerComponent::GetOutputDataSize(unsigned long& constBase, doubl
 {
   //see header file for documentation
   constBase = 0;
-  inputMultiplier = (float)sizeof(AliHLTCaloDigitDataStruct)/sizeof(AliHLTPHOSChannelDataStruct) + 1;
+  inputMultiplier = (float)sizeof(AliHLTCaloDigitDataStruct)/sizeof(AliHLTCaloChannelDataStruct) + 1;
 }
 
 int 
@@ -111,8 +120,6 @@ AliHLTPHOSDigitMakerComponent::DoEvent(const AliHLTComponentEventData& evtData,
   Int_t digitCount        = 0;
   Int_t ret               = 0;
 
-  AliHLTUInt8_t* outBPtr;
-  outBPtr = outputPtr;
   const AliHLTComponentBlockData* iter = 0; 
   unsigned long ndx; 
 
@@ -125,13 +132,48 @@ AliHLTPHOSDigitMakerComponent::DoEvent(const AliHLTComponentEventData& evtData,
 
   for( ndx = 0; ndx < evtData.fBlockCnt; ndx++ )
     {
+      
       iter = blocks+ndx;
       
       if(iter->fDataType != AliHLTPHOSDefinitions::fgkChannelDataType)
        {
-         HLTDebug("Data block is not of type fgkChannelDataType");
+//       HLTDebug("Data block is not of type fgkChannelDataType");
          continue;
        }
+      if(!fBCMInitialised)
+      {
+        AliHLTPHOSMapper mapper;
+        Int_t module = mapper.GetModuleFromSpec(iter->fSpecification);
+        if(module >= 0)
+          {
+            for(Int_t x = 0; x < fCaloConstants->GetNXCOLUMNSMOD(); x++)
+              {
+                for(Int_t z = 0; z < fCaloConstants->GetNZROWSMOD(); z++)
+                  {
+                    fDigitMakerPtr->SetBadChannel(x, z, fBadChannelMap->IsBadChannel(5-module, z+1, x+1));
+                  }
+              }
+        }
+        //delete fBadChannelMap;
+        fBCMInitialised = true;
+      }
+      if(!fGainsInitialised)
+      {
+        AliHLTPHOSMapper mapper;
+        Int_t module = mapper.GetModuleFromSpec(iter->fSpecification);
+        if(module >= 0 && module < 5)
+          {
+            for(Int_t x = 0; x < fCaloConstants->GetNXCOLUMNSMOD(); x++)
+              {
+                for(Int_t z = 0; z < fCaloConstants->GetNZROWSMOD(); z++)
+                  {
+                    fDigitMakerPtr->SetGain(x, z, fCalibData->GetHighLowRatioEmc(5-module, z+1, x+1), fCalibData->GetADCchannelEmc(5-module, z+1, x+1));
+                  }
+              }
+            fGainsInitialised = true;
+        }
+
+      }
 
       specification |= iter->fSpecification;
       tmpChannelData = reinterpret_cast<AliHLTCaloChannelDataHeaderStruct*>(iter->fPtr);
@@ -167,7 +209,6 @@ AliHLTPHOSDigitMakerComponent::DoEvent(const AliHLTComponentEventData& evtData,
   return 0;
 }
 
-
 int
 AliHLTPHOSDigitMakerComponent::DoInit(int argc, const char** argv )
 {
@@ -178,6 +219,9 @@ AliHLTPHOSDigitMakerComponent::DoInit(int argc, const char** argv )
   AliHLTCaloMapper *mapper = new AliHLTPHOSMapper();
   fDigitMakerPtr->SetMapper(mapper);
   
+  Float_t mintime = 0.;
+  Float_t maxtime =50.;
+  
   for(int i = 0; i < argc; i++)
     {
       if(!strcmp("-lowgainfactor", argv[i]))
@@ -188,13 +232,80 @@ AliHLTPHOSDigitMakerComponent::DoInit(int argc, const char** argv )
        {
          fDigitMakerPtr->SetGlobalHighGainFactor(atof(argv[i+1]));
        }
+       if(!strcmp("-mintime", argv[i]))
+       {
+          mintime = atof(argv[i+1]);
+       }
+       if(!strcmp("-maxtime", argv[i]))
+       {
+          maxtime = atof(argv[i+1]);
+       }
     }
  
+ fDigitMakerPtr->SetTimeWindow(mintime, maxtime);
+
+ if(GetBCMFromCDB()) return -1;
+ if(GetGainsFromCDB()) return -1;
+  
   //fDigitMakerPtr->SetDigitThreshold(2);
 
   return 0;
 }
 
+
+int AliHLTPHOSDigitMakerComponent::GetBCMFromCDB()
+{
+   fBCMInitialised = false;
+   
+//   HLTInfo("Getting bad channel map...");
+
+  AliCDBPath path("PHOS","Calib","EmcBadChannels");
+  if(path.GetPath())
+    {
+      //      HLTInfo("configure from entry %s", path.GetPath());
+      AliCDBEntry *pEntry = AliCDBManager::Instance()->Get(path/*,GetRunNo()*/);
+       if (pEntry) 
+       {
+           fBadChannelMap = (AliPHOSEmcBadChannelsMap*)pEntry->GetObject();
+       }
+      else
+       {
+           HLTError("can not fetch object \"%s\" from CDB", path.GetPath().Data());
+           return -1;
+       }
+    }
+   if(!fBadChannelMap) return -1;
+   return 0;
+}
+
+int AliHLTPHOSDigitMakerComponent::GetGainsFromCDB()
+{
+   fGainsInitialised = false;
+   
+//   HLTInfo("Getting bad channel map...");
+
+  AliCDBPath path("PHOS","Calib","EmcGainPedestals");
+  if(path.GetPath())
+    {
+      //      HLTInfo("configure from entry %s", path.GetPath());*/
+      AliCDBEntry *pEntry = AliCDBManager::Instance()->Get(path/*,GetRunNo()*/);
+      if (pEntry) 
+       {
+           fCalibData = (AliPHOSEmcCalibData*)pEntry->GetObject();
+       }
+      else     
+       {
+           HLTError("can not fetch object \"%s\" from CDB", path.GetPath().Data());
+           return -1;
+       }
+    }
+    
+    if(!fCalibData) return -1;
+   return 0;
+   
+}
+
+
 AliHLTComponent*
 AliHLTPHOSDigitMakerComponent::Spawn()
 {