complete the method comparing energy calibration in OADB and OCDB, other improvements
authorgconesab <gustavo.conesa.balbastre@cern.ch>
Fri, 4 Apr 2014 13:16:06 +0000 (15:16 +0200)
committergconesab <gustavo.conesa.balbastre@cern.ch>
Fri, 4 Apr 2014 13:17:24 +0000 (15:17 +0200)
EMCAL/macros/OADB/CompareAODB_OCDB.C

index d86291a..a5b8f5f 100644 (file)
@@ -4,7 +4,8 @@
 
 // Author : Gustavo Conesa Balbastre (LPSC-CNRS)
 
-void CompareAODB_OCDB(Int_t run = 146806, TString pathOADB = "$ALICE_ROOT/OADB/EMCAL")
+void CompareAODB_OCDB(Int_t run = 153323, TString pathOADB = "$ALICE_ROOT/OADB/EMCAL",
+                      Int_t checkObject = 1, TString pass = "pass1", Bool_t printAll = kFALSE)
 {  
 
   gSystem->Load("libOADB");
@@ -18,57 +19,129 @@ void CompareAODB_OCDB(Int_t run = 146806, TString pathOADB = "$ALICE_ROOT/OADB/E
   // Instantiate EMCAL geometry for the first time
 
   
-  if     (run < 140000) geom = AliEMCALGeometry::GetInstance("EMCAL_FIRSTYEARV1");
-  else if(run < 171000) geom = AliEMCALGeometry::GetInstance("EMCAL_COMPLETEV1"); 
-  else                  geom = AliEMCALGeometry::GetInstance("EMCAL_COMPLETE12SMV1"); 
-      
-  CheckBadChannels(run, pathOADB, storage, geom);
-  //CheckEnergyCalibration(run, pathOADB, storage, geom);
-  //CheckTimeCalibration(run, pathOADB, storage, geom);
+  if     (run < 140000) geom = AliEMCALGeometry::GetInstance("EMCAL_FIRSTYEARV1"); // 2010
+  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);
+  else printf("non existing object option\n");
   
+  printf("*** Comparisons ended *** \n");
 }  
 
 //___________________________
