]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - PHOS/AliPHOSPreprocessor.cxx
Merge branch 'master' into LocalDev
[u/mrichter/AliRoot.git] / PHOS / AliPHOSPreprocessor.cxx
index 6837cdc87efdac32918f5be97468888b7af89fe5..a11849edfb787e1d287a864628fa3adbf02dcacd 100644 (file)
@@ -159,18 +159,20 @@ Bool_t AliPHOSPreprocessor::ProcessLEDRun()
     for(Int_t mod=0; mod<nMod; mod++) {
       for(Int_t col=0; col<nCol; col++) {
        for(Int_t row=0; row<nRow; row++) {
-
+         
+         if(clb) {
+           Float_t  hg2lg = clb->GetHighLowRatioEmc(5-mod,col+1,row+1);
+           Double_t coeff = clb->GetADCchannelEmc(5-mod,col+1,row+1);
+           calibData.SetADCchannelEmc(5-mod,col+1,row+1,coeff);
+           calibData.SetHighLowRatioEmc(5-mod,col+1,row+1,hg2lg);
+         }     
+  
          //High Gain to Low Gain ratio
          Float_t ratio = HG2LG(mod,row,col,&f);
          if(ratio != 16.) {
            calibData.SetHighLowRatioEmc(5-mod,col+1,row+1,ratio);
            AliInfo(Form("mod %d iX %d iZ %d  ratio %.3f\n",mod,row,col,ratio));
          }
-         
-         if(clb) {
-           Double_t coeff = clb->GetADCchannelEmc(mod+1,col+1,row+1);
-           calibData.SetADCchannelEmc(mod+1,col+1,row+1,coeff);
-         }       
        }
       }
     }
@@ -181,9 +183,14 @@ Bool_t AliPHOSPreprocessor::ProcessLEDRun()
   AliCDBMetaData emcMetaData;
 
   //Data valid from current run until updated (validityInfinite=kTRUE)
-  Bool_t result = Store("Calib","EmcGainPedestals",&calibData,&emcMetaData,0,kTRUE);
-  return result;
+  //Bool_t result = Store("Calib","EmcGainPedestals",&calibData,&emcMetaData,0,kTRUE);
 
+  //Store reference data
+  Bool_t refOK = StoreReferenceLED(list);
+  if(refOK) Log(Form("LED reference data successfully stored."));
+  
+  //return result;
+  return kTRUE;
 }
 
 Float_t AliPHOSPreprocessor::HG2LG(Int_t mod, Int_t X, Int_t Z, TFile* f)
@@ -191,8 +198,8 @@ Float_t AliPHOSPreprocessor::HG2LG(Int_t mod, Int_t X, Int_t Z, TFile* f)
   //Calculates High gain to Low gain ratio 
   //for crystal at the position (X,Z) in the PHOS module mod.
   
-  char hname[128];
-  sprintf(hname,"%d_%d_%d",mod,X,Z);
+  char hname[128]; TString shname = "%d_%d_%d"; 
+  snprintf(hname,shname.Length(),shname.Data(),mod,X,Z);
 
   TH1F* h1 = (TH1F*)f->Get(hname);
   if(!h1) return 16.;
@@ -243,7 +250,9 @@ Bool_t AliPHOSPreprocessor::FindBadChannelsEmc()
   Bool_t result[2] = { kTRUE, kTRUE };
 
   for (Int_t i=0; i<2; i++) {
-
+    
+    if(system[i] == kHLT) continue;
+    
     AliPHOSEmcBadChannelsMap badMap;
     list = GetFileSources(system[i], "BAD_CHANNELS");
 
@@ -259,7 +268,8 @@ Bool_t AliPHOSPreprocessor::FindBadChannelsEmc()
       continue;
     }
 
-    result[i] *= DoFindBadChannelsEmc(system[i],list,badMap);
+    Bool_t findBadOK = DoFindBadChannelsEmc(system[i],list,badMap);
+    result[i] *= findBadOK;
 
     // Store the bad channels map.
   
@@ -272,7 +282,8 @@ Bool_t AliPHOSPreprocessor::FindBadChannelsEmc()
       path = "HLT";
   
     // Data valid from current run until being updated (validityInfinite=kTRUE)
-    result[i] *= Store(path.Data(), "EmcBadChannels", &badMap, &md, 0, kTRUE);
+    Bool_t storeOK = Store(path.Data(), "EmcBadChannels", &badMap, &md, 0, kTRUE);
+    result[i] *= storeOK;
     
   }
   
