1 #if !defined(__CINT__) || defined(__MAKECINT__)
11 #include <TObjArray.h>
12 #include "AliCDBEntry.h"
13 #include "AliITSCalibrationSDD.h"
14 #include "AliITSgeomTGeo.h"
17 // Macro to plot the calibration parameters from the OCDB file
18 // created from PEDESTAL and PULSER runs (OCDB/ITS/Calib/CalibSDD)
19 // Two methods ShowCalibrationSDD:
20 // - the first takes the name of the file to be displayed
21 // - the second builds the alien path+name from run number and file version
23 // Origin: F. Prino (prino@to.infn.it)
26 Int_t palette[3]={kGray,2,3};
27 gStyle->SetPalette(3,palette);
30 void ShowCalibrationSDD(Int_t iMod=0, Char_t *filnam="$ALICE_ROOT/OCDB/ITS/Calib/CalibSDD/Run0_9999999_v0_s0.root"){
33 TFile *f=TFile::Open(filnam);
34 AliCDBEntry *ent=(AliCDBEntry*)f->Get("AliCDBEntry");
35 TH2I* hlay3=new TH2I("hlay3","Layer 3",12,-0.5,5.5,14,-0.5,13.5);
36 hlay3->GetXaxis()->SetTitle("Detector");
37 hlay3->GetYaxis()->SetTitle("Ladder");
38 hlay3->GetXaxis()->SetTickLength(0);
39 hlay3->GetYaxis()->SetTickLength(0);
41 hlay3->SetMinimum(-1);
42 TH2I* hlay4=new TH2I("hlay4","Layer 4",16,-0.5,7.5,22,-0.5,21.5);
43 hlay4->GetXaxis()->SetTitle("Detector");
44 hlay4->GetYaxis()->SetTitle("Ladder");
45 hlay4->GetXaxis()->SetTickLength(0);
46 hlay4->GetYaxis()->SetTickLength(0);
47 hlay4->GetYaxis()->SetTitle("Ladder");
49 hlay4->SetMinimum(-1);
50 TH2I* hdeadlay3=new TH2I("hlay3","Layer 3",6,-0.5,5.5,14,-0.5,13.5);
51 hdeadlay3->GetXaxis()->SetTitle("Detector");
52 hdeadlay3->GetYaxis()->SetTitle("Ladder");
53 hdeadlay3->GetXaxis()->SetTickLength(0);
54 hdeadlay3->GetYaxis()->SetTickLength(0);
55 hdeadlay3->SetStats(0);
56 hdeadlay3->SetMinimum(-1.);
57 TH2I* hdeadlay4=new TH2I("hlay4","Layer 4",8,-0.5,7.5,22,-0.5,21.5);
58 hdeadlay4->GetXaxis()->SetTitle("Detector");
59 hdeadlay4->GetYaxis()->SetTitle("Ladder");
60 hdeadlay4->GetXaxis()->SetTickLength(0);
61 hdeadlay4->GetYaxis()->SetTickLength(0);
62 hdeadlay4->GetYaxis()->SetTitle("Ladder");
63 hdeadlay4->SetStats(0);
64 hdeadlay4->SetMinimum(-1.);
66 TObjArray *calSDD = (TObjArray *)ent->GetObject();
67 printf("Entries in array=%d\n",calSDD->GetEntriesFast());
68 TH1F* hmodstatus=new TH1F("hmodstatus","",260,0.5,260.5);
69 TH1F* hnbadch=new TH1F("hnbadch","",260,0.5,260.5);
70 TH1F* hbase=new TH1F("hbase","",60,0.5,120.5);
71 TH1F* hnoise=new TH1F("hnoise","",100,0.,7.);
72 TH1F* hgain=new TH1F("hgain","",100,0.,4.);
73 TH1F* hchstatus=new TH1F("hchstatus","",2,-0.5,1.5);
74 AliITSCalibrationSDD *cal;
75 Int_t badModCounter3=0;
76 Int_t badModCounter4=0;
77 Int_t badAnodeCounter3=0;
78 Int_t badAnodeCounter4=0;
79 Int_t badAnodeCounterGoodMod3=0;
80 Int_t badAnodeCounterGoodMod4=0;
81 Int_t badAnodeCounterGoodModAndChip3=0;
82 Int_t badAnodeCounterGoodModAndChip4=0;
83 Int_t badChipCounter3=0;
84 Int_t badChipCounter4=0;
85 for(Int_t i=0; i<260; i++){
86 cal=(AliITSCalibrationSDD*)calSDD->At(i);
88 printf("Module %d (%d) status = ",i,i+240);
90 AliITSgeomTGeo::GetModuleId(i+240,lay,lad,det);
91 Int_t index=1+(det-1)*2;
96 hlay3->SetBinContent(index,lad,0);
97 hlay3->SetBinContent(index+1,lad,0);
100 hlay4->SetBinContent(index,lad,0);
101 hlay4->SetBinContent(index+1,lad,0);
103 hmodstatus->SetBinContent(i+1,0);
106 hmodstatus->SetBinContent(i+1,1);
108 badAnodeCounterGoodMod3+=cal->GetDeadChannels();
109 if(cal->IsChipBad(0) && cal->IsChipBad(1) && cal->IsChipBad(2) && cal->IsChipBad(3)){
110 hlay3->SetBinContent(index,lad,0);
112 hlay3->SetBinContent(index,lad,1);
114 if(cal->IsChipBad(4) && cal->IsChipBad(5) && cal->IsChipBad(6) && cal->IsChipBad(7)){
115 hlay3->SetBinContent(index+1,lad,0);
117 hlay3->SetBinContent(index+1,lad,1);
120 badAnodeCounterGoodMod4+=cal->GetDeadChannels();
121 if(cal->IsChipBad(0) && cal->IsChipBad(1) && cal->IsChipBad(2) && cal->IsChipBad(3)){
122 hlay4->SetBinContent(index,lad,0);
124 hlay4->SetBinContent(index,lad,1);
126 if(cal->IsChipBad(4) && cal->IsChipBad(5) && cal->IsChipBad(6) && cal->IsChipBad(7)){
127 hlay4->SetBinContent(index+1,lad,0);
129 hlay4->SetBinContent(index+1,lad,1);
133 printf(" Chip Status (0=OK, 1=BAD): ");
134 for(Int_t ic=0; ic<8;ic++){
135 printf("%d ",cal->IsChipBad(ic));
136 if(cal->IsChipBad(ic) && !cal->IsBad()){
137 if(i<84) badChipCounter3++;
138 else badChipCounter4++;
141 printf(" # bad anodes = %d ",cal->GetDeadChannels());
142 if(cal->IsAMAt20MHz()) printf(" 20 MHz sampling");
143 else printf(" 40 MHz sampling");
145 if(i<84) badAnodeCounter3+=cal->GetDeadChannels();
146 else badAnodeCounter4+=cal->GetDeadChannels();
147 hnbadch->SetBinContent(i+1,cal->GetDeadChannels());
148 if(lay==3) hdeadlay3->SetBinContent(det,lad,cal->GetDeadChannels());
149 if(lay==4) hdeadlay4->SetBinContent(det,lad,cal->GetDeadChannels());
150 for(Int_t iAn=0; iAn<512; iAn++){
151 Int_t ic=cal->GetChip(iAn);
152 if(!cal->IsChipBad(ic) && !cal->IsBad() && cal->IsBadChannel(iAn)){
153 if(i<84) badAnodeCounterGoodModAndChip3++;
154 else badAnodeCounterGoodModAndChip4++;
156 Float_t base=cal->GetBaseline(iAn);
157 Float_t noise=cal->GetNoiseAfterElectronics(iAn);
158 Float_t gain=cal->GetChannelGain(iAn);
159 if(cal->IsBadChannel(iAn)) hchstatus->Fill(0);
160 if(!cal->IsBadChannel(iAn) && !cal->IsChipBad(ic) && !cal->IsBad() ){
168 Int_t totbad3=badModCounter3*512+badChipCounter3*64+badAnodeCounterGoodModAndChip3;
170 Float_t fracbad3=(Float_t)totbad3/(Float_t)tot3;
171 Int_t totbad4=badModCounter4*512+badChipCounter4*64+badAnodeCounterGoodModAndChip4;
173 Float_t fracbad4=(Float_t)totbad4/(Float_t)tot4;
174 Float_t fractot=(Float_t)(totbad3+totbad4)/(Float_t)(tot3+tot4);
175 printf("----------------------Summary----------------------\n");
176 printf("---- Layer 3 ----\n");
177 printf("# of bad modules = %d\n",badModCounter3);
178 printf("# of bad chips in good modules = %d\n",badChipCounter3);
179 printf("# of bad anodes in good modules+chips = %d\n",badAnodeCounterGoodModAndChip3);
180 printf("Fraction of bads (anodes+chips+mod) = %f\n",fracbad3);
181 printf("---- Layer 4 ----\n");
182 printf("# of bad modules = %d\n",badModCounter4);
183 printf("# of bad chips in good modules = %d\n",badChipCounter4);
184 printf("# of bad anodes in good modules+chips = %d\n",badAnodeCounterGoodModAndChip4);
185 printf("Fraction of bads (anodes+chips+mod) = %f\n",fracbad4);
186 printf("---- Total ----\n");
187 printf("# of bad modules = %d\n",badModCounter3+badModCounter4);
188 printf("# of bad chips in good modules = %d\n",badChipCounter3+badChipCounter4);
189 printf("# of bad anodes in good modules+chips = %d\n",badAnodeCounterGoodModAndChip3+badAnodeCounterGoodModAndChip4);
190 printf("Fraction of bads (anodes+chips+mod) = %f\n",fractot);
191 printf("---------------------------------------------------\n");
194 TLine* lin=new TLine(0,0,0,23);
195 TExec *ex1 = new TExec("ex1","MakePalette();");
196 TExec *ex2 = new TExec("ex2","gStyle->SetPalette(1);");
198 TCanvas* clay=new TCanvas("clay","Layer status",900,600);
203 hlay3->DrawCopy("col same");
204 for(Int_t i=0;i<6;i++){
211 for(Int_t i=0;i<14;i++){
219 hlay4->DrawCopy("col");
220 for(Int_t i=0;i<8;i++){
227 for(Int_t i=0;i<22;i++){
235 TCanvas *c0=new TCanvas("c0","Module status",800,800);
239 hmodstatus->GetXaxis()->SetTitle("Module number");
240 hmodstatus->GetYaxis()->SetTitle("Module status (1=OK, 0=BAD)");
243 hnbadch->GetXaxis()->SetTitle("Module number");
244 hnbadch->GetYaxis()->SetTitle("Number of bad anodes");
249 TCanvas *c0b=new TCanvas("c0b","Bad Channels",900,600);
252 hdeadlay3->DrawCopy("colz");
254 hdeadlay3->DrawCopy("colz same");
255 for(Int_t i=0;i<6;i++){
262 for(Int_t i=0;i<14;i++){
270 hdeadlay4->DrawCopy("colz");
272 hdeadlay4->DrawCopy("colz same");
273 for(Int_t i=0;i<8;i++){
280 for(Int_t i=0;i<22;i++){
290 TCanvas *c1=new TCanvas("c1","Anode calibration",800,800);
294 hbase->GetXaxis()->SetTitle("Baseline after equalization");
295 hbase->GetXaxis()->CenterTitle();
298 hnoise->GetXaxis()->SetTitle("Noise");
299 hnoise->GetXaxis()->CenterTitle();
302 hgain->GetXaxis()->SetTitle("Gain");
303 hgain->GetXaxis()->CenterTitle();
306 hchstatus->GetXaxis()->SetTitle("Anode status (0=bad, 1=OK)");
307 hchstatus->GetXaxis()->CenterTitle();
318 // Plot quantities for specified module
320 cal=(AliITSCalibrationSDD*)calSDD->At(iMod);
322 printf("-----------------------------------\n");
323 printf("Module %d status = ",iMod);
324 if(cal->IsBad()) printf("BAD\n");
326 printf(" Chip Status (0=OK, 1=BAD): ");
327 for(Int_t ic=0; ic<8;ic++) printf("%d ",cal->IsChipBad(ic));
329 printf(" Number of bad anodes =%d\n",cal->GetDeadChannels());
330 printf("-----------------------------------\n");
332 TGraph *gbad=new TGraph(0);
333 gbad->SetTitle("Bad Channels");
334 TGraph *gbase=new TGraph(0);
335 gbase->SetTitle("Baselines");
336 TGraph *gnoi=new TGraph(0);
337 gnoi->SetTitle("Noise");
338 TGraph *ggain=new TGraph(0);
339 ggain->SetTitle("Gain");
340 for(Int_t iAn=0; iAn<512; iAn++){
342 if(cal->IsBadChannel(iAn)) bad=0;
343 Float_t base=cal->GetBaseline(iAn);
344 Float_t noise=cal->GetNoiseAfterElectronics(iAn);
345 Float_t gain=cal->GetChannelGain(iAn);
346 gbad->SetPoint(ipt,(Float_t)iAn,bad);
347 gbase->SetPoint(ipt,(Float_t)iAn,base);
348 ggain->SetPoint(ipt,(Float_t)iAn,gain);
349 gnoi->SetPoint(ipt,(Float_t)iAn,noise);
353 sprintf(ctit,"Module %d",iMod);
355 TCanvas *c2=new TCanvas("c2",ctit,1200,800);
359 gbase->SetMarkerStyle(7);
361 gbase->GetXaxis()->SetTitle("Anode Number");
362 gbase->GetYaxis()->SetTitle("Baseline after equalization");
364 gnoi->SetMarkerStyle(7);
366 gnoi->GetXaxis()->SetTitle("Anode Number");
367 gnoi->GetYaxis()->SetTitle("Noise");
369 ggain->SetMarkerStyle(7);
371 ggain->GetXaxis()->SetTitle("Anode Number");
372 ggain->GetYaxis()->SetTitle("Gain");
374 gbad->SetMarkerStyle(7);
376 gbad->SetMinimum(-0.1);
377 gbad->GetXaxis()->SetTitle("Anode Number");
378 gbad->GetYaxis()->SetTitle("Anode Status (1=OK, 0=bad)");
381 void ShowCalibrationSDD(Int_t nrun, Int_t nv, Int_t year=2009, Int_t nmod=0){
382 TGrid::Connect("alien:",0,0,"t");
384 sprintf(filnam,"alien:///alice/data/%d/OCDB/ITS/Calib/CalibSDD/Run%d_999999999_v%d_s0.root",year,nrun,nv);
385 printf("Open file: %s\n",filnam);
386 ShowCalibrationSDD(nmod,filnam);