1 #if !defined(__CINT__) || defined(__MAKECINT__)
10 #include <TObjArray.h>
11 #include "AliCDBEntry.h"
12 #include "AliITSCalibrationSDD.h"
13 #include "AliITSgeomTGeo.h"
16 // Macro to plot the calibration parameters from the OCDB file
17 // created from PEDESTAL and PULSER runs (OCDB/ITS/Calib/CalibSDD)
18 // Two methods ShowCalibrationSDD:
19 // - the first takes the name of the file to be displayed
20 // - the second builds the alien path+name from run number and file version
22 // Origin: F. Prino (prino@to.infn.it)
24 void ShowCalibrationSDD(Int_t iMod=0, Char_t *filnam="$ALICE_ROOT/ITS/Calib/CalibSDD/Run0_9999999_v0_s0.root"){
27 TFile *f=TFile::Open(filnam);
28 AliCDBEntry *ent=(AliCDBEntry*)f->Get("AliCDBEntry");
29 TH2I* hlay3=new TH2I("hlay3","Layer 3",12,-0.5,5.5,14,-0.5,13.5);
30 hlay3->GetXaxis()->SetTitle("Detector");
31 hlay3->GetYaxis()->SetTitle("Ladder");
32 hlay3->GetXaxis()->SetTickLength(0);
33 hlay3->GetYaxis()->SetTickLength(0);
35 hlay3->SetMinimum(-1);
36 TH2I* hlay4=new TH2I("hlay4","Layer 4",16,-0.5,7.5,22,-0.5,21.5);
37 hlay4->GetXaxis()->SetTitle("Detector");
38 hlay4->GetYaxis()->SetTitle("Ladder");
39 hlay4->GetXaxis()->SetTickLength(0);
40 hlay4->GetYaxis()->SetTickLength(0);
41 hlay4->GetYaxis()->SetTitle("Ladder");
43 hlay4->SetMinimum(-1);
45 TObjArray *calSDD = (TObjArray *)ent->GetObject();
46 printf("Entries in array=%d\n",calSDD->GetEntriesFast());
47 TH1F* hmodstatus=new TH1F("hmodstatus","",260,0.5,260.5);
48 TH1F* hnbadch=new TH1F("hnbadch","",260,0.5,260.5);
49 TH1F* hbase=new TH1F("hbase","",60,0.5,120.5);
50 TH1F* hnoise=new TH1F("hnoise","",100,0.,7.);
51 TH1F* hgain=new TH1F("hgain","",100,0.,4.);
52 TH1F* hchstatus=new TH1F("hchstatus","",2,-0.5,1.5);
53 AliITSCalibrationSDD *cal;
54 Int_t badModCounter3=0;
55 Int_t badModCounter4=0;
56 Int_t badAnodeCounter3=0;
57 Int_t badAnodeCounter4=0;
58 Int_t badAnodeCounterGoodMod3=0;
59 Int_t badAnodeCounterGoodMod4=0;
60 Int_t badAnodeCounterGoodModAndChip3=0;
61 Int_t badAnodeCounterGoodModAndChip4=0;
62 Int_t badChipCounter3=0;
63 Int_t badChipCounter4=0;
64 for(Int_t i=0; i<260; i++){
65 cal=(AliITSCalibrationSDD*)calSDD->At(i);
67 printf("Module %d (%d) status = ",i,i+240);
69 AliITSgeomTGeo::GetModuleId(i+240,lay,lad,det);
70 Int_t index=1+(det-1)*2;
75 hlay3->SetBinContent(index,lad,0);
76 hlay3->SetBinContent(index+1,lad,0);
79 hlay4->SetBinContent(index,lad,0);
80 hlay4->SetBinContent(index+1,lad,0);
82 hmodstatus->SetBinContent(i+1,0);
85 hmodstatus->SetBinContent(i+1,1);
87 badAnodeCounterGoodMod3+=cal->GetDeadChannels();
88 if(cal->IsChipBad(0) && cal->IsChipBad(1) && cal->IsChipBad(2) && cal->IsChipBad(3)){
89 hlay3->SetBinContent(index,lad,0);
91 hlay3->SetBinContent(index,lad,1);
93 if(cal->IsChipBad(4) && cal->IsChipBad(5) && cal->IsChipBad(6) && cal->IsChipBad(7)){
94 hlay3->SetBinContent(index+1,lad,0);
96 hlay3->SetBinContent(index+1,lad,1);
99 badAnodeCounterGoodMod4+=cal->GetDeadChannels();
100 if(cal->IsChipBad(0) && cal->IsChipBad(1) && cal->IsChipBad(2) && cal->IsChipBad(3)){
101 hlay4->SetBinContent(index,lad,0);
103 hlay4->SetBinContent(index,lad,1);
105 if(cal->IsChipBad(4) && cal->IsChipBad(5) && cal->IsChipBad(6) && cal->IsChipBad(7)){
106 hlay4->SetBinContent(index+1,lad,0);
108 hlay4->SetBinContent(index+1,lad,1);
112 printf(" Chip Status (0=OK, 1=BAD): ");
113 for(Int_t ic=0; ic<8;ic++){
114 printf("%d ",cal->IsChipBad(ic));
115 if(cal->IsChipBad(ic) && !cal->IsBad()){
116 if(i<84) badChipCounter3++;
117 else badChipCounter4++;
120 if(cal->IsAMAt20MHz()) printf(" 20 MHz sampling");
121 else printf(" 40 MHz sampling");
123 if(i<84) badAnodeCounter3+=cal->GetDeadChannels();
124 else badAnodeCounter4+=cal->GetDeadChannels();
125 hnbadch->SetBinContent(i+1,cal->GetDeadChannels());
126 for(Int_t iAn=0; iAn<512; iAn++){
127 Int_t ic=cal->GetChip(iAn);
128 if(!cal->IsChipBad(ic) && !cal->IsBad() && cal->IsBadChannel(iAn)){
129 if(i<84) badAnodeCounterGoodModAndChip3++;
130 else badAnodeCounterGoodModAndChip4++;
132 Float_t base=cal->GetBaseline(iAn);
133 Float_t noise=cal->GetNoiseAfterElectronics(iAn);
134 Float_t gain=cal->GetChannelGain(iAn);
135 if(cal->IsBadChannel(iAn)) hchstatus->Fill(0);
136 if(!cal->IsBadChannel(iAn) && !cal->IsChipBad(ic) && !cal->IsBad() ){
144 Int_t totbad3=badModCounter3*512+badChipCounter3*64+badAnodeCounterGoodModAndChip3;
146 Float_t fracbad3=(Float_t)totbad3/(Float_t)tot3;
147 Int_t totbad4=badModCounter4*512+badChipCounter4*64+badAnodeCounterGoodModAndChip4;
149 Float_t fracbad4=(Float_t)totbad4/(Float_t)tot4;
150 Float_t fractot=(Float_t)(totbad3+totbad4)/(Float_t)(tot3+tot4);
151 printf("----------------------Summary----------------------\n");
152 printf("---- Layer 3 ----\n");
153 printf("# of bad modules = %d\n",badModCounter3);
154 printf("# of bad chips in good modules = %d\n",badChipCounter3);
155 printf("# of bad anodes in good modules+chips = %d\n",badAnodeCounterGoodModAndChip3);
156 printf("Fraction of bads (anodes+chips+mod) = %f\n",fracbad3);
157 printf("---- Layer 4 ----\n");
158 printf("# of bad modules = %d\n",badModCounter4);
159 printf("# of bad chips in good modules = %d\n",badChipCounter4);
160 printf("# of bad anodes in good modules+chips = %d\n",badAnodeCounterGoodModAndChip4);
161 printf("Fraction of bads (anodes+chips+mod) = %f\n",fracbad4);
162 printf("---- Total ----\n");
163 printf("# of bad modules = %d\n",badModCounter3+badModCounter4);
164 printf("# of bad chips in good modules = %d\n",badChipCounter3+badChipCounter4);
165 printf("# of bad anodes in good modules+chips = %d\n",badAnodeCounterGoodModAndChip3+badAnodeCounterGoodModAndChip4);
166 printf("Fraction of bads (anodes+chips+mod) = %f\n",fractot);
167 printf("---------------------------------------------------\n");
170 TCanvas *c0=new TCanvas("c0","Module status",800,800);
174 hmodstatus->GetXaxis()->SetTitle("Module number");
175 hmodstatus->GetYaxis()->SetTitle("Module status (1=OK, 0=BAD)");
178 hnbadch->GetXaxis()->SetTitle("Module number");
179 hnbadch->GetYaxis()->SetTitle("Number of bad anodes");
181 TCanvas *c1=new TCanvas("c1","Anode calibration",800,800);
185 hbase->GetXaxis()->SetTitle("Baseline after equalization");
186 hbase->GetXaxis()->CenterTitle();
189 hnoise->GetXaxis()->SetTitle("Noise");
190 hnoise->GetXaxis()->CenterTitle();
193 hgain->GetXaxis()->SetTitle("Gain");
194 hgain->GetXaxis()->CenterTitle();
197 hchstatus->GetXaxis()->SetTitle("Anode status (0=bad, 1=OK)");
198 hchstatus->GetXaxis()->CenterTitle();
199 Int_t palette[3]={kGray,2,3};
200 gStyle->SetPalette(3,palette);
202 TLine* lin=new TLine(0,0,0,23);
203 TCanvas* clay=new TCanvas("clay","Layer status",900,600);
207 for(Int_t i=0;i<6;i++){
214 for(Int_t i=0;i<14;i++){
223 for(Int_t i=0;i<8;i++){
230 for(Int_t i=0;i<22;i++){
241 // Plot quantities for specified module
243 cal=(AliITSCalibrationSDD*)calSDD->At(iMod);
245 printf("-----------------------------------\n");
246 printf("Module %d status = ",iMod);
247 if(cal->IsBad()) printf("BAD\n");
249 printf(" Chip Status (0=OK, 1=BAD): ");
250 for(Int_t ic=0; ic<8;ic++) printf("%d ",cal->IsChipBad(ic));
252 printf(" Number of bad anodes =%d\n",cal->GetDeadChannels());
253 printf("-----------------------------------\n");
255 TGraph *gbad=new TGraph(0);
256 gbad->SetTitle("Bad Channels");
257 TGraph *gbase=new TGraph(0);
258 gbase->SetTitle("Baselines");
259 TGraph *gnoi=new TGraph(0);
260 gnoi->SetTitle("Noise");
261 TGraph *ggain=new TGraph(0);
262 ggain->SetTitle("Gain");
263 for(Int_t iAn=0; iAn<512; iAn++){
265 if(cal->IsBadChannel(iAn)) bad=0;
266 Float_t base=cal->GetBaseline(iAn);
267 Float_t noise=cal->GetNoiseAfterElectronics(iAn);
268 Float_t gain=cal->GetChannelGain(iAn);
269 gbad->SetPoint(ipt,(Float_t)iAn,bad);
270 gbase->SetPoint(ipt,(Float_t)iAn,base);
271 ggain->SetPoint(ipt,(Float_t)iAn,gain);
272 gnoi->SetPoint(ipt,(Float_t)iAn,noise);
276 sprintf(ctit,"Module %d",iMod);
278 TCanvas *c2=new TCanvas("c2",ctit,1200,800);
282 gbase->SetMarkerStyle(7);
284 gbase->GetXaxis()->SetTitle("Anode Number");
285 gbase->GetYaxis()->SetTitle("Baseline after equalization");
287 gnoi->SetMarkerStyle(7);
289 gnoi->GetXaxis()->SetTitle("Anode Number");
290 gnoi->GetYaxis()->SetTitle("Noise");
292 ggain->SetMarkerStyle(7);
294 ggain->GetXaxis()->SetTitle("Anode Number");
295 ggain->GetYaxis()->SetTitle("Gain");
297 gbad->SetMarkerStyle(7);
299 gbad->SetMinimum(-0.1);
300 gbad->GetXaxis()->SetTitle("Anode Number");
301 gbad->GetYaxis()->SetTitle("Anode Status (1=OK, 0=bad)");
304 void ShowCalibrationSDD(Int_t nrun, Int_t nv, Int_t year=2009, Int_t nmod=0){
305 TGrid::Connect("alien:",0,0,"t");
307 sprintf(filnam,"alien:///alice/data/%d/OCDB/ITS/Calib/CalibSDD/Run%d_999999999_v%d_s0.root",year,nrun,nv);
308 printf("Open file: %s\n",filnam);
309 ShowCalibrationSDD(nmod,filnam);