@@ -289,7 +300,6 @@ Bool_t AliPHOSPreprocessor::DoFindBadChannelsEmc(Int_t system, TList* list, AliP
 
   TIter iter(list);
   TObjString *source;
-  char hnam[80];
   TH1F* h1=0;
 
   const Float_t fQualityCut = 1.;
@@ -315,9 +325,10 @@ Bool_t AliPHOSPreprocessor::DoFindBadChannelsEmc(Int_t system, TList* list, AliP
       for(Int_t iX=0; iX<64; iX++) {
        for(Int_t iZ=0; iZ<56; iZ++) {
          
-         sprintf(hnam,"%d_%d_%d_%d",mod,iX,iZ,1); // high gain 
+         TString hnam;
+         hnam += mod; hnam += "_"; hnam += iX; hnam += "_"; hnam += iZ; hnam += "_"; hnam += "1";
          h1 = (TH1F*)f.Get(hnam);
-
+         
          if(h1) {
            Double_t mean = h1->GetMean();
            
@@ -362,6 +373,8 @@ Bool_t AliPHOSPreprocessor::CalibrateEmc()
 
   for (Int_t i=0; i<2; i++) {
 
+    if(system[i] == kHLT) continue;
+
     AliPHOSEmcCalibData calibData;
     list = GetFileSources(system[i], "AMPLITUDES");
   
@@ -403,19 +416,22 @@ Bool_t AliPHOSPreprocessor::CalibrateEmc()
     else
       lastCalib = (AliPHOSEmcCalibData*)entryEmc->GetObject();
 
-    if(lastCalib)
-      result[i] *= DoCalibrateEmc(system[i],list,badMap,*lastCalib);
-    else
+    if(lastCalib) 
+      result[i] *= DoCalibrateEmc(system[i],list,badMap,*lastCalib);    
+    else 
       result[i] *= DoCalibrateEmc(system[i],list,badMap,calibData);
-
+    
     //Store EMC calibration data
-
     AliCDBMetaData emcMetaData;
     
-    if(lastCalib)
-      result[i] *= Store(path.Data(), "EmcGainPedestals", lastCalib, &emcMetaData, 0, kTRUE);
-    else
-      result[i] *= Store(path.Data(), "EmcGainPedestals", &calibData, &emcMetaData, 0, kTRUE);
+    // if(lastCalib)
+    //   result[i] *= Store(path.Data(), "EmcGainPedestals", lastCalib, &emcMetaData, 0, kFALSE);
+    // else
+    //   result[i] *= Store(path.Data(), "EmcGainPedestals", &calibData, &emcMetaData, 0, kFALSE);
+
+    //Store reference data
+    Bool_t refOK = StoreReferenceEmc(system[i],list);
+    if(refOK) Log(Form("Reference data for %s amplitudes successfully stored.",sysn[i]));
     
   }
   
@@ -423,6 +439,37 @@ Bool_t AliPHOSPreprocessor::CalibrateEmc()
   else return kFALSE;
 }
 
+Bool_t AliPHOSPreprocessor::StoreReferenceEmc(Int_t system, TList* list)
+{
+  //Put 2D calibration histograms (E vs Time) prepared by DAQ/HLT to the reference storage.
+  //system is DAQ or HLT, TList is the list of FES sources.
+
+  if(system!=kDAQ) return kFALSE;
+
+  TObjString *source = dynamic_cast<TObjString *> (list->First());
+  if(!source) return kFALSE;
+
+  TString fileName = GetFile(system, "AMPLITUDES", source->GetName());
+
+  Bool_t resultRef = StoreReferenceFile(fileName.Data(),"CalibRefPHOS.root");
+  return resultRef;
+
+}
+
+Bool_t AliPHOSPreprocessor::StoreReferenceLED(TList* list)
+{
+  //Put HG/LG histograms to the reference storage.
+  
+  TObjString *source = dynamic_cast<TObjString *> (list->First());
+  if(!source) return kFALSE;
+  
+  TString fileName = GetFile(kDAQ, "LED", source->GetName());
+  
+  Bool_t resultRef = StoreReferenceFile(fileName.Data(),"LEDRefPHOS.root");
+  return resultRef;
+  
+}
+
 
 Bool_t AliPHOSPreprocessor::DoCalibrateEmc(Int_t system, TList* list, const AliPHOSEmcBadChannelsMap* badMap, AliPHOSEmcCalibData& calibData)
 {
@@ -434,7 +481,7 @@ Bool_t AliPHOSPreprocessor::DoCalibrateEmc(Int_t system, TList* list, const AliP
   // It is a responsibility of the SHUTTLE framework to form the fileName.
 
   gRandom->SetSeed(0); //the seed is set to the current  machine clock!
-  Int_t minEntries=100; // recalculate calibration coeff. if Nentries > minEntries.
+  Int_t minEntries=1000; // recalculate calibration coeff. if Nentries > minEntries.
 
   TIter iter(list);
   TObjString *source;
@@ -499,7 +546,7 @@ Bool_t AliPHOSPreprocessor::DoCalibrateEmc(Int_t system, TList* list, const AliP
          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();
-
+         delete tks;
          if(badMap) {
            if(badMap->IsBadChannel(5-md,Z+1,X+1)) {
              AliInfo(Form("Cell mod=%d col=%d row=%d is bad. Histogram %s rejected.",
@@ -526,12 +573,14 @@ Bool_t AliPHOSPreprocessor::DoCalibrateEmc(Int_t system, TList* list, const AliP
     Double_t refMean=hRef->GetMean();
     
     // Calculates relative calibration coefficients for all non-zero channels
+
+    TString shnam = "%d_%d_%d_1";
     
     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,"%d_%d_%d_1",mod,row,col); // high gain!
+         snprintf(hnam,shnam.Length(),shnam.Data(),mod,row,col); // high gain!
          h2 = (TH2F*)f.Get(hnam);
          
          //TODO: dead channels exclusion!