1 // Compare the contents of the calibration, bad channels, etc in OCDB and AODB
2 // You need connexion to the grid to run this macro
3 // The OADB file can be in a place different than the default in aliroot
5 // Author : Gustavo Conesa Balbastre (LPSC-CNRS)
7 void CompareAODB_OCDB(Int_t run = 153323, TString pathOADB = "$ALICE_ROOT/OADB/EMCAL",
8 Int_t checkObject = 1, TString pass = "pass1", Bool_t printAll = kFALSE)
11 gSystem->Load("libOADB");
12 TGrid::Connect("alien://");
14 AliCDBManager* man = AliCDBManager::Instance();
15 man->SetDefaultStorage("raw://");
17 AliCDBStorage *storage = man->GetDefaultStorage();
19 // Instantiate EMCAL geometry for the first time
22 if (run < 140000) geom = AliEMCALGeometry::GetInstance("EMCAL_FIRSTYEARV1"); // 2010
23 else if(run < 198000) geom = AliEMCALGeometry::GetInstance("EMCAL_COMPLETEV1"); // 2011-2012-2013
24 else geom = AliEMCALGeometry::GetInstance("EMCAL_COMPLETE12SMV1_DCAL_8SM"); // Run2
26 if (checkObject == 0) CheckBadChannels (run, pathOADB, storage, geom, printAll);
27 else if(checkObject == 1) CheckEnergyCalibration(run, pathOADB, storage, geom,pass,printAll);
28 else if(checkObject == 2) CheckTimeCalibration (run, pathOADB, storage, geom,pass,printAll);
29 else printf("non existing object option\n");
31 printf("*** Comparisons ended *** \n");
34 //___________________________
35 void CheckEnergyCalibration(Int_t run, TString pathOADB, AliCDBStorage * storage, AliEMCALGeometry *geom,
36 TString pass,Bool_t printAll = kTRUE)
38 // Check energy recalibration, Uncomplete
40 AliOADBContainer *contRF=new AliOADBContainer("");
41 contRF->InitFromFile(Form("%s/EMCALRecalib.root",pathOADB.Data()),"AliEMCALRecalib");
43 const Int_t nSM = geom->GetNumberOfSuperModules();
45 // Get the OCDB object
47 AliEMCALCalibData* cparam = (AliEMCALCalibData*) (storage->Get("EMCAL/Calib/Data", run)->GetObject());
49 // // Access directly the OCDB file and not the latest version
50 // TFile * f = TFile::Open("alien:///alice/data/2011/OCDB/EMCAL/Calib/Data/Run144484_999999999_v2_s0.root","READ");
51 // AliCDBEntry * cdb = (AliCDBEntry*) f->Get("AliCDBEntry");
52 // AliEMCALCalibData* cparam2 = (AliEMCALCalibData*) cdb->GetObject();
54 // Get the OADB object
58 TObjArray *recal=(TObjArray*)contRF->GetObject(run);
62 printf("Energy recalibration OADB not found 3\n");
66 TObjArray *recalpass=(TObjArray*)recal->FindObject(pass);
70 printf("Energy recalibration OADB not found 2\n");
74 TObjArray *recalib=(TObjArray*)recalpass->FindObject("Recalib");
78 printf("Energy recalibration OADB not found 1\n");
82 for (Int_t i=0; i < nSM; ++i)
84 h[i] = (TH2F*)recalib->FindObject(Form("EMCALRecalFactors_SM%d",i));
87 AliError(Form("Could not load EMCALRecalFactors_SM%d",i));
93 Float_t paramOCDB = -1;
94 Float_t paramAODB = -1;
97 Int_t iCol = -1, iRow = -1, iSM =-1, iMod = -1,iIphi =-1,iIeta = -1;
98 for(Int_t i=0;i < nSM*24*48; i++)
100 //printf("AbsID %d\n",i);
101 geom->GetCellIndex(i,iSM,iMod,iIphi,iIeta);
102 geom->GetCellPhiEtaIndexInSModule(iSM,iMod, iIphi, iIeta,iRow,iCol);
104 Float_t paramOCDB = -1;
105 if(cparam) paramOCDB = cparam->GetADCchannel(iSM,iCol,iRow);
107 // Float_t paramOCDB2 = -1;
108 // if(cparam) paramOCDB2 = cparam2->GetADCchannel(iSM,iCol,iRow);
110 Float_t paramAODB = -1;
111 if(h[iSM]) paramAODB = h[iSM]->GetBinContent(iCol,iRow);
112 paramAODB*=0.0162; // Transformation into OCDB parameter, it will not work for all channels
115 printf("STATUS: ID %d, col %d, row %d, sm %d OCDB %1.4f, OADB %1.4f\n",
116 i,iCol,iRow,iSM,paramOCDB, paramAODB);
117 else if(paramAODB > 0)
119 if (paramOCDB/paramAODB > 1.01 || paramOCDB/paramAODB < 0.99) )
121 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",
122 i,iCol,iRow,iSM,paramOCDB, paramAODB,paramOCDB/paramAODB);//,paramOCDB2);
125 else if(paramAODB <= 0)
127 printf("DIFFERENT STATUS: ID %d, col %d, row %d, sm %d OCDB %1.4f, OADB %1.4f\n",//, old OCDB param %1.4f\n",
128 i,iCol,iRow,iSM,paramOCDB, paramAODB);//,paramOCDB2);
132 // if(TMath::Abs(paramOCDB2-0.0162)> 0.0001)
134 // printf("\t Different initial calib! %1.4f\n",paramOCDB2);
140 if(!printAll) printf("Total number of different channels %d / %d\n",nDiff,nSM*24*48);//, origin %d\n",nDiff,nSM*24*48,nDiff2);
143 //_____________________
144 void CheckBadChannels(Int_t run, TString pathOADB, AliCDBStorage * storage, AliEMCALGeometry *geom, Bool_t printAll = kTRUE)
146 // Get the OCDB bad channels and compare to the OADB ones
148 //const Int_t nSM = static_const (geom->GetNumberOfSuperModules());
149 const Int_t nSM = static_cast<const Int_t> (geom->GetNumberOfSuperModules());
151 // Access OCDB histograms
152 AliCaloCalibPedestal* caloped = (AliCaloCalibPedestal*) (storage->Get("EMCAL/Calib/Pedestals", run)->GetObject());
154 // Access directly the OCDB file and not the latest version
155 //TFile * f = TFile::Open("alien:///alice/data/2011/OCDB/EMCAL/Calib/Pedestals/Run145954_146856_v3_s0.root","READ");
156 //AliCDBEntry * cdb = (AliCDBEntry*) f->Get("AliCDBEntry");
157 //AliCaloCalibPedestal * caloped = (AliCaloCalibPedestal *) cdb->GetObject();
159 TObjArray map = caloped->GetDeadMap();
161 // Access OADB histograms
164 AliOADBContainer *contBC=new AliOADBContainer("");
166 contBC->InitFromFile(Form("%s/EMCALBadChannels.root",pathOADB.Data()),"AliEMCALBadChannels");
168 TObjArray *arrayBC=(TObjArray*)contBC->GetObject(run);
172 printf("--- Bad map not available \n");
176 for (Int_t i=0; i < nSM; ++i)
178 hbm[i]=(TH2I*)arrayBC->FindObject(Form("EMCALBadChannelMap_Mod%d",i));
182 AliError(Form("Can not get EMCALBadChannelMap_Mod%d",i));
187 Int_t badMapOCDB = -1;
188 Int_t badMapAODB = -1;
189 Int_t iCol = -1, iRow = -1, iSM =-1, iMod = -1,iIphi =-1,iIeta = -1;
190 for(Int_t i=0;i < nSM*24*48; i++)
192 //printf("AbsID %d\n",i);
193 geom->GetCellIndex(i,iSM,iMod,iIphi,iIeta);
194 geom->GetCellPhiEtaIndexInSModule(iSM,iMod, iIphi, iIeta,iRow,iCol);
195 if(map.At(iSM))badMapOCDB = ((TH2F*)map.At(iSM))->GetBinContent(iCol,iRow);
196 else badMapOCDB = -1;
197 if(hbm[iSM]) badMapAODB = hbm[iSM]->GetBinContent(iCol,iRow);
198 else badMapAODB = -1;
200 if (printAll && badMapOCDB > 0)
201 printf("STATUS: ID %d, col %d, row %d, sm %d OCDB %d, OADB %d\n",
202 i,iCol,iRow,iSM,badMapOCDB, badMapAODB);
203 else if(badMapOCDB!=badMapAODB)
204 printf("DIFFERENT STATUS: ID %d, col %d, row %d, sm %d OCDB %d, OADB %d\n",
205 i,iCol,iRow,iSM,badMapOCDB, badMapAODB);
211 //_____________________
212 void CheckTimeCalibration(Int_t run, TString pathOADB, AliCDBStorage * storage, AliEMCALGeometry *geom, TString pass, Bool_t printAll = kTRUE)
214 printf(" === Comparison for this object is not implemented === \n");