]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - PHOS/AliPHOSPreprocessor.cxx
eff C++ warnings corrected.
[u/mrichter/AliRoot.git] / PHOS / AliPHOSPreprocessor.cxx
index f6a17aa9ebbd7dc66946642a4f2ad47761a37bcf..d66af6d9ac5a98b61fe4d0a4b3d325201050de15 100644 (file)
@@ -34,6 +34,7 @@
 #include "TKey.h"
 #include "TList.h"
 #include "TObjString.h"
+#include "AliPHOSEmcBadChannelsMap.h"
 
 ClassImp(AliPHOSPreprocessor)
 
@@ -60,18 +61,28 @@ UInt_t AliPHOSPreprocessor::Process(TMap* /*valueSet*/)
   // AliPHOSCalibHistoProducer.
   // It is a responsibility of the SHUTTLE framework to form the fileName
   
+  TString runType = GetRunType();
+  Log(Form("Run type: %s",runType.Data()));
+
+  if(runType=="LED") {
+    Bool_t ledOK = ProcessLEDRun();
+    if(ledOK) return 0;
+    else
+      return 1;
+  }
+
   gRandom->SetSeed(0); //the seed is set to the current  machine clock!
   AliPHOSEmcCalibData calibData;
-  
+
   TList* list = GetFileSources(kDAQ, "AMPLITUDES");
   if(!list) {
     Log("Sources list not found, exit.");
-    return 0;
+    return 1;
   }
 
   TIter iter(list);
   TObjString *source;
-
+  
   while ((source = dynamic_cast<TObjString *> (iter.Next()))) {
     AliInfo(Form("found source %s", source->String().Data()));
 
@@ -82,7 +93,7 @@ UInt_t AliPHOSPreprocessor::Process(TMap* /*valueSet*/)
 
     if(!f.IsOpen()) {
       Log(Form("File %s is not opened, something goes wrong!",fileName.Data()));
-      return 0;
+      return 1;
     }
 
     const Int_t nMod=5; // 1:5 modules
@@ -92,7 +103,7 @@ UInt_t AliPHOSPreprocessor::Process(TMap* /*valueSet*/)
     Double_t coeff;
     char hnam[80];
     TH1F* histo=0;
-
+    
     //Get the reference histogram
     //(author: Gustavo Conesa Balbastre)
 
@@ -104,7 +115,7 @@ UInt_t AliPHOSPreprocessor::Process(TMap* /*valueSet*/)
     Int_t ikey = 0;
     Int_t counter = 0;
     TH1F* hRef = 0;
-
+    
     //Check if the file contains any histogram
     
     if(nkeys< 2){
@@ -125,15 +136,15 @@ UInt_t AliPHOSPreprocessor::Process(TMap* /*valueSet*/)
        return 1;
       }
     }
-
+    
     Log(Form("reference histogram %s, %.1f entries, mean=%.3f, rms=%.3f.",
             hRef->GetName(),hRef->GetEntries(),
             hRef->GetMean(),hRef->GetRMS()));
 
     Double_t refMean=hRef->GetMean();
-
+    
     // Calculates relative calibration coefficients for all non-zero channels
-
+    
     for(Int_t mod=0; mod<nMod; mod++) {
       for(Int_t col=0; col<nCol; col++) {
        for(Int_t row=0; row<nRow; row++) {
@@ -142,7 +153,10 @@ UInt_t AliPHOSPreprocessor::Process(TMap* /*valueSet*/)
          //TODO: dead channels exclusion!
          if(histo) {
            coeff = histo->GetMean()/refMean;
-           calibData.SetADCchannelEmc(mod+1,col+1,row+1,0.001/coeff);
+           if(coeff>0)
+             calibData.SetADCchannelEmc(mod+1,col+1,row+1,0.001/coeff);
+           else 
+             calibData.SetADCchannelEmc(mod+1,col+1,row+1,0.001);
            AliInfo(Form("mod %d col %d row %d  coeff %f\n",mod,col,row,coeff));
          }
          else
@@ -154,9 +168,77 @@ UInt_t AliPHOSPreprocessor::Process(TMap* /*valueSet*/)
     f.Close();
   }
   
-  AliCDBMetaData metaData;
-  Int_t result = Store("Calib", "EmcData", &calibData, &metaData);
+  //Store EMC calibration data
+  
+  AliCDBMetaData emcMetaData;
+  Bool_t emcOK = Store("Calib", "EmcGainPedestals", &calibData, &emcMetaData);
+
+  if(emcOK) return 0;
+  else
+    return 1;
+
+}
+
+
+Bool_t AliPHOSPreprocessor::ProcessLEDRun()
+{
+  //Process LED run, fill bad channels map.
+
+  AliPHOSEmcBadChannelsMap badMap;
+
+  TList* list = GetFileSources(kDAQ, "LED");
+  if(!list) {
+    Log("Sources list for LED run not found, exit.");
+    return kFALSE;
+  }
+
+  TIter iter(list);
+  TObjString *source;
+  char hnam[80];
+  TH1F* histo=0;
+  
+  while ((source = dynamic_cast<TObjString *> (iter.Next()))) {
+
+    AliInfo(Form("found source %s", source->String().Data()));
+
+    TString fileName = GetFile(kDAQ, "LED", source->GetName());
+    AliInfo(Form("Got filename: %s",fileName.Data()));
+
+    TFile f(fileName);
+
+    if(!f.IsOpen()) {
+      Log(Form("File %s is not opened, something goes wrong!",fileName.Data()));
+      return kFALSE;
+    }
+
+    const Int_t nMod=5; // 1:5 modules
+    const Int_t nCol=56; //1:56 columns in each module
+    const Int_t nRow=64; //1:64 rows in each module
+
+    // Check for dead channels    
+    Log(Form("Begin check for dead channels."));
+
+    for(Int_t mod=0; mod<nMod; mod++) {
+      for(Int_t col=0; col<nCol; col++) {
+       for(Int_t row=0; row<nRow; row++) {
+         sprintf(hnam,"mod%dcol%drow%d",mod,col,row);
+         histo = (TH1F*)f.Get(hnam);
+         if(histo)
+           if (histo->GetMean()<1) {
+             Log(Form("Channel: [%d,%d,%d] seems dead, <E>=%.1f.",mod,col,row,histo->GetMean()));
+             badMap.SetBadChannel(mod,col,row);
+           }
+       }
+      }
+    }
+
+  }
+
+  //Store bad channels map
+  AliCDBMetaData badMapMetaData;
 
+  //Bad channels data valid from current run fRun until updated (validityInfinite=kTRUE)
+  Bool_t result = Store("Calib", "EmcBadChannels", &badMap, &badMapMetaData, fRun, kTRUE);
   return result;
 
 }