]>
Commit | Line | Data |
---|---|---|
c9120365 | 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 | |
4 | ||
5 | // Author : Gustavo Conesa Balbastre (LPSC-CNRS) | |
6 | ||
55606a2a | 7 | void CompareAODB_OCDB(Int_t run = 160000, TString pathOADB = "$ALICE_ROOT/OADB/EMCAL", |
8 | Int_t checkObject = 2, TString pass = "pass1", Bool_t printAll = kFALSE) | |
c9120365 | 9 | { |
10 | ||
11 | gSystem->Load("libOADB"); | |
12 | TGrid::Connect("alien://"); | |
13 | ||
14 | AliCDBManager* man = AliCDBManager::Instance(); | |
15 | man->SetDefaultStorage("raw://"); | |
16 | man->SetRun(run); | |
17 | AliCDBStorage *storage = man->GetDefaultStorage(); | |
18 | ||
19 | // Instantiate EMCAL geometry for the first time | |
20 | ||
21 | ||
3c90b4b0 | 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 | |
25 | ||
55606a2a | 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) CheckEnergyOnlineCalibration(run, pathOADB, storage, geom, printAll); | |
3c90b4b0 | 29 | else printf("non existing object option\n"); |
c9120365 | 30 | |
3c90b4b0 | 31 | printf("*** Comparisons ended *** \n"); |
c9120365 | 32 | } |
33 | ||
34 | //___________________________ | |
3c90b4b0 | 35 | void CheckEnergyCalibration(Int_t run, TString pathOADB, AliCDBStorage * storage, AliEMCALGeometry *geom, |
36 | TString pass,Bool_t printAll = kTRUE) | |
c9120365 | 37 | { |
3c90b4b0 | 38 | // Check energy recalibration, Uncomplete |
39 | ||
40 | AliOADBContainer *contRF=new AliOADBContainer(""); | |
41 | contRF->InitFromFile(Form("%s/EMCALRecalib.root",pathOADB.Data()),"AliEMCALRecalib"); | |
42 | ||
43 | const Int_t nSM = geom->GetNumberOfSuperModules(); | |
c9120365 | 44 | |
3c90b4b0 | 45 | // Get the OCDB object |
c9120365 | 46 | |
3c90b4b0 | 47 | AliEMCALCalibData* cparam = (AliEMCALCalibData*) (storage->Get("EMCAL/Calib/Data", run)->GetObject()); |
c9120365 | 48 | |
3c90b4b0 | 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(); | |
53 | ||
54 | // Get the OADB object | |
55 | ||
56 | TH2F *h[12]; | |
57 | ||
58 | TObjArray *recal=(TObjArray*)contRF->GetObject(run); | |
59 | ||
60 | if(!recal) | |
61 | { | |
62 | printf("Energy recalibration OADB not found 3\n"); | |
63 | return; | |
64 | } | |
65 | ||
66 | TObjArray *recalpass=(TObjArray*)recal->FindObject(pass); | |
67 | ||
68 | if(!recalpass) | |
69 | { | |
70 | printf("Energy recalibration OADB not found 2\n"); | |
71 | return; | |
72 | } | |
c9120365 | 73 | |
3c90b4b0 | 74 | TObjArray *recalib=(TObjArray*)recalpass->FindObject("Recalib"); |
75 | ||
76 | if(!recalib) | |
77 | { | |
78 | printf("Energy recalibration OADB not found 1\n"); | |
79 | return; | |
80 | } | |
81 | ||
82 | for (Int_t i=0; i < nSM; ++i) | |
83 | { | |
84 | h[i] = (TH2F*)recalib->FindObject(Form("EMCALRecalFactors_SM%d",i)); | |
85 | if (!h[i]) | |
c9120365 | 86 | { |
3c90b4b0 | 87 | AliError(Form("Could not load EMCALRecalFactors_SM%d",i)); |
88 | continue; | |
89 | } | |
90 | } | |
91 | ||
92 | // Do the comparison | |
93 | Float_t paramOCDB = -1; | |
94 | Float_t paramAODB = -1; | |
95 | Int_t nDiff = 0; | |
96 | // Int_t nDiff2 = 0; | |
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++) | |
99 | { | |
100 | //printf("AbsID %d\n",i); | |
101 | geom->GetCellIndex(i,iSM,iMod,iIphi,iIeta); | |
102 | geom->GetCellPhiEtaIndexInSModule(iSM,iMod, iIphi, iIeta,iRow,iCol); | |
c9120365 | 103 | |
3c90b4b0 | 104 | Float_t paramOCDB = -1; |
105 | if(cparam) paramOCDB = cparam->GetADCchannel(iSM,iCol,iRow); | |
106 | ||
107 | // Float_t paramOCDB2 = -1; | |
108 | // if(cparam) paramOCDB2 = cparam2->GetADCchannel(iSM,iCol,iRow); | |
109 | ||
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 | |
113 | ||
114 | if (printAll) | |
55606a2a | 115 | printf("Recalibration parameter: ID %d, col %d, row %d, sm %d OCDB %1.4f, OADB %1.4f\n", |
3c90b4b0 | 116 | i,iCol,iRow,iSM,paramOCDB, paramAODB); |
117 | else if(paramAODB > 0) | |
118 | { | |
119 | if (paramOCDB/paramAODB > 1.01 || paramOCDB/paramAODB < 0.99) ) | |
120 | { | |
55606a2a | 121 | 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", |
3c90b4b0 | 122 | i,iCol,iRow,iSM,paramOCDB, paramAODB,paramOCDB/paramAODB);//,paramOCDB2); |
123 | nDiff++; | |
124 | } | |
125 | else if(paramAODB <= 0) | |
126 | { | |
55606a2a | 127 | 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", |
3c90b4b0 | 128 | i,iCol,iRow,iSM,paramOCDB, paramAODB);//,paramOCDB2); |
129 | nDiff++; | |
130 | } | |
131 | ||
132 | // if(TMath::Abs(paramOCDB2-0.0162)> 0.0001) | |
133 | // { | |
134 | // printf("\t Different initial calib! %1.4f\n",paramOCDB2); | |
135 | // nDiff2++; | |
136 | // } | |
137 | } | |
138 | } | |
139 | ||
140 | if(!printAll) printf("Total number of different channels %d / %d\n",nDiff,nSM*24*48);//, origin %d\n",nDiff,nSM*24*48,nDiff2); | |
141 | } | |
c9120365 | 142 | |
55606a2a | 143 | //___________________________ |
144 | void CheckEnergyOnlineCalibration(Int_t run, TString pathOADB, AliCDBStorage * storage, AliEMCALGeometry *geom, | |
145 | Bool_t printAll = kTRUE) | |
146 | { | |
147 | // Check energy recalibration, Uncomplete | |
148 | ||
149 | AliOADBContainer *contRF=new AliOADBContainer(""); | |
150 | contRF->InitFromFile(Form("%s/EMCALCalibOnlineRef.root",pathOADB.Data()),"AliEMCALRecalib"); | |
151 | ||
152 | const Int_t nSM = geom->GetNumberOfSuperModules(); | |
153 | ||
154 | // Get the OCDB object | |
155 | // Access directly the OCDB file and not the latest version | |
156 | TFile * f = 0; | |
157 | if (run < 140000) | |
158 | f = TFile::Open("alien:///alice/data/2010/OCDB/EMCAL/Calib/Data/Run113461_999999999_v3_s0.root","READ"); | |
159 | else if(run < 171000) | |
160 | f = TFile::Open("alien:///alice/data/2011/OCDB/EMCAL/Calib/Data/Run144484_999999999_v3_s0.root","READ"); | |
161 | else if(run < 198000) | |
162 | f = TFile::Open("alien:///alice/data/2012/OCDB/EMCAL/Calib/Data/Run177115_999999999_v2_s0.root","READ"); | |
163 | else { | |
164 | printf("Run not available\n"); | |
165 | return; | |
166 | } | |
167 | ||
168 | AliCDBEntry * cdb = (AliCDBEntry*) f->Get("AliCDBEntry"); | |
169 | AliEMCALCalibData* cparam = (AliEMCALCalibData*) cdb->GetObject(); | |
170 | ||
171 | // Get the OADB object | |
172 | ||
173 | TH2F *h[12]; | |
174 | ||
175 | TObjArray *cal=(TObjArray*)contRF->GetObject(run); | |
176 | ||
177 | if(!cal) | |
178 | { | |
179 | printf("Energy online calibration OADB not found 3\n"); | |
180 | return; | |
181 | } | |
182 | ||
183 | for (Int_t i=0; i < nSM; ++i) | |
184 | { | |
185 | h[i] = (TH2F*)cal->FindObject(Form("EMCALRecalFactors_SM%d",i)); | |
186 | if (!h[i]) | |
187 | { | |
188 | AliError(Form("Could not load EMCALRecalFactors_SM%d",i)); | |
189 | continue; | |
190 | } | |
191 | } | |
192 | ||
193 | // Do the comparison | |
194 | Float_t paramOCDB = -1; | |
195 | Float_t paramAODB = -1; | |
196 | Int_t nDiff = 0; | |
197 | // Int_t nDiff2 = 0; | |
198 | Int_t iCol = -1, iRow = -1, iSM =-1, iMod = -1,iIphi =-1,iIeta = -1; | |
199 | for(Int_t i=0;i < nSM*24*48; i++) | |
200 | { | |
201 | //printf("AbsID %d\n",i); | |
202 | geom->GetCellIndex(i,iSM,iMod,iIphi,iIeta); | |
203 | geom->GetCellPhiEtaIndexInSModule(iSM,iMod, iIphi, iIeta,iRow,iCol); | |
204 | ||
205 | Float_t paramOCDB = -1; | |
206 | if(cparam) paramOCDB = cparam->GetADCchannel(iSM,iCol,iRow); | |
207 | ||
208 | Float_t paramAODB = -1; | |
209 | if(h[iSM]) paramAODB = h[iSM]->GetBinContent(iCol,iRow); | |
210 | ||
211 | if (printAll) | |
212 | printf("Online Calib: ID %d, col %d, row %d, sm %d OCDB %1.4f, OADB %1.4f\n", | |
213 | i,iCol,iRow,iSM,paramOCDB, paramAODB); | |
214 | ||
215 | if (TMath::Abs(paramOCDB-paramAODB) > 0.001)// || (TMath::Abs(paramOCDB-0.0162)> 0.001)) | |
216 | { | |
217 | printf("Online Calib DIFFERENT: ID %d, col %d, row %d, sm %d OCDB %1.4f, OADB %1.4f, diff OCDB-OADB %1.4f\n", | |
218 | i,iCol,iRow,iSM,paramOCDB, paramAODB,paramOCDB-paramAODB); | |
219 | nDiff++; | |
220 | } | |
221 | ||
222 | ||
223 | } | |
224 | ||
225 | if(!printAll) printf("Total number of different channels %d / %d\n",nDiff,nSM*24*48);//, origin %d\n",nDiff,nSM*24*48,nDiff2); | |
226 | } | |
227 | ||
c9120365 | 228 | //_____________________ |
3c90b4b0 | 229 | void CheckBadChannels(Int_t run, TString pathOADB, AliCDBStorage * storage, AliEMCALGeometry *geom, Bool_t printAll = kTRUE) |
c9120365 | 230 | { |
231 | // Get the OCDB bad channels and compare to the OADB ones | |
232 | ||
233 | //const Int_t nSM = static_const (geom->GetNumberOfSuperModules()); | |
234 | const Int_t nSM = static_cast<const Int_t> (geom->GetNumberOfSuperModules()); | |
235 | ||
236 | // Access OCDB histograms | |
237 | AliCaloCalibPedestal* caloped = (AliCaloCalibPedestal*) (storage->Get("EMCAL/Calib/Pedestals", run)->GetObject()); | |
238 | ||
239 | // Access directly the OCDB file and not the latest version | |
240 | //TFile * f = TFile::Open("alien:///alice/data/2011/OCDB/EMCAL/Calib/Pedestals/Run145954_146856_v3_s0.root","READ"); | |
241 | //AliCDBEntry * cdb = (AliCDBEntry*) f->Get("AliCDBEntry"); | |
242 | //AliCaloCalibPedestal * caloped = (AliCaloCalibPedestal *) cdb->GetObject(); | |
243 | ||
244 | TObjArray map = caloped->GetDeadMap(); | |
245 | ||
246 | // Access OADB histograms | |
247 | TH2I *hbm[12]; | |
248 | ||
249 | AliOADBContainer *contBC=new AliOADBContainer(""); | |
250 | ||
251 | contBC->InitFromFile(Form("%s/EMCALBadChannels.root",pathOADB.Data()),"AliEMCALBadChannels"); | |
252 | ||
253 | TObjArray *arrayBC=(TObjArray*)contBC->GetObject(run); | |
254 | ||
3c90b4b0 | 255 | if(!arrayBC) |
c9120365 | 256 | { |
c9120365 | 257 | printf("--- Bad map not available \n"); |
258 | return; | |
259 | } | |
3c90b4b0 | 260 | |
261 | for (Int_t i=0; i < nSM; ++i) | |
262 | { | |
263 | hbm[i]=(TH2I*)arrayBC->FindObject(Form("EMCALBadChannelMap_Mod%d",i)); | |
264 | ||
265 | if (!hbm) | |
266 | { | |
267 | AliError(Form("Can not get EMCALBadChannelMap_Mod%d",i)); | |
268 | continue; | |
269 | } | |
270 | } | |
271 | ||
c9120365 | 272 | Int_t badMapOCDB = -1; |
273 | Int_t badMapAODB = -1; | |
274 | Int_t iCol = -1, iRow = -1, iSM =-1, iMod = -1,iIphi =-1,iIeta = -1; | |
275 | for(Int_t i=0;i < nSM*24*48; i++) | |
276 | { | |
277 | //printf("AbsID %d\n",i); | |
278 | geom->GetCellIndex(i,iSM,iMod,iIphi,iIeta); | |
279 | geom->GetCellPhiEtaIndexInSModule(iSM,iMod, iIphi, iIeta,iRow,iCol); | |
280 | if(map.At(iSM))badMapOCDB = ((TH2F*)map.At(iSM))->GetBinContent(iCol,iRow); | |
281 | else badMapOCDB = -1; | |
282 | if(hbm[iSM]) badMapAODB = hbm[iSM]->GetBinContent(iCol,iRow); | |
283 | else badMapAODB = -1; | |
284 | ||
3c90b4b0 | 285 | if (printAll && badMapOCDB > 0) |
286 | printf("STATUS: ID %d, col %d, row %d, sm %d OCDB %d, OADB %d\n", | |
287 | i,iCol,iRow,iSM,badMapOCDB, badMapAODB); | |
288 | else if(badMapOCDB!=badMapAODB) | |
c9120365 | 289 | printf("DIFFERENT STATUS: ID %d, col %d, row %d, sm %d OCDB %d, OADB %d\n", |
290 | i,iCol,iRow,iSM,badMapOCDB, badMapAODB); | |
291 | ||
292 | } | |
293 | ||
294 | } | |
295 | ||
3c90b4b0 | 296 | //_____________________ |
297 | void CheckTimeCalibration(Int_t run, TString pathOADB, AliCDBStorage * storage, AliEMCALGeometry *geom, TString pass, Bool_t printAll = kTRUE) | |
298 | { | |
299 | printf(" === Comparison for this object is not implemented === \n"); | |
300 | } | |
c9120365 | 301 |