bugfix in filling of NJ and OC histos
[u/mrichter/AliRoot.git] / ITS / macrosSDD / CheckCalibs.C
CommitLineData
fe89227d 1#if !defined(__CINT__) || defined(__MAKECINT__)
2#include <TApplication.h>
3#include <TGClient.h>
4#include <TGButton.h>
5#include <TGFrame.h>
6#include <TGLayout.h>
7#include <TGWindow.h>
8#include <TGLabel.h>
9#include <TGNumberEntry.h>
10#include <TString.h>
11#include <TCanvas.h>
12#include <TStyle.h>
13#include <TPad.h>
14#include <TH1F.h>
15#include <TH2F.h>
16#include <TF1.h>
17#include <TSystem.h>
18#include <TGraph.h>
19#include <TLatex.h>
20#include <TLine.h>
21#include <TROOT.h>
22#endif
23
24// Macro to display the output of SDD calibration runs
25// -> copies the ASCII files with the DA output from the LDC
26// -> plot various histograms and graphs
27// Origin: F. Prino (prino@to.infn.it)
28
29class CheckCalibInterface : public TGMainFrame {
30
31private:
32 TGCompositeFrame *fHor1;
33 TGCompositeFrame *fHor2;
34 TGCompositeFrame *fHor3;
35 TGCompositeFrame *fHor4;
36 TGTextButton *fCopyFiles;
37 TGTextButton *fShowPedest;
38 TGTextButton *fShowPulser;
39 TGTextButton *fShowInject;
40 TGTextButton *fShowOneMod;
41 TGTextButton *fExit;
42 TGGroupFrame *fGframeALL;
43 TGGroupFrame *fGframeSING;
44 TGGroupFrame *fGframe1;
45 TGGroupFrame *fGframe2;
46 TGNumberEntry *fDDL;
47 TGNumberEntry *fChannel;
48 Int_t fNumDDL;
49 Int_t fNumChannel;
50
51public:
52 CheckCalibInterface(const TGWindow *p, UInt_t w, UInt_t h);
53 virtual ~CheckCalibInterface();
54 void DoSetlabel();
55
56 static void CopyFiles();
57 static void ShowPedestal();
58 static void ShowPulser();
59 static void ShowInjector();
60 static void ShowSingleModule(Int_t iddl, Int_t ichan);
61 static void ClearAll();
62
63 ClassDef(CheckCalibInterface, 0)
64};
65
66CheckCalibInterface::CheckCalibInterface(const TGWindow *p, UInt_t w, UInt_t h)
67 : TGMainFrame(p, w, h)
68{
69
70 fHor1 = new TGHorizontalFrame(this);
71 fHor2 = new TGHorizontalFrame(this);
72 fHor3 = new TGHorizontalFrame(this);
73 fHor4 = new TGHorizontalFrame(this);
74
75 TGLayoutHints *lh=new TGLayoutHints(kLHintsTop | kLHintsLeft, 5, 5, 5, 5);
76 TGLayoutHints *lhc=new TGLayoutHints(kLHintsCenterY | kLHintsExpandY, 5, 5, 5, 5);
77 TGLayoutHints *lh1=new TGLayoutHints(kLHintsTop | kLHintsExpandX, 5, 5, 5, 5);
78
79 fCopyFiles = new TGTextButton(fHor1, "&Copy Files", "CheckCalibInterface::CopyFiles()");
80 fHor1->AddFrame(fCopyFiles, lh1);
81
82 fGframeALL = new TGGroupFrame(fHor2,"All Modules",kHorizontalFrame);
83 fShowPedest = new TGTextButton(fGframeALL, "&Show Pedestal","CheckCalibInterface::ShowPedestal()");
84 fShowPulser = new TGTextButton(fGframeALL, "&Show Pulser","CheckCalibInterface::ShowPulser()");
85 fShowInject = new TGTextButton(fGframeALL, "&Show Injector","CheckCalibInterface::ShowInjector()");
86 fGframeALL->AddFrame(fShowPedest, lh1);
87 fGframeALL->AddFrame(fShowPulser, lh1);
88 fGframeALL->AddFrame(fShowInject, lh1);
89 fHor2->AddFrame(fGframeALL, lh1);
90
91 fGframeSING = new TGGroupFrame(fHor3,"Single Module",kHorizontalFrame);
92 fGframe1 = new TGGroupFrame(fGframeSING, "DDL");
93 fDDL = new TGNumberEntry(fGframe1, 0, 2,-1, TGNumberFormat::kNESInteger,
94 TGNumberFormat::kNEANonNegative,
95 TGNumberFormat::kNELLimitMinMax,
96 0, 23);
97 fGframe2 = new TGGroupFrame(fGframeSING, "Channel");
98 fChannel = new TGNumberEntry(fGframe2, 0, 2,-1, TGNumberFormat::kNESInteger,
99 TGNumberFormat::kNEANonNegative,
100 TGNumberFormat::kNELLimitMinMax,
101 0, 11);
102 fGframe1->AddFrame(fDDL,lh);
103 fGframe2->AddFrame(fChannel,lh);
104 fGframeSING->AddFrame(fGframe1,lh);
105 fGframeSING->AddFrame(fGframe2,lh);
106
107 fDDL->Connect("ValueSet(Long_t)", "CheckCalibInterface", this, "DoSetlabel()");
108 (fDDL->GetNumberEntry())->Connect("ReturnPressed()", "CheckCalibInterface", this, "DoSetlabel()");
109
110 fChannel->Connect("ValueSet(Long_t)", "CheckCalibInterface", this, "DoSetlabel()");
111 (fChannel->GetNumberEntry())->Connect("ReturnPressed()", "CheckCalibInterface", this, "DoSetlabel()");
112 fHor3->AddFrame(fGframeSING, lh1);
113
114 fShowOneMod = new TGTextButton(fGframeSING, "&Show Selected Module","CheckCalibInterface::ShowSingleModule(0,0)");
115 fGframeSING->AddFrame(fShowOneMod, lhc);
116
117 fExit = new TGTextButton(fHor4, "&Exit", "gApplication->Terminate(0)");
118 fHor4->AddFrame(fExit, lh1);
119
120 AddFrame(fHor1,lh1);
121 AddFrame(fHor2,lh1);
122 AddFrame(fHor3,lh1);
123 AddFrame(fHor4,lh1);
124
125 SetCleanup(kDeepCleanup);
126 SetWindowName("Main Control");
127 MapSubwindows();
128 Resize(GetDefaultSize());
129 MapWindow();
130}
131
132CheckCalibInterface::~CheckCalibInterface()
133{
134 // Destructor.
135
136 Cleanup();
137}
138
139
140void CheckCalibInterface::CopyFiles(){
141 //
d0853e41 142 // 8 LDCs in Run2 with new (simpler) dirs - M.S. 25 jul 14
fe89227d 143 TString command;
d0853e41 144 TString ldcName[8]={"aldaqpc009","aldaqpc010","aldaqpc011","aldaqpc012",
145 "aldaqpc013","aldaqpc014","aldaqpc015","aldaqpc016"};
fe89227d 146 gSystem->Exec("rm -rf calibFiles");
147 gSystem->Exec("mkdir calibFiles");
d0853e41 148 for(Int_t iLDC=0; iLDC<8; iLDC++){
149 Int_t firstDDL=iLDC*3;
150 Int_t lastDDL=iLDC*3+2;
151 command.Form("scp %s:/dateSite/ldc-SDD-%d/work/SDDbase_step2_LDC.tar calibFiles/.",ldcName[iLDC].Data(),iLDC);
fe89227d 152 gSystem->Exec(command.Data());
d0853e41 153 command.Form("scp %s:/dateSite/ldc-SDD-%d/work/SDDbase_LDC.tar calibFiles/.",ldcName[iLDC].Data(),iLDC);
fe89227d 154 gSystem->Exec(command.Data());
d0853e41 155 command.Form("scp %s:/dateSite/ldc-SDD-%d/work/SDDinj_LDC.tar calibFiles/.",ldcName[iLDC].Data(),iLDC);
fe89227d 156 gSystem->Exec(command.Data());
157 gSystem->Exec("cd calibFiles; tar xvf SDDbase_step2_LDC.tar; tar xvf SDDbase_LDC.tar; tar xvf SDDinj_LDC.tar; cd ..");
158 }
159 printf("-------------- DONE ---------------\n");
160
161 return;
162}
163
164void CheckCalibInterface::ShowPedestal(){
165 ClearAll();
166
167 TH2F* hbadchan=new TH2F("hbadchan","Number of bad channels",24,-0.25,11.75,24,-0.5,23.5);
168 TH2F* hrawnoisemod=new TH2F("hrawnoisemod","",288,-0.5,287.5,50,0.,10.);
169 TH1F* hrawnoise=new TH1F("hrawnoise","",100,0.,10.);
170 TH2F* hcornoisemod=new TH2F("hcornoisemod","",288,-0.5,287.5,50,0.,10.);
171 TH1F* hcornoise=new TH1F("hcornoise","",100,0.,10.);
172 TH2F* hbasemod=new TH2F("hbasemod","",288,-0.5,287.5,50,0.,150.);
173 TH1F* hbase=new TH1F("hbase","",100,0.,150.);
174 Int_t retfscf;
175 TString inpFileName;
176 Float_t baseline,rawnoise,cmn,corn;
177 Int_t isgoodan,i,basmin,basoff;
178 Int_t th,tl;
179 Int_t nGoodAnodes=0;
180 for(Int_t iddl=0;iddl<24;iddl++){
181 for(Int_t imod=0;imod<12;imod++){
182 for(Int_t isid=0;isid<2;isid++){
183 inpFileName.Form("./calibFiles/SDDbase_step2_ddl%02dc%02d_sid%d.data",iddl,imod,isid);
184 FILE* basFil = fopen(inpFileName.Data(),"read");
185 Int_t sideId=imod*2+isid;
186 Int_t modId=iddl*12+imod;
187 if (basFil == 0) hbadchan->SetBinContent(sideId+1,iddl+1,256);
188 else{
189 retfscf=fscanf(basFil,"%d\n",&th);
190 retfscf=fscanf(basFil,"%d\n",&tl);
191 if(th==255 && tl==20) continue;
192 for(Int_t ian=0;ian<256;ian++){
193 retfscf=fscanf(basFil,"%d %d %f %d %d %f %f %f\n",&i,&isgoodan,&baseline,&basmin,&basoff,&rawnoise,&cmn,&corn);
194 hrawnoisemod->Fill(modId,rawnoise);
195 hrawnoise->Fill(rawnoise);
196 hcornoisemod->Fill(modId,corn);
197 hcornoise->Fill(corn);
198 hbasemod->Fill(modId,baseline);
199 hbase->Fill(baseline);
200 if(!isgoodan){
201 hbadchan->SetBinContent(sideId+1,iddl+1, 1+hbadchan->GetBinContent(sideId+1,iddl+1));
202 }else{
203 nGoodAnodes++;
204 }
205 }
206 fclose(basFil);
207 }
208 }
209 }
210 }
211 hrawnoisemod->SetStats(0);
212 hcornoisemod->SetStats(0);
213 hbasemod->SetStats(0);
214 hbadchan->SetStats(0);
215 gStyle->SetPalette(1);
216 TString txtCountGood;
217 Float_t fracGood=100.*(Float_t)nGoodAnodes/(520.*260.);
218 txtCountGood.Form("Number of GoodAnodes = %d (%5.1f\%)\n",nGoodAnodes,fracGood);
219
220 TCanvas* c0=new TCanvas("c0","Bad Channels",800,900);
221 c0->SetRightMargin(0.14);
222 c0->SetBottomMargin(0.2);
223 hbadchan->Draw("colz");
224 hbadchan->GetXaxis()->SetTitle("Channel");
225 hbadchan->GetYaxis()->SetTitle("DDL");
226 hbadchan->GetXaxis()->SetTickLength(0);
227 hbadchan->GetYaxis()->SetTickLength(0);
228 c0->cd();
229 TLine** linv=new TLine*[12];
230 for(Int_t i=0;i<12;i++){
231 linv[i]=new TLine(i+0.75,-0.5,i+0.75,23.5);
232 linv[i]->SetLineColor(kGray+1);
233 linv[i]->Draw();
234 }
235 TLine** linh=new TLine*[24];
236 for(Int_t i=0;i<24;i++){
237 linh[i]=new TLine(-0.25,i+0.5,11.75,i+0.5);
238 linh[i]->SetLineColor(kGray+1);
239 linh[i]->Draw();
240 }
241 TLatex* tg=new TLatex(0.1,0.05,txtCountGood.Data());
242 tg->SetNDC();
243 tg->SetTextColor(4);
244 tg->SetTextSize(0.04);
245 tg->Draw();
246 c0->Update();
247
248 TCanvas* c1=new TCanvas("c1","Baseline",1200,700);
249 c1->Divide(2,1);
250 c1->cd(1);
251 gPad->SetLeftMargin(0.14);
252 gPad->SetRightMargin(0.14);
253 hbase->Draw();
254 hbase->GetXaxis()->SetTitle("Baseline (ADC)");
255 c1->cd(2);
256 gPad->SetLeftMargin(0.14);
257 gPad->SetRightMargin(0.14);
258 hbasemod->Draw("colz");
259 hbasemod->GetXaxis()->SetTitle("Module index (=DDL*12+Channel)");
260 hbasemod->GetYaxis()->SetTitle("Baseline (ADC)");
261 hbasemod->GetYaxis()->SetTitleOffset(1.35);
262
263 TCanvas* c2=new TCanvas("c2","Raw Noise",1200,700);
264 c2->Divide(2,1);
265 c2->cd(1);
266 gPad->SetLeftMargin(0.14);
267 gPad->SetRightMargin(0.14);
268 hrawnoise->Draw();
269 hrawnoise->GetXaxis()->SetTitle("Raw Noise (ADC)");
270 c2->cd(2);
271 gPad->SetLeftMargin(0.14);
272 gPad->SetRightMargin(0.14);
273 hrawnoisemod->Draw("colz");
274 hrawnoisemod->GetXaxis()->SetTitle("Module index (=DDL*12+Channel)");
275 hrawnoisemod->GetYaxis()->SetTitle("Raw Noise (ADC)");
276 hrawnoisemod->GetYaxis()->SetTitleOffset(1.35);
277
278 TCanvas* c3=new TCanvas("c3","Corr Noise",1200,700);
279 c3->Divide(2,1);
280 c3->cd(1);
281 gPad->SetLeftMargin(0.14);
282 gPad->SetRightMargin(0.14);
283 hcornoise->Draw();
284 hcornoise->GetXaxis()->SetTitle("Raw Noise (ADC)");
285 c3->cd(2);
286 gPad->SetLeftMargin(0.14);
287 gPad->SetRightMargin(0.14);
288 hcornoisemod->Draw("colz");
289 hcornoisemod->GetXaxis()->SetTitle("Module index (=DDL*12+Channel)");
290 hcornoisemod->GetYaxis()->SetTitle("Raw Noise (ADC)");
291 hcornoisemod->GetYaxis()->SetTitleOffset(1.35);
292}
293
294void CheckCalibInterface::ShowPulser(){
295 ClearAll();
296
297 TH2F* hbadchan=new TH2F("hbadchan","Number of bad channels",24,-0.25,11.75,24,-0.5,23.5);
298 TH2F* hrawnoisemod=new TH2F("hrawnoisemod","",288,-0.5,287.5,50,0.,10.);
299 TH1F* hrawnoise=new TH1F("hrawnoise","",100,0.,10.);
300 TH2F* hcornoisemod=new TH2F("hcornoisemod","",288,-0.5,287.5,50,0.,10.);
301 TH1F* hcornoise=new TH1F("hcornoise","",100,0.,10.);
302 TH2F* hbasemod=new TH2F("hbasemod","",288,-0.5,287.5,50,0.,150.);
303 TH1F* hbase=new TH1F("hbase","",100,0.,150.);
304 TH2F* hgainmod=new TH2F("hgainmod","",288,-0.5,287.5,50,0.,5.);
305 TH1F* hgain=new TH1F("hgain","",100,0.,5.);
306
307 Int_t retfscf;
308 TString inpFileName;
309 Float_t baseline,rawnoise,cmn,corn,gain;
310 Int_t isgoodan,i,basmin,basoff;
311 Int_t th,tl;
312 Int_t iii,jjj,kkk;
313 Int_t nGoodAnodes=0;
314
315 for(Int_t iddl=0;iddl<24;iddl++){
316 for(Int_t imod=0;imod<12;imod++){
317 for(Int_t isid=0;isid<2;isid++){
318 inpFileName.Form("./calibFiles/SDDbase_ddl%02dc%02d_sid%d.data",iddl,imod,isid);
319 FILE* basFil = fopen(inpFileName.Data(),"read");
320 Int_t sideId=imod*2+isid;
321 Int_t modId=iddl*12+imod;
322 if (basFil == 0) hbadchan->SetBinContent(sideId+1,iddl+1,256);
323 else{
324 retfscf=fscanf(basFil,"%d %d %d\n",&iii,&jjj,&kkk);
325 if(kkk==0) continue;
326 retfscf=fscanf(basFil,"%d\n",&th);
327 retfscf=fscanf(basFil,"%d\n",&tl);
328 if(th==255 && tl==20) continue;
329 for(Int_t ian=0;ian<256;ian++){
330 retfscf=fscanf(basFil,"%d %d %f %d %d %f %f %f %f\n",&i,&isgoodan,&baseline,&basmin,&basoff,&rawnoise,&cmn,&corn,&gain);
331 hrawnoisemod->Fill(modId,rawnoise);
332 hrawnoise->Fill(rawnoise);
333 hcornoisemod->Fill(modId,corn);
334 hcornoise->Fill(corn);
335 hbasemod->Fill(modId,baseline);
336 hbase->Fill(baseline);
337 hgainmod->Fill(modId,gain);
338 hgain->Fill(gain);
339 if(!isgoodan){
340 hbadchan->SetBinContent(sideId+1,iddl+1, 1+hbadchan->GetBinContent(sideId+1,iddl+1));
341 }else{
342 nGoodAnodes++;
343 }
344 }
345 fclose(basFil);
346 }
347 }
348 }
349 }
350 hrawnoisemod->SetStats(0);
351 hcornoisemod->SetStats(0);
352 hbasemod->SetStats(0);
353 hgainmod->SetStats(0);
354 hbadchan->SetStats(0);
355 gStyle->SetPalette(1);
356 TString txtCountGood;
357 Float_t fracGood=100.*(Float_t)nGoodAnodes/(520.*260.);
358 txtCountGood.Form("Number of GoodAnodes = %d (%5.1f\%)\n",nGoodAnodes,fracGood);
359
360 TCanvas* c0=new TCanvas("c0","Bad Channels",800,900);
361 c0->SetRightMargin(0.14);
362 c0->SetBottomMargin(0.2);
363 hbadchan->Draw("colz");
364 hbadchan->GetXaxis()->SetTitle("Channel");
365 hbadchan->GetYaxis()->SetTitle("DDL");
366 hbadchan->GetXaxis()->SetTickLength(0);
367 hbadchan->GetYaxis()->SetTickLength(0);
368 c0->cd();
369 TLine** linv=new TLine*[12];
370 for(Int_t i=0;i<12;i++){
371 linv[i]=new TLine(i+0.75,-0.5,i+0.75,23.5);
372 linv[i]->SetLineColor(kGray+1);
373 linv[i]->Draw();
374 }
375 TLine** linh=new TLine*[24];
376 for(Int_t i=0;i<24;i++){
377 linh[i]=new TLine(-0.25,i+0.5,11.75,i+0.5);
378 linh[i]->SetLineColor(kGray+1);
379 linh[i]->Draw();
380 }
381 TLatex* tg=new TLatex(0.1,0.05,txtCountGood.Data());
382 tg->SetNDC();
383 tg->SetTextColor(4);
384 tg->SetTextSize(0.04);
385 tg->Draw();
386 c0->Update();
387
388 TCanvas* c1=new TCanvas("c1","Baseline",1200,700);
389 c1->Divide(2,1);
390 c1->cd(1);
391 gPad->SetLeftMargin(0.14);
392 gPad->SetRightMargin(0.14);
393 hbase->Draw();
394 hbase->GetXaxis()->SetTitle("Baseline (ADC)");
395 c1->cd(2);
396 gPad->SetLeftMargin(0.14);
397 gPad->SetRightMargin(0.14);
398 hbasemod->Draw("colz");
399 hbasemod->GetXaxis()->SetTitle("Module index (=DDL*12+Channel)");
400 hbasemod->GetYaxis()->SetTitle("Baseline (ADC)");
401 hbasemod->GetYaxis()->SetTitleOffset(1.35);
402
403 TCanvas* c2=new TCanvas("c2","Raw Noise",1200,700);
404 c2->Divide(2,1);
405 c2->cd(1);
406 gPad->SetLeftMargin(0.14);
407 gPad->SetRightMargin(0.14);
408 hrawnoise->Draw();
409 hrawnoise->GetXaxis()->SetTitle("Raw Noise (ADC)");
410 c2->cd(2);
411 gPad->SetLeftMargin(0.14);
412 gPad->SetRightMargin(0.14);
413 hrawnoisemod->Draw("colz");
414 hrawnoisemod->GetXaxis()->SetTitle("Module index (=DDL*12+Channel)");
415 hrawnoisemod->GetYaxis()->SetTitle("Raw Noise (ADC)");
416 hrawnoisemod->GetYaxis()->SetTitleOffset(1.35);
417
418 TCanvas* c3=new TCanvas("c3","Corr Noise",1200,700);
419 c3->Divide(2,1);
420 c3->cd(1);
421 gPad->SetLeftMargin(0.14);
422 gPad->SetRightMargin(0.14);
423 hcornoise->Draw();
424 hcornoise->GetXaxis()->SetTitle("Raw Noise (ADC)");
425 c3->cd(2);
426 gPad->SetLeftMargin(0.14);
427 gPad->SetRightMargin(0.14);
428 hcornoisemod->Draw("colz");
429 hcornoisemod->GetXaxis()->SetTitle("Module index (=DDL*12+Channel)");
430 hcornoisemod->GetYaxis()->SetTitle("Raw Noise (ADC)");
431 hcornoisemod->GetYaxis()->SetTitleOffset(1.35);
432
433 TCanvas* c4=new TCanvas("c4","Gain",1200,700);
434 c4->Divide(2,1);
435 c4->cd(1);
436 gPad->SetLeftMargin(0.14);
437 gPad->SetRightMargin(0.14);
438 hgain->Draw();
439 hgain->GetXaxis()->SetTitle("Gain (ADC/DAC)");
440 c4->cd(2);
441 gPad->SetLeftMargin(0.14);
442 gPad->SetRightMargin(0.14);
443 hgainmod->Draw("colz");
444 hgainmod->GetXaxis()->SetTitle("Module index (=DDL*12+Channel)");
445 hgainmod->GetYaxis()->SetTitle("Gain (ADC/DAC)");
446 hgainmod->GetYaxis()->SetTitleOffset(1.35);
447
448 return;
449}
450
451void CheckCalibInterface::ShowInjector(){
452 ClearAll();
453
454 TH2F* hinjstatus=new TH2F("hinjstatus","Injector Status",24,-0.25,11.75,24,-0.5,23.5);
455 TGraph *vvsmod0=new TGraph(0);
456 TGraph *vvsmod1=new TGraph(0);
457 TGraph *poldegvsmod0=new TGraph(0);
458 TGraph *poldegvsmod1=new TGraph(0);
459 TGraph *anmaxvsmod0=new TGraph(0);
460 TGraph *anmaxvsmod1=new TGraph(0);
461 TGraph *dvcevsmod0=new TGraph(0);
462 TGraph *dvcevsmod1=new TGraph(0);
463 TGraph *dveevsmod0=new TGraph(0);
464 TGraph *dveevsmod1=new TGraph(0);
465 vvsmod0->SetTitle("Drift Speed vs. mod. number");
466 vvsmod1->SetTitle("Drift Speed vs. mod. number");
467 poldegvsmod0->SetTitle("Degree of poly fit vs. mod. number");
468 poldegvsmod1->SetTitle("Degree of poly fit vs. mod. number");
469 anmaxvsmod0->SetTitle("Anode with max. vdrift vs. mod. number");
470 anmaxvsmod1->SetTitle("Anode with max. vdrift vs. mod. number");
471 dvcevsmod0->SetTitle("Delta Vdrift 128-0 vs. mod. number");
472 dvcevsmod1->SetTitle("Delta Vdrift 128-0 vs. mod. number");
473 dveevsmod0->SetTitle("Delta Vdrift 256-0 vs. mod. number");
474 dveevsmod1->SetTitle("Delta Vdrift 256-0 vs. mod. number");
475
476 TF1* fPoly=new TF1("fPoly","pol3",0.,256.);
477
478 Int_t evNumb,polDeg;
479 UInt_t timeStamp,statusInj;
480 Int_t retfscf;
481 TString inpFileName;
482 Float_t auxP;
483 Int_t iGoodInj=0;
484 for(Int_t iddl=0;iddl<24;iddl++){
485 for(Int_t imod=0;imod<12;imod++){
486 for(Int_t isid=0;isid<2;isid++){
487 inpFileName.Form("./calibFiles/SDDinj_ddl%02dc%02d_sid%d.data",iddl,imod,isid);
488 FILE* injFil = fopen(inpFileName.Data(),"read");
489 Int_t sideId=imod*2+isid;
490 Int_t modId=iddl*12+imod;
491 if (injFil == 0){
492 hinjstatus->SetBinContent(sideId+1,iddl+1,0);
493 }else{
494 Bool_t firstEvent=kTRUE;
495 retfscf=fscanf(injFil,"%d",&polDeg);
496 while (!feof(injFil)){
497 retfscf=fscanf(injFil,"%d %u ",&evNumb,&timeStamp);
498 if(evNumb==-99){
499 statusInj=timeStamp;
500 Int_t n7=(statusInj&(0x1F<<25))>>25;
501 Int_t n6=(statusInj&(0x1F<<20))>>20;
502 Int_t n5=(statusInj&(0x1F<<15))>>15;
503 Int_t n4=(statusInj&(0x1F<<5))>>10;
504 Int_t n3=(statusInj&(0x1F<<5))>>5;
505 Int_t n2=statusInj&0x1F;
506 Float_t aveStatus=(7.*n7+6.*n6+5.*n5+4.*n4+3.*n3+2.*n2)/32;
507 hinjstatus->SetBinContent(sideId+1,iddl+1,aveStatus);
508 }else{
509 if(feof(injFil)) break;
510 for(Int_t ic=0;ic<4;ic++){
511 retfscf=fscanf(injFil,"%f ",&auxP);
512 fPoly->SetParameter(ic,auxP);
513 }
514 if(firstEvent && polDeg>0){
515 firstEvent=kFALSE;
516 ++iGoodInj;
517 if(isid==0){
518 vvsmod0->SetPoint(vvsmod0->GetN(),(Float_t)modId,fPoly->Eval(128));
519 poldegvsmod0->SetPoint(poldegvsmod0->GetN(),(Float_t)modId,polDeg);
520 anmaxvsmod0->SetPoint(anmaxvsmod0->GetN(),(Float_t)modId,fPoly->GetMaximumX(0.,256.));
521 dvcevsmod0->SetPoint(dvcevsmod0->GetN(),(Float_t)modId,fPoly->Eval(128)-fPoly->Eval(0));
522 dveevsmod0->SetPoint(dveevsmod0->GetN(),(Float_t)modId,fPoly->Eval(256)-fPoly->Eval(0));
523 }else{
524 vvsmod1->SetPoint(vvsmod1->GetN(),(Float_t)modId,fPoly->Eval(128));
525 poldegvsmod1->SetPoint(poldegvsmod1->GetN(),(Float_t)modId,polDeg);
526 anmaxvsmod1->SetPoint(anmaxvsmod1->GetN(),(Float_t)modId,fPoly->GetMaximumX(0.,256.));
527 dvcevsmod1->SetPoint(dvcevsmod1->GetN(),(Float_t)modId,fPoly->Eval(128)-fPoly->Eval(0));
528 dveevsmod1->SetPoint(dveevsmod1->GetN(),(Float_t)modId,fPoly->Eval(256)-fPoly->Eval(0));
529 }
530 }
531 }
532 }
533 fclose(injFil);
534 }
535 }
536 }
537 }
538 delete fPoly;
539
540 TString countmods;
541 countmods.Form("Number of half-modules with drift speed from injectors = %d",iGoodInj);
542 gStyle->SetPalette(59);
543 hinjstatus->SetStats(0);
544 hinjstatus->SetMinimum(-0.01);
545 hinjstatus->SetMaximum(7.);
546 TCanvas* c0=new TCanvas("c0","Injector status",800,900);
547 c0->SetRightMargin(0.14);
548 c0->SetBottomMargin(0.2);
549 hinjstatus->Draw("colz");
550 hinjstatus->GetXaxis()->SetTitle("Channel");
551 hinjstatus->GetYaxis()->SetTitle("DDL");
552 hinjstatus->GetXaxis()->SetTickLength(0);
553 hinjstatus->GetYaxis()->SetTickLength(0);
554 c0->cd();
555 TLine** linv=new TLine*[12];
556 for(Int_t i=0;i<12;i++){
557 linv[i]=new TLine(i+0.75,-0.5,i+0.75,23.5);
558 linv[i]->SetLineColor(kGray+1);
559 linv[i]->Draw();
560 }
561 TLine** linh=new TLine*[24];
562 for(Int_t i=0;i<24;i++){
563 linh[i]=new TLine(-0.25,i+0.5,11.75,i+0.5);
564 linh[i]->SetLineColor(kGray+1);
565 linh[i]->Draw();
566 }
567 TLatex* t3=new TLatex(0.1,0.05,countmods.Data());
568 t3->SetNDC();
569 t3->SetTextColor(4);
570 t3->SetTextSize(0.03);
571 t3->Draw();
572 c0->Update();
573
574 TLatex* tleft=new TLatex(0.2,0.82,"Side 0");
575 tleft->SetNDC();
576 tleft->SetTextColor(1);
577 TLatex* tright=new TLatex(0.2,0.75,"Side 1");
578 tright->SetNDC();
579 tright->SetTextColor(2);
580
581 TCanvas* c1;
582 c1=new TCanvas("c1","Vdrift vs. mod",1000,700);
583 vvsmod0->SetMarkerStyle(20);
584 vvsmod0->Draw("AP");
585 vvsmod0->GetXaxis()->SetLimits(-1,290);
586 vvsmod0->GetXaxis()->SetTitle("Module index (=DDL*12+Channel)");
587 vvsmod0->GetYaxis()->SetTitle("Vdrift (#mum/ns)");
588 vvsmod1->SetMarkerStyle(21);
589 vvsmod1->SetMarkerColor(2);
590 vvsmod1->Draw("SAMEP");
591 tleft->Draw();
592 tright->Draw();
593 TLine* ltop=new TLine(12*8-0.5,vvsmod0->GetYaxis()->GetXmin(),12*8-0.5,vvsmod0->GetYaxis()->GetXmax());
594 ltop->SetLineColor(4);
595 ltop->Draw();
596 TLatex* ttop=new TLatex(12*3.5,vvsmod0->GetYaxis()->GetXmin()+0.05,"TOP");
597 ttop->SetTextColor(4);
598 ttop->Draw();
599 TLine* lmed=new TLine(12*16-0.5,vvsmod0->GetYaxis()->GetXmin(),12*16-0.5,vvsmod0->GetYaxis()->GetXmax());
600 lmed->SetLineColor(4);
601 lmed->Draw();
602 TLatex* tmed=new TLatex(12*11.5,vvsmod0->GetYaxis()->GetXmin()+0.05,"MED");
603 tmed->SetTextColor(4);
604 tmed->Draw();
605 TLatex* tbot=new TLatex(12*19.5,vvsmod0->GetYaxis()->GetXmin()+0.05,"BOT");
606 tbot->SetTextColor(4);
607 tbot->Draw();
608
609
610 TCanvas* c2=new TCanvas("c2","Params vs. mod",900,900);
611 c2->Divide(2,2);
612
613 c2->cd(1);
614 gPad->SetLeftMargin(0.14);
615 poldegvsmod0->SetMarkerStyle(20);
616 poldegvsmod0->Draw("AP");
617 poldegvsmod0->GetXaxis()->SetLimits(-1,290);
618 poldegvsmod0->GetXaxis()->SetTitle("Module index (=DDL*12+Channel)");
619 poldegvsmod0->GetYaxis()->SetTitle("Degree of Polynomial fit");
620 poldegvsmod0->GetYaxis()->SetTitleOffset(1.4);
621 poldegvsmod1->SetMarkerStyle(21);
622 poldegvsmod1->SetMarkerColor(2);
623 poldegvsmod1->Draw("SAMEP");
624 tleft->Draw();
625 tright->Draw();
626 c2->cd(2);
627 gPad->SetLeftMargin(0.14);
628 anmaxvsmod0->SetMarkerStyle(20);
629 anmaxvsmod0->Draw("AP");
630 anmaxvsmod0->GetXaxis()->SetLimits(-1,290);
631 anmaxvsmod0->GetXaxis()->SetTitle("Module index (=DDL*12+Channel)");
632 anmaxvsmod0->GetYaxis()->SetTitle("Anode with max. drift speed");
633 anmaxvsmod0->GetYaxis()->SetTitleOffset(1.4);
634 anmaxvsmod1->SetMarkerStyle(21);
635 anmaxvsmod1->SetMarkerColor(2);
636 anmaxvsmod1->Draw("SAMEP");
637 tleft->Draw();
638 tright->Draw();
639 c2->cd(3);
640 gPad->SetLeftMargin(0.14);
641 dvcevsmod0->SetMarkerStyle(20);
642 dvcevsmod0->Draw("AP");
643 dvcevsmod0->GetXaxis()->SetLimits(-1,290);
644 dvcevsmod0->GetXaxis()->SetTitle("Module index (=DDL*12+Channel)");
645 dvcevsmod0->GetYaxis()->SetTitle("vdrift(anode128)-vdrift(anode0)");
646 dvcevsmod0->GetYaxis()->SetTitleOffset(1.4);
647 dvcevsmod1->SetMarkerStyle(21);
648 dvcevsmod1->SetMarkerColor(2);
649 dvcevsmod1->Draw("SAMEP");
650 tleft->Draw();
651 tright->Draw();
652 c2->cd(4);
653 gPad->SetLeftMargin(0.14);
654 dveevsmod0->SetMarkerStyle(20);
655 dveevsmod0->Draw("AP");
656 dveevsmod0->GetXaxis()->SetLimits(-1,290);
657 dveevsmod0->GetYaxis()->SetTitleOffset(1.4);
658 dveevsmod0->GetXaxis()->SetTitle("Module index (=DDL*12+Channel)");
659 dveevsmod0->GetYaxis()->SetTitle("vdrift(anode256)-vdrift(anode0)");
660 dveevsmod1->SetMarkerStyle(21);
661 dveevsmod1->SetMarkerColor(2);
662 dveevsmod1->Draw("SAMEP");
663 tleft->Draw();
664 tright->Draw();
665
666 return;
667}
668
669void CheckCalibInterface::ShowSingleModule(Int_t iddl, Int_t ichan){
670 //
671 ClearAll();
672 TString inpFileName1,inpFileName2,inpFileName3;
673 Int_t retfscf;
674 Float_t baseline,rawnoise,cmn,corn,gain;
675 Int_t isgoodan,i,basmin,basoff;
676 Int_t th,tl;
677 Int_t iii,jjj,kkk;
678 Int_t evNumb,polDeg;
679 UInt_t timeStamp,statusInj;
680 Float_t auxP;
681 TF1* fPoly=new TF1("fPoly","pol3",0.,256.);
682
683 TGraph* gbasel=new TGraph(0);
684 TGraph* gbaser=new TGraph(0);
685 TGraph* grawnl=new TGraph(0);
686 TGraph* grawnr=new TGraph(0);
687 TGraph* gcornl=new TGraph(0);
688 TGraph* gcornr=new TGraph(0);
689 TGraph* ggainl=new TGraph(0);
690 TGraph* ggainr=new TGraph(0);
691 TGraph* gstpdl=new TGraph(0);
692 TGraph* gstpdr=new TGraph(0);
693 TGraph* gstpul=new TGraph(0);
694 TGraph* gstpur=new TGraph(0);
695 TGraph* gdrspl=new TGraph(0);
696 TGraph* gdrspr=new TGraph(0);
697 gbasel->SetTitle("Baseline Left");
698 gbaser->SetTitle("Baseline Right");
699 grawnl->SetTitle("Noise Left");
700 grawnr->SetTitle("Noise Right");
701 gcornl->SetTitle("Noise Left");
702 gcornr->SetTitle("Noise Right");
703 ggainl->SetTitle("Gain Left");
704 ggainr->SetTitle("Gain Right");
705 gstpdl->SetTitle("Status Left");
706 gstpdr->SetTitle("Status Right");
707 gstpul->SetTitle("Status Left");
708 gstpur->SetTitle("Status Right");
709 gdrspl->SetTitle("Drift Speed Left");
710 gdrspr->SetTitle("Drift Speed Right");
711
712 for(Int_t isid=0;isid<2;isid++){
713 inpFileName1.Form("./calibFiles/SDDbase_step2_ddl%02dc%02d_sid%d.data",iddl,ichan,isid);
714 inpFileName2.Form("./calibFiles/SDDbase_ddl%02dc%02d_sid%d.data",iddl,ichan,isid);
715 inpFileName3.Form("./calibFiles/SDDinj_ddl%02dc%02d_sid%d.data",iddl,ichan,isid);
716
717
718 FILE* basFil = fopen(inpFileName1.Data(),"read");
719 if (basFil != 0){
720 retfscf=fscanf(basFil,"%d\n",&th);
721 retfscf=fscanf(basFil,"%d\n",&tl);
722 if(th==255 && tl==20) continue;
723 for(Int_t ian=0;ian<256;ian++){
724 retfscf=fscanf(basFil,"%d %d %f %d %d %f %f %f\n",&i,&isgoodan,&baseline,&basmin,&basoff,&rawnoise,&cmn,&corn);
725 if(isid==0){
726 gbasel->SetPoint(gbasel->GetN(),(Float_t)i,baseline);
727 grawnl->SetPoint(grawnl->GetN(),(Float_t)i,rawnoise);
728 gcornl->SetPoint(gcornl->GetN(),(Float_t)i,corn);
729 gstpdl->SetPoint(gstpdl->GetN(),(Float_t)i,(Float_t)isgoodan);
730 }else{
731 gbaser->SetPoint(gbaser->GetN(),(Float_t)i,baseline);
732 grawnr->SetPoint(grawnr->GetN(),(Float_t)i,rawnoise);
733 gcornr->SetPoint(gcornr->GetN(),(Float_t)i,corn);
734 gstpdr->SetPoint(gstpdr->GetN(),(Float_t)i,(Float_t)isgoodan);
735 }
736 }
737 fclose(basFil);
738 }
739
740 FILE* pulFil = fopen(inpFileName2.Data(),"read");
741 if (pulFil != 0){
742 retfscf=fscanf(pulFil,"%d %d %d\n",&iii,&jjj,&kkk);
743 retfscf=fscanf(pulFil,"%d\n",&th);
744 retfscf=fscanf(pulFil,"%d\n",&tl);
745 if(th==255 && tl==20) continue;
746 for(Int_t ian=0;ian<256;ian++){
747 retfscf=fscanf(pulFil,"%d %d %f %d %d %f %f %f %f\n",&i,&isgoodan,&baseline,&basmin,&basoff,&rawnoise,&cmn,&corn,&gain);
748 if(isid==0){
749 ggainl->SetPoint(ggainl->GetN(),(Float_t)i,gain);
750 gstpul->SetPoint(gstpul->GetN(),(Float_t)i,(Float_t)isgoodan);
751 }else{
752 ggainr->SetPoint(ggainr->GetN(),(Float_t)i,gain);
753 gstpur->SetPoint(gstpur->GetN(),(Float_t)i,(Float_t)isgoodan);
754 }
755 }
756 fclose(pulFil);
757 }
758
759 FILE* injFil = fopen(inpFileName3.Data(),"read");
760 Bool_t firstEvent=kTRUE;
761 if (injFil != 0){
762 retfscf=fscanf(injFil,"%d",&polDeg);
763 while (!feof(injFil)){
764 retfscf=fscanf(injFil,"%d %u ",&evNumb,&timeStamp);
765 if(evNumb==-99){
766 statusInj=timeStamp;
767 }else{
768 if(feof(injFil)) break;
769 for(Int_t ic=0;ic<4;ic++){
770 retfscf=fscanf(injFil,"%f ",&auxP);
771 fPoly->SetParameter(ic,auxP);
772 }
773 }
774 if(firstEvent==kTRUE && polDeg>0){
775 firstEvent=kFALSE;
776 for(Int_t ian=0; ian<256; ian+=8){
777 if(isid==0) gdrspl->SetPoint(gdrspl->GetN(),(Float_t)ian,fPoly->Eval(ian));
778 else gdrspr->SetPoint(gdrspr->GetN(),(Float_t)ian,fPoly->Eval(ian));
779
780 }
781 }
782 }
783 }
784 }
785
786
787 TCanvas * c0=new TCanvas("c0","Baselines",900,600);
788 c0->Divide(2,1);
789 c0->cd(1);
790 gPad->SetLeftMargin(0.14);
791 gbasel->SetMarkerStyle(7);
792 gbasel->Draw("AP");
793 gbasel->GetXaxis()->SetTitle("Anode");
794 gbasel->GetYaxis()->SetTitle("Baseline (ADC)");
795 gbasel->GetYaxis()->SetTitleOffset(1.35);
796 c0->cd(2);
797 gPad->SetLeftMargin(0.14);
798 gbaser->SetMarkerStyle(7);
799 gbaser->Draw("AP");
800 gbaser->GetXaxis()->SetTitle("Anode");
801 gbaser->GetYaxis()->SetTitle("Baseline (ADC)");
802 gbaser->GetYaxis()->SetTitleOffset(1.35);
803
804 TCanvas * c1=new TCanvas("c1","Noise",900,600);
805 c1->Divide(2,1);
806 c1->cd(1);
807 gPad->SetLeftMargin(0.14);
808 TLatex* t1=new TLatex(0.6,0.8,"Raw");
809 t1->SetNDC();
810 TLatex* t2=new TLatex(0.6,0.75,"Corrected");
811 t2->SetTextColor(2);
812 t2->SetNDC();
813 grawnl->SetMarkerStyle(7);
814 grawnl->Draw("AP");
815 grawnl->GetXaxis()->SetTitle("Anode");
816 grawnl->GetYaxis()->SetTitle("Noise (ADC)");
817 grawnl->GetYaxis()->SetTitleOffset(1.35);
818 gcornl->SetMarkerStyle(7);
819 gcornl->SetMarkerColor(2);
820 gcornl->Draw("SAMEP");
821 t1->Draw();
822 t2->Draw();
823 c1->cd(2);
824 gPad->SetLeftMargin(0.14);
825 grawnr->SetMarkerStyle(7);
826 grawnr->Draw("AP");
827 grawnr->GetXaxis()->SetTitle("Anode");
828 grawnr->GetYaxis()->SetTitle("Noise (ADC)");
829 grawnr->GetYaxis()->SetTitleOffset(1.35);
830 gcornr->SetMarkerStyle(7);
831 gcornr->SetMarkerColor(2);
832 gcornr->Draw("SAMEP");
833 t1->Draw();
834 t2->Draw();
835
836 TCanvas * c2=new TCanvas("c2","Gain",900,600);
837 c2->Divide(2,1);
838 c2->cd(1);
839 gPad->SetLeftMargin(0.14);
840 ggainl->SetMarkerStyle(7);
841 ggainl->Draw("AP");
842 ggainl->GetXaxis()->SetTitle("Anode");
843 ggainl->GetYaxis()->SetTitle("Gain (ADC/DAC)");
844 ggainl->GetYaxis()->SetTitleOffset(1.35);
845 c2->cd(2);
846 gPad->SetLeftMargin(0.14);
847 ggainr->SetMarkerStyle(7);
848 ggainr->Draw("AP");
849 ggainr->GetXaxis()->SetTitle("Anode");
850 ggainr->GetYaxis()->SetTitle("Gain (ADC/DAC)");
851 ggainr->GetYaxis()->SetTitleOffset(1.35);
852
853 TCanvas * c3=new TCanvas("c3","Anode Status",900,600);
854 c3->Divide(2,1);
855 c3->cd(1);
856 gPad->SetLeftMargin(0.14);
857 TLatex* t3=new TLatex(0.6,0.85,"Pedestal");
858 t3->SetNDC();
859 TLatex* t4=new TLatex(0.6,0.8,"Pulser");
860 t4->SetTextColor(4);
861 t4->SetNDC();
862 gstpdl->SetMarkerStyle(7);
863 gstpdl->Draw("AP");
864 gstpdl->SetMinimum(-0.001);
865 gstpdl->SetMaximum(1.2);
866 gstpdl->GetXaxis()->SetTitle("Anode");
867 gstpdl->GetYaxis()->SetTitle("Status (1=OK, 0=BAD)");
868 gstpdl->GetYaxis()->SetTitleOffset(1.35);
869 gstpul->SetMarkerStyle(7);
870 gstpul->SetMarkerColor(4);
871 gstpul->Draw("SAMEP");
872 t3->Draw();
873 t4->Draw();
874 c3->cd(2);
875 gPad->SetLeftMargin(0.14);
876 gstpdr->SetMarkerStyle(7);
877 gstpdr->Draw("AP");
878 gstpdr->SetMinimum(-0.001);
879 gstpdr->SetMaximum(1.2);
880 gstpdr->GetXaxis()->SetTitle("Anode");
881 gstpdr->GetYaxis()->SetTitle("Status (1=OK, 0=BAD)");
882 gstpdr->GetYaxis()->SetTitleOffset(1.35);
883 gstpur->SetMarkerStyle(7);
884 gstpur->SetMarkerColor(4);
885 gstpur->Draw("SAMEP");
886 t3->Draw();
887 t4->Draw();
888
889 TCanvas * c4=new TCanvas("c4","Drift Speed",900,600);
890 c4->Divide(2,1);
891 c4->cd(1);
892 gPad->SetLeftMargin(0.14);
893 gdrspl->SetMarkerStyle(7);
894 gdrspl->Draw("APL");
895 gdrspl->GetXaxis()->SetTitle("Anode");
896 gdrspl->GetYaxis()->SetTitle("Drift Speed (#mum/ns)");
897 gdrspl->GetYaxis()->SetTitleOffset(1.35);
898 c4->cd(2);
899 gPad->SetLeftMargin(0.14);
900 gdrspr->SetMarkerStyle(7);
901 gdrspr->Draw("APL");
902 gdrspr->GetXaxis()->SetTitle("Anode");
903 gdrspr->GetYaxis()->SetTitle("Drift Speed (#mum/ns)");
904 gdrspr->GetYaxis()->SetTitleOffset(1.35);
905
906 return;
907}
908
909void CheckCalibInterface::DoSetlabel()
910{
911 // Slot method connected to the ValueSet(Long_t) signal.
912 // It displays the value set in TGNumberEntry widget.
913 fNumDDL=fDDL->GetNumberEntry()->GetIntNumber();
914 fNumChannel=fChannel->GetNumberEntry()->GetIntNumber();
915 fShowOneMod->SetCommand(Form("CheckCalibInterface::ShowSingleModule(%d,%d)",
916 fNumDDL,fNumChannel));
917}
918
919void CheckCalibInterface::ClearAll(){
920
921 gROOT->Clear();
922 if(gROOT->FindObject("c0")) delete gROOT->FindObject("c0");
923 if(gROOT->FindObject("c1")) delete gROOT->FindObject("c1");
924 if(gROOT->FindObject("c2")) delete gROOT->FindObject("c2");
925 if(gROOT->FindObject("c3")) delete gROOT->FindObject("c3");
926 if(gROOT->FindObject("c4")) delete gROOT->FindObject("c4");
927 if(gROOT->FindObject("hbadchan")) delete gROOT->FindObject("hbadchan");
928 if(gROOT->FindObject("hrawnoisemod")) delete gROOT->FindObject("hrawnoisemod");
929 if(gROOT->FindObject("hrawnoise")) delete gROOT->FindObject("hrawnoise");
930 if(gROOT->FindObject("hcornoisemod")) delete gROOT->FindObject("hcornoisemod");
931 if(gROOT->FindObject("hcornoise")) delete gROOT->FindObject("hcornoise");
932 if(gROOT->FindObject("hbasemod")) delete gROOT->FindObject("hbasemod");
933 if(gROOT->FindObject("hbase")) delete gROOT->FindObject("hbase");
934 if(gROOT->FindObject("hgainmod")) delete gROOT->FindObject("hgainmod");
935 if(gROOT->FindObject("hgain")) delete gROOT->FindObject("hgainnoise");
936
937}
938
939void CheckCalibs()
940{
941 new CheckCalibInterface(gClient->GetRoot(), 400, 400);
942}