.so cleanup: no .so ext to GetLibraries()
[u/mrichter/AliRoot.git] / HMPID / HplotDA.C
CommitLineData
20071be0 1#if !defined(__CINT__) || defined(__MAKECINT__)
77e40af5 2
20071be0 3#include <Riostream.h>
4
5#include <TSystem.h>
6#include <TCanvas.h>
77e40af5 7#include <TStyle.h>
20071be0 8#include <TH2F.h>
9#include <TH1F.h>
10#include <TH1I.h>
11
48cbaaf6 12#include "AliHMPIDDigit.h"
20071be0 13#include "AliHMPIDRawStream.h"
77e40af5 14
20071be0 15#endif
77e40af5 16
20071be0 17
18
48cbaaf6 19TH2F hgPedMapMean[14][6];
20TH2F hgPedMapSigma[14][6];
21TH1F hgPedMapMean1D[14][6];
22TH1F hgPedMapSigma1D[14][6];
77e40af5 23TH1F hgPedMapSigma1Db[14][6];
24
20071be0 25
48cbaaf6 26TH1I hgDdlErr[14];
77e40af5 27TH1I *hgtmp,*hgtmp2;
28
20071be0 29
48cbaaf6 30Int_t fgRunNum;
77e40af5 31TFile *fgin[14];
32TFile *fgout=0x0;
33
48cbaaf6 34//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
20071be0 35void Convert(Int_t ddl,Int_t r,Int_t d,Int_t a,Int_t &ch, Int_t &pc, Int_t &px, Int_t &py)
36{
20071be0 37 Int_t a2y[6]={3,2,4,1,5,0};//pady for a given address (for single DILOGIC chip)
38
39 Int_t ch=ddl/2;
48cbaaf6 40 Int_t tmp=(24-r)/8; Int_t pc=(ddl%2)? 5-2*tmp:2*tmp;
08801509 41 Int_t px=dil*8-pad/6-1; //flip according to Paolo (26-3-2008)
48cbaaf6 42 tmp=(ddl%2)?r-1:(24-r); Int_t py=6*(tmp%8)+a2y[a%6];
20071be0 43}
48cbaaf6 44//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
77e40af5 45void PlotPedHisto(Char_t *tag,Int_t runNum, Int_t ddl=0,Int_t row=1,Int_t dil=1,Int_t pad=0)
46{
47
48 if( 0<=ddl && ddl<=13 && 1<=dil && dil<=10 && 1<=row && row<=24 && 0<=pad && pad<=47)
49 {
50
51 fgin[ddl]->cd();
52
53 hgtmp=(TH1I*)(fgin[ddl]->Get(Form("hDDL_%d_Row_%d_Dil_%d_Pad_%d",ddl,row,dil,pad)))->Clone();
54 hgtmp2=(TH1I*)(fgin[ddl]->Get(Form("hDDL_%d_Row_%d_Dil_%d_Pad_%d",ddl,row,dil,pad)))->Clone();
55
56 TCanvas *c1=new TCanvas(Form("hDDL%s_%d_Row_%d_Dil_%d_Pad_%d",tag,ddl,row,dil,pad),Form("hDDL%s_%d_Row_%d_Dil_%d_Pad_%d",tag,ddl,row,dil,pad));
57
58 hgtmp->SetXTitle("ADC");
59 hgtmp->SetYTitle("Entries");
60 hgtmp->Draw();
61 hgtmp->SetAxisRange(0,350);
62 hgtmp->Draw("hist same");
63 hgtmp2->SetFillColor(5);
64 hgtmp2->Draw("hist same");
65 hgtmp->Draw("same");
66
67 c1->SaveAs(Form("hDDL%s_%d_Row_%d_Dil_%d_Pad_%d.eps",tag,ddl,row,dil,pad));
68 c1->SaveAs(Form("hDDL%s_%d_Row_%d_Dil_%d_Pad_%d.gif",tag,ddl,row,dil,pad));
69
70 if(fgout!=0x0)
71 {
72 fgout->cd();
73 hgtmp2->Write();
74 }
75
76 hgtmp->Reset();
77 hgtmp2->Reset();
78
79 }
80 else
81 {
82 if( ddl < 0 || ddl > 13) {Printf("Not a valid DDL, exiting %d ...",ddl); }
83 if( dil < 1 || dil > 10) {Printf("Not a valid DIL, exiting %d ...",dil); }
84 if( row < 1 || row > 24) {Printf("Not a valid ROW, exiting %d ...",row); }
85 if( pad < 0 || pad > 48) {Printf("Not a valid PAD, exiting %d ...",pad); }
86 }
87}
88//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
89void PlotHisto1D(TH1& hin,Char_t* name)
90{
91 TCanvas *c1=new TCanvas("c1","c1");
92 hin.Draw();
93 c1->SaveAs(Form("%s.eps",name));
94 c1->SaveAs(Form("%s.gif",name));
95}
96//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
97void PlotHisto2D(TH2 &hin,Char_t* name,Char_t* opt)
98{
99 TCanvas *c1=new TCanvas("c1","c1");
100 hin.Draw(opt);
101 c1->SaveAs(Form("%s.eps",name));
102 c1->SaveAs(Form("%s.gif",name));
103}
104//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
105void ProcPed(Int_t nDDL,Int_t mode)
20071be0 106{
107
108 if(gSystem->IsFileInIncludePath(Form("./HmpidPedDdl%02i.txt",nDDL)))
109 ifstream infile(Form("./HmpidPedDdl%02i.txt",nDDL));
110 else return;
77e40af5 111 if(mode==1) {
20071be0 112 for(Int_t ni=0;ni<6;ni++)
113 {
48cbaaf6 114 hgPedMapMean[nDDL][ni] = new TH2F(Form("hPedMapMean_DDL%d_PC_%d" ,nDDL,ni), Form("Pedestal: Mean, DDL(0-13): %d PC(0-5): %d;padx;pady" ,nDDL,ni),80,0,80,48,0,48);
115 hgPedMapSigma[nDDL][ni] = new TH2F(Form("hPedMapSigma_DDL%d_PC_%d",nDDL,ni), Form("Pedestal: Sigma, DDL(0-13): %d PC(0-5): %d;padx;pady",nDDL,ni),80,0,80,48,0,48);
116 hgPedMapMean1D[nDDL][ni] = new TH1F(Form("hPedMapMean1D_DDL%d_PC_%d" ,nDDL,ni), Form("Pedestal: Mean, DDL(0-13): %d PC(0-5): %d;pad;Mean" ,nDDL,ni),3841,-0.5,3840.5);
117 hgPedMapSigma1D[nDDL][ni] = new TH1F(Form("hPedMapSigma1D_DDL%d_PC_%d" ,nDDL,ni), Form("Pedestal: Sigma, DDL(0-13): %d PC(0-5): %d;pad;Sigma" ,nDDL,ni),3841,-0.5,3840.5);
77e40af5 118 hgPedMapSigma1Db[nDDL][ni] = new TH1F(Form("hPedMapSigma1Db_DDL%d_PC_%d" ,nDDL,ni), Form("Pedestal: Sigma, DDL(0-13): %d PC(0-5): %d;pad;Sigma" ,nDDL,ni),3841,-0.5,3840.5);
119 hgPedMapSigma1Db[nDDL][ni]->SetMaximum(2.5);
120 }
121 }
20071be0 122 Int_t nSigCut,r,d,a,hard; Float_t mean,sigma;
123 Int_t ch=0,pc=0,px=0,py=0;
124 Int_t cnt=0;
125 Int_t runNumber=-99999;
126 Char_t tName[10];
127 Int_t ldcId;
128 Int_t timeStamp;
48cbaaf6 129 Int_t nEv,nDdlEv;
130 Int_t nBadEv;Float_t nBadEvPer;
20071be0 131 Printf("Start reading DDL: %d ...",nDDL);
77e40af5 132 infile>>tName>>runNumber;fgRunNum=runNumber;
20071be0 133 infile>>tName>>ldcId;
134 infile>>tName>>timeStamp;
135 infile>>tName>>nEv;
48cbaaf6 136 infile>>tName>>nDdlEv;
137 infile>>tName>>nBadEv;
138 infile>>tName>>nBadEvPer;
20071be0 139 infile>>tName>>nSigCut;
48cbaaf6 140
77e40af5 141 Printf("RunNumber: %d, LdcId: %d TimeStamp: %d nEv: %d",fgRunNum,ldcId,timeStamp,nEv);
48cbaaf6 142
20071be0 143 while(!infile.eof()){
144 infile>>dec>>r>>d>>a>>mean>>sigma>>hex>>hard;
77e40af5 145 switch(mode)
146 {
147 case 1:
148 Convert(nDDL,r,d,a,ch,pc,px,py);
149 hgPedMapMean[nDDL][pc].Fill(px,py,mean);
150 hgPedMapSigma[nDDL][pc].Fill(px,py,sigma);
151 hgPedMapMean1D[nDDL][pc].Fill(cnt%3840,mean);
152 hgPedMapSigma1D[nDDL][pc].Fill(cnt%3840,sigma);
153 hgPedMapSigma1Db[nDDL][pc].Fill(cnt%3840,sigma);
154 break;
155 case 2:
156 if(sigma>3 && sigma!=1000) PlotPedHisto("Sigma",runNumber,nDDL,r,d,a);
157 break;
158 case 3:
159 if(sigma==1000) PlotPedHisto("NoEntry",runNumber,nDDL,r,d,a);
160 break;
161
162 }
163
48cbaaf6 164 cnt++;
20071be0 165 }
166 infile.close();
167 Printf("Stop reading DDL: %d ...",nDDL);
48cbaaf6 168
169 /* fill the overall histos */
170
77e40af5 171 if(mode==1)
172 {
173 for(Int_t npc=0;npc<6;npc++)
174 {
175 /* plot pedestal mean values */
176 if(hgPedMapMean[nDDL][npc].GetEntries()!=0) {
177 hgPedMapMean[nDDL][npc].SetStats(0);
178 PlotHisto2D(hgPedMapMean[nDDL][npc],Form("Run%d_PedMeanA_DDL%d_PC%d",fgRunNum,nDDL,npc),"colz");
179 PlotHisto2D(hgPedMapMean[nDDL][npc],Form("Run%d_PedMeanB_DDL%d_PC%d",fgRunNum,nDDL,npc),"surf1");
180 }
181 /* plot pedestal sigma values */
182 if(hgPedMapSigma[nDDL][npc].GetEntries()!=0) {
183 hgPedMapSigma[nDDL][npc].SetStats(0);
184 PlotHisto2D(hgPedMapSigma[nDDL][npc],Form("Run%d_PedSigmaA_DDL%d_PC%d",fgRunNum,nDDL,npc),"colz");
185 PlotHisto2D(hgPedMapSigma[nDDL][npc],Form("Run%d_PedSigmaB_DDL%d_PC%d",fgRunNum,nDDL,npc),"surf1");
186 }
187 /* plot pedestal sigma values */
188 if(hgPedMapSigma[nDDL][npc].GetEntries()!=0) {
189 hgPedMapSigma[nDDL][npc].SetStats(0);
190 hgPedMapSigma[nDDL][npc].SetMaximum(2.5);
191 PlotHisto2D(hgPedMapSigma[nDDL][npc],Form("Run%d_PedSigmaC_DDL%d_PC%d",fgRunNum,nDDL,npc),"colz");
192 PlotHisto2D(hgPedMapSigma[nDDL][npc],Form("Run%d_PedSigmaD_DDL%d_PC%d",fgRunNum,nDDL,npc),"surf1");
193 }
194 /* plot pedestal mean values */
195 if(hgPedMapMean1D[nDDL][npc].GetEntries()!=0) {
196 hgPedMapMean1D[nDDL][npc].SetStats(0);
197 PlotHisto1D(hgPedMapMean1D[nDDL][npc],Form("Run%d_PedMean1DA_DDL%d_PC%d",fgRunNum,nDDL,npc));
198 }
199 /* plot pedestal sigma values */
200 if(hgPedMapSigma1D[nDDL][npc].GetEntries()!=0) {
201 hgPedMapSigma1D[nDDL][npc].SetStats(0);
202 PlotHisto1D(hgPedMapSigma1D[nDDL][npc],Form("Run%d_PedSigma1DA_DDL%d_PC%d",fgRunNum,nDDL,npc));
203 }
204 /* plot pedestal sigma values */
205 if(hgPedMapSigma1Db[nDDL][npc].GetEntries()!=0) {
206 hgPedMapSigma1Db[nDDL][npc].SetStats(0);
207 PlotHisto1D(hgPedMapSigma1D[nDDL][npc],Form("Run%d_PedSigma1DA_DDL%d_PC%d",fgRunNum,nDDL,npc));
208 }
209 }
20071be0 210 }
77e40af5 211
20071be0 212
213}//ProcPed()
214//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
77e40af5 215void ProcErr(Int_t nDDL,Int_t mode)
20071be0 216{
217 if(gSystem->IsFileInIncludePath(Form("./HmpidErrorsDdl%02i.txt",nDDL)))
218 ifstream infile(Form("./HmpidErrorsDdl%02i.txt",nDDL));
219 else return;
77e40af5 220 if(mode==1)
221 {
48cbaaf6 222 hgDdlErr[nDDL] = new TH1I(Form("hPedErr_DDL%d",nDDL),Form("DDL(%d) Decoding Errors",nDDL),AliHMPIDRawStream::kSumErr+1,-0.5,AliHMPIDRawStream::kSumErr+0.5);
20071be0 223 for(Int_t ilabel=0; ilabel< AliHMPIDRawStream::kSumErr; ilabel++) {
48cbaaf6 224 hgDdlErr[nDDL].SetStats(0);
225 hgDdlErr[nDDL].GetXaxis()->CenterLabels(kTRUE);
226 hgDdlErr[nDDL].GetXaxis()->SetBinLabel((ilabel+1),Form("%i %s",ilabel+1,AliHMPIDRawStream::GetErrName(ilabel)));
227 hgDdlErr[nDDL].SetYTitle("Error #");
228 }
229 hgDdlErr[nDDL].SetFillColor(5);
77e40af5 230 }
20071be0 231
232 Int_t runNumber=-99999;
233 Char_t tName[10];
234 Int_t ldcId;
235 Int_t timeStamp;
48cbaaf6 236 Int_t nEv,nDdlEv;
237 Int_t rerr;Int_t nBadEv;Float_t nBadEvPer;
77e40af5 238 Int_t row,dil,pad,nzero;
239 Int_t ch,pc,px,py;
48cbaaf6 240 Printf("Start reading Error File DDL: %d ...",nDDL);
77e40af5 241 infile>>tName>>runNumber;fgRunNum=runNumber;
20071be0 242 infile>>tName>>ldcId;
243 infile>>tName>>timeStamp;
48cbaaf6 244 infile>>tName>>nEv;
245 infile>>tName>>nDdlEv;
246 infile>>tName>>nBadEv;
247 infile>>tName>>nBadEvPer;
20071be0 248 Printf("RunNumber: %d, LdcId: %d TimeStamp: %d nEv: %d",runNumber,ldcId,timeStamp,nEv);
249 for(Int_t ierr=0;ierr<AliHMPIDRawStream::kSumErr;ierr++)
250 {
48cbaaf6 251 infile>>rerr;hgDdlErr[nDDL].SetBinContent(ierr+1,rerr);
20071be0 252 }
253
77e40af5 254 switch(mode)
255 {
256 case 1:
257 TCanvas *cerr = new TCanvas("cped","cped");
258 cerr.cd();
259 hgDdlErr[nDDL]->Draw();
260 cerr->SaveAs(Form("PedError_DDL%d.eps",nDDL));
261 cerr->SaveAs(Form("PedError_DDL%d.gif",nDDL));
20071be0 262
77e40af5 263 break;
264
265 case 2:
266 while(!infile.eof()){
267 infile>>dec>>row>>dil>>pad>>nzero;
268 if( 0<=nDDL && nDDL<=13 && 1<=dil && dil<=10 && 1<=row && row<=24 && 0<=pad && pad<=47)
269 {
270 PlotPedHisto("ZeroQ",runNumber,nDDL,row,dil,pad);
271 }
272 }
273
274 break;
20071be0 275
77e40af5 276 default:
277 break;
278 }
279 infile.close();
20071be0 280}
281//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
77e40af5 282void HplotDA(Int_t runNumber)
48cbaaf6 283{
77e40af5 284 gStyle->SetPalette(1);
285 fgRunNum=runNumber;
48cbaaf6 286
77e40af5 287 Printf("********************************************************************");
288 Printf("********************** HplotDA *************************************");
289 Printf("*** ***");
290 Printf("*** Choose from the following options: ***");
291 Printf("*** ***");
292 Printf("*** 1.) Draw errors for all DDL ***");
293 Printf("*** 2.) Draw pedestals for all DDL ***");
294 Printf("*** 3.) Draw ADC histo for pads with sigma > 3 ***");
295 Printf("*** 4.) Draw ADC histo for pads with zero charge ***");
296 Printf("*** 5.) Draw ADC histo for pads with no valid charge ***");
297 Printf("*** 6.) Run all ***");
298 Printf("*** ***");
299 Printf("********************************************************************");
300 Printf("*** Please select: ");
48cbaaf6 301
77e40af5 302 Int_t set=0;
303 cin>>set;
48cbaaf6 304
305
77e40af5 306 for(Int_t i=0;i<14;i++)
307 {
308 switch(set){
48cbaaf6 309
77e40af5 310 case 1:
311 ProcErr(i,1);
312 break;
313 case 2:
314 ProcPed(i,1);
315 break;
316 case 3:
317 fgin[i]=new TFile(Form("Run%d_DDL%d.root",runNumber,i),"read");
318 ProcPed(i,2);
319 fgin[i]->Close();
320 break;
321 case 4:
322 fgin[i]=new TFile(Form("Run%d_DDL%d.root",runNumber,i),"read");
323 ProcErr(i,2);
324 fgin[i]->Close();
325 break;
326 case 5:
327 fgin[i]=new TFile(Form("Run%d_DDL%d.root",runNumber,i),"read");
328 ProcPed(i,3);
329 fgin[i]->Close();
330 break;
331 case 6:
332 if(i==0) fgout=new TFile(Form("SummaryOfRun%d.root",fgRunNum),"recreate");
48cbaaf6 333
77e40af5 334 ProcErr(i,1);
335 ProcPed(i,1);
336 fgin[i]=new TFile(Form("Run%d_DDL%d.root",runNumber,i),"read");
337 ProcPed(i,2);
338 ProcErr(i,2);
339 ProcPed(i,3);
340 fgin[i]->Close();
341
342 if(i==13) {
343
344 for(Int_t ipc=0;ipc<6;ipc++)
345 {
346 hgPedMapMean[i][ipc].Write();
347 hgPedMapSigma[i][ipc].Write();
348 hgPedMapMean1D[i][ipc].Write();
349 hgPedMapSigma1D[i][ipc].Write();
350 hgPedMapSigma1Db[i][ipc].Write();
351 }
352 hgDdlErr[i].Write();
353 }
354 break;
355 default:
356 Printf("Not a valid selection bye-bye....");
357 break;
358 }
359 }
360
361 if(fgout!=0x0)fgout->Close();
48cbaaf6 362
20071be0 363}
364//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++