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("hlay3","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("hlay4","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 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;
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;
87 for(Int_t i=0; i<260; i++){
88 cal=(AliITSCalibrationSDD*)calSDD->At(i);
90 printf("Module %d (%d) status = ",i,i+240);
92 AliITSgeomTGeo::GetModuleId(i+240,lay,lad,det);
93 Int_t index=1+(det-1)*2;
98 hlay3->SetBinContent(index,lad,0);
99 hlay3->SetBinContent(index+1,lad,0);
102 hlay4->SetBinContent(index,lad,0);
103 hlay4->SetBinContent(index+1,lad,0);
105 hmodstatus->SetBinContent(i+1,0);
108 hmodstatus->SetBinContent(i+1,1);
110 badAnodeCounterGoodMod3+=cal->GetDeadChannels();
111 if(cal->IsChipBad(0) && cal->IsChipBad(1) && cal->IsChipBad(2) && cal->IsChipBad(3)){
112 hlay3->SetBinContent(index,lad,0);
114 hlay3->SetBinContent(index,lad,1);
116 if(cal->IsChipBad(4) && cal->IsChipBad(5) && cal->IsChipBad(6) && cal->IsChipBad(7)){
117 hlay3->SetBinContent(index+1,lad,0);
119 hlay3->SetBinContent(index+1,lad,1);
122 badAnodeCounterGoodMod4+=cal->GetDeadChannels();
123 if(cal->IsChipBad(0) && cal->IsChipBad(1) && cal->IsChipBad(2) && cal->IsChipBad(3)){
124 hlay4->SetBinContent(index,lad,0);
126 hlay4->SetBinContent(index,lad,1);
128 if(cal->IsChipBad(4) && cal->IsChipBad(5) && cal->IsChipBad(6) && cal->IsChipBad(7)){
129 hlay4->SetBinContent(index+1,lad,0);
131 hlay4->SetBinContent(index+1,lad,1);
135 printf(" Chip Status (0=OK, 1=BAD): ");
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++;
143 printf(" # bad anodes = %d ",cal->GetDeadChannels());
144 if(cal->IsAMAt20MHz()) printf(" 20 MHz sampling");
145 else printf(" 40 MHz sampling");
147 if(i<84) badAnodeCounter3+=cal->GetDeadChannels();
148 else badAnodeCounter4+=cal->GetDeadChannels();
149 hnbadch->SetBinContent(i+1,cal->GetDeadChannels());
150 if(lay==3) hdeadlay3->SetBinContent(det,lad,cal->GetDeadChannels());
151 if(lay==4) hdeadlay4->SetBinContent(det,lad,cal->GetDeadChannels());
152 for(Int_t iAn=0; iAn<512; iAn++){
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++;
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);
162 if(!cal->IsBadChannel(iAn) && !cal->IsChipBad(ic) && !cal->IsBad() ){
170 Int_t totbad3=badModCounter3*512+badChipCounter3*64+badAnodeCounterGoodModAndChip3;
172 Float_t fracbad3=(Float_t)totbad3/(Float_t)tot3;
173 Int_t totbad4=badModCounter4*512+badChipCounter4*64+badAnodeCounterGoodModAndChip4;
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");
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);");
200 TCanvas* clay=new TCanvas("clay","Layer status",900,600);
205 hlay3->DrawCopy("col same");
206 for(Int_t i=0;i<6;i++){
213 for(Int_t i=0;i<14;i++){
221 hlay4->DrawCopy("col");
222 for(Int_t i=0;i<8;i++){
229 for(Int_t i=0;i<22;i++){
237 TCanvas *c0=new TCanvas("c0","Module status",800,800);
241 hmodstatus->GetXaxis()->SetTitle("Module number");
242 hmodstatus->GetYaxis()->SetTitle("Module status (1=OK, 0=BAD)");
245 hnbadch->GetXaxis()->SetTitle("Module number");
246 hnbadch->GetYaxis()->SetTitle("Number of bad anodes");
251 TCanvas *c0b=new TCanvas("c0b","Bad Channels",900,600);
254 hdeadlay3->DrawCopy("colz");
256 hdeadlay3->DrawCopy("colz same");
257 for(Int_t i=0;i<6;i++){
264 for(Int_t i=0;i<14;i++){
272 hdeadlay4->DrawCopy("colz");
274 hdeadlay4->DrawCopy("colz same");
275 for(Int_t i=0;i<8;i++){
282 for(Int_t i=0;i<22;i++){
292 TCanvas *c1=new TCanvas("c1","Anode calibration",800,800);
296 hbase->GetXaxis()->SetTitle("Baseline after equalization");
297 hbase->GetXaxis()->CenterTitle();
300 hnoise->GetXaxis()->SetTitle("Noise");
301 hnoise->GetXaxis()->CenterTitle();
304 hgain->GetXaxis()->SetTitle("Gain");
305 hgain->GetXaxis()->CenterTitle();
308 hchstatus->GetXaxis()->SetTitle("Anode status (0=bad, 1=OK)");
309 hchstatus->GetXaxis()->CenterTitle();
320 // Plot quantities for specified module
322 cal=(AliITSCalibrationSDD*)calSDD->At(iMod);
324 printf("-----------------------------------\n");
325 printf("Module %d status = ",iMod);
326 if(cal->IsBad()) printf("BAD\n");
328 printf(" Chip Status (0=OK, 1=BAD): ");
329 for(Int_t ic=0; ic<8;ic++) printf("%d ",cal->IsChipBad(ic));
331 printf(" Number of bad anodes =%d\n",cal->GetDeadChannels());
332 printf("-----------------------------------\n");
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++){
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);
355 sprintf(ctit,"Module %d",iMod);
357 TCanvas *c2=new TCanvas("c2",ctit,1200,800);
361 gbase->SetMarkerStyle(7);
363 gbase->GetXaxis()->SetTitle("Anode Number");
364 gbase->GetYaxis()->SetTitle("Baseline after equalization");
366 gnoi->SetMarkerStyle(7);
368 gnoi->GetXaxis()->SetTitle("Anode Number");
369 gnoi->GetYaxis()->SetTitle("Noise");
371 ggain->SetMarkerStyle(7);
373 ggain->GetXaxis()->SetTitle("Anode Number");
374 ggain->GetYaxis()->SetTitle("Gain");
376 gbad->SetMarkerStyle(7);
378 gbad->SetMinimum(-0.1);
379 gbad->GetXaxis()->SetTitle("Anode Number");
380 gbad->GetYaxis()->SetTitle("Anode Status (1=OK, 0=bad)");
383 void ShowCalibrationSDD(Int_t nrun, Int_t year=2009, Int_t nmod=0){
384 TGrid::Connect("alien:",0,0,"t");
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");
395 sprintf(filnamalien,"alien://%s",filnam);
397 printf("Open file: %s\n",filnamalien);
398 ShowCalibrationSDD(filnamalien,nmod);
400 gSystem->Exec("rm run.txt");