]>
Commit | Line | Data |
---|---|---|
8d024204 | 1 | #if !defined(__CINT__) || defined(__MAKECINT__) |
2 | #include <TFile.h> | |
3 | #include <TH1F.h> | |
4 | #include <TGraph.h> | |
5 | #include <TGraphErrors.h> | |
6 | #include <TStyle.h> | |
7 | #include <TGrid.h> | |
8 | #include <TCanvas.h> | |
9 | #include <TSystem.h> | |
10 | #include <TLatex.h> | |
3afb1a42 | 11 | #include <TLegend.h> |
12 | #include <TLegendEntry.h> | |
8d024204 | 13 | #include <TObjArray.h> |
14 | #include "AliCDBEntry.h" | |
15 | #include "AliITSCalibrationSDD.h" | |
16 | #endif | |
17 | ||
e8eba358 | 18 | /* $Id: PlotCalibSDDVsTime.C 41568 2010-06-03 09:08:39Z prino $ */ |
8d024204 | 19 | |
20 | // Macro to plot the calibration parameters from the OCDB files | |
21 | // created from PEDESTAL and PULSER runs vs. Time | |
22 | // Origin: F. Prino (prino@to.infn.it) | |
23 | ||
4d8feb56 | 24 | void PlotCalibSDDVsTime(Int_t year=2011, Int_t firstRun=142600, |
92d11caa | 25 | Int_t lastRun=999999999, |
26 | Int_t selectedMod=-1){ | |
8d024204 | 27 | |
28 | gStyle->SetOptTitle(0); | |
29 | gStyle->SetOptStat(0); | |
30 | gStyle->SetPadLeftMargin(0.14); | |
31 | gStyle->SetTitleOffset(1.4,"Y"); | |
32 | ||
33 | ||
34 | TGrid::Connect("alien:",0,0,"t"); | |
eefdc0ab | 35 | gSystem->Exec(Form("gbbox find \"/alice/data/%d/OCDB/ITS/Calib/CalibSDD\" \"Run*.root\" > runCalibAlien.txt",year)); |
8d024204 | 36 | FILE* listruns=fopen("runCalibAlien.txt","r"); |
37 | ||
38 | TH1F* hbase=new TH1F("hbase","",60,0.5,120.5); | |
39 | TH1F* hnoise=new TH1F("hnoise","",100,0.,7.); | |
40 | TH1F* hgain=new TH1F("hgain","",100,0.,4.); | |
41 | TH1F* hchstatus=new TH1F("hchstatus","",2,-0.5,1.5); | |
3afb1a42 | 42 | TH1F* hchstatus3=new TH1F("hchstatus3","",2,-0.5,1.5); |
43 | TH1F* hchstatus4=new TH1F("hchstatus4","",2,-0.5,1.5); | |
8d024204 | 44 | TGraphErrors* gbasevstim=new TGraphErrors(0); |
45 | TGraphErrors* gnoisevstim=new TGraphErrors(0); | |
46 | TGraphErrors* ggainvstim=new TGraphErrors(0); | |
47 | TGraphErrors* gstatvstim=new TGraphErrors(0); | |
3afb1a42 | 48 | TGraphErrors* gfracvstim=new TGraphErrors(0); |
49 | TGraphErrors* gfrac3vstim=new TGraphErrors(0); | |
50 | TGraphErrors* gfrac4vstim=new TGraphErrors(0); | |
8d024204 | 51 | gbasevstim->SetName("gbasevstim"); |
52 | gnoisevstim->SetName("gnoisevstim"); | |
53 | ggainvstim->SetName("ggainvstim"); | |
54 | gstatvstim->SetName("gstatvstim"); | |
3afb1a42 | 55 | gfracvstim->SetName("gfracvstim"); |
56 | gfrac3vstim->SetName("gfrac3vstim"); | |
57 | gfrac4vstim->SetName("gfrac4vstim"); | |
8d024204 | 58 | gbasevstim->SetTitle("Baseline vs. run"); |
59 | gnoisevstim->SetTitle("Noise vs. run"); | |
60 | ggainvstim->SetTitle("Gain vs. run"); | |
61 | gstatvstim->SetTitle("Good Anodes vs. run"); | |
3afb1a42 | 62 | gfracvstim->SetTitle("Fraction of Good Anodes vs. run"); |
63 | gfrac3vstim->SetTitle("Fraction of Good Anodes vs. run"); | |
64 | gfrac4vstim->SetTitle("Fraction of Good Anodes vs. run"); | |
8d024204 | 65 | |
66 | ||
67 | Char_t filnam[200],filnamalien[200]; | |
68 | Int_t iPoint=0; | |
9c3758ab | 69 | Int_t nrun,nrun2,nv,ns; |
8d024204 | 70 | |
71 | while(!feof(listruns)){ | |
72 | hbase->Reset(); | |
73 | hnoise->Reset(); | |
74 | hgain->Reset(); | |
75 | hchstatus->Reset(); | |
3afb1a42 | 76 | hchstatus3->Reset(); |
77 | hchstatus4->Reset(); | |
8d024204 | 78 | fscanf(listruns,"%s\n",filnam); |
eefdc0ab | 79 | Char_t directory[100]; |
80 | sprintf(directory,"/alice/data/%d",year); | |
81 | if(!strstr(filnam,directory)) continue; | |
82 | sscanf(filnam,"/alice/data/%d/OCDB/ITS/Calib/CalibSDD/Run%d_%d_v%d_s%d.root",&year,&nrun,&nrun2,&nv,&ns); | |
83 | if(year==2009 && (nrun<85639 && nrun2> 85639)) continue; // protection for files with swapped ladders 4-5 of layer 3 | |
84 | if(year==2009 && (nrun>100000 && nv< 184)) continue; // protection for files with swapped ladder 0-1 of layer 4 | |
f6b78d45 | 85 | if(year==2010 && (nrun>=114603 && nv< 98)) continue; // protection for files without treatment of masked hybrids |
76662cc7 | 86 | if(year==2011 && (nrun>=145349 && nrun<=148978) && nrun2> 148978) continue; // protection for files affected by problem in second DA |
8d024204 | 87 | if(nrun<firstRun) continue; |
88 | if(nrun>lastRun) continue; | |
89 | sprintf(filnamalien,"alien://%s",filnam); | |
90 | printf("Open file: %s\n",filnam); | |
91 | TFile *f= TFile::Open(filnamalien); | |
92 | AliCDBEntry *ent=(AliCDBEntry*)f->Get("AliCDBEntry"); | |
93 | TObjArray *calSDD = (TObjArray *)ent->GetObject(); | |
eefdc0ab | 94 | printf("Run %d Entries in array=%d \n",nrun,calSDD->GetEntriesFast()); |
8d024204 | 95 | |
96 | ||
97 | AliITSCalibrationSDD *cal; | |
98 | for(Int_t iMod=0; iMod<260;iMod++){ | |
92d11caa | 99 | if(selectedMod>=240 && (iMod+240)!=selectedMod) continue; |
8d024204 | 100 | cal=(AliITSCalibrationSDD*)calSDD->At(iMod); |
101 | if(cal==0) continue; | |
102 | for(Int_t iAn=0; iAn<512; iAn++){ | |
103 | Int_t ic=cal->GetChip(iAn); | |
104 | Float_t base=cal->GetBaseline(iAn); | |
105 | Float_t noise=cal->GetNoiseAfterElectronics(iAn); | |
106 | Float_t gain=cal->GetChannelGain(iAn); | |
3afb1a42 | 107 | if(cal->IsBadChannel(iAn)){ |
108 | hchstatus->Fill(0); | |
109 | if(iMod<84) hchstatus3->Fill(0); | |
110 | else hchstatus4->Fill(0); | |
111 | } | |
8d024204 | 112 | if(!cal->IsBadChannel(iAn) && !cal->IsChipBad(ic) && !cal->IsBad() ){ |
113 | hbase->Fill(base); | |
114 | hchstatus->Fill(1); | |
3afb1a42 | 115 | if(iMod<84) hchstatus3->Fill(1); |
116 | else hchstatus4->Fill(1); | |
8d024204 | 117 | hnoise->Fill(noise); |
118 | hgain->Fill(gain); | |
119 | } | |
120 | } | |
121 | } | |
eefdc0ab | 122 | printf("Run %d <Base> = %f <Noise> =%f Entries = %d\n",nrun,hbase->GetMean(),hnoise->GetMean(),(Int_t)hbase->GetEntries()); |
92d11caa | 123 | if(selectedMod==-1 && (Int_t)hbase->GetEntries()==0) continue; |
8d024204 | 124 | gbasevstim->SetPoint(iPoint,(Double_t)nrun,hbase->GetMean()); |
125 | gbasevstim->SetPointError(iPoint,0.,hbase->GetRMS()); | |
126 | gnoisevstim->SetPoint(iPoint,(Double_t)nrun,hnoise->GetMean()); | |
127 | gnoisevstim->SetPointError(iPoint,0.,hnoise->GetRMS()); | |
128 | ggainvstim->SetPoint(iPoint,(Double_t)nrun,hgain->GetMean()); | |
129 | ggainvstim->SetPointError(iPoint,0.,hgain->GetRMS()); | |
130 | gstatvstim->SetPoint(iPoint,(Double_t)nrun,hchstatus->GetBinContent(2)); | |
92d11caa | 131 | Float_t normMod=260.; |
132 | if(selectedMod!=-1) normMod=1.; | |
133 | gfracvstim->SetPoint(iPoint,(Double_t)nrun,hchstatus->GetBinContent(2)/normMod/512.); | |
3afb1a42 | 134 | gfrac3vstim->SetPoint(iPoint,(Double_t)nrun,hchstatus3->GetBinContent(2)/84./512.); |
135 | gfrac4vstim->SetPoint(iPoint,(Double_t)nrun,hchstatus4->GetBinContent(2)/176./512.); | |
8d024204 | 136 | iPoint++; |
137 | f->Close(); | |
138 | } | |
139 | ||
eefdc0ab | 140 | TFile *ofil=new TFile(Form("Calib%dVsTime.root",year),"recreate"); |
8d024204 | 141 | gbasevstim->Write(); |
142 | gnoisevstim->Write(); | |
143 | ggainvstim->Write(); | |
144 | gstatvstim->Write(); | |
145 | ofil->Close(); | |
146 | ||
147 | TCanvas* cbase=new TCanvas("cbase","Baselines"); | |
148 | gbasevstim->SetFillColor(kOrange-2); | |
149 | gbasevstim->SetMarkerStyle(20); | |
150 | gbasevstim->Draw("AP3"); | |
151 | gbasevstim->Draw("PLXSAME"); | |
152 | gbasevstim->SetMinimum(0.); | |
153 | gbasevstim->SetMaximum(70.); | |
154 | gbasevstim->GetXaxis()->SetTitle("Run number"); | |
155 | gbasevstim->GetYaxis()->SetTitle("<Baseline> (ADC counts)"); | |
3afb1a42 | 156 | cbase->SaveAs(Form("BaseRun%d.gif",year)); |
8d024204 | 157 | |
158 | TCanvas* cnoise=new TCanvas("cnoise","Noise"); | |
159 | gnoisevstim->SetFillColor(kOrange-2); | |
160 | gnoisevstim->SetMarkerStyle(20); | |
161 | gnoisevstim->Draw("AP3"); | |
162 | gnoisevstim->Draw("PLXSAME"); | |
163 | gnoisevstim->SetMinimum(0.); | |
164 | gnoisevstim->SetMaximum(4.); | |
165 | gnoisevstim->GetXaxis()->SetTitle("Run number"); | |
166 | gnoisevstim->GetYaxis()->SetTitle("<Noise> (ADC counts)"); | |
3afb1a42 | 167 | cnoise->SaveAs(Form("NoiseRun%d.gif",year)); |
8d024204 | 168 | |
169 | TCanvas* cgain=new TCanvas("cgain","Gain"); | |
170 | ggainvstim->SetFillColor(kOrange-2); | |
171 | ggainvstim->SetMarkerStyle(20); | |
172 | ggainvstim->Draw("AP3"); | |
173 | ggainvstim->Draw("PLXSAME"); | |
174 | ggainvstim->SetMinimum(0.); | |
175 | ggainvstim->SetMaximum(4.); | |
176 | ggainvstim->GetXaxis()->SetTitle("Run number"); | |
177 | ggainvstim->GetYaxis()->SetTitle("<Gain> (ADC/DAC)"); | |
3afb1a42 | 178 | cgain->SaveAs(Form("GainRun%d.gif",year)); |
8d024204 | 179 | |
3afb1a42 | 180 | TCanvas* cstatus=new TCanvas("cstatus","Good channels"); |
8d024204 | 181 | gstatvstim->SetFillColor(kOrange-2); |
182 | gstatvstim->SetMarkerStyle(20); | |
183 | gstatvstim->Draw("AP3"); | |
184 | gstatvstim->Draw("PLXSAME"); | |
92d11caa | 185 | if(selectedMod==-1){ |
186 | gstatvstim->SetMinimum(100000.); | |
187 | gstatvstim->SetMaximum(133000.); | |
188 | }else{ | |
189 | gstatvstim->SetMinimum(0.); | |
190 | gstatvstim->SetMaximum(512.); | |
191 | } | |
8d024204 | 192 | gstatvstim->GetXaxis()->SetTitle("Run number"); |
92d11caa | 193 | if(selectedMod==-1){ |
194 | gstatvstim->GetYaxis()->SetTitle("Number of good anodes in acquisition"); | |
195 | }else{ | |
196 | gstatvstim->GetYaxis()->SetTitle(Form("Number of good anodes in od %d",selectedMod)); | |
197 | } | |
3afb1a42 | 198 | cstatus->SaveAs(Form("GoodAnodesRun%d.gif",year)); |
199 | ||
200 | TCanvas* cfrac=new TCanvas("cfrac","Fraction of Good"); | |
201 | gfracvstim->SetMarkerStyle(20); | |
202 | gfrac3vstim->SetMarkerStyle(22); | |
203 | gfrac3vstim->SetMarkerColor(2); | |
204 | gfrac3vstim->SetLineColor(2); | |
205 | gfrac4vstim->SetMarkerStyle(23); | |
206 | gfrac4vstim->SetMarkerColor(4); | |
207 | gfrac4vstim->SetLineColor(4); | |
208 | gfracvstim->Draw("APL"); | |
3afb1a42 | 209 | gfracvstim->SetMinimum(0.7); |
210 | gfracvstim->SetMaximum(1.05); | |
211 | gfracvstim->GetXaxis()->SetTitle("Run number"); | |
92d11caa | 212 | if(selectedMod==-1){ |
213 | gfracvstim->GetYaxis()->SetTitle("Fraction of good anodes in acquisition"); | |
214 | gfrac3vstim->Draw("PLSAME"); | |
215 | gfrac4vstim->Draw("PLSAME"); | |
216 | ||
217 | TLegend* leg=new TLegend(0.2,0.15,0.45,0.35); | |
218 | leg->SetFillColor(0); | |
219 | TLegendEntry* entr=leg->AddEntry(gfrac3vstim,"Layer 3","P"); | |
220 | entr->SetTextColor(2); | |
221 | entr=leg->AddEntry(gfrac4vstim,"Layer 4","P"); | |
222 | entr->SetTextColor(4); | |
223 | entr=leg->AddEntry(gfracvstim,"All","P"); | |
224 | entr->SetTextColor(1); | |
225 | leg->Draw(); | |
226 | }else{ | |
227 | gfracvstim->GetYaxis()->SetTitle(Form("Fraction of good anodes in mod %d",selectedMod)); | |
228 | } | |
3afb1a42 | 229 | cfrac->SaveAs(Form("FractionGoodRun%d.gif",year)); |
8d024204 | 230 | |
231 | } |