]> git.uio.no Git - u/mrichter/AliRoot.git/blame - ITS/macrosSDD/PlotCalibSDDVsTime.C
Update master to aliroot
[u/mrichter/AliRoot.git] / ITS / macrosSDD / PlotCalibSDDVsTime.C
CommitLineData
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
a26920b9 24void PlotCalibSDDVsTime(Int_t year=2012, Int_t firstRun=172600,
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
1c13a3a0 87 if(year==2011 && nrun==156856) continue;
8d024204 88 if(nrun<firstRun) continue;
89 if(nrun>lastRun) continue;
90 sprintf(filnamalien,"alien://%s",filnam);
91 printf("Open file: %s\n",filnam);
92 TFile *f= TFile::Open(filnamalien);
93 AliCDBEntry *ent=(AliCDBEntry*)f->Get("AliCDBEntry");
94 TObjArray *calSDD = (TObjArray *)ent->GetObject();
eefdc0ab 95 printf("Run %d Entries in array=%d \n",nrun,calSDD->GetEntriesFast());
8d024204 96
97
98 AliITSCalibrationSDD *cal;
99 for(Int_t iMod=0; iMod<260;iMod++){
92d11caa 100 if(selectedMod>=240 && (iMod+240)!=selectedMod) continue;
8d024204 101 cal=(AliITSCalibrationSDD*)calSDD->At(iMod);
102 if(cal==0) continue;
103 for(Int_t iAn=0; iAn<512; iAn++){
104 Int_t ic=cal->GetChip(iAn);
105 Float_t base=cal->GetBaseline(iAn);
106 Float_t noise=cal->GetNoiseAfterElectronics(iAn);
107 Float_t gain=cal->GetChannelGain(iAn);
3afb1a42 108 if(cal->IsBadChannel(iAn)){
109 hchstatus->Fill(0);
110 if(iMod<84) hchstatus3->Fill(0);
111 else hchstatus4->Fill(0);
112 }
8d024204 113 if(!cal->IsBadChannel(iAn) && !cal->IsChipBad(ic) && !cal->IsBad() ){
114 hbase->Fill(base);
115 hchstatus->Fill(1);
3afb1a42 116 if(iMod<84) hchstatus3->Fill(1);
117 else hchstatus4->Fill(1);
8d024204 118 hnoise->Fill(noise);
119 hgain->Fill(gain);
120 }
121 }
122 }
eefdc0ab 123 printf("Run %d <Base> = %f <Noise> =%f Entries = %d\n",nrun,hbase->GetMean(),hnoise->GetMean(),(Int_t)hbase->GetEntries());
92d11caa 124 if(selectedMod==-1 && (Int_t)hbase->GetEntries()==0) continue;
8d024204 125 gbasevstim->SetPoint(iPoint,(Double_t)nrun,hbase->GetMean());
126 gbasevstim->SetPointError(iPoint,0.,hbase->GetRMS());
127 gnoisevstim->SetPoint(iPoint,(Double_t)nrun,hnoise->GetMean());
128 gnoisevstim->SetPointError(iPoint,0.,hnoise->GetRMS());
129 ggainvstim->SetPoint(iPoint,(Double_t)nrun,hgain->GetMean());
130 ggainvstim->SetPointError(iPoint,0.,hgain->GetRMS());
131 gstatvstim->SetPoint(iPoint,(Double_t)nrun,hchstatus->GetBinContent(2));
92d11caa 132 Float_t normMod=260.;
133 if(selectedMod!=-1) normMod=1.;
134 gfracvstim->SetPoint(iPoint,(Double_t)nrun,hchstatus->GetBinContent(2)/normMod/512.);
3afb1a42 135 gfrac3vstim->SetPoint(iPoint,(Double_t)nrun,hchstatus3->GetBinContent(2)/84./512.);
136 gfrac4vstim->SetPoint(iPoint,(Double_t)nrun,hchstatus4->GetBinContent(2)/176./512.);
8d024204 137 iPoint++;
138 f->Close();
139 }
140
eefdc0ab 141 TFile *ofil=new TFile(Form("Calib%dVsTime.root",year),"recreate");
8d024204 142 gbasevstim->Write();
143 gnoisevstim->Write();
144 ggainvstim->Write();
145 gstatvstim->Write();
146 ofil->Close();
147
148 TCanvas* cbase=new TCanvas("cbase","Baselines");
149 gbasevstim->SetFillColor(kOrange-2);
150 gbasevstim->SetMarkerStyle(20);
151 gbasevstim->Draw("AP3");
152 gbasevstim->Draw("PLXSAME");
153 gbasevstim->SetMinimum(0.);
154 gbasevstim->SetMaximum(70.);
155 gbasevstim->GetXaxis()->SetTitle("Run number");
156 gbasevstim->GetYaxis()->SetTitle("<Baseline> (ADC counts)");
3afb1a42 157 cbase->SaveAs(Form("BaseRun%d.gif",year));
8d024204 158
159 TCanvas* cnoise=new TCanvas("cnoise","Noise");
160 gnoisevstim->SetFillColor(kOrange-2);
161 gnoisevstim->SetMarkerStyle(20);
162 gnoisevstim->Draw("AP3");
163 gnoisevstim->Draw("PLXSAME");
164 gnoisevstim->SetMinimum(0.);
165 gnoisevstim->SetMaximum(4.);
166 gnoisevstim->GetXaxis()->SetTitle("Run number");
167 gnoisevstim->GetYaxis()->SetTitle("<Noise> (ADC counts)");
3afb1a42 168 cnoise->SaveAs(Form("NoiseRun%d.gif",year));
8d024204 169
170 TCanvas* cgain=new TCanvas("cgain","Gain");
171 ggainvstim->SetFillColor(kOrange-2);
172 ggainvstim->SetMarkerStyle(20);
173 ggainvstim->Draw("AP3");
174 ggainvstim->Draw("PLXSAME");
175 ggainvstim->SetMinimum(0.);
176 ggainvstim->SetMaximum(4.);
177 ggainvstim->GetXaxis()->SetTitle("Run number");
178 ggainvstim->GetYaxis()->SetTitle("<Gain> (ADC/DAC)");
3afb1a42 179 cgain->SaveAs(Form("GainRun%d.gif",year));
8d024204 180
3afb1a42 181 TCanvas* cstatus=new TCanvas("cstatus","Good channels");
8d024204 182 gstatvstim->SetFillColor(kOrange-2);
183 gstatvstim->SetMarkerStyle(20);
184 gstatvstim->Draw("AP3");
185 gstatvstim->Draw("PLXSAME");
92d11caa 186 if(selectedMod==-1){
187 gstatvstim->SetMinimum(100000.);
188 gstatvstim->SetMaximum(133000.);
189 }else{
190 gstatvstim->SetMinimum(0.);
191 gstatvstim->SetMaximum(512.);
192 }
8d024204 193 gstatvstim->GetXaxis()->SetTitle("Run number");
92d11caa 194 if(selectedMod==-1){
195 gstatvstim->GetYaxis()->SetTitle("Number of good anodes in acquisition");
196 }else{
197 gstatvstim->GetYaxis()->SetTitle(Form("Number of good anodes in od %d",selectedMod));
198 }
3afb1a42 199 cstatus->SaveAs(Form("GoodAnodesRun%d.gif",year));
200
201 TCanvas* cfrac=new TCanvas("cfrac","Fraction of Good");
202 gfracvstim->SetMarkerStyle(20);
203 gfrac3vstim->SetMarkerStyle(22);
204 gfrac3vstim->SetMarkerColor(2);
205 gfrac3vstim->SetLineColor(2);
206 gfrac4vstim->SetMarkerStyle(23);
207 gfrac4vstim->SetMarkerColor(4);
208 gfrac4vstim->SetLineColor(4);
209 gfracvstim->Draw("APL");
3afb1a42 210 gfracvstim->SetMinimum(0.7);
211 gfracvstim->SetMaximum(1.05);
212 gfracvstim->GetXaxis()->SetTitle("Run number");
92d11caa 213 if(selectedMod==-1){
214 gfracvstim->GetYaxis()->SetTitle("Fraction of good anodes in acquisition");
215 gfrac3vstim->Draw("PLSAME");
216 gfrac4vstim->Draw("PLSAME");
217
218 TLegend* leg=new TLegend(0.2,0.15,0.45,0.35);
219 leg->SetFillColor(0);
220 TLegendEntry* entr=leg->AddEntry(gfrac3vstim,"Layer 3","P");
221 entr->SetTextColor(2);
222 entr=leg->AddEntry(gfrac4vstim,"Layer 4","P");
223 entr->SetTextColor(4);
224 entr=leg->AddEntry(gfracvstim,"All","P");
225 entr->SetTextColor(1);
226 leg->Draw();
227 }else{
228 gfracvstim->GetYaxis()->SetTitle(Form("Fraction of good anodes in mod %d",selectedMod));
229 }
3afb1a42 230 cfrac->SaveAs(Form("FractionGoodRun%d.gif",year));
8d024204 231
232}