]> git.uio.no Git - u/mrichter/AliRoot.git/blame - ITS/ShowCalibrationSDD.C
Avoid numerical problems in calc. if eff. mass.
[u/mrichter/AliRoot.git] / ITS / ShowCalibrationSDD.C
CommitLineData
40b3a8c7 1#if !defined(__CINT__) || defined(__MAKECINT__)
2#include <TFile.h>
3#include <TH1F.h>
3615e762 4#include <TH2I.h>
40b3a8c7 5#include <TGraph.h>
e34418c7 6#include <TExec.h>
40b3a8c7 7#include <TStyle.h>
551eb942 8#include <TString.h>
9#include <TSystem.h>
40b3a8c7 10#include <TGrid.h>
3615e762 11#include <TLine.h>
40b3a8c7 12#include <TCanvas.h>
13#include <TObjArray.h>
14#include "AliCDBEntry.h"
15#include "AliITSCalibrationSDD.h"
3615e762 16#include "AliITSgeomTGeo.h"
40b3a8c7 17#endif
18
19// Macro to plot the calibration parameters from the OCDB file
20// created from PEDESTAL and PULSER runs (OCDB/ITS/Calib/CalibSDD)
21// Two methods ShowCalibrationSDD:
22// - the first takes the name of the file to be displayed
23// - the second builds the alien path+name from run number and file version
24//
25// Origin: F. Prino (prino@to.infn.it)
26
e34418c7 27void MakePalette(){
28 Int_t palette[3]={kGray,2,3};
29 gStyle->SetPalette(3,palette);
30}
31
551eb942 32void ShowCalibrationSDD(Char_t *filnam="$ALICE_ROOT/OCDB/ITS/Calib/CalibSDD/Run0_9999999_v0_s0.root", Int_t iMod=0){
40b3a8c7 33
34
35 TFile *f=TFile::Open(filnam);
36 AliCDBEntry *ent=(AliCDBEntry*)f->Get("AliCDBEntry");
296ee458 37 TH2I* hlay3=new TH2I("hlay3","Layer 3",12,-0.5,5.5,14,-0.5,13.5);
3615e762 38 hlay3->GetXaxis()->SetTitle("Detector");
39 hlay3->GetYaxis()->SetTitle("Ladder");
40 hlay3->GetXaxis()->SetTickLength(0);
41 hlay3->GetYaxis()->SetTickLength(0);
42 hlay3->SetStats(0);
43 hlay3->SetMinimum(-1);
296ee458 44 TH2I* hlay4=new TH2I("hlay4","Layer 4",16,-0.5,7.5,22,-0.5,21.5);
3615e762 45 hlay4->GetXaxis()->SetTitle("Detector");
46 hlay4->GetYaxis()->SetTitle("Ladder");
47 hlay4->GetXaxis()->SetTickLength(0);
48 hlay4->GetYaxis()->SetTickLength(0);
49 hlay4->GetYaxis()->SetTitle("Ladder");
50 hlay4->SetStats(0);
51 hlay4->SetMinimum(-1);
9c3758ab 52 TH2I* hdeadlay3=new TH2I("hdlay3","Layer 3",6,-0.5,5.5,14,-0.5,13.5);
e34418c7 53 hdeadlay3->GetXaxis()->SetTitle("Detector");
54 hdeadlay3->GetYaxis()->SetTitle("Ladder");
55 hdeadlay3->GetXaxis()->SetTickLength(0);
56 hdeadlay3->GetYaxis()->SetTickLength(0);
57 hdeadlay3->SetStats(0);
58 hdeadlay3->SetMinimum(-1.);
9c3758ab 59 TH2I* hdeadlay4=new TH2I("hdlay4","Layer 4",8,-0.5,7.5,22,-0.5,21.5);
e34418c7 60 hdeadlay4->GetXaxis()->SetTitle("Detector");
61 hdeadlay4->GetYaxis()->SetTitle("Ladder");
62 hdeadlay4->GetXaxis()->SetTickLength(0);
63 hdeadlay4->GetYaxis()->SetTickLength(0);
64 hdeadlay4->GetYaxis()->SetTitle("Ladder");
65 hdeadlay4->SetStats(0);
66 hdeadlay4->SetMinimum(-1.);
3615e762 67
40b3a8c7 68 TObjArray *calSDD = (TObjArray *)ent->GetObject();
69 printf("Entries in array=%d\n",calSDD->GetEntriesFast());
70 TH1F* hmodstatus=new TH1F("hmodstatus","",260,0.5,260.5);
71 TH1F* hnbadch=new TH1F("hnbadch","",260,0.5,260.5);
72 TH1F* hbase=new TH1F("hbase","",60,0.5,120.5);
73 TH1F* hnoise=new TH1F("hnoise","",100,0.,7.);
74 TH1F* hgain=new TH1F("hgain","",100,0.,4.);
75 TH1F* hchstatus=new TH1F("hchstatus","",2,-0.5,1.5);
76 AliITSCalibrationSDD *cal;
b3ba5bd1 77 Int_t badModCounter3=0;
78 Int_t badModCounter4=0;
79 Int_t badAnodeCounter3=0;
80 Int_t badAnodeCounter4=0;
81 Int_t badAnodeCounterGoodMod3=0;
82 Int_t badAnodeCounterGoodMod4=0;
83 Int_t badAnodeCounterGoodModAndChip3=0;
84 Int_t badAnodeCounterGoodModAndChip4=0;
85 Int_t badChipCounter3=0;
86 Int_t badChipCounter4=0;
40b3a8c7 87 for(Int_t i=0; i<260; i++){
88 cal=(AliITSCalibrationSDD*)calSDD->At(i);
89 if(cal==0) continue;
90 printf("Module %d (%d) status = ",i,i+240);
3615e762 91 Int_t lay,lad,det;
92 AliITSgeomTGeo::GetModuleId(i+240,lay,lad,det);
296ee458 93 Int_t index=1+(det-1)*2;
b3ba5bd1 94 if(cal->IsBad()){
95 printf("BAD\t");
3615e762 96 if(lay==3){
97 badModCounter3++;
296ee458 98 hlay3->SetBinContent(index,lad,0);
99 hlay3->SetBinContent(index+1,lad,0);
3615e762 100 }else if(lay==4){
101 badModCounter4++;
296ee458 102 hlay4->SetBinContent(index,lad,0);
103 hlay4->SetBinContent(index+1,lad,0);
3615e762 104 }
b3ba5bd1 105 hmodstatus->SetBinContent(i+1,0);
3615e762 106 }else{
b3ba5bd1 107 printf("OK\t");
108 hmodstatus->SetBinContent(i+1,1);
3615e762 109 if(lay==3){
110 badAnodeCounterGoodMod3+=cal->GetDeadChannels();
296ee458 111 if(cal->IsChipBad(0) && cal->IsChipBad(1) && cal->IsChipBad(2) && cal->IsChipBad(3)){
112 hlay3->SetBinContent(index,lad,0);
113 }else{
114 hlay3->SetBinContent(index,lad,1);
115 }
116 if(cal->IsChipBad(4) && cal->IsChipBad(5) && cal->IsChipBad(6) && cal->IsChipBad(7)){
117 hlay3->SetBinContent(index+1,lad,0);
118 }else{
119 hlay3->SetBinContent(index+1,lad,1);
120 }
3615e762 121 }else{
122 badAnodeCounterGoodMod4+=cal->GetDeadChannels();
296ee458 123 if(cal->IsChipBad(0) && cal->IsChipBad(1) && cal->IsChipBad(2) && cal->IsChipBad(3)){
124 hlay4->SetBinContent(index,lad,0);
125 }else{
126 hlay4->SetBinContent(index,lad,1);
127 }
128 if(cal->IsChipBad(4) && cal->IsChipBad(5) && cal->IsChipBad(6) && cal->IsChipBad(7)){
129 hlay4->SetBinContent(index+1,lad,0);
130 }else{
131 hlay4->SetBinContent(index+1,lad,1);
132 }
3615e762 133 }
134 }
40b3a8c7 135 printf(" Chip Status (0=OK, 1=BAD): ");
b3ba5bd1 136 for(Int_t ic=0; ic<8;ic++){
137 printf("%d ",cal->IsChipBad(ic));
138 if(cal->IsChipBad(ic) && !cal->IsBad()){
139 if(i<84) badChipCounter3++;
140 else badChipCounter4++;
141 }
142 }
bc031ee2 143 printf(" # bad anodes = %d ",cal->GetDeadChannels());
40b3a8c7 144 if(cal->IsAMAt20MHz()) printf(" 20 MHz sampling");
145 else printf(" 40 MHz sampling");
146 printf("\n");
b3ba5bd1 147 if(i<84) badAnodeCounter3+=cal->GetDeadChannels();
148 else badAnodeCounter4+=cal->GetDeadChannels();
40b3a8c7 149 hnbadch->SetBinContent(i+1,cal->GetDeadChannels());
e34418c7 150 if(lay==3) hdeadlay3->SetBinContent(det,lad,cal->GetDeadChannels());
151 if(lay==4) hdeadlay4->SetBinContent(det,lad,cal->GetDeadChannels());
40b3a8c7 152 for(Int_t iAn=0; iAn<512; iAn++){
b3ba5bd1 153 Int_t ic=cal->GetChip(iAn);
154 if(!cal->IsChipBad(ic) && !cal->IsBad() && cal->IsBadChannel(iAn)){
155 if(i<84) badAnodeCounterGoodModAndChip3++;
156 else badAnodeCounterGoodModAndChip4++;
157 }
40b3a8c7 158 Float_t base=cal->GetBaseline(iAn);
159 Float_t noise=cal->GetNoiseAfterElectronics(iAn);
160 Float_t gain=cal->GetChannelGain(iAn);
161 if(cal->IsBadChannel(iAn)) hchstatus->Fill(0);
266a4b47 162 if(!cal->IsBadChannel(iAn) && !cal->IsChipBad(ic) && !cal->IsBad() ){
40b3a8c7 163 hbase->Fill(base);
164 hchstatus->Fill(1);
165 hnoise->Fill(noise);
166 hgain->Fill(gain);
167 }
168 }
169 }
b3ba5bd1 170 Int_t totbad3=badModCounter3*512+badChipCounter3*64+badAnodeCounterGoodModAndChip3;
171 Int_t tot3=6*14*512;
172 Float_t fracbad3=(Float_t)totbad3/(Float_t)tot3;
173 Int_t totbad4=badModCounter4*512+badChipCounter4*64+badAnodeCounterGoodModAndChip4;
174 Int_t tot4=8*22*512;
175 Float_t fracbad4=(Float_t)totbad4/(Float_t)tot4;
176 Float_t fractot=(Float_t)(totbad3+totbad4)/(Float_t)(tot3+tot4);
177 printf("----------------------Summary----------------------\n");
178 printf("---- Layer 3 ----\n");
179 printf("# of bad modules = %d\n",badModCounter3);
180 printf("# of bad chips in good modules = %d\n",badChipCounter3);
181 printf("# of bad anodes in good modules+chips = %d\n",badAnodeCounterGoodModAndChip3);
182 printf("Fraction of bads (anodes+chips+mod) = %f\n",fracbad3);
183 printf("---- Layer 4 ----\n");
184 printf("# of bad modules = %d\n",badModCounter4);
185 printf("# of bad chips in good modules = %d\n",badChipCounter4);
186 printf("# of bad anodes in good modules+chips = %d\n",badAnodeCounterGoodModAndChip4);
187 printf("Fraction of bads (anodes+chips+mod) = %f\n",fracbad4);
188 printf("---- Total ----\n");
189 printf("# of bad modules = %d\n",badModCounter3+badModCounter4);
190 printf("# of bad chips in good modules = %d\n",badChipCounter3+badChipCounter4);
191 printf("# of bad anodes in good modules+chips = %d\n",badAnodeCounterGoodModAndChip3+badAnodeCounterGoodModAndChip4);
192 printf("Fraction of bads (anodes+chips+mod) = %f\n",fractot);
193 printf("---------------------------------------------------\n");
194
195
e34418c7 196 TLine* lin=new TLine(0,0,0,23);
197 TExec *ex1 = new TExec("ex1","MakePalette();");
198 TExec *ex2 = new TExec("ex2","gStyle->SetPalette(1);");
199
200 TCanvas* clay=new TCanvas("clay","Layer status",900,600);
201 clay->Divide(2,1);
202 clay->cd(1);
203 hlay3->Draw("col");
204 ex1->Draw();
205 hlay3->DrawCopy("col same");
206 for(Int_t i=0;i<6;i++){
207 lin->SetY1(-0.5);
208 lin->SetY2(13.5);
209 lin->SetX1(i+0.5);
210 lin->SetX2(i+0.5);
211 lin->DrawClone();
212 }
213 for(Int_t i=0;i<14;i++){
214 lin->SetX1(-0.5);
215 lin->SetX2(5.5);
216 lin->SetY1(i+0.5);
217 lin->SetY2(i+0.5);
218 lin->DrawClone();
219 }
220 clay->cd(2);
221 hlay4->DrawCopy("col");
222 for(Int_t i=0;i<8;i++){
223 lin->SetY1(-0.5);
224 lin->SetY2(21.5);
225 lin->SetX1(i+0.5);
226 lin->SetX2(i+0.5);
227 lin->DrawClone();
228 }
229 for(Int_t i=0;i<22;i++){
230 lin->SetX1(-0.5);
231 lin->SetX2(7.5);
232 lin->SetY1(i+0.5);
233 lin->SetY2(i+0.5);
234 lin->DrawClone();
235 }
236
40b3a8c7 237 TCanvas *c0=new TCanvas("c0","Module status",800,800);
238 c0->Divide(1,2);
239 c0->cd(1);
240 hmodstatus->Draw();
241 hmodstatus->GetXaxis()->SetTitle("Module number");
242 hmodstatus->GetYaxis()->SetTitle("Module status (1=OK, 0=BAD)");
243 c0->cd(2);
244 hnbadch->Draw();
e34418c7 245 hnbadch->GetXaxis()->SetTitle("Module number");
40b3a8c7 246 hnbadch->GetYaxis()->SetTitle("Number of bad anodes");
247
e34418c7 248
249
250
251 TCanvas *c0b=new TCanvas("c0b","Bad Channels",900,600);
252 c0b->Divide(2,1);
253 c0b->cd(1);
254 hdeadlay3->DrawCopy("colz");
255 ex2->Draw();
256 hdeadlay3->DrawCopy("colz same");
3615e762 257 for(Int_t i=0;i<6;i++){
258 lin->SetY1(-0.5);
259 lin->SetY2(13.5);
260 lin->SetX1(i+0.5);
261 lin->SetX2(i+0.5);
262 lin->DrawClone();
263 }
264 for(Int_t i=0;i<14;i++){
265 lin->SetX1(-0.5);
266 lin->SetX2(5.5);
267 lin->SetY1(i+0.5);
268 lin->SetY2(i+0.5);
269 lin->DrawClone();
270 }
e34418c7 271 c0b->cd(2);
272 hdeadlay4->DrawCopy("colz");
273 ex2->Draw();
274 hdeadlay4->DrawCopy("colz same");
3615e762 275 for(Int_t i=0;i<8;i++){
276 lin->SetY1(-0.5);
277 lin->SetY2(21.5);
278 lin->SetX1(i+0.5);
279 lin->SetX2(i+0.5);
280 lin->DrawClone();
281 }
282 for(Int_t i=0;i<22;i++){
283 lin->SetX1(-0.5);
284 lin->SetX2(7.5);
285 lin->SetY1(i+0.5);
286 lin->SetY2(i+0.5);
287 lin->DrawClone();
288 }
289
290
e34418c7 291
292 TCanvas *c1=new TCanvas("c1","Anode calibration",800,800);
293 c1->Divide(2,2);
294 c1->cd(1);
295 hbase->Draw();
296 hbase->GetXaxis()->SetTitle("Baseline after equalization");
297 hbase->GetXaxis()->CenterTitle();
298 c1->cd(2);
299 hnoise->Draw();
300 hnoise->GetXaxis()->SetTitle("Noise");
301 hnoise->GetXaxis()->CenterTitle();
302 c1->cd(3);
303 hgain->Draw();
304 hgain->GetXaxis()->SetTitle("Gain");
305 hgain->GetXaxis()->CenterTitle();
306 c1->cd(4);
307 hchstatus->Draw();
308 hchstatus->GetXaxis()->SetTitle("Anode status (0=bad, 1=OK)");
309 hchstatus->GetXaxis()->CenterTitle();
310
311
312
313
314
315
316
317
40b3a8c7 318
b3ba5bd1 319
320 // Plot quantities for specified module
321
40b3a8c7 322 cal=(AliITSCalibrationSDD*)calSDD->At(iMod);
323 if(cal==0) return;
324 printf("-----------------------------------\n");
325 printf("Module %d status = ",iMod);
326 if(cal->IsBad()) printf("BAD\n");
327 else printf("OK\n");
328 printf(" Chip Status (0=OK, 1=BAD): ");
329 for(Int_t ic=0; ic<8;ic++) printf("%d ",cal->IsChipBad(ic));
330 printf("\n");
b3ba5bd1 331 printf(" Number of bad anodes =%d\n",cal->GetDeadChannels());
40b3a8c7 332 printf("-----------------------------------\n");
333 Int_t ipt=0;
334 TGraph *gbad=new TGraph(0);
335 gbad->SetTitle("Bad Channels");
336 TGraph *gbase=new TGraph(0);
337 gbase->SetTitle("Baselines");
338 TGraph *gnoi=new TGraph(0);
339 gnoi->SetTitle("Noise");
340 TGraph *ggain=new TGraph(0);
341 ggain->SetTitle("Gain");
342 for(Int_t iAn=0; iAn<512; iAn++){
343 Float_t bad=1;
344 if(cal->IsBadChannel(iAn)) bad=0;
345 Float_t base=cal->GetBaseline(iAn);
346 Float_t noise=cal->GetNoiseAfterElectronics(iAn);
347 Float_t gain=cal->GetChannelGain(iAn);
348 gbad->SetPoint(ipt,(Float_t)iAn,bad);
349 gbase->SetPoint(ipt,(Float_t)iAn,base);
350 ggain->SetPoint(ipt,(Float_t)iAn,gain);
351 gnoi->SetPoint(ipt,(Float_t)iAn,noise);
352 ipt++;
353 }
354 Char_t ctit[100];
355 sprintf(ctit,"Module %d",iMod);
356
357 TCanvas *c2=new TCanvas("c2",ctit,1200,800);
358 c2->Divide(2,2);
359
360 c2->cd(1);
361 gbase->SetMarkerStyle(7);
362 gbase->Draw("AP");
363 gbase->GetXaxis()->SetTitle("Anode Number");
364 gbase->GetYaxis()->SetTitle("Baseline after equalization");
365 c2->cd(2);
366 gnoi->SetMarkerStyle(7);
367 gnoi->Draw("AP");
368 gnoi->GetXaxis()->SetTitle("Anode Number");
369 gnoi->GetYaxis()->SetTitle("Noise");
370 c2->cd(3);
371 ggain->SetMarkerStyle(7);
372 ggain->Draw("AP");
373 ggain->GetXaxis()->SetTitle("Anode Number");
374 ggain->GetYaxis()->SetTitle("Gain");
375 c2->cd(4);
376 gbad->SetMarkerStyle(7);
377 gbad->Draw("AP");
378 gbad->SetMinimum(-0.1);
379 gbad->GetXaxis()->SetTitle("Anode Number");
380 gbad->GetYaxis()->SetTitle("Anode Status (1=OK, 0=bad)");
381}
382
2420973e 383void ShowCalibrationSDD(Int_t nrun, Int_t year=2010, Int_t nmod=0){
40b3a8c7 384 TGrid::Connect("alien:",0,0,"t");
551eb942 385 TString cmd=Form("gbbox find \"/alice/data/%d/OCDB/ITS/Calib/CalibSDD\" \"Run%d*.root\" > run.txt",year,nrun);
386 gSystem->Exec(cmd.Data());
387 Char_t filnam[200],filnamalien[200];
388 FILE* runtxt=fopen("run.txt","r");
389 fscanf(runtxt,"%s\n",filnam);
390 if(!strstr(filnam,"/alice/data/")){
391 printf("Bad run number\n");
392 gSystem->Exec("rm run.txt");
393 return;
394 }
395 sprintf(filnamalien,"alien://%s",filnam);
396
397 printf("Open file: %s\n",filnamalien);
398 ShowCalibrationSDD(filnamalien,nmod);
399 fclose(runtxt);
400 gSystem->Exec("rm run.txt");
40b3a8c7 401}