StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
calibFmsShow.C
1 /*
2  FMS calibration tools for QA/plot production
3  Aligned in alphabetical order unless dependency problem exists
4 
5  Chong Kim
6  UC Riverside
7  ckim@bnl.gov
8 */
9 
10 #include "calibFmsTools.C"
11 
12 static map<int, int> DumMapI[4]; //Default dummy maps
13 static map<int, float> DumMapF[4];
14 static map<int, string> DumMapS[4];
15 static vector<int> DumVecI[4];
16 static TH2F* DumTH2F[4];
17 
18 //-------------
19 void DrawAdcQa(
20  map<int, int> iToCh[4],
21  const char* inList, //List of files contain ADC vs. ch
22  bool PRINT = false,
23  map<int, string> chToInfo[4] = DumMapS,
24  map<int, int> chToBS[4] = DumMapI, //If this list is given channels w/ BS > 0 will be scaled by it
25  map<int, float> chToGain[4] = DumMapF,
26  map<int, float> chToGainCorr[4] = DumMapF, //If this list is given hit energy will be drawn too
27  vector<int> chMarked[4] = DumVecI,
28  TH2F* H2Mass[4] = DumTH2F //If this TH2 is given mass distribution will be drawn on ADC
29  )
30 {
31  const int adcMin = 5; //Lower limit, empty any filled bins (adc <= 5) below this
32  const int cutSig = 2; //# of sigma for the rough hot channel decision
33 
34  //Get list of runs
35  string runList[500];
36  unsigned int nRun = 0;
37  ifstream in;
38  in.open(inList);
39  if (!in.is_open()) { cout <<"Cannot open " <<inList <<endl; return; }
40  while (in.is_open())
41  {
42  string inFile;
43  in >> inFile;
44  if (!in.good()) { break; in.close(); }
45 
46  runList[nRun].clear();
47  runList[nRun] = inFile;
48 
49  nRun++;
50  if (nRun > sizeof(runList)/sizeof(runList[0])) cout <<"WARNING! # of runs exceeds allowed limit!" <<endl;
51  }//Loop over runs
52 
53  //QA histograms
54  TH2F* H2AdcQa1[4]; //Channel vs. run, each entry corresponds to # of hit/trig
55  TH2F* H2AdcQa2[4]; //ADC vs. channel
56  for (int a=0; a<4; a++)
57  {
58  const int nCh = iToCh[a].size();
59  H2AdcQa1[a] = new TH2F(Form("AdcQa1_d%i", a+8), "", nRun,-0.5,nRun-0.5, nCh,0.5,nCh+0.5);
60  H2AdcQa1[a]->SetTitle(Form("detId=%i, nHit/nTrig;run index;ch index", a+8));
61  H2AdcQa1[a]->Sumw2();
62  }
63 
64  //Fill QA histograms
65  for (unsigned int i=0; i<nRun; i++)
66  {
67  const char* inFile = runList[i].c_str();
68  TFile* F = TFile::Open(inFile);
69  if (!F || F->IsZombie()) { cout <<"Cannot open file " <<inFile <<endl; return; }
70  else cout <<Form("Open %s... %i", inFile, i) <<endl;
71 
72  TH1F* H1TempTrig = (TH1F*)F->Get("trig");
73  if (!H1TempTrig || H1TempTrig->GetEntries()==0) { cout <<"Trigger TH1?" <<endl; return; }
74  const float nTrig = H1TempTrig->GetEntries();
75  H1TempTrig->Delete();
76 
77  for (int a=0; a<4; a++)
78  {
79  TH2F* H2TempAdc = (TH2F*)F->Get(Form("adc_d%i_wide", a+8));
80  if (!H2TempAdc || H2TempAdc->GetEntries()==0) { cout <<"ADC TH2?" <<endl; return; }
81 
82  //QA1
83  const int adcMinBin = H2TempAdc->GetYaxis()->FindBin(adcMin + 0.1);
84  const int adcMaxBin = H2TempAdc->GetNbinsY();
85  TH1F* H1TempAdc = (TH1F*)H2TempAdc->ProjectionX(Form("detId%i", a+8), adcMinBin, adcMaxBin);
86  for (unsigned int b=0; b<iToCh[a].size(); b++)
87  {
88  const int ch = iToCh[a][b];
89  if (ch == 0) continue;
90  const float nHitNorm = H1TempAdc->GetBinContent(ch) / nTrig;
91  H2AdcQa1[a]->SetBinContent(i+1, b+1, nHitNorm);
92  }
93  H1TempAdc->Delete();
94 
95  //QA2
96  if (i==0)
97  {
98  H2AdcQa2[a] = (TH2F*)H2TempAdc->Clone(Form("AdcQa2_d%i", a+8));
99  H2AdcQa2[a]->SetTitle(Form("detId=%i;ch;ADC", a+8));
100  }
101  else H2AdcQa2[a]->Add(H2TempAdc);
102 
103  H2TempAdc->Delete();
104  }//a, detId
105  }//i, Loop over runs
106 
107  //--------------------------------------------------------------------
108 
109  #if 1
110  gStyle->SetOptDate(0);
111  gStyle->SetTitleFontSize(0.06);
112 
113  //Draw QA1
114  TCanvas* c1 = new TCanvas("adcQaAll", "AdcQaAll", 1600, 900);
115  c1->Divide(2, 2);
116  for (int a=0; a<4; a++)
117  {
118  c1->cd(a+1)->SetLogz();
119  gPad->SetRightMargin(0.125);
120  H2AdcQa1[a]->SetStats(false);
121  H2AdcQa1[a]->Draw("colz");
122  }
123  if (PRINT) c1->Print(Form("%s.png", c1->GetName()));
124 
125  //-------------------------------------------
126 
127  //Do rough QA + Draw QA1A
128  TCanvas* c1a = new TCanvas("adcQaHit", "AdcQaHit", 1600, 900);
129  c1a->Divide(2, 2);
130  TH1F* H1AdcQa1A[4];
131  vector<int> HotList[4];
132  for (int a=0; a<4; a++)
133  {
134  const int nCh = iToCh[a].size();
135  if (nCh != H2AdcQa1[a]->GetNbinsY()) cout <<"WARNING! # of channels doesn't match!" <<endl;
136  TH1F* H1Temp = (TH1F*)H2AdcQa1[a]->ProjectionY(); //Integrate over all runs
137  H1Temp->Scale(1./nRun);
138 
139  //Get QA histogram
140  const float xMin = 1.e-3;
141  const float xMax = H1Temp->GetMaximum()*1.01;
142  H1AdcQa1A[a] = new TH1F(Form("AdcQa1A_d%i", a+8), "", 150,xMin,xMax);
143  H1AdcQa1A[a]->SetTitle(Form("detId=%i, Drawn x: [%4.3f, %4.3f];nHit/nTrig/nRun", a+8, xMin, xMax));
144  H1AdcQa1A[a]->Sumw2();
145 
146  //Fill
147  for (int b=0; b<nCh; b++)
148  {
149  const float nScaledHit = H1Temp->GetBinContent(b+1);
150  H1AdcQa1A[a]->Fill(nScaledHit);
151  }
152  c1a->cd(a+1);
153  H1AdcQa1A[a]->DrawCopy("hist e");
154 
155  //Get rough hot channel cut
156  const float tempM = H1AdcQa1A[a]->GetMean();
157  const float tempR = H1AdcQa1A[a]->GetRMS();
158  const float tempC = tempM + tempR * cutSig;
159  TLine* L1 = new TLine(tempC, 0, tempC, H1AdcQa1A[a]->GetMaximum());
160  L1->SetLineColor(2);
161  L1->SetLineStyle(2);
162  L1->SetLineWidth(2);
163  L1->Draw("same");
164 
165  for (int b=0; b<nCh; b++)
166  {
167  const int ch = iToCh[a][b];
168  const float nScaledHit = H1Temp->GetBinContent(b+1);
169  if (nScaledHit > tempC)
170  {
171  cout <<Form("Potential hot channels: %2i, %3i", a+8, ch) <<endl;
172  HotList[a].push_back(ch);
173  }
174  }
175 
176  H1Temp->Delete();
177  }//a, detId
178  cout <<Form("Total: %i", HotList[0].size() + HotList[1].size() + HotList[2].size() + HotList[3].size()) <<endl;
179  if (PRINT) c1a->Print(Form("%s.png", c1a->GetName()));
180 
181  //-------------------------------------------
182 
183  //Draw QA2
184  bool showMark = false;
185  bool showHitE = false;
186  bool showMass = false;
187  for (int a=0; a<4; a++) { if (chMarked[a].size() != 0) { showMark = true; break; } }
188  for (int a=0; a<4; a++) { if (chToGain[a].size()!=0 && chToGainCorr[a].size()!=0) { showHitE = true; break; } }
189  for (int a=0; a<4; a++) { DumTH2F[a] = new TH2F(); if (H2Mass[a]->GetEntries() > 0) { showMass = true; break; } }
190 
191  TCanvas* c2;
192  const int nCOL = 4;
193  const int nPAD = 16;
194  int iCVS = 0;
195  int iPAD = 1;
196  for (int a=0; a<4; a++) //detId
197  {
198  if (!showMark)
199  {
200  iCVS = 0;
201  iPAD = 1;
202  }
203 
204  TH2F* H2Temp = (TH2F*)H2AdcQa2[a]->Clone();
205  const int adcMinBin = H2AdcQa2[a]->GetYaxis()->FindBin(adcMin + 0.1); //Cut out pedestal tail
206  for (int x=0; x<H2AdcQa2[a]->GetNbinsX(); x++)
207  for (int y=0; y<adcMinBin; y++)
208  {
209  H2Temp->SetBinContent(x+1, y+1, 0);
210  H2Temp->SetBinError (x+1, y+1, 0);
211  }
212 
213  //Get each ADC spectrum
214  for (unsigned int b=0; b<iToCh[a].size(); b++)
215  {
216  const int ch = iToCh[a][b];
217 
218  //Draw only specified, if showMark is true
219  if (showMark)
220  {
221  bool drawThis = false;
222  for (unsigned int i=0; i<chMarked[a].size(); i++) { if (ch == chMarked[a][i]) drawThis = true; }
223  if (!drawThis) continue;
224  }
225 
226  //Generate new canvas
227  if (iPAD == 1)
228  {
229  const int REX = 400*nCOL;
230  const int REY = 225*nPAD/nCOL;
231  c2 = new TCanvas(Form("adcQaSep%s_%i", showMark?"":Form("_d%i", a+8), iCVS), "", REX, REY);
232  c2->SetTitle(c2->GetName());
233  c2->Divide(nCOL, nPAD/nCOL);
234  }
235  c2->cd(iPAD)->SetLogy();
236 
237  //Draw
238  TH1F* H1 = (TH1F*)H2Temp->ProjectionY(Form("d%i_ch%i", a+8, ch), ch, ch);
239  H1->SetStats(true);
240  H1->GetYaxis()->SetLabelSize(0.055);
241  string Title = chToInfo[a][ch];
242  if (!strcmp(Title.c_str(), "")) Title = Form("d%i_ch%i", a+8, ch);
243  if (H1->GetXaxis()->GetBinUpEdge(H1->GetNbinsX()) > 250)
244  {
245  H1->GetXaxis()->SetRangeUser(0, 250);
246  const int nHitOverflow = H1->Integral(251, H1->GetNbinsX());
247  Title = Form("%s, ADC > 250: %i", Title.c_str(), nHitOverflow);
248  }
249  for (unsigned int c=0; c<HotList[a].size(); c++) { if (ch == HotList[a][c]) H1->SetLineColor(2); }
250  if (chToBS[a].size()!=0 && chToBS[a][ch]>0)
251  {
252  const float scaleF = pow(2, chToBS[a][ch]);
253  H1->Scale(1./scaleF);
254  Title = Form("%s, Scaled (1/2^{%i})", Title.c_str(), chToBS[a][ch]);
255  }
256  if (showHitE) Title = Form("%s, GC = %4.3f", Title.c_str(), chToGainCorr[a][ch]);
257  H1->SetTitle(Title.c_str());
258  H1->DrawCopy("hist e");
259 
260  //Draw hit e distribution with 2nd y axis
261  if (showHitE)
262  {
263  TH1F* H1e = new TH1F(Form("%s_hitE", H1->GetName()), ";hit E", 1000, 0, 250);
264  for (int x=0; x<H1->GetNbinsX(); x++)
265  {
266  if (x > 250) continue;
267  const float tempGain = chToGain[a][ch];
268  const float tempGainCorr = chToGainCorr[a][ch];
269  const float tempHitE = H1->GetBinCenter(x+1) * tempGain * tempGainCorr * 10; //x10
270 
271  const int xBin = H1e->GetXaxis()->FindBin(tempHitE);
272  H1e->SetBinContent(xBin, H1->GetBinContent(x+1));
273  H1e->SetBinError (xBin, H1->GetBinError (x+1));
274  }
275 
276  H1e->SetLineColor(4);
277  H1e->DrawCopy("hist same");
278  }
279 
280  //Draw mass
281  if (showMass)
282  {
283  TPad* tempPad = new TPad(Form("tempPad_d%i_ch%i", a+8, ch), "", 0,0,1,1);
284  tempPad->SetFillColor(0);
285  tempPad->SetFillStyle(4000);
286  tempPad->SetFrameFillStyle(0);
287  tempPad->SetGrid(0, 0);
288  tempPad->SetTicks(0, 0);
289  tempPad->Draw();
290  tempPad->cd();
291 
292  TH1F* H1Mass = (TH1F*)H2Mass[a]->ProjectionY(Form("d%i_ch%i_mass", a+8, ch), ch, ch);
293  H1Mass->SetLineColor(6);
294  H1Mass->SetStats(true);
295  H1Mass->GetXaxis()->SetLabelSize(0);
296  H1Mass->GetXaxis()->SetTitleSize(0);
297  H1Mass->GetYaxis()->SetLabelSize(0);
298  H1Mass->GetYaxis()->SetTitleSize(0);
299  H1Mass->DrawCopy("hist e");
300 
301  TLine* L1Mass = new TLine(0.135, 0, 0.135, H1Mass->GetMaximum());
302  L1Mass->SetLineColor(6);
303  L1Mass->SetLineStyle(2);
304  L1Mass->SetLineWidth(2);
305  L1Mass->Draw("same");
306  //H1Mass->Delete();
307  }
308 
309  //Update pad/canvas index
310  iPAD++;
311  if ( (iPAD == nPAD+1) || (!showMark && b==iToCh[a].size()-1) )
312  {
313  if (PRINT) c2->Print(Form("%s.png", c2->GetName()));
314  iPAD = 1;
315  iCVS++;
316  }
317  }//b, channel
318 
319  H2Temp->Delete();
320  }//a, detId
321  if (PRINT && showMark) c2->Print(Form("%s.png", c2->GetName()));
322 
323  if (PRINT)
324  {
325  gSystem->Exec("mkdir -p adcQa");
326  gSystem->Exec("mv adcQa*.png adcQa");
327  }
328  #endif
329 
330  return;
331 }//DrawAdcQa
332 
333 //-----------
334 void DrawMap(
335  map<int, int> iToCh[4],
336  map<int, st_pos> chToPos[4],
337  const char* mapName = "FMS",
338  bool smallOnly = false,
339  bool showEta = false,
340  bool PRINT = false,
341  map<int, float> chToGainCorr[4] = DumMapF,
342  map<int, int> chToCellStat[4] = DumMapI,
343  vector<int> chMarked[4] = DumVecI
344  )
345 {
346  /*
347  Draw 2D map of FMS cells with additional info
348  - iToCh and chToPos are essentially required
349  - Use chToGainCorr, chToCellStat, and chMarked by necessaity:
350  if not needed, provide dummy map on top of this code as argument
351  */
352 
353  bool showGain = false;
354  bool showStat = false;
355  bool showMark = false;
356  for (int a=0; a<4; a++) { if (chToGainCorr[a].size()!=0) {showGain = true; break;} }
357  for (int a=0; a<4; a++) { if (chToCellStat[a].size()!=0) {showStat = true; break;} }
358  for (int a=0; a<4; a++) { if (chMarked[a].size()!=0) {showMark = true; break;} }
359 
360  //-------------------------------------------
361 
362  gStyle->SetOptDate(0);
363  gStyle->SetOptStat(0);
364 
365  //Draw map frame
366  TCanvas* c1 = new TCanvas(Form("Map%s", mapName), mapName, PRINT?2700:1000, PRINT?2700:1000);
367  c1->cd();
368  const float fBin = (int)(smallOnly?110:210);
369  const float fEnd = fBin/2;
370  TH2F* H2F = new TH2F(Form("FRM%s", mapName), Form("%s;X;Y", c1->GetTitle()), fBin,-fEnd,fEnd, fBin,-fEnd,fEnd);
371  if (showGain)
372  {
373  gPad->SetRightMargin(0.125);
374  H2F->SetMaximum(5.0);
375  H2F->Fill(fEnd, fEnd, H2F->GetMaximum());
376  }
377  H2F->GetYaxis()->SetTitleOffset(1.25);
378  H2F->Draw("colz 9");
379 
380  //Draw rings of eta
381  if (showEta)
382  {
383  const int nRings = smallOnly?10:8;
384  const float stepWidth = smallOnly?0.1:0.2;
385  const float minEta = 4.1 - nRings*stepWidth;
386  H2F->SetTitle(Form("%s, %2.1f #leq #eta #leq 4.1", c1->GetTitle(), minEta));
387  for (int i=0; i<=nRings; i++)
388  {
389  const float tempEta = 4.1 - stepWidth * i;
390  const float tempTheta = 2 * atan(exp(-tempEta));
391  const float tempRadius = tan(tempTheta) * 720.0;
392  TEllipse *E1 = new TEllipse(0, 0, tempRadius);
393  E1->SetFillColor(0);
394  E1->SetFillStyle(4000);
395  E1->SetLineColor(2);
396  E1->SetLineWidth(2);
397  E1->SetLineStyle(2);
398  E1->Draw("same");
399  }
400  }
401 
402  //Draw each cell
403  for (unsigned int a=0; a<4; a++)
404  for (unsigned int b=0; b<iToCh[a].size(); b++)
405  {
406  if (smallOnly && a<2) continue;
407 
408  const int ch = iToCh[a][b];
409  const float x = chToPos[a][ch].chX;
410  const float y = chToPos[a][ch].chY;
411  const float cellHW = a<2?(5.8/2):(3.8/2);
412 
413  int boxColor = 33; //Light cyan
414  if (showGain)
415  {
416  const float gainCorr = chToGainCorr[a][ch];
417  if (fabs(gainCorr) >= H2F->GetMaximum()) boxColor = 100;
418  else boxColor = (int)(fabs(gainCorr * 50.)/H2F->GetMaximum()) + 51;
419  }
420 
421  if (showStat)
422  {
423  const int cellStat = chToCellStat[a][ch];
424  if (cellStat == DEAD) boxColor = showGain?17:0;
425  else if (cellStat == BAD) boxColor = 1;
426  if (!showGain && cellStat == CONVERGED) boxColor = 220; //Light gold
427  }
428 
429  TPaveText* PT = new TPaveText(x-cellHW, y-cellHW, x+cellHW, y+cellHW);
430  PT->SetFillStyle(3001);
431  PT->SetFillColor(boxColor);
432  PT->SetTextColor(kBlack);
433  PT->AddText(Form("%3i", ch));
434  if (showGain) PT->AddText(Form("%4.3f", chToGainCorr[a][ch]));
435  PT->Draw("9");
436 
437  if (showGain && chToCellStat[a][ch]==CONVERGED)
438  {
439  TMarker* MK = new TMarker(x, y, 20);
440  MK->SetMarkerColor(220);
441  if (boxColor>85 && boxColor<95) { MK->SetMarkerStyle(24); MK->SetMarkerColor(1); }
442  MK->SetMarkerSize(PRINT?1.1:0.4);
443  MK->Draw("same");
444  }
445  if (showStat && chToCellStat[a][ch]==DEAD)
446  {
447  TLine* DL1 = new TLine(x-cellHW,y-cellHW,x+cellHW,y+cellHW); DL1->SetLineWidth(2); DL1->Draw("same");
448  TLine* DL2 = new TLine(x-cellHW,y+cellHW,x+cellHW,y-cellHW); DL2->SetLineWidth(2); DL2->Draw("same");
449  }
450  if (showMark)
451  {
452  bool Marked = false;
453  for (unsigned int c=0; c<chMarked[a].size(); c++) { if (ch == chMarked[a][c]) Marked = true; }
454  if (!Marked) continue;
455 
456  const int mCOL = 206; //Dark red
457  PT->SetFillColor(mCOL);
458  PT->SetTextColor(mCOL);
459  TLine* LX1 = new TLine(x-cellHW,y-cellHW,x-cellHW,y+cellHW); LX1->SetLineColor(mCOL); LX1->Draw("same");
460  TLine* LX2 = new TLine(x+cellHW,y-cellHW,x+cellHW,y+cellHW); LX2->SetLineColor(mCOL); LX2->Draw("same");
461  TLine* LY1 = new TLine(x-cellHW,y-cellHW,x+cellHW,y-cellHW); LY1->SetLineColor(mCOL); LY1->Draw("same");
462  TLine* LY2 = new TLine(x-cellHW,y+cellHW,x+cellHW,y+cellHW); LY2->SetLineColor(mCOL); LY2->Draw("same");
463  }
464  }
465 
466  if (PRINT) c1->Print(Form("%s%s%s.png", c1->GetName(), smallOnly?"_small":"", showMark?"_marked":""));
467 
468  return;
469 }//DrawMap
470 
471 //--------------------
472 void DrawCompGainCorr(
473  map<int, int> iToCh[4],
474  map<int, int> chToCellStat[2][4],
475  map<int, float> chToGainCorr[2][4],
476  const char* setName1 = "Set1",
477  const char* setName2 = "Set2",
478  bool PRINT = false,
479  bool excBadDead = false,
480  bool convOnly = false
481  )
482 {
483  //Draw comparison between two different gainCorr set
484 
485  TH1F* H1[2][4]; //Entries vs. gainCorr
486  TGraph* G1[2][4]; //gainCorr vs. ch
487  TGraph* G2[4]; //gainCorr difference divided by 1st set
488  for (int i=0; i<2; i++) //Set
489  for (int a=0; a<4; a++) //detId
490  {
491  H1[i][a] = new TH1F(Form("H1GainCorr_%i_d%i", i, a+8), "", 105, -0.1, 4.1);
492  G1[i][a] = new TGraph();
493  G1[i][a]->SetName(Form("G1GainCorr_%i_d%i", i, a+8));
494  if (i==0)
495  {
496  G2[a] = new TGraph();
497  G2[a]->SetName(Form("G2GainCorrDelta_d%i", a+8));
498  }
499 
500  for (unsigned int b=0; b<iToCh[a].size(); b++)
501  {
502  const int ch = iToCh[a][b];
503 
504  if (convOnly &&
505  chToCellStat[0][a][ch]!=CONVERGED &&
506  chToCellStat[1][a][ch]!=CONVERGED) continue;
507 
508  if (excBadDead &&
509  (chToCellStat[0][a][ch]==BAD ||
510  chToCellStat[1][a][ch]==BAD ||
511  chToCellStat[0][a][ch]==DEAD ||
512  chToCellStat[1][a][ch]==DEAD) ) continue;
513 
514  const float maxGC = H1[i][a]->GetXaxis()->GetBinUpEdge(H1[i][a]->GetNbinsX());
515  float tempGC = chToGainCorr[i][a][ch];
516  if (tempGC > maxGC) tempGC = maxGC;
517 
518  H1[i][a]->Fill(tempGC);
519  G1[i][a]->SetPoint(G1[i][a]->GetN(), ch, tempGC);
520  if (i==0)
521  {
522  const float GC1 = chToGainCorr[0][a][ch];
523  const float GC2 = chToGainCorr[1][a][ch];
524  if (GC1==0. || GC2==0.) continue;
525 
526  //Enforce min/max to 1.5, otherwise b option in TGraph won't draw it
527  float dGC = (GC1 - GC2)/GC1;
528  if (dGC < -1.5) dGC = -1.5;
529  if (dGC > +1.5) dGC = +1.5;
530  G2[a]->SetPoint(G2[a]->GetN(), ch, dGC);
531  }
532  }//b
533  }//i, a
534 
535  //-------------------------------------------
536 
537  gStyle->SetOptDate(0);
538  gStyle->SetOptStat(0);
539 
540  const char* TitleOp = "";
541  if (excBadDead) TitleOp = Form("%s, Excluded Bad/Dead", TitleOp);
542  if (convOnly) TitleOp = Form("%s, Converged Only", TitleOp);
543 
544  TCanvas* c1[3];
545  for (int x=0; x<3; x++)
546  {
547  c1[x] = new TCanvas(Form("GCcomp%i_%sVs%s", x, setName1, setName2), "", 1600, 900);
548  c1[x]->SetTitle(c1[x]->GetName());
549  c1[x]->Divide(2, 2);
550  }
551 
552  for (int i=0; i<2; i++)
553  for (int a=0; a<4; a++)
554  {
555  c1[0]->cd(a+1);
556  H1[i][a]->SetLineColor(i+1);
557  if (i==0)
558  {
559  H1[i][a]->SetTitle(Form("detId=%i%s;gainCorr", a+8, TitleOp));
560  const float max0 = H1[0][a]->GetMaximum();
561  const float max1 = H1[1][a]->GetMaximum();
562  if (max1 > max0) H1[0][a]->SetMaximum(max1*1.1);
563  }
564  if (i==1)
565  {
566  H1[i][a]->SetFillColor(i+1);
567  H1[i][a]->SetFillStyle(3001);
568  TLegend *L1 = new TLegend(0.70, 0.75, 0.95, 0.95);
569  L1->SetMargin(0.2);
570  L1->SetTextAlign(22);
571  L1->AddEntry(H1[0][a], Form("%s, RMS: %4.3f", setName1, H1[0][a]->GetRMS()), "l");
572  L1->AddEntry(H1[1][a], Form("%s, RMS: %4.3f", setName2, H1[1][a]->GetRMS()), "lf");
573  L1->Draw("same");
574  }
575  H1[i][a]->DrawCopy(i==0?"hist e":"hist ef same");
576 
577  c1[1]->cd(a+1);
578  const char* TitleG1 = Form("detId=%i%s;ch;gainCorr", a+8, TitleOp);
579  if (i==0) gPad->DrawFrame(-10,-0.2,a<2?588:298,4.2, TitleG1);
580  G1[i][a]->SetMarkerSize(0.85);
581  G1[i][a]->SetMarkerColor(i+1);
582  G1[i][a]->SetMarkerStyle(i*4 + 20);
583  G1[i][a]->Draw("p same");
584  if (i==1 && a==0)
585  {
586  TLegend *L2 = new TLegend(0.65, 0.80, 0.95, 0.95);
587  L2->SetMargin(0.2);
588  L2->SetTextAlign(22);
589  L2->AddEntry(G1[0][a], setName1, "p");
590  L2->AddEntry(G1[1][a], setName2, "p");
591  L2->Draw("same");
592  }
593 
594  if (i==0)
595  {
596  c1[2]->cd(a+1);
597  const char* TitleG2 = Form("detId=%i%s;ch;#DeltagainCorr (%s-%s)/%s",
598  a+8, TitleOp, setName1, setName2, setName1);
599  gPad->DrawFrame(-10, -1.5, a<2?588:298, 1.5, TitleG2);
600  G2[a]->SetFillColor(2);
601  G2[a]->SetFillStyle(3001);
602  G2[a]->Draw("b same");
603  }
604  }//i, a
605 
606  if (PRINT)
607  {
608  for (int x=0; x<3; x++)
609  {
610  c1[x]->Print(Form("%s%s%s.png", c1[x]->GetName(), excBadDead?"_excBD":"", convOnly?"_conv":""));
611  }
612  }
613 
614  return;
615 }//DrawCompGainCorr
616 
617 //-------------------
618 void DrawCompMassAll(
619  map<int, int> iToCh[4],
620  const int nComp,
621  TH1F* (*H1)[4],
622  bool Normalize = false,
623  bool PRINT = false
624  )
625 {
626  /*
627  Draw comparison of mass distributions
628  - Draw inclusive mass separated by detId
629  - Can enforce nomalization by its own height to compare width
630  */
631 
632  gStyle->SetOptDate(0);
633  gStyle->SetOptStat(0);
634 
635  TCanvas* c1 = new TCanvas("massAll", "massAll", 1600, 900);
636  c1->Divide(2, 2);
637 
638  for (int a=0; a<4; a++)
639  {
640  c1->cd(a+1);
641 
642  TLegend* LEG = new TLegend(0.6, 0.85-nComp*0.055, 0.85, 0.85);
643  LEG->SetMargin(0.3);
644 
645  float yMax = 0;
646  for (int i=0; i<nComp; i++)
647  {
648  if (H1[i][a]->GetMaximum()*1.1 > yMax) yMax = H1[i][a]->GetMaximum()*1.1;
649  }
650 
651  for (int i=0; i<nComp; i++)
652  {
653  TH1F* H1Temp = (TH1F*)H1[i][a]->Clone(Form("d%i_i%i", a+8, i));
654  H1Temp->SetTitle(Form("detId=%i", a+8));
655 
656  if (Normalize) H1Temp->Scale(1/H1Temp->GetMaximum());
657  else H1Temp->SetMaximum(yMax);
658 
659  H1Temp->SetLineColor((i+1)!=5?(i+1):95);
660  if (i==nComp-1)
661  {
662  H1Temp->SetFillColor(H1Temp->GetLineColor());
663  H1Temp->SetFillStyle(3001);
664  }
665  H1Temp->DrawCopy(i==0?"hist e":"hist e same");
666 
667  //Vertical pi0 line
668  if (i==nComp-1)
669  {
670  TLine* L1 = new TLine(0.135, 0, 0.135, H1Temp->GetMaximum());
671  L1->SetLineColor(1);
672  L1->SetLineStyle(2);
673  L1->SetLineWidth(2);
674  L1->Draw("same");
675  }
676 
677  //Legend: get title from given TH1 histogram, NOT temporary one
678  LEG->AddEntry(H1Temp, H1[i][a]->GetTitle(), "lf");
679  if (i==nComp-1) LEG->Draw("same");
680  }//i, iteration index
681  }//a, detId
682  if (PRINT) c1->Print(Form("%s%s.png", c1->GetName(), Normalize?"_norm":""));
683 
684  return;
685 }//DrawCompMassAll
686 
687 //-------------------
688 void DrawCompMassSep(
689  map<int, int> iToCh[4],
690  const int nComp,
691  TH2F* (*H2)[4],
692  bool Normalize = false,
693  bool PRINT = false,
694  map<int, string> chToInfo[4] = DumMapS,
695  vector<int> chMarked[4] = DumVecI
696  )
697 {
698  /*
699  Draw comparison of mass distributions
700  - Draw mass distribution cell by cell
701  - Can draw only a few selective channels in chMarked
702  - Can enforce nomalization by its own height to compare width
703  */
704 
705  bool showMark = false;
706  for (int a=0; a<4; a++) { if (chMarked[a].size() != 0) { showMark = true; break; } }
707 
708  //-------------------------------------------
709 
710  gStyle->SetOptDate(0);
711  gStyle->SetOptStat(0);
712  gStyle->SetTitleFontSize(0.06);
713 
714  TCanvas* c1;
715  const int nCOL = 4;
716  const int nPAD = 16;
717  int iCVS = 0;
718  int iPAD = 1;
719 
720  for (int a=0; a<4; a++) //detId
721  {
722  if (!showMark)
723  {
724  iCVS = 0;
725  iPAD = 1;
726  }
727 
728  for (unsigned int b=0; b<iToCh[a].size(); b++)
729  {
730  const int ch = iToCh[a][b];
731 
732  //Draw only specified, if showMark is true
733  if (showMark)
734  {
735  bool drawThis = false;
736  for (unsigned int i=0; i<chMarked[a].size(); i++) { if (ch == chMarked[a][i]) drawThis = true; }
737  if (!drawThis) continue;
738  }
739 
740  //Generate new canvas
741  if (iPAD == 1)
742  {
743  const int REX = 400*nCOL;
744  const int REY = 225*nPAD/nCOL;
745  c1 = new TCanvas(Form("massSep%s_%i", showMark?"":Form("_d%i", a+8), iCVS), "", REX, REY);
746  c1->SetTitle(c1->GetName());
747  c1->Divide(nCOL, nPAD/nCOL);
748  }
749  c1->cd(iPAD);
750 
751  //Get maximum
752  float yMax = 0;
753  for (int i=0; i<nComp; i++)
754  {
755  TH1F* H1 = (TH1F*)H2[i][a]->ProjectionY("H1Temp", ch, ch);
756  if (H1->GetNbinsX() == 250) H1->Rebin(5);
757  if (H1->GetMaximum()*1.1 > yMax) yMax = H1->GetMaximum()*1.1;
758  H1->Delete();
759  }
760 
761  //Draw
762  for (int i=0; i<nComp; i++)
763  {
764  TH1F* H1 = (TH1F*)H2[i][a]->ProjectionY(Form("d%i_ch%i_%i", a+8, ch, i), ch, ch);
765  if (H1->GetNbinsX() == 250) H1->Rebin(5);
766  if (Normalize && H1->GetEntries()!=0) H1->Scale(1/H1->GetMaximum());
767  else H1->SetMaximum(yMax);
768 
769  if (i==0)
770  {
771  string Title = chToInfo[a][ch];
772  if (!strcmp(Title.c_str(), "")) Title = Form("d%i_ch%i", a+8, ch);
773  H1->SetTitle(Title.c_str());
774  }
775 
776  H1->SetLineColor((i+1)!=5?(i+1):95);
777  if (i==nComp-1 && i!=0)
778  {
779  H1->SetFillColor(H1->GetLineColor());
780  H1->SetFillStyle(3001);
781  }
782  H1->DrawCopy(i==0?"hist e":"hist e same");
783 
784  if (i==nComp-1)
785  {
786  TLine* L1 = new TLine(0.135, 0, 0.135, H1->GetMaximum());
787  L1->SetLineColor(1);
788  L1->SetLineStyle(2);
789  L1->SetLineWidth(2);
790  L1->Draw("same");
791  }
792 
793  H1->Delete();
794  }//i
795 
796  //Update pad/canvas index
797  iPAD++;
798  if ( (iPAD == nPAD+1) || (!showMark && b==iToCh[a].size()-1) )
799  {
800  if (PRINT) c1->Print(Form("%s%s.png", c1->GetName(), Normalize?"_norm":""));
801  iPAD = 1;
802  iCVS++;
803  }
804  }//b, channel
805  }//a, detId
806  if (PRINT && showMark) c1->Print(Form("%s%s.png", c1->GetName(), Normalize?"_norm":""));
807 
808  if (PRINT)
809  {
810  gSystem->Exec(Form("mkdir -p massComp%s", Normalize?"_norm":""));
811  gSystem->Exec(Form("mv massSep*.png massComp%s", Normalize?"_norm":""));
812  }
813 
814  return;
815 }//DrawCompMassSep
816 
817 //--------------------
818 void DrawConvProgress(
819  const int nIter,
820  const char* pathIter,
821  map<int, int>iToCh[4],
822  bool excBadDead = false, //Always get bad/dead cells from 1st available FmsCellStat.txt
823  bool PRINT = false
824  )
825 {
826  //Draw progress of convergence over iterations
827 
828  int nCellAll = 1264;
829  int nCellSep[4];
830  for (unsigned int a=0; a<4; a++) nCellSep[a] = iToCh[a].size();
831 
832  TGraphErrors* G1All = new TGraphErrors();
833  TGraphErrors* G1Sep[4];
834  for (int a=0; a<4; a++) G1Sep[a] = new TGraphErrors();
835 
836  bool checkedFirstSet = false;
837  for (int i=0; i<nIter; i++)
838  {
839  const char* cellStatFile = Form("%s/FmsCellStat_%i.txt", pathIter, i);
840  if (FILE *FTest = fopen(cellStatFile, "r")) fclose(FTest);
841  else continue;
842 
843  map<int, int> chToCellStatIter[4];
844  GetMapChToCellStat(cellStatFile, chToCellStatIter);
845 
846  //Check # of valid cells
847  if (excBadDead==true && checkedFirstSet==false)
848  {
849  for (unsigned int a=0; a<4; a++)
850  {
851  for (unsigned int b=0; b<iToCh[a].size(); b++)
852  {
853  const int ch = iToCh[a][b];
854  const int cellStat = chToCellStatIter[a][ch];
855  if (cellStat==BAD || cellStat==DEAD)
856  {
857  nCellAll--;
858  nCellSep[a]--;
859  }
860  }//b
861  cout <<Form("# of valid cells (detId=%2i): %3i", a+8, nCellSep[a]) <<endl;
862  }//a
863  cout <<Form("# of valid cells (total): %i", nCellAll) <<endl;
864  checkedFirstSet = true;
865  }
866 
867  //Count # of converged cells in this iteration
868  int nConvAll = 0;
869  int nConvSep[4] = {0};
870  float rConvSep[4] = {0};
871  for (int a=0; a<4; a++)
872  {
873  for (unsigned int b=0; b<iToCh[a].size(); b++)
874  {
875  const int ch = iToCh[a][b];
876  if (chToCellStatIter[a][ch] == CONVERGED)
877  {
878  nConvAll++;
879  nConvSep[a]++;
880  }
881  }
882  rConvSep[a] = (float)nConvSep[a]/(float)nCellSep[a];
883  G1Sep[a]->SetPoint(G1Sep[a]->GetN(), i, rConvSep[a]);
884  }//a
885  const float rConvAll = (float)nConvAll/(float)nCellAll;
886  G1All->SetPoint(G1All->GetN(), i, rConvAll);
887  }//i, iterations
888 
889  gStyle->SetOptDate(0);
890  gStyle->SetOptStat(0);
891 
892  TLegend* LEG = new TLegend(0.55, 0.225, 0.825, 0.375);
893  LEG->SetMargin(0.35);
894  TCanvas* c1 = new TCanvas("convProg", "Convergence ratio over iterations", 1600, 900);
895  c1->Divide(2, 2);
896  for (int a=0; a<4; a++)
897  {
898  const char* tempTitle1 = excBadDead?", Excluded Bad/Dead":"";
899  const char* tempTitle2 = Form("detId=%i%s;Iteration index;Convergence ratio", a+8, tempTitle1);
900  c1->cd(a+1)->DrawFrame(-1, -0.05, nIter, 1.05, tempTitle2);
901  G1Sep[a]->SetMarkerSize(1.1);
902  G1Sep[a]->SetMarkerStyle(20);
903  G1Sep[a]->Draw("pl same");
904 
905  if (a==0)
906  {
907  G1All->SetLineColor(2);
908  G1All->SetMarkerColor(2);
909  G1All->SetMarkerSize(1.1);
910  G1All->SetMarkerStyle(24);
911 
912  LEG->AddEntry(G1Sep[a], Form("Ratio (each detId)"), "pl");
913  LEG->AddEntry(G1All, Form("Ratio (all)"), "pl");
914  LEG->Draw("same");
915  }
916  G1All->Draw("pl same");
917  }
918  if (PRINT) c1->Print(Form("%s%s.png", c1->GetName(), excBadDead?"_excBD":""));
919 
920  return;
921 }//DrawConvProgress
922 
923 //----------------
924 void DrawIterMass(
925  const int nIter,
926  const char* pathIter,
927  map<int, int> iToCh[4],
928  map<int, int> chToCellStat[4],
929  bool PRINT = false,
930  vector<int> chMarked[4] = DumVecI
931  )
932 {
933  //Draw a cell's mass distribution over multiple iterations
934 
935  bool showMark = false;
936  for (int a=0; a<4; a++) { if (chMarked[a].size() != 0) { showMark = true; break; } }
937 
938  //-------------------------------------------
939 
940  gStyle->SetOptDate(0);
941 
942  TFile* F[nIter];
943  TCanvas* c1;
944  const int nCOL = 3;
945  const int nPAD = 9;
946  int iCVS = 0;
947  int iPAD = 1;
948 
949  for (int a=0; a<4; a++) //detId
950  {
951  if (!showMark)
952  {
953  iCVS = 0;
954  iPAD = 1;
955  }
956 
957  for (unsigned int b=0; b<iToCh[a].size(); b++)
958  {
959  const int ch = iToCh[a][b];
960  if (!showMark && (chToCellStat[a][ch]==BAD || chToCellStat[a][ch]==DEAD))
961  {
962  cout <<Form("Invalid channel: detId%i_ch%i, skip...", a+8, ch) <<endl;
963  continue;
964  }
965 
966  //Draw only specified, if showMark is true
967  if (showMark)
968  {
969  bool drawThis = false;
970  for (unsigned int i=0; i<chMarked[a].size(); i++) { if (ch == chMarked[a][i]) drawThis = true; }
971  if (!drawThis) continue;
972  }
973 
974  //Loop over iteration index
975  iCVS = 0;
976  iPAD = 1;
977  for (int i=0; i<nIter; i++)
978  {
979  F[i] = TFile::Open(Form("%s/out_fmsCalib_%i.root", pathIter, i));
980  if (iPAD == 1)
981  {
982  c1 = new TCanvas(Form("mass_d%i_ch%i_%i", a+8, ch, iCVS), "", 400*nCOL, 300*(nPAD/nCOL));
983  c1->SetTitle(c1->GetName());
984  c1->Divide(nCOL, nPAD/nCOL);
985  }
986 
987  //Draw
988  TCanvas* tempCVS = (TCanvas*)F[i]->Get(Form("mass_d%i_ch%i", a+8, ch))->Clone();
989  c1->cd(iPAD);
990  tempCVS->DrawClonePad();
991  iPAD++;
992 
993  //Update pad/canvas
994  if ( (iPAD==nPAD+1) || (iPAD>nIter) || (!showMark && b==iToCh[a].size()) || (showMark && i==nIter-1) )
995  {
996  if (PRINT) c1->Print(Form("%s.png", c1->GetName()));
997  iPAD = 1;
998  iCVS++;
999  }
1000  }//i, iteration
1001 
1002  for (int i=0; i<nIter; i++) F[i]->Close(); //FUCKING STUPID ROOT...
1003  }//b, channel
1004  }//a, detId
1005 
1006  if (PRINT)
1007  {
1008  gSystem->Exec("mkdir -p iterMass");
1009  gSystem->Exec("mv *.png iterMass");
1010  }
1011 
1012  return;
1013 }//DrawIterMass
1014 
1015 //----------------------
1016 void DrawIterMassSingle(
1017  const int iIter,
1018  const char* pathIter,
1019  vector<int> chMarked[4] = DumVecI,
1020  const char* outDir = "iterMass"
1021  )
1022 {
1023  //Printout entire channel by channel mass distribution of an iteration index
1024 
1025  bool showMark = false;
1026  for (int a=0; a<4; a++) { if (chMarked[a].size() != 0) { showMark = true; break; } }
1027 
1028  //-------------------------------------------
1029 
1030  gStyle->SetOptDate(0);
1031 
1032  TFile* F = TFile::Open(Form("%s/out_fmsCalib_%i.root", pathIter, iIter));
1033  if (!F || F->IsZombie()) return;
1034 
1035  TDirectory* cDir = gDirectory;
1036  TIter keyNext(cDir->GetListOfKeys());
1037  TKey* keyOld = 0;
1038  TKey* keyNew;
1039  TObject* obj;
1040 
1041  while (keyNew = (TKey*)keyNext())
1042  {
1043  if (showMark)
1044  {
1045  bool Proceed = false;
1046  for (unsigned int a=0; a<4; a++)
1047  for (unsigned int b=0; b<chMarked[a].size(); b++)
1048  {
1049  const char* chMarkedName = Form("mass_d%i_ch%i", a+8, chMarked[a][b]);
1050  if (!strcmp(chMarkedName, keyNew->GetName())) Proceed = true;
1051  }
1052  if (!Proceed) continue;
1053  }
1054 
1055  if (keyOld && !strcmp(keyOld->GetName(), keyNew->GetName())) continue;
1056  obj = keyNew->ReadObj();
1057  obj->Draw();
1058  obj->Print(Form("%s.png", obj->GetName()));
1059  }
1060 
1061  gSystem->Exec(Form("mkdir -p %s_i%i", outDir, iIter));
1062  gSystem->Exec(Form("mv mass_*.png %s_i%i", outDir, iIter));
1063  F->Close();
1064 
1065  return;
1066 }//DrawIterMassSingle
1067 
1068 //-----------------
1069 void DrawIterPars(
1070  const int nIter,
1071  const char* pathIter,
1072  map<int, int> iToCh[4],
1073  map<int, int> chToCellStat[4], //Use cellStat file in final iteration index
1074  bool PRINT = false,
1075  vector<int> chMarked[4] = DumVecI
1076  )
1077 {
1078  /*
1079  Draw parameters vs. iteration index, channel by channel
1080 
1081  - Chi2/NDF, Mass (obtained by fit), Width, and gainCorr applied
1082  - Can draw only a few selective channels in chMarked
1083  */
1084 
1085  bool showMark = false;
1086  for (int a=0; a<4; a++) { if (chMarked[a].size() != 0) { showMark = true; break; } }
1087 
1088  //-------------------------------------------
1089 
1090  //Read iteration results
1091  map<int, float> chToGainCorr[nIter][4];
1092  map<int, st_fitR> chToFitR[nIter][4];
1093  for (int i=0; i<nIter; i++)
1094  {
1095  GetMapChToGainCorr(Form("%s/FmsGainCorr_%i.txt", pathIter, i), chToGainCorr[i]);
1096  GetMapChToFitR(Form("%s/out_fmsCalibFit_%i.txt", pathIter, i), chToFitR[i]);
1097  }
1098 
1099  gStyle->SetOptDate(0);
1100  gStyle->SetOptStat(0);
1101  gStyle->SetLabelSize(0.055, "xyz");
1102  gStyle->SetTitleSize(0.060, "xyz");
1103  gStyle->SetTitleOffset(0.75, "xyz");
1104  gStyle->SetTitleFontSize(0.055);
1105 
1106  for (unsigned int a=0; a<4; a++)
1107  for (unsigned int b=0; b<iToCh[a].size(); b++)
1108  {
1109  const int detId = a+8;
1110  const int ch = iToCh[a][b];
1111  if (chToCellStat[a][ch]==BAD || chToCellStat[a][ch]==DEAD) continue;
1112 
1113  //Draw only specified, if showMark is true
1114  if (showMark)
1115  {
1116  bool drawThis = false;
1117  for (unsigned int i=0; i<chMarked[a].size(); i++) { if (ch == chMarked[a][i]) drawThis = true; }
1118  if (!drawThis) continue;
1119  }
1120 
1121  //Prepare graphs for chi2, mass, width, and gainCorr
1122  TGraphErrors* G1[4];
1123  for (int x=0; x<4; x++)
1124  {
1125  G1[x] = new TGraphErrors();
1126  G1[x]->SetName(Form("G1_d%i_ch%i_%i", detId, ch, x));
1127  G1[x]->SetLineColor(x+1);
1128  G1[x]->SetMarkerColor(x+1);
1129  G1[x]->SetMarkerStyle(20);
1130  }
1131 
1132  //Fill the graphs
1133  for (int i=0; i<nIter; i++)
1134  {
1135  const float chi2 = chToFitR[i][a][ch].chi2;
1136  const float mass = chToFitR[i][a][ch].mass;
1137  const float massErr = chToFitR[i][a][ch].massErr;
1138  const float width = chToFitR[i][a][ch].width;
1139  const float widthErr = chToFitR[i][a][ch].widthErr;
1140  const float gainCorr = chToGainCorr[i][a][ch];
1141 
1142  G1[0]->SetPoint(G1[0]->GetN(), i, chi2);
1143  G1[1]->SetPoint(G1[1]->GetN(), i, mass);
1144  G1[2]->SetPoint(G1[2]->GetN(), i, width);
1145  G1[3]->SetPoint(G1[3]->GetN(), i, gainCorr);
1146  G1[1]->SetPointError(G1[1]->GetN()-1, 0, massErr);
1147  G1[2]->SetPointError(G1[2]->GetN()-1, 0, widthErr);
1148  }
1149  if (G1[0]->GetN() == 0) continue;
1150 
1151  TCanvas* c1 = new TCanvas(Form("d%i_ch%i", detId, ch), Form("detId=%i, ch=%i", detId, ch), 800, 1000);
1152  c1->Divide(1, 4);
1153  TLine *L1[4];
1154  for (int x=0; x<4; x++)
1155  {
1156  const char* statTitle = (chToCellStat[a][ch]==CONVERGED)?"CONVERGED, ":"";
1157  const char* subTitle = "";
1158  if (x==0) subTitle = Form("chi2;Iteration;chi2/NDF");
1159  if (x==1) subTitle = Form("mass;Iteration;mass");
1160  if (x==2) subTitle = Form("width;Iteration;width");
1161  if (x==3) subTitle = Form("gainCorr;Iteration;gainCorr");
1162  const char* lastTitle = Form("%s%s, %s", statTitle, c1->GetTitle(), subTitle);
1163 
1164  const float yMin = G1[x]->GetHistogram()->GetMinimum()*0.9;
1165  const float yMax = G1[x]->GetHistogram()->GetMaximum()*1.1;
1166  c1->cd(x+1)->DrawFrame(-1,yMin,nIter,yMax, lastTitle);
1167  G1[x]->Draw("lp");
1168 
1169  float yLine;
1170  if (x==0) yLine = 1.0;
1171  if (x==1) yLine = 0.135;
1172  if (x==2) yLine = (a<2)?0.02:0.03;
1173  if (x==3) yLine = 1.0;
1174  L1[x] = new TLine(-1, yLine, nIter, yLine);
1175  L1[x]->SetLineColor(6);
1176  L1[x]->SetLineStyle(2);
1177  L1[x]->SetLineWidth(2);
1178  if (yLine>yMin && yLine<yMax) L1[x]->Draw("same");
1179  }
1180 
1181  if (PRINT)
1182  {
1183  c1->Print(Form("iterPars_%s%s.png", c1->GetName(), (chToCellStat[a][ch]==CONVERGED)?"_CONV":""));
1184  for (int x=0; x<4; x++) { G1[x]->Delete(); L1[x]->Delete(); }
1185  delete c1;
1186  }
1187 
1188  }//a (detId), b (ch)
1189 
1190  if (PRINT)
1191  {
1192  gSystem->Exec("mkdir -p iterPars");
1193  gSystem->Exec("mv *.png iterPars");
1194  }
1195 
1196  return;
1197 }//DrawIterPars