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 badAnodeCounter3=0;
85 Int_t badAnodeCounter4=0;
86 Int_t badAnodeCounterGoodMod3=0;
87 Int_t badAnodeCounterGoodMod4=0;
88 Int_t badAnodeCounterGoodModAndChip3=0;
89 Int_t badAnodeCounterGoodModAndChip4=0;
90 Int_t badChipCounter3=0;
91 Int_t badChipCounter4=0;
92 for(Int_t i=0; i<260; i++){
93 cal=(AliITSCalibrationSDD*)calSDD->At(i);
95 printf("Module %d (%d) status = ",i,i+240);
97 AliITSgeomTGeo::GetModuleId(i+240,lay,lad,det);
98 Int_t index=1+(det-1)*2;
103 hlay3->SetBinContent(index,lad,0);
104 hlay3->SetBinContent(index+1,lad,0);
107 hlay4->SetBinContent(index,lad,0);
108 hlay4->SetBinContent(index+1,lad,0);
110 hmodstatus->SetBinContent(i+1,0);
113 hmodstatus->SetBinContent(i+1,1);
115 badAnodeCounterGoodMod3+=cal->GetDeadChannels();
116 if(cal->IsChipBad(0) && cal->IsChipBad(1) && cal->IsChipBad(2) && cal->IsChipBad(3)){
117 hlay3->SetBinContent(index,lad,0);
119 hlay3->SetBinContent(index,lad,1);
121 if(cal->IsChipBad(4) && cal->IsChipBad(5) && cal->IsChipBad(6) && cal->IsChipBad(7)){
122 hlay3->SetBinContent(index+1,lad,0);
124 hlay3->SetBinContent(index+1,lad,1);
127 badAnodeCounterGoodMod4+=cal->GetDeadChannels();
128 if(cal->IsChipBad(0) && cal->IsChipBad(1) && cal->IsChipBad(2) && cal->IsChipBad(3)){
129 hlay4->SetBinContent(index,lad,0);
131 hlay4->SetBinContent(index,lad,1);
133 if(cal->IsChipBad(4) && cal->IsChipBad(5) && cal->IsChipBad(6) && cal->IsChipBad(7)){
134 hlay4->SetBinContent(index+1,lad,0);
136 hlay4->SetBinContent(index+1,lad,1);
140 printf(" Chip Status (0=OK, 1=BAD): ");
141 for(Int_t ic=0; ic<8;ic++){
142 printf("%d ",cal->IsChipBad(ic));
143 if(cal->IsChipBad(ic) && !cal->IsBad()){
144 if(i<84) badChipCounter3++;
145 else badChipCounter4++;
148 printf(" # bad anodes = %d ",cal->GetDeadChannels());
149 if(cal->IsAMAt20MHz()) printf(" 20 MHz sampling");
150 else printf(" 40 MHz sampling");
151 printf(" Threshold L %d %d H %d %d\n",cal->GetZSLowThreshold(0),cal->GetZSLowThreshold(1),cal->GetZSHighThreshold(0),cal->GetZSHighThreshold(1));
152 if(i<84) badAnodeCounter3+=cal->GetDeadChannels();
153 else badAnodeCounter4+=cal->GetDeadChannels();
154 hnbadch->SetBinContent(i+1,cal->GetDeadChannels());
155 if(lay==3) hdeadlay3->SetBinContent(det,lad,cal->GetDeadChannels());
156 if(lay==4) hdeadlay4->SetBinContent(det,lad,cal->GetDeadChannels());
157 for(Int_t iAn=0; iAn<512; iAn++){
158 Int_t ic=cal->GetChip(iAn);
159 if(!cal->IsChipBad(ic) && !cal->IsBad() && cal->IsBadChannel(iAn)){
160 if(i<84) badAnodeCounterGoodModAndChip3++;
161 else badAnodeCounterGoodModAndChip4++;
163 Float_t base=cal->GetBaseline(iAn);
164 Float_t noise=cal->GetNoiseAfterElectronics(iAn);
165 Float_t gain=cal->GetChannelGain(iAn);
166 if(cal->IsBadChannel(iAn)) hchstatus->Fill(0);
167 if(!cal->IsBadChannel(iAn) && !cal->IsChipBad(ic) && !cal->IsBad() ){
169 hbasemod->Fill(i+240,base);
172 hnoisemod->Fill(i+240,noise);
174 hgainmod->Fill(i+240,gain);
178 Int_t totbad3=badModCounter3*512+badChipCounter3*64+badAnodeCounterGoodModAndChip3;
180 Float_t fracbad3=(Float_t)totbad3/(Float_t)tot3;
181 Float_t fracgm3=(Float_t)(84.-badModCounter3)/84.;
182 Float_t fracgm4=(Float_t)(176.-badModCounter4)/176.;
183 Float_t fraccgm3=1.-(Float_t)(badAnodeCounterGoodModAndChip3+badChipCounter3*64)/(512.*(Float_t)(84.-badModCounter3));
184 Float_t fraccgm4=1.-(Float_t)(badAnodeCounterGoodModAndChip4+badChipCounter4*64)/(512.*(Float_t)(176.-badModCounter4));
185 Int_t totbad4=badModCounter4*512+badChipCounter4*64+badAnodeCounterGoodModAndChip4;
187 Float_t fracbad4=(Float_t)totbad4/(Float_t)tot4;
188 Float_t fractot=(Float_t)(totbad3+totbad4)/(Float_t)(tot3+tot4);
189 printf("----------------------Summary----------------------\n");
190 printf("---- Layer 3 ----\n");
191 printf("# of bad modules = %d\n",badModCounter3);
192 printf("# of bad chips in good modules = %d\n",badChipCounter3);
193 printf("# of bad anodes in good modules+chips = %d\n",badAnodeCounterGoodModAndChip3);
194 printf("Fraction of Good modules=%f\n",fracgm3);
195 printf("Fraction of good anodes in good modules+chips = %f\n",fraccgm3);
196 printf("Fraction of bads (anodes+chips+mod) = %f\n",fracbad3);
197 printf("---- Layer 4 ----\n");
198 printf("# of bad modules = %d\n",badModCounter4);
199 printf("# of bad chips in good modules = %d\n",badChipCounter4);
200 printf("# of bad anodes in good modules+chips = %d\n",badAnodeCounterGoodModAndChip4);
201 printf("Fraction of Good modules=%f\n",fracgm4);
202 printf("Fraction of good anodes in good modules+chips = %f\n",fraccgm4);
203 printf("Fraction of bads (anodes+chips+mod) = %f\n",fracbad4);
204 printf("---- Total ----\n");
205 printf("# of bad modules = %d\n",badModCounter3+badModCounter4);
206 printf("# of bad chips in good modules = %d\n",badChipCounter3+badChipCounter4);
207 printf("# of bad anodes in good modules+chips = %d\n",badAnodeCounterGoodModAndChip3+badAnodeCounterGoodModAndChip4);
208 printf("Fraction of bads (anodes+chips+mod) = %f\n",fractot);
209 printf("---------------------------------------------------\n");
212 TLine* lin=new TLine(0,0,0,23);
213 TExec *ex1 = new TExec("ex1","MakePalette();");
214 TExec *ex2 = new TExec("ex2","gStyle->SetPalette(1);");
216 TCanvas* clay=new TCanvas("clay","Layer status",900,600);
221 hlay3->DrawCopy("col same");
222 for(Int_t i=0;i<6;i++){
229 for(Int_t i=0;i<14;i++){
237 hlay4->DrawCopy("col");
238 for(Int_t i=0;i<8;i++){
245 for(Int_t i=0;i<22;i++){
256 TCanvas *c0b=new TCanvas("c0b","Bad Channels",900,600);
259 hdeadlay3->DrawCopy("colz");
261 hdeadlay3->DrawCopy("colz same");
262 for(Int_t i=0;i<6;i++){
269 for(Int_t i=0;i<14;i++){
277 hdeadlay4->DrawCopy("colz");
279 hdeadlay4->DrawCopy("colz same");
280 for(Int_t i=0;i<8;i++){
287 for(Int_t i=0;i<22;i++){
297 TCanvas *c1=new TCanvas("c1","Anode calibration",800,800);
301 hbase->GetXaxis()->SetTitle("Baseline after equalization");
302 hbase->GetXaxis()->CenterTitle();
305 hnoise->GetXaxis()->SetTitle("Noise");
306 hnoise->GetXaxis()->CenterTitle();
309 hgain->GetXaxis()->SetTitle("Gain");
310 hgain->GetXaxis()->CenterTitle();
313 hchstatus->GetXaxis()->SetTitle("Anode status (0=bad, 1=OK)");
314 hchstatus->GetXaxis()->CenterTitle();
316 TCanvas *c1m=new TCanvas("c1m","Calib. vs. mod",1000,800);
319 gPad->SetRightMargin(0.14);
320 hbasemod->SetStats(0);
321 hbasemod->Draw("colz");
322 hbasemod->GetXaxis()->SetTitle("Module Number");
323 hbasemod->GetYaxis()->SetTitle("Baseline");
325 gPad->SetRightMargin(0.14);
326 hnoisemod->SetStats(0);
327 hnoisemod->Draw("colz");
328 hnoisemod->GetXaxis()->SetTitle("Module Number");
329 hnoisemod->GetYaxis()->SetTitle("Noise");
331 gPad->SetRightMargin(0.14);
332 hgainmod->SetStats(0);
333 hgainmod->Draw("colz");
334 hgainmod->GetXaxis()->SetTitle("Module Number");
335 hgainmod->GetYaxis()->SetTitle("Gain");
337 hnbadch->Scale(1/512.);
338 hnbadch->SetMarkerStyle(20);
339 hnbadch->SetMarkerSize(0.8);
340 hnbadch->SetStats(0);
342 hnbadch->GetXaxis()->SetTitle("Module number");
343 hnbadch->GetYaxis()->SetTitle("Fraction of bad anodes");
352 // Plot quantities for specified module
354 cal=(AliITSCalibrationSDD*)calSDD->At(iMod);
356 printf("-----------------------------------\n");
357 printf("Module %d status = ",iMod);
358 if(cal->IsBad()) printf("BAD\n");
360 printf(" Chip Status (0=OK, 1=BAD): ");
361 for(Int_t ic=0; ic<8;ic++) printf("%d ",cal->IsChipBad(ic));
363 printf(" Number of bad anodes =%d\n",cal->GetDeadChannels());
364 printf("-----------------------------------\n");
366 TGraph *gbad=new TGraph(0);
367 gbad->SetTitle("Bad Channels");
368 TGraph *gbase=new TGraph(0);
369 gbase->SetTitle("Baselines");
370 TGraph *gnoi=new TGraph(0);
371 gnoi->SetTitle("Noise");
372 TGraph *ggain=new TGraph(0);
373 ggain->SetTitle("Gain");
374 for(Int_t iAn=0; iAn<512; iAn++){
376 if(cal->IsBadChannel(iAn)) bad=0;
377 Float_t base=cal->GetBaseline(iAn);
378 Float_t noise=cal->GetNoiseAfterElectronics(iAn);
379 Float_t gain=cal->GetChannelGain(iAn);
380 gbad->SetPoint(ipt,(Float_t)iAn,bad);
381 gbase->SetPoint(ipt,(Float_t)iAn,base);
382 ggain->SetPoint(ipt,(Float_t)iAn,gain);
383 gnoi->SetPoint(ipt,(Float_t)iAn,noise);
387 sprintf(ctit,"Module %d",iMod);
389 TCanvas *c2=new TCanvas("c2",ctit,1200,800);
393 gbase->SetMarkerStyle(7);
395 gbase->GetXaxis()->SetTitle("Anode Number");
396 gbase->GetYaxis()->SetTitle("Baseline after equalization");
398 gnoi->SetMarkerStyle(7);
400 gnoi->GetXaxis()->SetTitle("Anode Number");
401 gnoi->GetYaxis()->SetTitle("Noise");
403 ggain->SetMarkerStyle(7);
405 ggain->GetXaxis()->SetTitle("Anode Number");
406 ggain->GetYaxis()->SetTitle("Gain");
408 gbad->SetMarkerStyle(7);
410 gbad->SetMinimum(-0.1);
411 gbad->GetXaxis()->SetTitle("Anode Number");
412 gbad->GetYaxis()->SetTitle("Anode Status (1=OK, 0=bad)");
415 void ShowCalibrationSDD(Int_t nrun, Int_t year=2010, Int_t nmod=0){
416 TGrid::Connect("alien:",0,0,"t");
417 TString cmd=Form("gbbox find \"/alice/data/%d/OCDB/ITS/Calib/CalibSDD\" \"Run%d*.root\" > run.txt",year,nrun);
418 gSystem->Exec(cmd.Data());
419 Char_t filnam[200],filnamalien[200];
420 FILE* runtxt=fopen("run.txt","r");
421 fscanf(runtxt,"%s\n",filnam);
422 if(!strstr(filnam,"/alice/data/")){
423 printf("Bad run number\n");
424 gSystem->Exec("rm run.txt");
427 sprintf(filnamalien,"alien://%s",filnam);
429 printf("Open file: %s\n",filnamalien);
430 ShowCalibrationSDD(filnamalien,nmod);
432 gSystem->Exec("rm run.txt");