1 #if !defined(__CINT__) || defined(__MAKECINT__)
13 #include <TObjArray.h>
14 #include "AliCDBEntry.h"
15 #include "AliITSCalibrationSDD.h"
16 #include "AliITSgeomTGeo.h"
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
25 // Origin: F. Prino (prino@to.infn.it)
28 Int_t palette[3]={kGray,2,3};
29 gStyle->SetPalette(3,palette);
32 void ShowCalibrationSDD(Char_t *filnam="$ALICE_ROOT/OCDB/ITS/Calib/CalibSDD/Run0_9999999_v0_s0.root", Int_t iMod=0){
35 TFile *f=TFile::Open(filnam);
36 AliCDBEntry *ent=(AliCDBEntry*)f->Get("AliCDBEntry");
37 TH2I* hlay3=new TH2I("hlay3","Layer 3",12,-0.5,5.5,14,-0.5,13.5);
38 hlay3->GetXaxis()->SetTitle("Detector");
39 hlay3->GetYaxis()->SetTitle("Ladder");
40 hlay3->GetXaxis()->SetTickLength(0);
41 hlay3->GetYaxis()->SetTickLength(0);
43 hlay3->SetMinimum(-1);
44 TH2I* hlay4=new TH2I("hlay4","Layer 4",16,-0.5,7.5,22,-0.5,21.5);
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");
51 hlay4->SetMinimum(-1);
52 TH2I* hdeadlay3=new TH2I("hdlay3","Layer 3",6,-0.5,5.5,14,-0.5,13.5);
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.);
59 TH2I* hdeadlay4=new TH2I("hdlay4","Layer 4",8,-0.5,7.5,22,-0.5,21.5);
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.);
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 TH2F* hbasemod=new TH2F("hbasemod","",260,239.5,499.5,50,0.,100.);
74 TH1F* hnoise=new TH1F("hnoise","",100,0.,7.);
75 TH2F* hnoisemod=new TH2F("hnoisemod","",260,239.5,499.5,50,0.,10.);
76 TH1F* hgain=new TH1F("hgain","",100,0.,4.);
77 TH2F* hgainmod=new TH2F("hgainmod","",260,239.5,499.5,50,0.,4.);
78 TH1F* hchstatus=new TH1F("hchstatus","",2,-0.5,1.5);
81 AliITSCalibrationSDD *cal;
82 Int_t badModCounter3=0;
83 Int_t badModCounter4=0;
84 Int_t badHybridCounter3=0;
85 Int_t badHybridCounter4=0;
86 Int_t badAnodeCounter3=0;
87 Int_t badAnodeCounter4=0;
88 Int_t badAnodeCounterGoodMod3=0;
89 Int_t badAnodeCounterGoodMod4=0;
90 Int_t badAnodeCounterGoodHybrid3=0;
91 Int_t badAnodeCounterGoodHybrid4=0;
92 Int_t badAnodeCounterGoodModAndChip3=0;
93 Int_t badAnodeCounterGoodModAndChip4=0;
94 Int_t badChipCounter3=0;
95 Int_t badChipCounter4=0;
96 for(Int_t i=0; i<260; i++){
97 cal=(AliITSCalibrationSDD*)calSDD->At(i);
99 printf("Module %d (%d) status = ",i,i+240);
101 AliITSgeomTGeo::GetModuleId(i+240,lay,lad,det);
102 Int_t index=1+(det-1)*2;
107 badHybridCounter3+=2;
108 hlay3->SetBinContent(index,lad,0);
109 hlay3->SetBinContent(index+1,lad,0);
112 badHybridCounter4+=2;
113 hlay4->SetBinContent(index,lad,0);
114 hlay4->SetBinContent(index+1,lad,0);
116 hmodstatus->SetBinContent(i+1,0);
119 hmodstatus->SetBinContent(i+1,1);
121 badAnodeCounterGoodMod3+=cal->GetDeadChannels();
122 if(cal->IsChipBad(0) && cal->IsChipBad(1) && cal->IsChipBad(2) && cal->IsChipBad(3)){
123 hlay3->SetBinContent(index,lad,0);
126 hlay3->SetBinContent(index,lad,1);
127 for(Int_t iAn=0; iAn<256; iAn++){
128 if(cal->IsBadChannel(iAn)) badAnodeCounterGoodHybrid3++;
131 if(cal->IsChipBad(4) && cal->IsChipBad(5) && cal->IsChipBad(6) && cal->IsChipBad(7)){
132 hlay3->SetBinContent(index+1,lad,0);
135 hlay3->SetBinContent(index+1,lad,1);
136 for(Int_t iAn=256; iAn<512; iAn++){
137 if(cal->IsBadChannel(iAn)) badAnodeCounterGoodHybrid3++;
141 badAnodeCounterGoodMod4+=cal->GetDeadChannels();
142 if(cal->IsChipBad(0) && cal->IsChipBad(1) && cal->IsChipBad(2) && cal->IsChipBad(3)){
143 hlay4->SetBinContent(index,lad,0);
146 hlay4->SetBinContent(index,lad,1);
147 for(Int_t iAn=0; iAn<256; iAn++){
148 if(cal->IsBadChannel(iAn)) badAnodeCounterGoodHybrid4++;
151 if(cal->IsChipBad(4) && cal->IsChipBad(5) && cal->IsChipBad(6) && cal->IsChipBad(7)){
152 hlay4->SetBinContent(index+1,lad,0);
155 hlay4->SetBinContent(index+1,lad,1);
156 for(Int_t iAn=256; iAn<512; iAn++){
157 if(cal->IsBadChannel(iAn)) badAnodeCounterGoodHybrid4++;
162 printf(" Chip Status (0=OK, 1=BAD): ");
163 for(Int_t ic=0; ic<8;ic++){
164 printf("%d ",cal->IsChipBad(ic));
165 if(cal->IsChipBad(ic) && !cal->IsBad()){
166 if(i<84) badChipCounter3++;
167 else badChipCounter4++;
170 printf(" # bad anodes = %d ",cal->GetDeadChannels());
171 if(cal->IsAMAt20MHz()) printf(" 20 MHz sampling");
172 else printf(" 40 MHz sampling");
173 printf(" Threshold L %d %d H %d %d\n",cal->GetZSLowThreshold(0),cal->GetZSLowThreshold(1),cal->GetZSHighThreshold(0),cal->GetZSHighThreshold(1));
174 if(i<84) badAnodeCounter3+=cal->GetDeadChannels();
175 else badAnodeCounter4+=cal->GetDeadChannels();
176 hnbadch->SetBinContent(i+1,cal->GetDeadChannels());
177 if(lay==3) hdeadlay3->SetBinContent(det,lad,cal->GetDeadChannels());
178 if(lay==4) hdeadlay4->SetBinContent(det,lad,cal->GetDeadChannels());
179 for(Int_t iAn=0; iAn<512; iAn++){
180 Int_t ic=cal->GetChip(iAn);
181 if(!cal->IsChipBad(ic) && !cal->IsBad() && cal->IsBadChannel(iAn)){
182 if(i<84) badAnodeCounterGoodModAndChip3++;
183 else badAnodeCounterGoodModAndChip4++;
185 Float_t base=cal->GetBaseline(iAn);
186 Float_t noise=cal->GetNoiseAfterElectronics(iAn);
187 Float_t gain=cal->GetChannelGain(iAn);
188 if(cal->IsBadChannel(iAn)) hchstatus->Fill(0);
189 if(!cal->IsBadChannel(iAn) && !cal->IsChipBad(ic) && !cal->IsBad() ){
191 hbasemod->Fill(i+240,base);
194 hnoisemod->Fill(i+240,noise);
196 hgainmod->Fill(i+240,gain);
200 Int_t totbad3=badModCounter3*512+badChipCounter3*64+badAnodeCounterGoodModAndChip3;
202 Float_t fracbad3=(Float_t)totbad3/(Float_t)tot3;
203 Float_t fracgm3=(Float_t)(84.-badModCounter3)/84.;
204 Float_t fracgm4=(Float_t)(176.-badModCounter4)/176.;
205 Float_t fracgh3=(Float_t)(84.*2.-badHybridCounter3)/84./2.;
206 Float_t fracgh4=(Float_t)(176.*2-badHybridCounter4)/176./2.;
207 Float_t fraccgm3=1.-(Float_t)(badAnodeCounterGoodModAndChip3+badChipCounter3*64)/(512.*(Float_t)(84.-badModCounter3));
208 Float_t fraccgm4=1.-(Float_t)(badAnodeCounterGoodModAndChip4+badChipCounter4*64)/(512.*(Float_t)(176.-badModCounter4));
209 Float_t fraccgh3=1.-(Float_t)badAnodeCounterGoodHybrid3/(256.*(84.*2.-badHybridCounter3));
210 Float_t fraccgh4=1.-(Float_t)badAnodeCounterGoodHybrid4/(256.*(176.*2.-badHybridCounter4));
211 Int_t totbad4=badModCounter4*512+badChipCounter4*64+badAnodeCounterGoodModAndChip4;
213 Float_t fracbad4=(Float_t)totbad4/(Float_t)tot4;
214 Float_t fractot=(Float_t)(totbad3+totbad4)/(Float_t)(tot3+tot4);
215 printf("----------------------Summary----------------------\n");
216 printf("---- Layer 3 ----\n");
217 printf("# of bad modules = %d\n",badModCounter3);
218 printf("# of bad chips in good modules = %d\n",badChipCounter3);
219 printf("# of bad hybrids = %d\n",badHybridCounter3);
220 printf("# of bad anodes in good hybrids = %d\n",badAnodeCounterGoodHybrid3);
221 printf("Fraction of Good modules=%f\n",fracgm3);
222 printf("Fraction of Good hybrids=%f\n",fracgh3);
223 printf("Fraction of good anodes in good modules = %f\n",fraccgm3);
224 printf("Fraction of good anodes in good hybrids = %f\n",fraccgh3);
225 printf("Fraction of bads (anodes+chips+mod) = %f\n",fracbad3);
226 printf("---- Layer 4 ----\n");
227 printf("# of bad modules = %d\n",badModCounter4);
228 printf("# of bad chips in good modules = %d\n",badChipCounter4);
229 printf("# of bad hybrids = %d\n",badHybridCounter4);
230 printf("# of bad anodes in good hybrids = %d\n",badAnodeCounterGoodHybrid4);
231 printf("Fraction of Good modules=%f\n",fracgm4);
232 printf("Fraction of Good hybrids=%f\n",fracgh4);
233 printf("Fraction of good anodes in good modules = %f\n",fraccgm4);
234 printf("Fraction of good anodes in good hybrids = %f\n",fraccgh4);
235 printf("Fraction of bads (anodes+chips+mod) = %f\n",fracbad4);
236 printf("---- Total ----\n");
237 printf("# of bad modules = %d\n",badModCounter3+badModCounter4);
238 printf("# of bad chips in good modules = %d\n",badChipCounter3+badChipCounter4);
239 printf("# of bad anodes in good modules+chips = %d\n",badAnodeCounterGoodModAndChip3+badAnodeCounterGoodModAndChip4);
240 printf("Fraction of bads (anodes+chips+mod) = %f\n",fractot);
241 printf("---------------------------------------------------\n");
244 TLine* lin=new TLine(0,0,0,23);
245 TExec *ex1 = new TExec("ex1","MakePalette();");
246 TExec *ex2 = new TExec("ex2","gStyle->SetPalette(1);");
248 TCanvas* clay=new TCanvas("clay","Layer status",900,600);
253 hlay3->DrawCopy("col same");
254 for(Int_t i=0;i<6;i++){
261 for(Int_t i=0;i<14;i++){
269 hlay4->DrawCopy("col");
270 for(Int_t i=0;i<8;i++){
277 for(Int_t i=0;i<22;i++){
288 TCanvas *c0b=new TCanvas("c0b","Bad Channels",900,600);
291 hdeadlay3->DrawCopy("colz");
293 hdeadlay3->DrawCopy("colz same");
294 for(Int_t i=0;i<6;i++){
301 for(Int_t i=0;i<14;i++){
309 hdeadlay4->DrawCopy("colz");
311 hdeadlay4->DrawCopy("colz same");
312 for(Int_t i=0;i<8;i++){
319 for(Int_t i=0;i<22;i++){
329 TCanvas *c1=new TCanvas("c1","Anode calibration",800,800);
333 hbase->GetXaxis()->SetTitle("Baseline after equalization");
334 hbase->GetXaxis()->CenterTitle();
337 hnoise->GetXaxis()->SetTitle("Noise");
338 hnoise->GetXaxis()->CenterTitle();
341 hgain->GetXaxis()->SetTitle("Gain");
342 hgain->GetXaxis()->CenterTitle();
345 hchstatus->GetXaxis()->SetTitle("Anode status (0=bad, 1=OK)");
346 hchstatus->GetXaxis()->CenterTitle();
348 TCanvas *c1m=new TCanvas("c1m","Calib. vs. mod",1000,800);
351 gPad->SetRightMargin(0.14);
352 hbasemod->SetStats(0);
353 hbasemod->Draw("colz");
354 hbasemod->GetXaxis()->SetTitle("Module Number");
355 hbasemod->GetYaxis()->SetTitle("Baseline");
357 gPad->SetRightMargin(0.14);
358 hnoisemod->SetStats(0);
359 hnoisemod->Draw("colz");
360 hnoisemod->GetXaxis()->SetTitle("Module Number");
361 hnoisemod->GetYaxis()->SetTitle("Noise");
363 gPad->SetRightMargin(0.14);
364 hgainmod->SetStats(0);
365 hgainmod->Draw("colz");
366 hgainmod->GetXaxis()->SetTitle("Module Number");
367 hgainmod->GetYaxis()->SetTitle("Gain");
369 hnbadch->Scale(1/512.);
370 hnbadch->SetMarkerStyle(20);
371 hnbadch->SetMarkerSize(0.8);
372 hnbadch->SetStats(0);
374 hnbadch->GetXaxis()->SetTitle("Module number");
375 hnbadch->GetYaxis()->SetTitle("Fraction of bad anodes");
384 // Plot quantities for specified module
386 cal=(AliITSCalibrationSDD*)calSDD->At(iMod);
388 printf("-----------------------------------\n");
389 printf("Module %d status = ",iMod);
390 if(cal->IsBad()) printf("BAD\n");
392 printf(" Chip Status (0=OK, 1=BAD): ");
393 for(Int_t ic=0; ic<8;ic++) printf("%d ",cal->IsChipBad(ic));
395 printf(" Number of bad anodes =%d\n",cal->GetDeadChannels());
396 printf("-----------------------------------\n");
398 TGraph *gbad=new TGraph(0);
399 gbad->SetTitle("Bad Channels");
400 TGraph *gbase=new TGraph(0);
401 gbase->SetTitle("Baselines");
402 TGraph *gnoi=new TGraph(0);
403 gnoi->SetTitle("Noise");
404 TGraph *ggain=new TGraph(0);
405 ggain->SetTitle("Gain");
406 for(Int_t iAn=0; iAn<512; iAn++){
408 if(cal->IsBadChannel(iAn)) bad=0;
409 Float_t base=cal->GetBaseline(iAn);
410 Float_t noise=cal->GetNoiseAfterElectronics(iAn);
411 Float_t gain=cal->GetChannelGain(iAn);
412 gbad->SetPoint(ipt,(Float_t)iAn,bad);
413 gbase->SetPoint(ipt,(Float_t)iAn,base);
414 ggain->SetPoint(ipt,(Float_t)iAn,gain);
415 gnoi->SetPoint(ipt,(Float_t)iAn,noise);
419 sprintf(ctit,"Module %d",iMod);
421 TCanvas *c2=new TCanvas("c2",ctit,1200,800);
425 gbase->SetMarkerStyle(7);
427 gbase->GetXaxis()->SetTitle("Anode Number");
428 gbase->GetYaxis()->SetTitle("Baseline after equalization");
430 gnoi->SetMarkerStyle(7);
432 gnoi->GetXaxis()->SetTitle("Anode Number");
433 gnoi->GetYaxis()->SetTitle("Noise");
435 ggain->SetMarkerStyle(7);
437 ggain->GetXaxis()->SetTitle("Anode Number");
438 ggain->GetYaxis()->SetTitle("Gain");
440 gbad->SetMarkerStyle(7);
442 gbad->SetMinimum(-0.1);
443 gbad->GetXaxis()->SetTitle("Anode Number");
444 gbad->GetYaxis()->SetTitle("Anode Status (1=OK, 0=bad)");
447 void ShowCalibrationSDD(Int_t nrun, Int_t year=2010, Int_t nmod=0){
448 TGrid::Connect("alien:",0,0,"t");
449 TString cmd=Form("gbbox find \"/alice/data/%d/OCDB/ITS/Calib/CalibSDD\" \"Run%d*.root\" > run.txt",year,nrun);
450 gSystem->Exec(cmd.Data());
451 Char_t filnam[200],filnamalien[200];
452 FILE* runtxt=fopen("run.txt","r");
453 fscanf(runtxt,"%s\n",filnam);
454 if(!strstr(filnam,"/alice/data/")){
455 printf("Bad run number\n");
456 gSystem->Exec("rm run.txt");
459 sprintf(filnamalien,"alien://%s",filnam);
461 printf("Open file: %s\n",filnamalien);
462 ShowCalibrationSDD(filnamalien,nmod);
464 gSystem->Exec("rm run.txt");