]> git.uio.no Git - u/mrichter/AliRoot.git/blame - ITS/ShowCalibrationSDD.C
Add plot with Z-Phi distribution of bad channels in the macro to monitor SDD calibrations
[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>
8#include <TGrid.h>
3615e762 9#include <TLine.h>
40b3a8c7 10#include <TCanvas.h>
11#include <TObjArray.h>
12#include "AliCDBEntry.h"
13#include "AliITSCalibrationSDD.h"
3615e762 14#include "AliITSgeomTGeo.h"
40b3a8c7 15#endif
16
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
22//
23// Origin: F. Prino (prino@to.infn.it)
24
e34418c7 25void MakePalette(){
26 Int_t palette[3]={kGray,2,3};
27 gStyle->SetPalette(3,palette);
28}
29
30void ShowCalibrationSDD(Int_t iMod=0, Char_t *filnam="$ALICE_ROOT/OCDB/ITS/Calib/CalibSDD/Run0_9999999_v0_s0.root"){
40b3a8c7 31
32
33 TFile *f=TFile::Open(filnam);
34 AliCDBEntry *ent=(AliCDBEntry*)f->Get("AliCDBEntry");
296ee458 35 TH2I* hlay3=new TH2I("hlay3","Layer 3",12,-0.5,5.5,14,-0.5,13.5);
3615e762 36 hlay3->GetXaxis()->SetTitle("Detector");
37 hlay3->GetYaxis()->SetTitle("Ladder");
38 hlay3->GetXaxis()->SetTickLength(0);
39 hlay3->GetYaxis()->SetTickLength(0);
40 hlay3->SetStats(0);
41 hlay3->SetMinimum(-1);
296ee458 42 TH2I* hlay4=new TH2I("hlay4","Layer 4",16,-0.5,7.5,22,-0.5,21.5);
3615e762 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");
48 hlay4->SetStats(0);
49 hlay4->SetMinimum(-1);
e34418c7 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.);
3615e762 65
40b3a8c7 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;
b3ba5bd1 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;
40b3a8c7 85 for(Int_t i=0; i<260; i++){
86 cal=(AliITSCalibrationSDD*)calSDD->At(i);
87 if(cal==0) continue;
88 printf("Module %d (%d) status = ",i,i+240);
3615e762 89 Int_t lay,lad,det;
90 AliITSgeomTGeo::GetModuleId(i+240,lay,lad,det);
296ee458 91 Int_t index=1+(det-1)*2;
b3ba5bd1 92 if(cal->IsBad()){
93 printf("BAD\t");
3615e762 94 if(lay==3){
95 badModCounter3++;
296ee458 96 hlay3->SetBinContent(index,lad,0);
97 hlay3->SetBinContent(index+1,lad,0);
3615e762 98 }else if(lay==4){
99 badModCounter4++;
296ee458 100 hlay4->SetBinContent(index,lad,0);
101 hlay4->SetBinContent(index+1,lad,0);
3615e762 102 }
b3ba5bd1 103 hmodstatus->SetBinContent(i+1,0);
3615e762 104 }else{
b3ba5bd1 105 printf("OK\t");
106 hmodstatus->SetBinContent(i+1,1);
3615e762 107 if(lay==3){
108 badAnodeCounterGoodMod3+=cal->GetDeadChannels();
296ee458 109 if(cal->IsChipBad(0) && cal->IsChipBad(1) && cal->IsChipBad(2) && cal->IsChipBad(3)){
110 hlay3->SetBinContent(index,lad,0);
111 }else{
112 hlay3->SetBinContent(index,lad,1);
113 }
114 if(cal->IsChipBad(4) && cal->IsChipBad(5) && cal->IsChipBad(6) && cal->IsChipBad(7)){
115 hlay3->SetBinContent(index+1,lad,0);
116 }else{
117 hlay3->SetBinContent(index+1,lad,1);
118 }
3615e762 119 }else{
120 badAnodeCounterGoodMod4+=cal->GetDeadChannels();
296ee458 121 if(cal->IsChipBad(0) && cal->IsChipBad(1) && cal->IsChipBad(2) && cal->IsChipBad(3)){
122 hlay4->SetBinContent(index,lad,0);
123 }else{
124 hlay4->SetBinContent(index,lad,1);
125 }
126 if(cal->IsChipBad(4) && cal->IsChipBad(5) && cal->IsChipBad(6) && cal->IsChipBad(7)){
127 hlay4->SetBinContent(index+1,lad,0);
128 }else{
129 hlay4->SetBinContent(index+1,lad,1);
130 }
3615e762 131 }
132 }
40b3a8c7 133 printf(" Chip Status (0=OK, 1=BAD): ");
b3ba5bd1 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++;
139 }
140 }
bc031ee2 141 printf(" # bad anodes = %d ",cal->GetDeadChannels());
40b3a8c7 142 if(cal->IsAMAt20MHz()) printf(" 20 MHz sampling");
143 else printf(" 40 MHz sampling");
144 printf("\n");
b3ba5bd1 145 if(i<84) badAnodeCounter3+=cal->GetDeadChannels();
146 else badAnodeCounter4+=cal->GetDeadChannels();
40b3a8c7 147 hnbadch->SetBinContent(i+1,cal->GetDeadChannels());
e34418c7 148 if(lay==3) hdeadlay3->SetBinContent(det,lad,cal->GetDeadChannels());
149 if(lay==4) hdeadlay4->SetBinContent(det,lad,cal->GetDeadChannels());
40b3a8c7 150 for(Int_t iAn=0; iAn<512; iAn++){
b3ba5bd1 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++;
155 }
40b3a8c7 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);
266a4b47 160 if(!cal->IsBadChannel(iAn) && !cal->IsChipBad(ic) && !cal->IsBad() ){
40b3a8c7 161 hbase->Fill(base);
162 hchstatus->Fill(1);
163 hnoise->Fill(noise);
164 hgain->Fill(gain);
165 }
166 }
167 }
b3ba5bd1 168 Int_t totbad3=badModCounter3*512+badChipCounter3*64+badAnodeCounterGoodModAndChip3;
169 Int_t tot3=6*14*512;
170 Float_t fracbad3=(Float_t)totbad3/(Float_t)tot3;
171 Int_t totbad4=badModCounter4*512+badChipCounter4*64+badAnodeCounterGoodModAndChip4;
172 Int_t tot4=8*22*512;
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");
192
193
e34418c7 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);");
197
198 TCanvas* clay=new TCanvas("clay","Layer status",900,600);
199 clay->Divide(2,1);
200 clay->cd(1);
201 hlay3->Draw("col");
202 ex1->Draw();
203 hlay3->DrawCopy("col same");
204 for(Int_t i=0;i<6;i++){
205 lin->SetY1(-0.5);
206 lin->SetY2(13.5);
207 lin->SetX1(i+0.5);
208 lin->SetX2(i+0.5);
209 lin->DrawClone();
210 }
211 for(Int_t i=0;i<14;i++){
212 lin->SetX1(-0.5);
213 lin->SetX2(5.5);
214 lin->SetY1(i+0.5);
215 lin->SetY2(i+0.5);
216 lin->DrawClone();
217 }
218 clay->cd(2);
219 hlay4->DrawCopy("col");
220 for(Int_t i=0;i<8;i++){
221 lin->SetY1(-0.5);
222 lin->SetY2(21.5);
223 lin->SetX1(i+0.5);
224 lin->SetX2(i+0.5);
225 lin->DrawClone();
226 }
227 for(Int_t i=0;i<22;i++){
228 lin->SetX1(-0.5);
229 lin->SetX2(7.5);
230 lin->SetY1(i+0.5);
231 lin->SetY2(i+0.5);
232 lin->DrawClone();
233 }
234
40b3a8c7 235 TCanvas *c0=new TCanvas("c0","Module status",800,800);
236 c0->Divide(1,2);
237 c0->cd(1);
238 hmodstatus->Draw();
239 hmodstatus->GetXaxis()->SetTitle("Module number");
240 hmodstatus->GetYaxis()->SetTitle("Module status (1=OK, 0=BAD)");
241 c0->cd(2);
242 hnbadch->Draw();
e34418c7 243 hnbadch->GetXaxis()->SetTitle("Module number");
40b3a8c7 244 hnbadch->GetYaxis()->SetTitle("Number of bad anodes");
245
e34418c7 246
247
248
249 TCanvas *c0b=new TCanvas("c0b","Bad Channels",900,600);
250 c0b->Divide(2,1);
251 c0b->cd(1);
252 hdeadlay3->DrawCopy("colz");
253 ex2->Draw();
254 hdeadlay3->DrawCopy("colz same");
3615e762 255 for(Int_t i=0;i<6;i++){
256 lin->SetY1(-0.5);
257 lin->SetY2(13.5);
258 lin->SetX1(i+0.5);
259 lin->SetX2(i+0.5);
260 lin->DrawClone();
261 }
262 for(Int_t i=0;i<14;i++){
263 lin->SetX1(-0.5);
264 lin->SetX2(5.5);
265 lin->SetY1(i+0.5);
266 lin->SetY2(i+0.5);
267 lin->DrawClone();
268 }
e34418c7 269 c0b->cd(2);
270 hdeadlay4->DrawCopy("colz");
271 ex2->Draw();
272 hdeadlay4->DrawCopy("colz same");
3615e762 273 for(Int_t i=0;i<8;i++){
274 lin->SetY1(-0.5);
275 lin->SetY2(21.5);
276 lin->SetX1(i+0.5);
277 lin->SetX2(i+0.5);
278 lin->DrawClone();
279 }
280 for(Int_t i=0;i<22;i++){
281 lin->SetX1(-0.5);
282 lin->SetX2(7.5);
283 lin->SetY1(i+0.5);
284 lin->SetY2(i+0.5);
285 lin->DrawClone();
286 }
287
288
e34418c7 289
290 TCanvas *c1=new TCanvas("c1","Anode calibration",800,800);
291 c1->Divide(2,2);
292 c1->cd(1);
293 hbase->Draw();
294 hbase->GetXaxis()->SetTitle("Baseline after equalization");
295 hbase->GetXaxis()->CenterTitle();
296 c1->cd(2);
297 hnoise->Draw();
298 hnoise->GetXaxis()->SetTitle("Noise");
299 hnoise->GetXaxis()->CenterTitle();
300 c1->cd(3);
301 hgain->Draw();
302 hgain->GetXaxis()->SetTitle("Gain");
303 hgain->GetXaxis()->CenterTitle();
304 c1->cd(4);
305 hchstatus->Draw();
306 hchstatus->GetXaxis()->SetTitle("Anode status (0=bad, 1=OK)");
307 hchstatus->GetXaxis()->CenterTitle();
308
309
310
311
312
313
314
315
40b3a8c7 316
b3ba5bd1 317
318 // Plot quantities for specified module
319
40b3a8c7 320 cal=(AliITSCalibrationSDD*)calSDD->At(iMod);
321 if(cal==0) return;
322 printf("-----------------------------------\n");
323 printf("Module %d status = ",iMod);
324 if(cal->IsBad()) printf("BAD\n");
325 else printf("OK\n");
326 printf(" Chip Status (0=OK, 1=BAD): ");
327 for(Int_t ic=0; ic<8;ic++) printf("%d ",cal->IsChipBad(ic));
328 printf("\n");
b3ba5bd1 329 printf(" Number of bad anodes =%d\n",cal->GetDeadChannels());
40b3a8c7 330 printf("-----------------------------------\n");
331 Int_t ipt=0;
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++){
341 Float_t bad=1;
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);
350 ipt++;
351 }
352 Char_t ctit[100];
353 sprintf(ctit,"Module %d",iMod);
354
355 TCanvas *c2=new TCanvas("c2",ctit,1200,800);
356 c2->Divide(2,2);
357
358 c2->cd(1);
359 gbase->SetMarkerStyle(7);
360 gbase->Draw("AP");
361 gbase->GetXaxis()->SetTitle("Anode Number");
362 gbase->GetYaxis()->SetTitle("Baseline after equalization");
363 c2->cd(2);
364 gnoi->SetMarkerStyle(7);
365 gnoi->Draw("AP");
366 gnoi->GetXaxis()->SetTitle("Anode Number");
367 gnoi->GetYaxis()->SetTitle("Noise");
368 c2->cd(3);
369 ggain->SetMarkerStyle(7);
370 ggain->Draw("AP");
371 ggain->GetXaxis()->SetTitle("Anode Number");
372 ggain->GetYaxis()->SetTitle("Gain");
373 c2->cd(4);
374 gbad->SetMarkerStyle(7);
375 gbad->Draw("AP");
376 gbad->SetMinimum(-0.1);
377 gbad->GetXaxis()->SetTitle("Anode Number");
378 gbad->GetYaxis()->SetTitle("Anode Status (1=OK, 0=bad)");
379}
380
266a4b47 381void ShowCalibrationSDD(Int_t nrun, Int_t nv, Int_t year=2009, Int_t nmod=0){
40b3a8c7 382 TGrid::Connect("alien:",0,0,"t");
383 Char_t filnam[200];
266a4b47 384 sprintf(filnam,"alien:///alice/data/%d/OCDB/ITS/Calib/CalibSDD/Run%d_999999999_v%d_s0.root",year,nrun,nv);
40b3a8c7 385 printf("Open file: %s\n",filnam);
b3ba5bd1 386 ShowCalibrationSDD(nmod,filnam);
40b3a8c7 387}