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