]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
add option to compare the online reference stored in OADB and OCDB
authorgconesab <gustavo.conesa.balbastre@cern.ch>
Tue, 8 Apr 2014 15:09:52 +0000 (17:09 +0200)
committergconesab <gustavo.conesa.balbastre@cern.ch>
Tue, 8 Apr 2014 15:12:41 +0000 (17:12 +0200)
EMCAL/macros/OADB/CompareAODB_OCDB.C

index a5b8f5f0876cb2774c11f1d5c2c447edc7052116..2e6ce66abd8dc2e0e846247dab5dde06299d31b5 100644 (file)
@@ -4,8 +4,8 @@
 
 // Author : Gustavo Conesa Balbastre (LPSC-CNRS)
 
-void CompareAODB_OCDB(Int_t run = 153323, TString pathOADB = "$ALICE_ROOT/OADB/EMCAL",
-                      Int_t checkObject = 1, TString pass = "pass1", Bool_t printAll = kFALSE)
+void CompareAODB_OCDB(Int_t run = 160000, TString pathOADB = "$ALICE_ROOT/OADB/EMCAL",
+                      Int_t checkObject = 2, TString pass = "pass1", Bool_t printAll = kFALSE)
 {  
 
   gSystem->Load("libOADB");
@@ -23,9 +23,9 @@ void CompareAODB_OCDB(Int_t run = 153323, TString pathOADB = "$ALICE_ROOT/OADB/E
   else if(run < 198000) geom = AliEMCALGeometry::GetInstance("EMCAL_COMPLETEV1");  // 2011-2012-2013
   else                  geom = AliEMCALGeometry::GetInstance("EMCAL_COMPLETE12SMV1_DCAL_8SM"); // Run2
   
-  if     (checkObject == 0) CheckBadChannels      (run, pathOADB, storage, geom,     printAll);
-  else if(checkObject == 1) CheckEnergyCalibration(run, pathOADB, storage, geom,pass,printAll);
-  else if(checkObject == 2) CheckTimeCalibration  (run, pathOADB, storage, geom,pass,printAll);
+  if     (checkObject == 0) CheckBadChannels            (run, pathOADB, storage, geom,     printAll);
+  else if(checkObject == 1) CheckEnergyCalibration      (run, pathOADB, storage, geom,pass,printAll);
+  else if(checkObject == 2) CheckEnergyOnlineCalibration(run, pathOADB, storage, geom,     printAll);
   else printf("non existing object option\n");
   
   printf("*** Comparisons ended *** \n");
@@ -112,19 +112,19 @@ void CheckEnergyCalibration(Int_t run, TString pathOADB, AliCDBStorage * storage
     paramAODB*=0.0162; // Transformation into OCDB parameter, it will not work for all channels
     
     if    (printAll)
-    printf("STATUS: ID %d, col %d, row %d, sm %d  OCDB %1.4f, OADB %1.4f\n",
+    printf("Recalibration parameter: ID %d, col %d, row %d, sm %d  OCDB %1.4f, OADB %1.4f\n",
            i,iCol,iRow,iSM,paramOCDB, paramAODB);
     else if(paramAODB > 0)
     {
       if (paramOCDB/paramAODB > 1.01 || paramOCDB/paramAODB < 0.99) )
       {
-        printf("DIFFERENT STATUS: ID %d, col %d, row %d, sm %d  OCDB %1.4f, OADB %1.4f, ratio OCDB/OADB %1.4f\n",//, old OCDB param %1.4f\n",
+        printf("DIFFERENT recalibration parameter: ID %d, col %d, row %d, sm %d  OCDB %1.4f, OADB %1.4f, ratio OCDB/OADB %1.4f\n",//, old OCDB param %1.4f\n",
                i,iCol,iRow,iSM,paramOCDB, paramAODB,paramOCDB/paramAODB);//,paramOCDB2);
         nDiff++;
       }
       else if(paramAODB <= 0)
       {
-        printf("DIFFERENT STATUS: ID %d, col %d, row %d, sm %d  OCDB %1.4f, OADB %1.4f\n",//, old OCDB param %1.4f\n",
+        printf("DIFFERENT recalibration parameter: ID %d, col %d, row %d, sm %d  OCDB %1.4f, OADB %1.4f\n",//, old OCDB param %1.4f\n",
                i,iCol,iRow,iSM,paramOCDB, paramAODB);//,paramOCDB2);
         nDiff++;
       }
@@ -140,6 +140,91 @@ void CheckEnergyCalibration(Int_t run, TString pathOADB, AliCDBStorage * storage
   if(!printAll) printf("Total number of different channels %d / %d\n",nDiff,nSM*24*48);//, origin %d\n",nDiff,nSM*24*48,nDiff2);
 }
 
+//___________________________
+void CheckEnergyOnlineCalibration(Int_t run, TString pathOADB, AliCDBStorage * storage, AliEMCALGeometry *geom,
+                            Bool_t printAll = kTRUE)
+{
+  // Check energy recalibration, Uncomplete
+  
+  AliOADBContainer *contRF=new AliOADBContainer("");
+  contRF->InitFromFile(Form("%s/EMCALCalibOnlineRef.root",pathOADB.Data()),"AliEMCALRecalib");
+  
+  const Int_t nSM = geom->GetNumberOfSuperModules();
+  
+  // Get the OCDB object
+  // Access directly the OCDB file and not the latest version
+  TFile * f = 0;
+  if     (run < 140000)
+    f = TFile::Open("alien:///alice/data/2010/OCDB/EMCAL/Calib/Data/Run113461_999999999_v3_s0.root","READ");
+  else if(run < 171000)
+    f = TFile::Open("alien:///alice/data/2011/OCDB/EMCAL/Calib/Data/Run144484_999999999_v3_s0.root","READ");
+  else if(run < 198000)
+    f = TFile::Open("alien:///alice/data/2012/OCDB/EMCAL/Calib/Data/Run177115_999999999_v2_s0.root","READ");
+  else {
+    printf("Run not available\n");
+    return;
+  }
+  
+  AliCDBEntry * cdb = (AliCDBEntry*) f->Get("AliCDBEntry");
+  AliEMCALCalibData* cparam = (AliEMCALCalibData*)  cdb->GetObject();
+  
+  // Get the OADB object
+  
+  TH2F *h[12];
+  
+  TObjArray *cal=(TObjArray*)contRF->GetObject(run);
+  
+  if(!cal)
+  {
+    printf("Energy online calibration OADB not found  3\n");
+    return;
+  }
+
+  for (Int_t i=0; i < nSM; ++i)
+  {
+    h[i] = (TH2F*)cal->FindObject(Form("EMCALRecalFactors_SM%d",i));
+    if (!h[i])
+    {
+      AliError(Form("Could not load EMCALRecalFactors_SM%d",i));
+      continue;
+    }
+  }
+  
+  // Do the comparison
+  Float_t paramOCDB = -1;
+  Float_t paramAODB = -1;
+  Int_t nDiff = 0;
+  //  Int_t nDiff2 = 0;
+  Int_t iCol = -1, iRow = -1, iSM =-1, iMod = -1,iIphi =-1,iIeta = -1;
+  for(Int_t i=0;i < nSM*24*48; i++)
+  {
+    //printf("AbsID %d\n",i);
+    geom->GetCellIndex(i,iSM,iMod,iIphi,iIeta);
+    geom->GetCellPhiEtaIndexInSModule(iSM,iMod, iIphi, iIeta,iRow,iCol);
+    
+    Float_t paramOCDB = -1;
+    if(cparam) paramOCDB = cparam->GetADCchannel(iSM,iCol,iRow);
+    
+    Float_t paramAODB = -1;
+    if(h[iSM]) paramAODB = h[iSM]->GetBinContent(iCol,iRow);
+    
+    if    (printAll)
+    printf("Online Calib: ID %d, col %d, row %d, sm %d  OCDB %1.4f, OADB %1.4f\n",
+           i,iCol,iRow,iSM,paramOCDB, paramAODB);
+    
+    if (TMath::Abs(paramOCDB-paramAODB) > 0.001)//  || (TMath::Abs(paramOCDB-0.0162)> 0.001))
+    {
+      printf("Online Calib DIFFERENT: ID %d, col %d, row %d, sm %d  OCDB %1.4f, OADB %1.4f, diff OCDB-OADB %1.4f\n",
+             i,iCol,iRow,iSM,paramOCDB, paramAODB,paramOCDB-paramAODB);
+      nDiff++;
+    }
+    
+    
+  }
+  
+  if(!printAll) printf("Total number of different channels %d / %d\n",nDiff,nSM*24*48);//, origin %d\n",nDiff,nSM*24*48,nDiff2);
+}
+
 //_____________________
 void CheckBadChannels(Int_t run, TString pathOADB, AliCDBStorage * storage, AliEMCALGeometry *geom, Bool_t printAll = kTRUE)
 {