-void CheckEnergyCalibration(Int_t run, TString pathOADB, AliCDBStorage * storage, AliEMCALGeometry *geom)
+void CheckEnergyCalibration(Int_t run, TString pathOADB, AliCDBStorage * storage, AliEMCALGeometry *geom,
+                            TString pass,Bool_t printAll = kTRUE)
 {
-    // Check energy recalibration, Uncomplete
+  // Check energy recalibration, Uncomplete
+  
+  AliOADBContainer *contRF=new AliOADBContainer("");
+  contRF->InitFromFile(Form("%s/EMCALRecalib.root",pathOADB.Data()),"AliEMCALRecalib");
+  
+  const Int_t nSM = geom->GetNumberOfSuperModules();
   
-    AliOADBContainer *contRF=new AliOADBContainer("");
-    contRF->InitFromFile(Form("%s/EMCALRecalib.root",pathOADB.Data()),"AliEMCALRecalib");
+  // Get the OCDB object
   
-    const Int_t nSM = geom->GetNumberOfSuperModules();
+  AliEMCALCalibData* cparam = (AliEMCALCalibData*) (storage->Get("EMCAL/Calib/Data", run)->GetObject());
 
-    TH2I *h[12];
+//  // Access directly the OCDB file and not the latest version
+//  TFile * f = TFile::Open("alien:///alice/data/2011/OCDB/EMCAL/Calib/Data/Run144484_999999999_v2_s0.root","READ");
+//  AliCDBEntry * cdb = (AliCDBEntry*) f->Get("AliCDBEntry");
+//  AliEMCALCalibData* cparam2 = (AliEMCALCalibData*)  cdb->GetObject();
+
+  // Get the OADB object
+  
+  TH2F *h[12];
+  
+  TObjArray *recal=(TObjArray*)contRF->GetObject(run);
+  
+  if(!recal)
+  {
+    printf("Energy recalibration OADB not found  3\n");
+    return;
+  }
+  
+  TObjArray *recalpass=(TObjArray*)recal->FindObject(pass);
+  
+  if(!recalpass)
+  {
+    printf("Energy recalibration OADB not found 2\n");
+    return;
+  }
   
-    TObjArray *recal=(TObjArray*)contRF->GetObject(run); 
-    if(recal)
+  TObjArray *recalib=(TObjArray*)recalpass->FindObject("Recalib");
+  
+  if(!recalib)
+  {
+    printf("Energy recalibration OADB not found 1\n");
+    return;
+  }
+  
+  for (Int_t i=0; i < nSM; ++i)
+  {
+    h[i] = (TH2F*)recalib->FindObject(Form("EMCALRecalFactors_SM%d",i));
+    if (!h[i])
     {
-      TObjArray *recalpass=(TObjArray*)recal->FindObject(pass);
-      
-      if(recalpass)
-      {
-        TObjArray *recalib=(TObjArray*)recalpass->FindObject("Recalib");
-        
-        if(recalib)
-        {
-          for (Int_t i=0; i < nSM; ++i) 
-          {
-            h[i] = (TH2F*)recalib->FindObject(Form("EMCALRecalFactors_SM%d",i));
-            if (!h[i]) 
-            {
-              AliError(Form("Could not load EMCALRecalFactors_SM%d",i));
-              continue;
-            }
-          } 
-        }else printf("Energy recalibration OADB not found 1\n");
-      }else printf("Energy recalibration OADB not found 2\n");
-    }else printf("Energy recalibration OADB not found  3\n");
+      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);
     
-    // TO COMPLETE
-}  
+    Float_t paramOCDB = -1;
+    if(cparam) paramOCDB = cparam->GetADCchannel(iSM,iCol,iRow);
+
+//    Float_t paramOCDB2 = -1;
+//    if(cparam) paramOCDB2 = cparam2->GetADCchannel(iSM,iCol,iRow);
+    
+    Float_t paramAODB = -1;
+    if(h[iSM]) paramAODB = h[iSM]->GetBinContent(iCol,iRow);
+    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",
+           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",
+               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",
+               i,iCol,iRow,iSM,paramOCDB, paramAODB);//,paramOCDB2);
+        nDiff++;
+      }
+      
+//      if(TMath::Abs(paramOCDB2-0.0162)> 0.0001)
+//      {
+//        printf("\t Different initial calib! %1.4f\n",paramOCDB2);
+//        nDiff2++;
+//      }
+    }
+  }
+  
+  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)
+void CheckBadChannels(Int_t run, TString pathOADB, AliCDBStorage * storage, AliEMCALGeometry *geom, Bool_t printAll = kTRUE)
 {
   // Get the OCDB bad channels and compare to the OADB ones
   
@@ -94,25 +167,23 @@ void CheckBadChannels(Int_t run, TString pathOADB, AliCDBStorage * storage, AliE
   
   TObjArray *arrayBC=(TObjArray*)contBC->GetObject(run);
   
-  if(arrayBC)
+  if(!arrayBC)
   {
-    for (Int_t i=0; i < nSM; ++i) 
-    {
-      hbm[i]=(TH2I*)arrayBC->FindObject(Form("EMCALBadChannelMap_Mod%d",i));
-      
-      if (!hbm) 
-      {
-        AliError(Form("Can not get EMCALBadChannelMap_Mod%d",i));
-        continue;
-      }
-    }
-  } 
-  else 
-  { 
     printf("--- Bad map not available \n");
     return;
   }
-
+  
+  for (Int_t i=0; i < nSM; ++i)
+  {
+    hbm[i]=(TH2I*)arrayBC->FindObject(Form("EMCALBadChannelMap_Mod%d",i));
+    
+    if (!hbm)
+    {
+      AliError(Form("Can not get EMCALBadChannelMap_Mod%d",i));
+      continue;
+    }
+  }
+  
   Int_t badMapOCDB = -1;
   Int_t badMapAODB = -1;
   Int_t iCol = -1, iRow = -1, iSM =-1, iMod = -1,iIphi =-1,iIeta = -1;    
@@ -126,8 +197,10 @@ void CheckBadChannels(Int_t run, TString pathOADB, AliCDBStorage * storage, AliE
     if(hbm[iSM])   badMapAODB = hbm[iSM]->GetBinContent(iCol,iRow);
      else badMapAODB = -1;
 
-    //if(badMapOCDB>0)
-      if(badMapOCDB!=badMapAODB)  
+    if    (printAll && badMapOCDB > 0)
+      printf("STATUS: ID %d, col %d, row %d, sm %d  OCDB %d, OADB %d\n",
+             i,iCol,iRow,iSM,badMapOCDB, badMapAODB);
+    else if(badMapOCDB!=badMapAODB)
       printf("DIFFERENT STATUS: ID %d, col %d, row %d, sm %d  OCDB %d, OADB %d\n",
              i,iCol,iRow,iSM,badMapOCDB, badMapAODB);
 
@@ -135,4 +208,9 @@ void CheckBadChannels(Int_t run, TString pathOADB, AliCDBStorage * storage, AliE
   
 }
 
+//_____________________
+void CheckTimeCalibration(Int_t run, TString pathOADB, AliCDBStorage * storage, AliEMCALGeometry *geom, TString pass, Bool_t printAll = kTRUE)
+{
+  printf(" === Comparison for this object is not implemented === \n");
+}