]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - PHOS/AliPHOSPreprocessor.cxx
Changes with time coordinate (Marian)
[u/mrichter/AliRoot.git] / PHOS / AliPHOSPreprocessor.cxx
index 9ce681a77ce86411d05534de203d9cf4bb923402..4c3e7261b8820ad66d047fb8c37cf94b319cae0d 100644 (file)
@@ -26,6 +26,7 @@
 #include "AliPHOSPreprocessor.h"
 #include "AliLog.h"
 #include "AliCDBMetaData.h"
+#include "AliCDBEntry.h"
 #include "AliPHOSEmcCalibData.h"
 #include "TFile.h"
 #include "TH1.h"
 #include "TKey.h"
 #include "TList.h"
 #include "TObjString.h"
+#include "TObjArray.h"
 #include "TObject.h"
 #include "TString.h"
 #include "TMath.h"
+#include "TAxis.h"
 #include "AliPHOSEmcBadChannelsMap.h"
 
 ClassImp(AliPHOSPreprocessor)
@@ -62,6 +65,9 @@ AliPHOSPreprocessor::AliPHOSPreprocessor(AliShuttleInterface* shuttle):
 AliPreprocessor("PHS",shuttle)
 {
   // Constructor
+
+  AddRunType("PHYSICS");
+  AddRunType("STANDALONE");
 }
 
 //_______________________________________________________________________________________
@@ -188,7 +194,7 @@ Float_t AliPHOSPreprocessor::HG2LG(Int_t mod, Int_t X, Int_t Z, TFile* f)
   gaus1->SetLineColor(kBlue);
   h1->Fit(gaus1,"LERQ+");
 
-  Log(Form("\t%s: %d entries, mean=%.3f, peak=%.3f, rms= %.3f. HG/LG = %.3f\n",
+  AliInfo(Form("%s: %d entries, mean=%.3f, peak=%.3f, rms= %.3f. HG/LG = %.3f\n",
           h1->GetTitle(),h1->GetEntries(),h1->GetMean(),max,h1->GetRMS(),
           gaus1->GetParameter("Mean"))); 
 
@@ -305,6 +311,19 @@ Bool_t AliPHOSPreprocessor::CalibrateEmc()
     return kFALSE;
   }
 
+  // Retrieve Bad Channels Map (BCM)
+
+  const AliPHOSEmcBadChannelsMap* badMap=0;
+  AliCDBEntry* entryBCM = GetFromOCDB("Calib", "EmcBadChannels");
+
+  if(!entryBCM)
+    Log(Form("WARNING!! Cannot find any AliCDBEntry for [Calib, EmcBadChannels]!"));
+  else
+    badMap = (AliPHOSEmcBadChannelsMap*)entryBCM->GetObject();
+
+  if(!badMap)
+    Log(Form("WARNING!! No Bad Channels Map in AliCDBEntry. All cells considered _GOOD_!"));
+
   TIter iter(list);
   TObjString *source;
   
@@ -358,9 +377,25 @@ Bool_t AliPHOSPreprocessor::CalibrateEmc()
        TString htitl = h2->GetTitle();
        if(htitl.Contains("and gain 1")) {
          hRef = h2->ProjectionX();
-         hRef->SetBins(1000,0.,1000.); // to cut off saturation peak at 1023
+         hRef->GetXaxis()->SetRange(10,1000); // to cut off saturation peak and noise
          // Check if the reference histogram has too little statistics
-         if(hRef->GetEntries()>2) ok=kTRUE;
+         if(hRef->GetMean() && hRef->GetEntries()>2) ok=kTRUE;
+
+         const TString delim = "_";
+         TString str = hRef->GetName();
+         TObjArray* tks = str.Tokenize(delim);
+         const Int_t md = ((TObjString*)tks->At(0))->GetString().Atoi();
+         const Int_t X   = ((TObjString*)tks->At(1))->GetString().Atoi();
+         const Int_t Z   = ((TObjString*)tks->At(2))->GetString().Atoi();
+
+         if(badMap) {
+           if(badMap->IsBadChannel(md+1,Z+1,X+1)) {
+             AliInfo(Form("Cell mod=%d col=%d row=%d is bad. Histogram %s rejected.",
+                          md+1,Z+1,X+1,hRef->GetName()));
+             ok=kFALSE;
+           }
+         }
+
        }
       }
       
@@ -394,7 +429,7 @@ Bool_t AliPHOSPreprocessor::CalibrateEmc()
          //TODO: dead channels exclusion!
          if(h2) {
            h1 = h2->ProjectionX();
-           h1->SetBins(1000,0.,1000.); // to cut off saturation peak at 1023
+           h1->GetXaxis()->SetRange(10,1000); //to cut off saturation peak and noise
            coeff = h1->GetMean()/refMean;
            if(coeff>0)
              calibData.SetADCchannelEmc(mod+1,col+1,row+1,1./coeff);