AliPhysics  2c6b7ad (2c6b7ad)
MultiplyPi0CalibrationFactors_TextToHisto.C
Go to the documentation of this file.
1 #include <TChain.h>
2 #include <TNtuple.h>
3 #include <TObjArray.h>
4 #include <TSystem.h>
5 #include <TString.h>
6 #include <TH1F.h>
7 #include <TVector.h>
8 #include <TRefArray.h>
9 #include <TArrayS.h>
10 #include "TError.h"
11 #include "TTree.h"
12 #include "TClonesArray.h"
13 #include "TGraphErrors.h"
14 #include "TPostScript.h"
15 #include "TLegend.h"
16 #include "TH2I.h"
17 #include "TF1.h"
18 #include "TStyle.h"
19 #include "TCanvas.h"
20 #include "TPolyLine.h"
21 #include "TLine.h"
22 #include "TFile.h"
23 #include "TMath.h"
24 #include "TLeaf.h"
25 #include "TBranch.h"
26 
27 //#include "/cebaf/cebaf/EMCAL/cosmicsAnalysis/macros/defineMyPalette40All.C"
28 
40 
45 {int a,b,c,d,aTot,bTot,cTot,dTot,i,j,jFile,kNbFiles,iSM;
46  float e,eTot;
47  double minHist,maxHist,minHistProduct;
48 
49 
50  char SMP2Name[][100]={"SMA0","SMC0","SMA1","SMC1","SMA2","SMC2","SMA3","SMC3","SMA4","SMC4","SMA5","SMC5","SMA9","SMC9","SMA10","SMC10","SMA11","SMC11","SMA12","SMC12"};
51  char SMnumber[][100]={"0","1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18","19"};
52 
54  int detTypeType[]={kEMCAL,kEMCALthird,kDCAL,kDCALthird};
55  char detTypeString[][100]={"EMCAL","EMCALthird","DCAL","DCALthird"};
57  const int kNbColEMCAL=48;
58  const int kNbRowEMCAL=24;
59  const int kNbSMEMCAL=10;
60  const int kNbColEMCALthird=kNbColEMCAL;
61  const int kNbRowEMCALthird=(int)(kNbRowEMCAL/3);
62  const int kNbSMEMCALthird=2;
63  const int kNbColDCAL=32;
64  const int kNbRowDCAL=kNbRowEMCAL;
65  const int kNbSMDCAL=6;
68  const int kNbSMDCALthird=2;
69  const int kNbSMtot=kNbSMEMCAL+kNbSMEMCALthird+kNbSMDCAL+kNbSMDCALthird;
70  const int kTabNbCol[4]={kNbColEMCAL,kNbColEMCALthird,kNbColDCAL,kNbColDCALthird};
71  const int kTabNbRow[4]={kNbRowEMCAL,kNbRowEMCALthird,kNbRowDCAL,kNbRowDCALthird};
72  const int kTabNbSM[4]={kNbSMEMCAL,kNbSMEMCALthird,kNbSMDCAL,kNbSMDCALthird};
73  const int kNbColMax=kNbColEMCAL;
74  const int kNbRowMax=kNbRowEMCAL;
75  const int kNbColOffsetDCAL=kNbColEMCAL-kNbColDCAL;
76 
77 
78  //CUSTOMIZE customize :
79  kNbFiles=5;
80  //kNbFiles=2; To create special files like that for Anders.
81 
82 
83  char psfile[150];
84  FILE *txtFileOut = NULL;
85 
86  //Standard calibration process :
87  txtFileOut = fopen(Form("multiplyPi0CalibrationFactors_TextToHisto_forIter%d.txt",kNbFiles),"w");
88  TFile * f = new TFile(Form("multiplyPi0CalibrationFactors_TextToHisto_forIter%d.root",kNbFiles),"recreate");
89  sprintf(psfile,Form("multiplyPi0CalibrationFactors_TextToHisto_forIter%d.ps",kNbFiles));
90 
91  //calib 2012 coeff for EMCAL, and DCAL + third SMs coeffs at 1.0 :
92  /*txtFileOut = fopen("multiplyPi0CalibrationFactors_TextToHisto_forEMCALandDCALwith2012coeffs.txt","w");
93  TFile * f = new TFile("multiplyPi0CalibrationFactors_TextToHisto_forEMCALandDCALwith2012coeffs.root","recreate");
94  sprintf(psfile,"multiplyPi0CalibrationFactors_TextToHisto_forEMCALandDCALwith2012coeffs.ps");*/
95 
96  //calib 2012 coeff for EMCAL (pi0 only, no E-spectrum calib), and DCAL + third SMs coeffs at 1.0 :
97  /*txtFileOut = fopen("multiplyPi0CalibrationFactors_TextToHisto_EMCALcoeffs2012pizOnlyNoEspectra_DCALandThirdsAllOne.txt","w");
98  TFile * f = new TFile("multiplyPi0CalibrationFactors_TextToHisto_EMCALcoeffs2012pizOnlyNoEspectra_DCALandThirdsAllOne.root","recreate");
99  sprintf(psfile,"multiplyPi0CalibrationFactors_TextToHisto_EMCALcoeffs2012pizOnlyNoEspectra_DCALandThirdsAllOne.ps");*/
100 
101  //calib 2012 coeff for EMCAL (pi0 only, no E-spectrum calib), and DCAL + third SMs coeffs as obtained after pass2 :
102  /*txtFileOut = fopen("multiplyPi0CalibrationFactors_TextToHisto_forIter3WithAndersValues.txt","w");
103  TFile * f = new TFile("multiplyPi0CalibrationFactors_TextToHisto_forIter3WithAndersValues.root","recreate");
104  sprintf(psfile,"multiplyPi0CalibrationFactors_TextToHisto_forIter3WithAndersValues.ps");*/
105 
106  //defineMyPalette40All(30,5);
107 
108  //Coeff files to be read and multiplied :
109  FILE **calibCoeffsInput;
110  calibCoeffsInput = new FILE*[kNbFiles];
111  //CUSTOMIZE customize :
112  //calibCoeffsInput[0] = fopen("/cebaf/cebaf/EMCAL/calibPi0_run2/calibPi0_4_with2015data/output/pass0_mergedDCALandThirdSMs/output_calibPi0_coeffs_clean.txt","r");
113  calibCoeffsInput[0] = fopen("/cebaf/cebaf/EMCAL/calibPi0_run2/calibPi0_4_with2015data/output/pass0_mergedDCALandThirdSMs/output_calibPi0_coeffs_clean_veryHighTowers.txt","r"); //Chosen among various pass0, for pass1.
114  //calibCoeffsInput[1] = fopen("/cebaf/cebaf/EMCAL/calibPi0_run2/calibPi0_4_with2015data/output/pass1_DCALandThirdSMs/output_calibPi0_coeffs_clean.txt","r");
115  calibCoeffsInput[1] = fopen("/cebaf/cebaf/EMCAL/calibPi0_run2/calibPi0_4_with2015data/output/pass1_DCALandThirdSMs/output_calibPi0_coeffs_clean_veryHighTowers.txt","r"); //Chosen among various pass1, for pass2.
116  //calibCoeffsInput[2] = fopen("/cebaf/cebaf/EMCAL/calibPi0_run2/calibPi0_4_with2015data/output/pass2_DCALandThirdSMsVeryHighTowers/output_calibPi0_coeffs_clean.txt","r"); //Chosen in 2015 among various pass2, for pass3.
117  //calibCoeffsInput[2] = fopen("/cebaf/cebaf/EMCAL/calibPi0_run2/calibPi0_4_with2015data/output/pass2_DCALandThirdSMsVeryHighTowers/output_calibPi0_coeffs_clean_veryHighGains.txt","r");
118  //calibCoeffsInput[2] = fopen("/cebaf/cebaf/EMCAL/calibPi0_run2/calibPi0_4_with2015data/output/pass2_DCALandThirdSMsVeryHighTowers/output_calibPi0_coeffs_clean_finalFile4HVcalculation.txt","r"); //Chosen in 2015 among various pass2, for the 2015 new HV calculation.
119  calibCoeffsInput[2] = fopen("/cebaf/cebaf/EMCAL/calibPi0_run2/calibPi0_4_with2015data/output/pass2_DCALandThirdSMsVeryHighTowers/output_calibPi0_coeffs_clean_AndersCorrectionTowersVeryFar.txt","r"); //Chosen in 2016 among various pass2, for pass3 : includes correction for towers with peak very far from PDG mass.
120  calibCoeffsInput[3] = fopen("/cebaf/cebaf/EMCAL/calibPi0_run2/calibPi0_4_with2015data/output/pass3_DCALandThirdSMsWithAndersCoeffsTowersVeryFarFromPDG/output_calibPi0_coeffs_cleanForMultiply.txt","r"); //Chosen among various pass3, for pass4.
121  calibCoeffsInput[4] = fopen("/cebaf/cebaf/EMCAL/calibPi0_run2/calibPi0_4_with2015data/output/pass4_DCALandEMCALThirds/output_calibPi0_coeffs_cleanForMultiply.txt","r"); //From pass4, for pass5.
122 
123  //calib 2012 coeff for EMCAL, and DCAL + third SMs coeffs at 1.0 :
124  //(The EMCAL coeffs come from /cebaf/cebaf/EMCAL/calibPi0/RecalibrationFactors2012_10SM_final.txt and include the E spectra coeffs).
125  //calibCoeffsInput[0] = fopen("/cebaf/cebaf/EMCAL/calibPi0_run2/calibPi0_4_with2015data/calib2012onEMCALandDCAL/multiplyPi0CalibrationFactors2012WithFakeValuesForDCALandThirds_TextToHisto_Final.txt","r");
126 
127  //calib 2012 coeff for EMCAL (pi0 only, no E-spectrum calib), and DCAL + third SMs coeffs at 1.0 :
128  //calibCoeffsInput[0] = fopen("/cebaf/cebaf/EMCAL/calibPi0_run2/calibPi0_4_with2015data/calib2012onEMCALandDCAL/RecalibrationFactors2012_10SM_iter8_addDCALandThirdsAllOne.txt","r");
129 
130  //calib 2012 coeff for EMCAL (pi0 only, no E-spectrum calib), and DCAL + third SMs coeffs as obtained after pass2 :
131  //calibCoeffsInput[0] = fopen("/cebaf/cebaf/EMCAL/calibPi0_run2/calibPi0_4_with2015data/calib2012onEMCALandDCAL/RecalibrationFactors2012_10SM_iter8_addDCALandThirdsAfterPass2.txt","r");
132  //calibCoeffsInput[1] = fopen("/cebaf/cebaf/EMCAL/calibPi0_run2/studiesWith2015ppData/testInvMassPeakMeanVsSampleUsed/output_Sample2/output_calibPi0_coeffs_clean.txt","r");
133 
134  //calib 2012 coeff for EMCAL (pi0 only, no E-spectrum calib), and DCAL + third SMs coeffs as obtained after pass2 + Anders values for towers with peak far from pi0 PDG mass:
135  /*calibCoeffsInput[0] = fopen("/cebaf/cebaf/EMCAL/calibPi0_run2/calibPi0_4_with2015data/calib2012onEMCALandDCAL/RecalibrationFactors2012_10SM_iter8_addDCALandThirdsAfterPass2.txt","r");
136  calibCoeffsInput[1] = fopen("/cebaf/cebaf/EMCAL/calibPi0_run2/calibPi0_4_with2015data/output/pass2_DCALandThirdSMsVeryHighTowers/output_calibPi0_coeffs_clean_WithAndersValues.txt","r");*/
137 
138 
139  //Histoes definition :
140  TH2F **h2Coeffs;
141  h2Coeffs = new TH2F*[kNbSMtot];
142  for (i=0;i<kNbSMtot;i++)
143  {h2Coeffs[i] = new TH2F(Form("EMCALRecalFactors_SM%d",i),Form("EMCALRecalFactors_SM%d",i),kNbColMax,0,kNbColMax,kNbRowMax,0,kNbRowMax); //All SMs use the same size.
144  }
145 
146  TH2F **hSpace;
147  TH1F **hDistr; //Coeff for all SMs, per step
148  TH1F **hDistrPerSM; //Coeff for all steps, per SM
149  TH1F **hDistrNoone; //Coeff for all SMs, per step, exclude towers at 1.
150  TH1F **hDistrNoonePerSM; //Coeff for all steps, per SM, exclude towers at 1.
151  hSpace = new TH2F*[(kNbFiles+1)*kNbSMtot];
152  hDistr = new TH1F*[(kNbFiles+1)*2];
153  hDistrPerSM = new TH1F*[kNbSMtot];
154  hDistrNoone = new TH1F*[(kNbFiles+1)*2];
155  hDistrNoonePerSM = new TH1F*[kNbSMtot];
156  for (i=0;i<kNbSMtot;i++)
157  {hDistrPerSM[i] = new TH1F(Form("hDistrPerSM%d",i),Form("hDistrPerSM%d",i),100,0.6,1.4);
158  hDistrPerSM[i]->SetXTitle("Coefficient");
159  hDistrPerSM[i]->SetYTitle("Counts");
160  hDistrPerSM[i]->SetStats(0);
161  hDistrNoonePerSM[i] = new TH1F(Form("hDistrNoonePerSM%d",i),Form("hDistrNoonePerSM%d",i),100,0.6,1.4);
162  hDistrNoonePerSM[i]->SetXTitle("Coefficient");
163  hDistrNoonePerSM[i]->SetYTitle("Counts");
164  hDistrNoonePerSM[i]->SetStats(0);
165  for (j=0;j<kNbFiles+1;j++)
166  {hSpace[(kNbFiles+1)*i+j] = new TH2F(Form("hSpace_%d_%d",i,j),Form("hSpace_%d_%d",i,j),kNbColMax,-0.5,kNbColMax-0.5,kNbRowMax,-0.5,kNbRowMax-0.5);
167  hSpace[(kNbFiles+1)*i+j]->SetXTitle("Column");
168  hSpace[(kNbFiles+1)*i+j]->SetYTitle("Row");
169  hSpace[(kNbFiles+1)*i+j]->SetStats(0);
170  hSpace[(kNbFiles+1)*i+j]->SetContour(30);
171  }
172  }
173  for (j=0;j<kNbFiles+1;j++)
174  {hDistr[j] = new TH1F(Form("hDistr_%d",j),Form("hDistr_%d",j),100,0.0,3.0);
175  hDistr[j]->SetMaximum(20.);
176  hDistr[(kNbFiles+1)+j] = new TH1F(Form("hDistrZm_%d",j),Form("hDistrZm_%d",j),100,0.85,1.15);
177  hDistrNoone[j] = new TH1F(Form("hDistrNoone_%d",j),Form("hDistrNoone_%d",j),100,0.0,3.0);
178  hDistrNoone[j]->SetMaximum(20.);
179  hDistrNoone[(kNbFiles+1)+j] = new TH1F(Form("hDistrNooneZm_%d",j),Form("hDistrNooneZm_%d",j),100,0.85,1.15);
180  for (i=0;i<2;i++)
181  {hDistr[(kNbFiles+1)*i+j]->SetXTitle("Coefficient");
182  hDistr[(kNbFiles+1)*i+j]->SetYTitle("Counts");
183  hDistr[(kNbFiles+1)*i+j]->SetStats(0);
184  hDistr[(kNbFiles+1)*i+j]->SetLineColor(4);
185  hDistrNoone[(kNbFiles+1)*i+j]->SetXTitle("Coefficient");
186  hDistrNoone[(kNbFiles+1)*i+j]->SetYTitle("Counts");
187  hDistrNoone[(kNbFiles+1)*i+j]->SetStats(0);
188  hDistrNoone[(kNbFiles+1)*i+j]->SetLineColor(4);
189  }
190  }
191 
192  //Calculation of coeffs :
193  for (iSM=0;iSM<kNbSMtot;iSM++)
194  {for(i = 0;i<kTabNbCol[SMdetType[iSM]]*kTabNbRow[SMdetType[iSM]];i++)
195  {jFile=0;
196  fscanf(calibCoeffsInput[jFile], " %d %d %d %d %f\n", &a, &b, &c,&d,&e);
197  //printf( " %d %d %d %d %f\n", a, b, c,d,e);
198  if (b != iSM) printf("$$$ File reading out of sync : received SM %d while expected %d.\n",b,iSM);
199  if (e < 0.) e=1.00; //When coeff is used as a flag for towers not to be touched again.
200  hSpace[(kNbFiles+1)*b+jFile]->Fill(c,d,e);
201  hDistr[jFile]->Fill(e);
202  hDistr[(kNbFiles+1)+jFile]->Fill(e);
203  if (e != 1.)
204  {hDistrNoone[jFile]->Fill(e);
205  hDistrNoone[(kNbFiles+1)+jFile]->Fill(e);
206  }
207  aTot=a;
208  bTot=b;
209  cTot=c;
210  dTot=d;
211  eTot=e;
212  for (jFile=1;jFile<kNbFiles;jFile++)
213  {fscanf(calibCoeffsInput[jFile], " %d %d %d %d %f\n", &a, &b, &c,&d,&e);
214  if (bTot != b) printf("$$$ Files reading out of sync : (%d,%d,%d) vs (%d,%d,%d)\n",b,c,d,bTot,cTot,dTot);
215  if (cTot != c) printf("$$$ Files reading out of sync : (%d,%d,%d) vs (%d,%d,%d)\n",b,c,d,bTot,cTot,dTot);
216  if (dTot != d) printf("$$$ Files reading out of sync : (%d,%d,%d) vs (%d,%d,%d)\n",b,c,d,bTot,cTot,dTot);
217  if (e < 0.) e=1.00; //When coeff is used as a flag for towers not to be touched again.
218  hSpace[(kNbFiles+1)*b+jFile]->Fill(c,d,e);
219  hDistr[jFile]->Fill(e);
220  hDistr[(kNbFiles+1)+jFile]->Fill(e);
221  if (e != 1.)
222  {hDistrNoone[jFile]->Fill(e);
223  hDistrNoone[(kNbFiles+1)+jFile]->Fill(e);
224  }
225  eTot*=e;
226  /*if (jFile == (kNbFiles-1))
227  {if (e == 1) eTot=1.0; //If tower not trusted at last iteration, don't trust it for the whole process.
228  }*/
229  //We take the previous lines out and use this only at the very last iteration, in a special code similar to this one. In this way, towers can be made converge, then untrusted for a while and re-converged if needed.
230  }
231  hSpace[(kNbFiles+1)*bTot+kNbFiles]->Fill(cTot,dTot,eTot);
232  hDistr[kNbFiles]->Fill(eTot);
233  hDistr[(kNbFiles+1)+kNbFiles]->Fill(eTot);
234  hDistrPerSM[bTot]->Fill(eTot);
235  if (eTot != 1.)
236  {hDistrNoone[kNbFiles]->Fill(eTot);
237  hDistrNoone[(kNbFiles+1)+kNbFiles]->Fill(eTot);
238  hDistrNoonePerSM[bTot]->Fill(eTot);
239  }
240  fprintf(txtFileOut,"%d %d %d %f\n",bTot,cTot,dTot,eTot);
241  if(eTot==0) printf("\n###### Coeff cannot be 0 ! Please check tower : %d %d %d %f #######\n\n",bTot,cTot,dTot,eTot);
242  else h2Coeffs[bTot]->SetBinContent(cTot,dTot,1./eTot);
243  }
244  }
245 
246 
247  // Draw plots :
248 
249  const int cWidth=500;
250  const int cHeight=(int)(500*(29./21.));
251  TCanvas *c1 = new TCanvas("c1","EMCal cosmics analysis",cWidth,cHeight);
252  TPostScript *ps = new TPostScript(psfile,111);
253 
254  //Spatial distrib of coeffs, per SM, for each pass and integrated over all passes.
255  for (i=0;i<kNbSMtot;i++)
256  {minHist=1.;
257  maxHist=1.;
258  minHistProduct=1.;
259  for (j=0;j<kNbFiles;j++)
260  {//if (hSpace[(kNbFiles+1)*i+j]->GetMinimum() < minHist) minHist=hSpace[(kNbFiles+1)*i+j]->GetMinimum();
261  if (hSpace[(kNbFiles+1)*i+j]->GetMaximum() > maxHist) maxHist=hSpace[(kNbFiles+1)*i+j]->GetMaximum();
262  for (int iCol=0;iCol<kTabNbCol[SMdetType[i]];iCol++)
263  {for (int iRow=0;iRow<kTabNbRow[SMdetType[i]];iRow++)
264  {if (hSpace[(kNbFiles+1)*i+j]->GetBinContent(iCol+1,iRow+1) < minHist) minHist=hSpace[(kNbFiles+1)*i+j]->GetBinContent(iCol+1,iRow+1);
265  }
266  }
267  }
268  for (int iCol=0;iCol<kTabNbCol[SMdetType[i]];iCol++)
269  {for (int iRow=0;iRow<kTabNbRow[SMdetType[i]];iRow++)
270  {if (hSpace[(kNbFiles+1)*i+kNbFiles]->GetBinContent(iCol+1,iRow+1) < minHistProduct) minHistProduct=hSpace[(kNbFiles+1)*i+kNbFiles]->GetBinContent(iCol+1,iRow+1);
271  }
272  }
273  ps->NewPage();
274  c1->Clear();
275  c1->Divide(2,5);
276  for (j=0;j<kNbFiles;j++)
277  {c1->cd(j+1);
278  hSpace[(kNbFiles+1)*i+j]->SetMinimum(minHist);
279  hSpace[(kNbFiles+1)*i+j]->SetMaximum(maxHist);
280  hSpace[(kNbFiles+1)*i+j]->Draw("COLZ");
281  hSpace[(kNbFiles+1)*i+j]->Write();
282  }
283  c1->cd(kNbFiles+1);
284  hSpace[(kNbFiles+1)*i+kNbFiles]->SetMinimum(minHistProduct);
285  hSpace[(kNbFiles+1)*i+kNbFiles]->Draw("COLZ");
286  hSpace[(kNbFiles+1)*i+kNbFiles]->Write();
287  c1->Update();
288  }
289 
290  //1-D distribs of all calib coeffs, per pass and all passes integrated.
291  //Page "1" : zoomed (in y) ; page "0" : not zoomed.
292  for (i=0;i<2;i++)
293  {ps->NewPage();
294  c1->Clear();
295  c1->Divide(2,5);
296  for (j=0;j<kNbFiles;j++)
297  {c1->cd(j+1);
298  /*printf("Histo coeffs pass %d ",j+1);
299  switch (i)
300  {case 0 : printf("(large range) ");
301  break;
302  case 1 : printf("(reduced range) ");
303  break;
304  default : printf("##### unknown histo i=%d ##### \n",i);
305  }
306  printf(": mean = %f, RMS = %f\n",hDistr[(kNbFiles+1)*i+j]->GetMean(),hDistr[(kNbFiles+1)*i+j]->GetRMS());*/
307  hDistr[(kNbFiles+1)*i+j]->Draw();
308  hDistr[(kNbFiles+1)*i+j]->Write();
309  }
310  c1->cd(kNbFiles+1);
311  /*printf("Histo 'product of all coeffs' ");
312  switch (i)
313  {case 0 : printf("(large range) ");
314  break;
315  case 1 : printf("(reduced range) ");
316  break;
317  default : printf("##### unknown histo i=%d ##### \n",i);
318  }
319  printf(": mean = %f, RMS = %f\n",hDistr[(kNbFiles+1)*i+kNbFiles]->GetMean(),hDistr[(kNbFiles+1)*i+kNbFiles]->GetRMS());*/
320  /*if (i == 1)
321  {TF1 *func = new TF1("func","gaus(0)",0.85,1.15);
322  func->SetParLimits(0,10.,500.);
323  func->SetParLimits(1,0.9,1.1);
324  func->SetParLimits(2,0.01,0.2);
325  func->SetParameter(0,hDistr[(kNbFiles+1)+kNbFiles]->GetMaximum());
326  func->SetParameter(1,1.);
327  func->SetParameter(2,0.1);
328  printf("\n");
329  hDistr[(kNbFiles+1)+kNbFiles]->Fit(func,"BRM"); //Option I crashe
330  //printf("Histo moy = %f, RMS = %f\n",hDistr[(kNbFiles+1)+kNbFiles]->GetMean(),hDistr[(kNbFiles+1)+kNbFiles]->GetRMS());
331  printf("\nFit over 'product of all coeffs' (reduced range) : mean = %f, RMS = %f\n",func->GetParameter(1),func->GetParameter(2));
332  }*/
333  hDistr[(kNbFiles+1)*i+kNbFiles]->Draw();
334  hDistr[(kNbFiles+1)*i+kNbFiles]->Write();
335  c1->Update();
336  }
337 
338  //Same thing now without the towers with coeff at 1 :
339  for (i=0;i<2;i++)
340  {ps->NewPage();
341  c1->Clear();
342  c1->Divide(2,5);
343  for (j=0;j<kNbFiles;j++)
344  {c1->cd(j+1);
345  printf("Histo coeffs pass %d ",j+1);
346  switch (i)
347  {case 0 : printf("(large range) ");
348  break;
349  case 1 : printf("(reduced range) ");
350  break;
351  default : printf("##### unknown histo i=%d ##### \n",i);
352  }
353  printf(": mean = %f, RMS = %f\n",hDistrNoone[(kNbFiles+1)*i+j]->GetMean(),hDistrNoone[(kNbFiles+1)*i+j]->GetRMS());
354  hDistrNoone[(kNbFiles+1)*i+j]->Draw();
355  hDistrNoone[(kNbFiles+1)*i+j]->Write();
356  }
357  c1->cd(kNbFiles+1);
358  printf("Histo 'product of all coeffs' ");
359  switch (i)
360  {case 0 : printf("(large range) ");
361  break;
362  case 1 : printf("(reduced range) ");
363  break;
364  default : printf("##### unknown histo i=%d ##### \n",i);
365  }
366  printf(": mean = %f, RMS = %f\n",hDistrNoone[(kNbFiles+1)*i+kNbFiles]->GetMean(),hDistrNoone[(kNbFiles+1)*i+kNbFiles]->GetRMS());
367  if (i == 1)
368  {TF1 *func = new TF1("func","gaus(0)",0.85,1.15);
369  func->SetParLimits(0,10.,500.);
370  func->SetParLimits(1,0.9,1.1);
371  func->SetParLimits(2,0.01,0.2);
372  func->SetParameter(0,hDistrNoone[(kNbFiles+1)+kNbFiles]->GetMaximum());
373  func->SetParameter(1,1.);
374  func->SetParameter(2,0.1);
375  printf("\n");
376  hDistrNoone[(kNbFiles+1)+kNbFiles]->Fit(func,"BRM"); //Option I crashe
377  //printf("Histo moy = %f, RMS = %f\n",hDistrNoone[(kNbFiles+1)+kNbFiles]->GetMean(),hDistrNoone[(kNbFiles+1)+kNbFiles]->GetRMS());
378  printf("\nFit over 'product of all coeffs' (reduced range) : mean = %f, RMS = %f\n",func->GetParameter(1),func->GetParameter(2));
379  }
380  hDistrNoone[(kNbFiles+1)*i+kNbFiles]->Draw();
381  hDistrNoone[(kNbFiles+1)*i+kNbFiles]->Write();
382  c1->Update();
383  }
384 
385  //Coeff (all iterations multiplied) distrib SM per SM
386  printf("\n\nHistoes 'product of all coeffs' for each SM :\n");
387 
388  ps->NewPage();
389  c1->Clear();
390  c1->Divide(2,5);
391  for (j=0;j<kNbSMEMCAL;j++)
392  {c1->cd(j+1);
393  //printf(" SM %d : mean = %f, RMS = %f\n",j,hDistrPerSM[j]->GetMean(),hDistrPerSM[j]->GetRMS());
394  hDistrPerSM[j]->Draw();
395  hDistrPerSM[j]->Write();
396  }
397  c1->Update();
398 
399  ps->NewPage();
400  c1->Clear();
401  c1->Divide(2,5);
402  for (j=kNbSMEMCAL;j<kNbSMtot;j++)
403  {c1->cd(j-kNbSMEMCAL+1);
404  //printf(" SM %d : mean = %f, RMS = %f\n",j,hDistrPerSM[j]->GetMean(),hDistrPerSM[j]->GetRMS());
405  hDistrPerSM[j]->Draw();
406  hDistrPerSM[j]->Write();
407  }
408  c1->Update();
409 
410  //Same thing excluding the towers which have coeff equal to 1 :
411  ps->NewPage();
412  c1->Clear();
413  c1->Divide(2,5);
414  for (j=0;j<kNbSMEMCAL;j++)
415  {c1->cd(j+1);
416  printf(" SM %d : mean = %f, RMS = %f\n",j,hDistrNoonePerSM[j]->GetMean(),hDistrNoonePerSM[j]->GetRMS());
417  hDistrNoonePerSM[j]->Draw();
418  hDistrNoonePerSM[j]->Write();
419  }
420  c1->Update();
421 
422  ps->NewPage();
423  c1->Clear();
424  c1->Divide(2,5);
425  for (j=kNbSMEMCAL;j<kNbSMtot;j++)
426  {c1->cd(j-kNbSMEMCAL+1);
427  printf(" SM %d : mean = %f, RMS = %f\n",j,hDistrNoonePerSM[j]->GetMean(),hDistrNoonePerSM[j]->GetRMS());
428  hDistrNoonePerSM[j]->Draw();
429  hDistrNoonePerSM[j]->Write();
430  }
431  c1->Update();
432 
433 
434  ps->Close();
435 
436  for (i=0;i<kNbSMtot;i++) h2Coeffs[i]->Write();
437 
438  f->Close();
439 
440  fclose(txtFileOut);
441 
442  for (jFile=kNbFiles-1;jFile>-1;jFile--) fclose(calibCoeffsInput[jFile]);
443 
444  return;
445 
446  }
447 
448 
449 
450 
void Draw(const char *filename, const char *title="", const char *others="ALL", const char *options="DEFAULT", const char *outFlg="ALL", UShort_t rebin=5, Float_t eff=0, const char *base="")
Definition: DrawdNdeta.C:3603
const int kNbColEMCALthird
Definition: External.C:236
const int kTabNbCol[4]
char detTypeString[][100]
const int kNbRowMax
TCanvas * c
Definition: TestFitELoss.C:172
const int kNbSMtot
const int kNbSMEMCAL
const int kNbRowEMCAL
const int kNbColOffsetDCAL
int SMdetType[]
const int kNbRowDCAL
void MultiplyPi0CalibrationFactors_TextToHisto()
const int kNbRowDCALthird
char SMnumber[][100]
const int kNbColMax
const int kNbSMEMCALthird
const int kNbColDCAL
char SMP2Name[][100]
const int kTabNbRow[4]
const int kNbColEMCAL
int detTypeType[]
const int kNbSMDCALthird
const int kNbRowEMCALthird
const int kNbSMDCAL
const int kTabNbSM[4]
const int kNbColDCALthird