AliPhysics  4646b6b (4646b6b)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Pi0CalibInvMassAnalysis3.C
Go to the documentation of this file.
1 #include <Riostream.h>
2 #include <TChain.h>
3 #include <TNtuple.h>
4 #include <TObjArray.h>
5 #include <TSystem.h>
6 #include <TString.h>
7 #include <TH1F.h>
8 #include <TVector.h>
9 #include <TRefArray.h>
10 #include <TArrayS.h>
11 #include "TError.h"
12 #include "TTree.h"
13 #include "TClonesArray.h"
14 #include "TGraphErrors.h"
15 #include "TPostScript.h"
16 #include "TLegend.h"
17 #include "TH2I.h"
18 #include "TF1.h"
19 #include "TStyle.h"
20 #include "TPaveStats.h"
21 #include "TCanvas.h"
22 #include "TPolyLine.h"
23 #include "TLine.h"
24 #include "TFile.h"
25 #include "TMath.h"
26 #include "TLeaf.h"
27 #include "TBranch.h"
28 
29 //#include "/cebaf/cebaf/EMCAL/cosmicsAnalysis/macros/defineMyPalette40All.C"
30 
31  char SMP2Name[][100]={"SMA0","SMC0","SMA1","SMC1","SMA2","SMC2","SMA3","SMC3","SMA4","SMC4","SMA5","SMC5","SMA9","SMC9","SMA10","SMC10","SMA11","SMC11","SMA12","SMC12"};
32  char SMnumber[][100]={"0","1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18","19"};
33 
36  char detTypeString[][100]={"EMCAL","EMCALthird","DCAL","DCALthird"};
38  const int kNbColEMCAL=48;
39  const int kNbRowEMCAL=24;
40  const int kNbSMEMCAL=10;
42  const int kNbRowEMCALthird=(int)(kNbRowEMCAL/3);
43  const int kNbSMEMCALthird=2;
44  const int kNbColDCAL=32;
46  const int kNbSMDCAL=6;
49  const int kNbSMDCALthird=2;
50  const int kNbSMtot=kNbSMEMCAL+kNbSMEMCALthird+kNbSMDCAL+kNbSMDCALthird;
51  const int kTabNbCol[4]={kNbColEMCAL,kNbColEMCALthird,kNbColDCAL,kNbColDCALthird};
52  const int kTabNbRow[4]={kNbRowEMCAL,kNbRowEMCALthird,kNbRowDCAL,kNbRowDCALthird};
53  const int kTabNbSM[4]={kNbSMEMCAL,kNbSMEMCALthird,kNbSMDCAL,kNbSMDCALthird};
57 
58 
59 
60 
61 
62 
63  const int kNbFitParams=6;
64  const int kNbExtraParams=7;
65  //const int kNbExtraParamsToBeRead=4; //Previous version of the code had 10 parameters written in output_calibPi0_parameters.txt, up to the analysis of input/pass3/ (included).
66  const int kNbExtraParamsToBeRead=7; //Valid from the analysis of input/pass4/.
67  const int kNbTotParams=kNbFitParams+kNbExtraParams+1; //We add the calib coeff.
68 
69 
70 
84 
88 //__________________________________________________________________
89 void Pi0CalibInvMassAnalysis3(int choice=0b0110)
90 //choice indicates which SM are used :
91 // 10^0 = EMCAL, 10^1 = EMCAL thirds, 10^2 = DCAL, 10^3 = DCAL thirds,
92 // 0 = no, 1 = yes.
93 //Therefore : old EMCAL SMs only -> choice = 0b0001 ;
94 // thirds only -> choice = 0b1010 ;
95 // DCAL only -> choice = 0b0100.
96 //Caution, do not write eg '0001', because integers with a leading zero in C are interpreted as octal values.
97 //Instead, write '0b0001' to state it's binary.
98 {int m,n,i,j,k,iCol,iRow,iSM,iPt,iStruct,iBin,discardFlag;
99  int testChoice,isFirstIteration,shiftCol,shiftRow,cmpt,flag[kNbFitParams+kNbExtraParams],sm2,c2,r2,cmpt2,flag2[kNbFitParams+kNbExtraParams],tmpFlag,tmpFlagTab[23],cmpt3,sm3,c3,r3,cmptEntriesDiscard,cmptAmpDiscard,cmptMasked,cmptEdge,cmptNDF;
100  int kNbColMinEff,kNbColMaxEff,cEff;
101  int tabChoiceCalos[4],tmpChoice,nbTowersConsideredTot,choiceNoEMCAL,choiceNoDCAL;
102  int kCalibrateMidRapBorderCol,kCalibrateLastBorderCol,kCalibrateTouchingBorderRow,kCalibrateLastBorderRow,flagBorderTower;
103  double tabMin[kNbFitParams+kNbExtraParams],tabMax[kNbFitParams+kNbExtraParams],nbEntriesMax,cutMin[kNbFitParams+kNbExtraParams],cutMax[kNbFitParams+kNbExtraParams],param2[kNbTotParams],tabMinDiff[9],tabMaxDiff[9],cutEntriesDiscard,cutAmpDiscard;
104  double tmpX,tmpY,fitPar3,fitPar4,fitPar5,nbTot,nbSig,intgS,intgSbincounting,intgN,intgKhi2,coeff,coeff3,maxGaussAmpl,maxIntgAmpl;
105  double coeffPower,coeffPowerPrev,fitRangeMin,fitRangeMax,maxHisto,fitResultMean,fitResultSigma,fitKhi2SmallRange,fitKhi2PeakLeft,fitKhi2PeakRight,valStatUncert,paramFitStatUncert_a,paramFitStatUncert_b,uncertKSpec,uncertSpec,uncertDist;
106  char txtPS[100];
107 
108  int kTabColOffset[kNbSMtot];
109  for (int i=0;i<kNbSMtot;i++)
110  {kTabColOffset[i]=0;
111  if (SMdetType[i] == kDCAL) kTabColOffset[i]=kNbColOffsetDCAL;
112  }
113 
114 
115 
116 printf("\n\n\n\n##############\n###############\n#### Change one thing : when, at the last iteration, the calib coeff = 1, tower is untrusted and product of all calib coeffs of previous iterations must be 1, independantly of their actual value. Check mail a Catherine Apr 18th, 2013 w/ subject 'Calib status'.\n##################\n#################!!!!!!!!!!!!!!!!!!!!!\n\n\n");
117 
118 
119 
120 
121 
122 
123 
124  //*****************************************
125  // Define parameters for running the code :
126  //*****************************************
127 
128  //CUSTOMIZE customize :
129  isFirstIteration=0; //Not the first iteration.
130  testChoice=0; //Not a test.
131  //isFirstIteration=1; //This is the first iteration.
132  //testChoice=1; //Test with all SMs, 2 col.
133  //testChoice=2; //Test with 1 SM, 2 col.
134  //testChoice=3; //Test with all SMs but don't plot the inv mass distrib for all the towers (lighter ps file)
135 
136  //CUSTOMIZE customize : (if necessary) :
137  //Calib coeff = mass ratio to the power of coeffPower.
138  //coeffPower=1.0; //This choice considers that the observed mass shift is due to an energy shift equally shared by both clusters (ultra-safe but slower convergence).
139  coeffPower=1.5; //This choice is an intermediate solution. //Chosen from the analysis of input/pass4/ (previous passes : coeff = 1.0).
140  //coeffPower=2.0; //This choice considers that the observed mass shift is entirely due to an energy shift of the considered tower (fastest convergence but may fail when many towers around are all shifted the same way).
141  coeffPowerPrev=1.0;
142  //coeffPowerPrev=1.5;
143 
144  //CUSTOMIZE customize : (if necessary) :
145  //0 = don't calibrate, 1 = do calibrate.
146  kCalibrateMidRapBorderCol=0;
147  kCalibrateLastBorderCol=0;
148  kCalibrateTouchingBorderRow=0;
149  kCalibrateLastBorderRow=0;
150 
151  paramFitStatUncert_a=18.1227/100.; //This is for the relative uncert : uncert/mean=paramFitStatUncert_a/sqrt(N_pi0) (+) paramFitStatUncert_b. A value of 15./100. means a 15%/sqrt(N) uncertainty.
152  paramFitStatUncert_b=0.151497/100.;
153  uncertKSpec=0.5; //Want the uncertainty on the mean to be lower than uncertKSpec*uncertSpec : ensure we know the mean, before testing that this mean is close to mPDG.
154  uncertSpec=0.02; //Tolerate an additional 2% decalibration with respect to the test-beam status.
155  uncertDist=2.; //How much times the tolerated decalibration away from mPDG do we consider that a tower is not yet OK.
156 
157  choiceNoEMCAL=0;
158  choiceNoDCAL=0;
159  for (i=4-1;i>=0;i--)
160  {tmpChoice=choice>>i;
161  tabChoiceCalos[i]=tmpChoice;
162  choice-=tmpChoice*pow(2,i);
163  }
164  nbTowersConsideredTot=0;
165  printf("\n\n---------------------------------\n| Running for :");
166  for (i=0;i<4;i++)
167  {if (tabChoiceCalos[i] == 1)
168  {nbTowersConsideredTot+=kTabNbSM[detTypeType[i]]*kTabNbCol[detTypeType[i]]*kTabNbRow[detTypeType[i]];
169  printf(" %s",detTypeString[i]);
170  if (i<2) choiceNoEMCAL++;
171  else choiceNoDCAL++;
172  }
173  }
174  printf(".\n");
175  if (choiceNoEMCAL == 0) printf("| Chose to run with no EMCAL supermodules.\n");
176  if (choiceNoDCAL == 0) printf("| Chose to run with no DCAL supermodules.\n");
177  if (isFirstIteration == 0) printf("| Declared that this is NOT the first iteration.\n");
178  else printf("| Declared that this IS the first iteration.\n");
179  printf("---------------------------------\n\n");
180 
181  double mPDG = 134.9766; //MeV
182  double typicalWidth = 13.; //MeV
183 
184 
185  switch (testChoice)
186  {case 0 : kNbColMinEff=0;
187  kNbColMaxEff=kNbColMax;
188  printf("Calib mode, max tower col span %d -> %d.\n",kNbColMinEff,kNbColMaxEff-1);
189  break;
190  case 1 : kNbColMinEff=0;
191  kNbColMaxEff=2;
192  printf("\n########### TEST mode, max tower col span %d -> %d.\n",kNbColMinEff,kNbColMaxEff-1);
193  printf("#############################################\n\n");
194  gSystem->Exec("sleep 2");
195  break;
196  case 2 : kNbColMinEff=0;
197  kNbColMaxEff=2;
198  printf("\n########### TEST mode, 1 SM and max tower col span %d -> %d.\n",kNbColMinEff,kNbColMaxEff-1);
199  printf("#############################################\n\n");
200  gSystem->Exec("sleep 2");
201  break;
202  case 3 : kNbColMinEff=0;
203  kNbColMaxEff=kNbColMax;
204  printf("\n########### TEST mode, max tower col span %d -> %d.\n",kNbColMinEff,kNbColMaxEff-1);
205  printf("########### Don't plot the inv mass histoes per tower.\n");
206  printf("#############################################\n\n");
207  gSystem->Exec("sleep 2");
208  break;
209  default : printf("\nUnknown test mode option, exiting.\n\n");
210  return;
211  }
212 
213  printf("Running with target mass %f MeV.\n",mPDG);
214  if (mPDG != 134.9766) printf("\n########### CAUTION ! This is not the PDG mass %f MeV !\n",134.9766);
215  printf("\n");
216 
220 
221  int rebin=2;
222 
223 
224 
225 
226 
227 
228  //*****************************************
229  // Define input/output files :
230  //*****************************************
231 
232  //Current iteration :
233  //CUSTOMIZE customize :
234  //TFile *f05 = new TFile("/cebaf/cebaf/EMCAL/calibPi0_run2/calibPi0_4_with2015data/AnalysisResults-fMinNCells2.root","read"); //Test
235  //TFile *f05 = new TFile("/cebaf/cebaf/EMCAL/calibPi0_run2/calibPi0_4_with2015data/AnalysisResults-1_3SMstriggerfMinNCells2.root","read"); //Test
236  //TFile *f05 = new TFile("/cebaf/cebaf/EMCAL/calibPi0_run2/calibPi0_4_with2015data/AnalysisResults-tiersSM.root","read"); //Test
237  //TFile *f05 = new TFile("/cebaf/cebaf/EMCAL/calibPi0_run2/calibPi0_4_with2015data/input/pass0/pi0calib.root","read"); //pass0
238  //TFile *f05 = new TFile("/cebaf/cebaf/EMCAL/calibPi0_run2/calibPi0_4_with2015data/AnalysisResults-LHC15imuoncalo_fMinNCells2WithMaskOnTowers.root","read"); //Test
239  //TFile *f05 = new TFile("/cebaf/cebaf/EMCAL/calibPi0_run2/calibPi0_4_with2015data/AnalysisResultsLHC15jtot.root","read"); //Test
240  //TFile *f05 = new TFile("/cebaf/cebaf/EMCAL/calibPi0_run2/calibPi0_4_with2015data/AnalysisResults-LHC15jMartinRunsFull.root","read"); //Test
241  //TFile *f05 = new TFile("/cebaf/cebaf/EMCAL/calibPi0_run2/calibPi0_4_with2015data/AnalysisResults_LHC15iBadMap.root","read"); //
242  //TFile *f05 = new TFile("/cebaf/cebaf/EMCAL/calibPi0_run2/calibPi0_4_with2015data/AnalysisResults_LHC15iTrigEMC.root","read"); //
243  //TFile *f05 = new TFile("/cebaf/cebaf/EMCAL/calibPi0_run2/calibPi0_4_with2015data/AnalysisResults_LHC15iMaskTowersByHand.root","read"); //
244  //TFile *f05 = new TFile("/cebaf/cebaf/EMCAL/calibPi0_run2/calibPi0_4_with2015data/AnalysisResults_LHC15jMaskTowersByHand.root","read"); //
245  //TFile *f05 = new TFile("/cebaf/cebaf/EMCAL/calibPi0_run2/calibPi0_4_with2015data/AnalysisResults_LHC15iMaskTowersByHand26oct2015.root","read"); //
246  //TFile *f05 = new TFile("/cebaf/cebaf/EMCAL/calibPi0_run2/calibPi0_4_with2015data/AnalysisResults_LHC15jBadMap27oct2015.root","read"); //
247  //TFile *f05 = new TFile("/cebaf/cebaf/EMCAL/calibPi0_run2/calibPi0_4_with2015data/AnalysisResults_LHC15jOnlyEdgesMaskTowersByHand28oct2015.root","read"); //
248 
249  //pass 0 :
250  //TFile *f05 = new TFile("/cebaf/cebaf/EMCAL/calibPi0_run2/calibPi0_4_with2015data/input/pass0/AnalysisResults_LHC15sumijMaskTowersByHand.root","read");
251  //pass 1 :
252  //TFile *f05 = new TFile("/cebaf/cebaf/EMCAL/calibPi0_run2/calibPi0_4_with2015data/input/pass1/AnalysisResults_LHC15sumijMaskTowersByHandpass1VeryHighTowers.root","read");
253  //TFile *f05 = new TFile("/cebaf/cebaf/EMCAL/calibPi0_run2/calibPi0_4_with2015data/AnalysisResults_LHC15sumijBadMappass1VeryHighTowersMinCells3.root","read"); //Test cut minCells at 3.
254  //pass 2 :
255  //TFile *f05 = new TFile("/cebaf/cebaf/EMCAL/calibPi0_run2/calibPi0_4_with2015data/input/pass2/AnalysisResults_LHC15sumijMaskTowersByHandpass2VeryHighTowers.root","read"); //Chose that one.
256  //TFile *f05 = new TFile("/cebaf/cebaf/EMCAL/calibPi0_run2/calibPi0_4_with2015data/input/pass2/AnalysisResults_LHC15sumijMaskTowersByHandpass2.root","read");
257  //pass 3 :
258  //TFile *f05 = new TFile("/cebaf/cebaf/EMCAL/calibPi0_run2/calibPi0_4_with2015data/input/pass3/AnalysisResults_LHC15sumijMaskTowersByHandpass3.root","read");
259  //TFile *f05 = new TFile("/cebaf/cebaf/EMCAL/calibPi0_run2/calibPi0_4_with2015data/input/pass3/AnalysisResults_LHC15sumijMaskTowersByHandpass3VeryHighTowers.root","read");
260  //TFile *f05 = new TFile("/cebaf/cebaf/EMCAL/calibPi0_run2/calibPi0_4_with2015data/input/pass3/AnalysisResults_LHC15sumij4HV.root","read"); //For HV calculation.
261  //TFile *f05 = new TFile("/cebaf/cebaf/EMCAL/calibPi0_run2/calibPi0_4_with2015data/input/pass3/AnalysisResults_LHC15sumijMaskTowersByHandpass3WithTimeCalibAndAndersValues.root","read"); //Chose that one.
262  //pass 4 :
263  //TFile *f05 = new TFile("/cebaf/cebaf/EMCAL/calibPi0_run2/calibPi0_4_with2015data/input/pass4/AnalysisResults_LHC15sumijMaskTowersByHand24Nov2016_pass4_NoNegCoeffs.root","read");
264  //pass 5 :
265  //TFile *f05 = new TFile("/cebaf/cebaf/EMCAL/calibPi0_run2/calibPi0_4_with2015data/input/pass5/AnalysisResults_LHC15sumijMaskTowersByHand27Nov2016_pass5.root","read");
266 
267  //Various studies :
268  //TFile *f05 = new TFile("/cebaf/cebaf/EMCAL/calibPi0_run2/calibPi0_4_with2015data/AnalysisResults_LHC15sumij2012Calib.root","read");
269  //TFile *f05 = new TFile("/cebaf/cebaf/EMCAL/calibPi0_run2/calibPi0_4_with2015data/AnalysisResults_LHC15sumijBadMap2012Calib.root","read");
270  //TFile *f05 = new TFile("/cebaf/cebaf/EMCAL/calibPi0_run2/calibPi0_4_with2015data/AnalysisResults_LHC15sumijFakeDeadRegions2012Calib.root","read");
271  //TFile *f05 = new TFile("/cebaf/cebaf/EMCAL/calibPi0_run2/calibPi0_4_with2015data/TestLowMassPeakTowers/AnalysisResults_LHC15iBadMapNoMask.root","read");
272  //TFile *f05 = new TFile("/cebaf/cebaf/EMCAL/calibPi0_run2/calibPi0_4_with2015data/TestLowMassPeakTowers/AnalysisResults_LHC15iBadMapMask.root","read");
273  //TFile *f05 = new TFile("/cebaf/cebaf/EMCAL/calibPi0_run2/calibPi0_4_with2015data/TestLowMassPeakTowers/AnalysisResults_LHC15iNoBadMapNoMask.root","read");
274  //TFile *f05 = new TFile("/cebaf/cebaf/EMCAL/calibPi0_run2/calibPi0_4_with2015data/TestLowMassPeakTowers/AnalysisResults_LHC15iNoBadMapMask.root","read");
275  //Test fitted mean change wrt sample used :
276  //TFile *f05 = new TFile("/cebaf/cebaf/EMCAL/calibPi0_run2/calibPi0_4_with2015data/testInvMassPeakMeanVsSampleUsed/LHC15i_Sample1.root","read");
277  //TFile *f05 = new TFile("/cebaf/cebaf/EMCAL/calibPi0_run2/calibPi0_4_with2015data/testInvMassPeakMeanVsSampleUsed/LHC15i_Sample2.root","read");
278  //TFile *f05 = new TFile("/cebaf/cebaf/EMCAL/calibPi0_run2/calibPi0_4_with2015data/testInvMassPeakMeanVsSampleUsed/LHC15i_Sample2.root","read");
279  //TFile *f05 = new TFile("/cebaf/cebaf/EMCAL/calibPi0_run2/calibPi0_4_with2015data/AnalysisResultsLHC15ij_pass3TenderOn.root","read");
280  //Test factor 2 :
281  //TFile *f05 = new TFile("/cebaf/cebaf/EMCAL/calibPi0_run2/calibPi0_4_with2015data/LHC15iTenderOnPass2AllOn.root","read");
282  //TFile *f05 = new TFile("/cebaf/cebaf/EMCAL/calibPi0_run2/calibPi0_4_with2015data/LHC15iTenderOffPass2L1PhaseOn.root","read");
283  //TFile *f05 = new TFile("/cebaf/cebaf/EMCAL/calibPi0_run2/calibPi0_4_with2015data/LHC15iTenderOnPass2L1PhaseOn.root","read");
284  //TFile *f05 = new TFile("/cebaf/cebaf/EMCAL/calibPi0_run2/studiesWith2015ppData/testInvMassPeakMeanVsSampleUsed/inputSample1/LHC15i_Sample1_TenderOn_muoncalopass2.root","read");
285  //TFile *f05 = new TFile("/cebaf/cebaf/EMCAL/calibPi0_run2/calibPi0_4_with2015data/LHC15ijTenderOnTimeCutAppliedNoBadMap.root","read");
286  //TFile *f05 = new TFile("/cebaf/cebaf/EMCAL/calibPi0_run2/calibPi0_4_with2015data/LHC15jTenderOnTimeCutAppliedNoBadMapMaskAppliedForAnders.root","read");
287  //TFile *f05 = new TFile("/cebaf/cebaf/EMCAL/calibPi0_run2/studiesWith2015ppData/testAlignment/input/LHC15i_DifferentSM.root","read");
288  //TFile *f05 = new TFile("/cebaf/cebaf/EMCAL/calibPi0_run2/studiesWith2015ppData/testSpecialTriggerEffect/input/LHC15j_SpecialTriggerOnly2by4Structure_SpecialMask.root","read");
289  //TFile *f05 = new TFile("/cebaf/cebaf/EMCAL/calibPi0_run2/studiesWith2015ppData/testBkgShapeEffect/input/LHC15i_TenderNoBadMapTightTimeCutAppliedTightM02Plus1to3_Good_Emax0_7_FixOpAngle_0_112.root","read");
290  //TFile *f05 = new TFile("/cebaf/cebaf/EMCAL/calibPi0_run2/studiesWith2015ppData/testBkgShapeEffect/input/LHC15ij_RemoveLeftShoulder_5MeVShift.root","read");
291  //TFile *f05 = new TFile("/cebaf/cebaf/EMCAL/calibPi0_run2/studiesWith2015ppData/testBkgShapeEffect/input/LHC15ij_Ref.root","read");
292  //TFile *f05 = new TFile("/cebaf/cebaf/EMCAL/calibPi0_run2/calibPi0_4_with2015data/input/pass3/LHC15sumijTenderOnTimeCutAppliedNoBadMapMaskApplied_WithAndersValues.root","read");
293  //TFile *f05 = new TFile("/cebaf/cebaf/EMCAL/calibPi0_run2/calibPi0_4_with2015data/input/pass3/AnalysisResults_LHC15sumijMaskTowersByHandpass3WithTimeCalib.root","read");
294 
295  //TFile *f05 = new TFile("/cebaf/cebaf/EMCAL/calibPi0_run2/calibPi0_4_with2015data/input/pass3/AnalysisResults_LHC15iMaskTowersByHandpass3WithTimeCalibSameSM.root","read");
296 
297  TFile *f05 = new TFile("/cebaf/cebaf/EMCAL/calibPi0_run2/calibPi0_4_with2015data/input/pass5/AnalysisResults_LHC15sumijMaskMoreTowersByHand_pass5.root","read");
298 
299  FILE *txtFileCalibIn = NULL;
300  FILE *txtFileParamsIn = NULL;
301  FILE *txtFileParamsOut = NULL;
302  //Previous iterations :
303  //Pointless ; to change at 1st iteration :
304  //CUSTOMIZE customize :
305  // Pass 8 2012 EMCAL :
306  /*txtFileCalibIn = fopen("/cebaf/cebaf/EMCAL/calibPi0/output2012/pass7/output_calibPi0_coeffs_clean.txt","r");
307  txtFileParamsIn = fopen("/cebaf/cebaf/EMCAL/calibPi0/output2012/pass7/output_calibPi0_parameters.txt","r");*/
308  // Pass 0 DCAL :
309  /*txtFileCalibIn = fopen("/cebaf/cebaf/EMCAL/calibPi0_run2/calibPi0_4_with2015data/output/pass0_DCAL/output_calibPi0_coeffs_clean.txt","r");
310  txtFileParamsIn = fopen("/cebaf/cebaf/EMCAL/calibPi0_run2/calibPi0_4_with2015data/output/pass0_DCAL/output_calibPi0_parameters.txt","r");*/
311  // Pass 0 third-SMs :
312  /*txtFileCalibIn = fopen("/cebaf/cebaf/EMCAL/calibPi0_run2/calibPi0_4_with2015data/output/pass0_thirdSMs/output_calibPi0_coeffs_clean.txt","r");
313  txtFileParamsIn = fopen("/cebaf/cebaf/EMCAL/calibPi0_run2/calibPi0_4_with2015data/output/pass0_thirdSMs/output_calibPi0_parameters.txt","r");*/
314  // Pass 0 DCAL + third-SMs :
315  /*txtFileCalibIn = fopen("/cebaf/cebaf/EMCAL/calibPi0_run2/calibPi0_4_with2015data/output/pass0_mergedDCALandThirdSMs/output_calibPi0_coeffs_clean_veryHighTowers_onlyDCALandThirdSMs.txt","r");
316  txtFileParamsIn = fopen("/cebaf/cebaf/EMCAL/calibPi0_run2/calibPi0_4_with2015data/output/pass0_mergedDCALandThirdSMs/output_calibPi0_parameters_onlyDCALandThirdSMs.txt","r");*/
317  // Pass 1 DCAL + third-SMs :
318  /*txtFileCalibIn = fopen("/cebaf/cebaf/EMCAL/calibPi0_run2/calibPi0_4_with2015data/output/pass1_DCALandThirdSMs/output_calibPi0_coeffs_clean_veryHighTowers_onlyDCALandThirdSMs.txt","r");
319  txtFileParamsIn = fopen("/cebaf/cebaf/EMCAL/calibPi0_run2/calibPi0_4_with2015data/output/pass1_DCALandThirdSMs/output_calibPi0_parameters.txt","r");*/
320  // Pass 2 DCAL + third SMs
321  /*txtFileCalibIn = fopen("/cebaf/cebaf/EMCAL/calibPi0_run2/calibPi0_4_with2015data/output/pass2_DCALandThirdSMsVeryHighTowers/output_calibPi0_coeffs_clean_OnlyDCALandThirdSMs.txt","r");
322  txtFileParamsIn = fopen("/cebaf/cebaf/EMCAL/calibPi0_run2/calibPi0_4_with2015data/output/pass2_DCALandThirdSMsVeryHighTowers/output_calibPi0_parameters.txt","r");*/ //Chose this one.
323  /*txtFileCalibIn = fopen("/cebaf/cebaf/EMCAL/calibPi0_run2/calibPi0_4_with2015data/output/pass2_DCALandThirdSMsVeryHighTowers/output_calibPi0_coeffs_clean_veryHighGains_OnlyDCALandThirdSMs.txt","r");
324  txtFileParamsIn = fopen("/cebaf/cebaf/EMCAL/calibPi0_run2/calibPi0_4_with2015data/output/pass2_DCALandThirdSMsVeryHighTowers/output_calibPi0_parameters.txt","r");*/
325  // Pass 3 DCal + thirds SM
326  /*txtFileCalibIn = fopen("/cebaf/cebaf/EMCAL/calibPi0_run2/calibPi0_4_with2015data/output/pass3_DCALandThirdSMsWithAndersCoeffsTowersVeryFarFromPDG/output_calibPi0_coeffs_clean.txt","r");
327  txtFileParamsIn = fopen("/cebaf/cebaf/EMCAL/calibPi0_run2/calibPi0_4_with2015data/output/pass3_DCALandThirdSMsWithAndersCoeffsTowersVeryFarFromPDG/output_calibPi0_parameters.txt","r");*/
328  // Pass 4 DCal + thirds SM EMCAL
329  txtFileCalibIn = fopen("/cebaf/cebaf/EMCAL/calibPi0_run2/calibPi0_4_with2015data/output/pass4_DCALandEMCALThirds/output_calibPi0_coeffs_clean.txt","r");
330  txtFileParamsIn = fopen("/cebaf/cebaf/EMCAL/calibPi0_run2/calibPi0_4_with2015data/output/pass4_DCALandEMCALThirds/output_calibPi0_parameters.txt","r");
331 
332 
333  TString txtFileParamsOutName("output_calibPi0_parameters.txt");
334  TString txtFileCalibOutName("output_calibPi0_coeffs.txt");
335  txtFileParamsOut = fopen(txtFileParamsOutName.Data(),"w");
336  ofstream txtFileCalibOut(txtFileCalibOutName.Data());
337 
338 
339 
340 
341 
342 
343  //*****************************************
344  // Define graphical tools :
345  //*****************************************
346 
347  //defineMyPalette40All(30,5);
348 
349  Int_t colorIndex[]={1,4,6,8};
350  Int_t colorIndexStruct[]={kBlack,kGreen+2,kRed};
351  Int_t colorIndexZones[]={kGreen+2,kGreen+3,kAzure-5,kBlue+2,kPink+2,kRed,kRed+2};
352  Int_t colorIndexRatiosZones[]={kGreen+2,kBlue,kRed,kRed+2,kBlack};
353 
354  TLine *linePDGMass = new TLine(mPDG,0.,mPDG,1.);
355  TLine *lineFittedMass = new TLine(mPDG,0.,mPDG,1.);
356  TLine *lineFittedWidth1 = new TLine(mPDG,0.,mPDG,1.);
357  TLine *lineFittedWidth2 = new TLine(mPDG,0.,mPDG,1.);
358  TLine *linePreviousFittedMass = new TLine(mPDG,0.,mPDG,1.);
359  TLine *linePreviousFittedWidth1 = new TLine(mPDG,0.,mPDG,1.);
360  TLine *linePreviousFittedWidth2 = new TLine(mPDG,0.,mPDG,1.);
361  TLine *linePreviousDesiredMass = new TLine(mPDG,0.,mPDG,1.);
362  TLine *linePreviousUntrustedFit = new TLine(mPDG,0.,mPDG,1.);
363  linePDGMass->SetLineColor(kSpring+4);
364  lineFittedMass->SetLineColor(kMagenta);
365  lineFittedWidth1->SetLineColor(kMagenta-10);
366  lineFittedWidth2->SetLineColor(kMagenta-10);
367  TLine *lineSMborderVEMCAL = new TLine(kNbColEMCAL-0.5,-0.5,kNbColEMCAL-0.5,(int)((kNbSMEMCAL+1)/2)*kNbRowEMCAL+(int)((kNbSMEMCALthird+1)/2)*kNbRowEMCALthird-0.5);
368  TLine *lineSMborderVDCALthird = new TLine(kNbColDCALthird-0.5,(int)((kNbSMDCAL+1)/2)*kNbRowDCAL-0.5,kNbColDCALthird-0.5,(int)((kNbSMDCAL+1)/2)*kNbRowDCAL+(int)((kNbSMDCALthird+1)/2)*kNbRowDCALthird-0.5);
369  TLine *lineSMborderVDCAL1 = new TLine(kNbColDCAL-0.5,-0.5,kNbColDCAL-0.5,(int)((kNbSMDCAL+1)/2)*kNbRowDCAL-0.5);
370  TLine *lineSMborderVDCAL2 = new TLine(2*kNbColEMCAL-kNbColDCAL-0.5,-0.5,2*kNbColEMCAL-kNbColDCAL-0.5,(int)((kNbSMDCAL+1)/2)*kNbRowDCAL-0.5);
371  TLine **lineSMborderHEMCAL,**lineSMborderHDCAL;
372  lineSMborderHEMCAL = new TLine*[(int)((kNbSMEMCAL+1)/2)];
373  lineSMborderHDCAL = new TLine*[(int)((kNbSMDCAL+1)/2)];
374  for (i=0;i<(int)((kNbSMEMCAL+1)/2);i++) lineSMborderHEMCAL[i] = new TLine(-0.5,(i+1)*kNbRowEMCAL-0.5,2.*kNbColEMCAL-0.5,(i+1)*kNbRowEMCAL-0.5);
375  for (i=0;i<(int)((kNbSMDCAL+1)/2);i++) lineSMborderHDCAL[i] = new TLine(-0.5,(i+1)*kNbRowDCAL-0.5,2.*kNbColDCALthird-0.5,(i+1)*kNbRowDCAL-0.5);
376  TLine *lineMin = new TLine(0.,0.,1.,1.);
377  TLine *lineMax = new TLine(0.,0.,1.,1.);
378  lineMin->SetLineColor(kGreen+2);
379  lineMax->SetLineColor(kGreen+2);
380 
381  gStyle->SetPaintTextFormat("1.0f"); //For histo hSpaceEntriesDiscard.
382  gStyle->SetTextSize(0.5);
383 
384  //gStyle->SetStatFontSize(0.05); //So as to increase the size of the tower numbers in the stat box. But we don't want to do that for all the histoes in the file, so we prefer the following instead.
385  TPaveStats *ptrPaveStat;
386  TPave *paveUncertStatus = new TPave(0.95,1.0,0.845,0.850,2,"NDC");
387  paveUncertStatus->SetFillStyle(1001);
388  TPave *paveMassStatus = new TPave(0.95,1.0,0.845,0.850,2,"NDC");
389  paveMassStatus->SetFillStyle(1001);
390  TPave **paveCutsStatus;
391  paveCutsStatus = new TPave*[kNbFitParams];
392  for (i=0;i<kNbFitParams;i++)
393  {paveCutsStatus[i] = new TPave(0.95,1.0,0.845,0.850,4,"NDC");
394  //paveCutsStatus[i]->SetFillStyle(1001);
395  }
396 
397  char **varName;
398  varName = new char*[kNbFitParams+kNbExtraParams];
399  char **varNameLong;
400  varNameLong = new char*[kNbFitParams+kNbExtraParams];
401  varName[0]="A";
402  varName[1]="#mu (MeV)";
403  varName[2]="#sigma (MeV)";
404  varName[3]="c";
405  varName[4]="b";
406  varName[5]="a";
407  varName[6]="I";
408  varName[7]="Khi2/Ndf";
409  varName[8]="S";
410  varName[9]="I-S";
411  varName[10]="Khi2/Ndf peak";
412  varName[11]="Khi2/Ndf peakLeft";
413  varName[12]="Khi2/Ndf peakRight";
414  varNameLong[0]="Amplitude of gaussian fit";
415  varNameLong[1]="Mean of gaussian fit";
416  varNameLong[2]="Width of gaussian fit";
417  varNameLong[3]="Polynom coeff c";
418  varNameLong[4]="Polynom coeff b";
419  varNameLong[5]="Polynom coeff a";
420  varNameLong[6]="Histogram integral";
421  varNameLong[7]="Khi2/Ndf";
422  varNameLong[8]="Integral of gaussian fit";
423  varNameLong[9]="Histo-gaussian integrals";
424  varNameLong[10]="Khi2/Ndf around peak";
425  varNameLong[11]="Khi2/Ndf half-peak left";
426  varNameLong[12]="Khi2/Ndf half-peak right";
427 
428 
429 
430 
431 
432 
433  //*****************************************
434  // Define plots'ranges and cut values :
435  //*****************************************
436 
437  //CUSTOMIZE customize : (if necessary) :
438  //Pass0 on DCAL and third-SMs :
439  //Pass1 on DCAL and third-SMs :
440  //Pass2 on DCAL and third-SMs :
441  //Pass3 on DCAL and third-SMs :
442  tabMin[0]=0.;
443  tabMin[1]=78.;
444  tabMin[2]=1.;
445  tabMin[3]=-150.;
446  tabMin[4]=-3.0;
447  tabMin[5]=-0.014;
448  tabMin[6]=0.;
449  tabMin[7]=0.;
450  tabMin[8]=-100.;
451  tabMin[9]=-700.;
452  tabMin[10]=0.;
453  tabMin[11]=0.;
454  tabMin[12]=0.;
455  tabMax[0]=1200.;
456  tabMax[1]=161.;
457  tabMax[2]=36.;
458  tabMax[3]=600.;
459  tabMax[4]=5.0;
460  tabMax[5]=0.0100;
461  tabMax[6]=100000.;
462  tabMax[7]=30.;
463  tabMax[8]=20000.;
464  tabMax[9]=80000.;
465  tabMax[10]=30.;
466  tabMax[11]=7.5;
467  tabMax[12]=7.5;
468  nbEntriesMax=100000.;
469 
470  tabMinDiff[0]=0.;
471  tabMinDiff[1]=0.8;
472  tabMinDiff[2]=0;
473  tabMinDiff[3]=-20.;
474  tabMinDiff[4]=-0.7;
475  tabMinDiff[5]=-0.004;
476  tabMinDiff[6]=0.7;
477  tabMinDiff[7]=0.7;
478  tabMinDiff[8]=0.;
479  tabMaxDiff[0]=4.;
480  tabMaxDiff[1]=1.2;
481  tabMaxDiff[2]=4.;
482  tabMaxDiff[3]=25.;
483  tabMaxDiff[4]=1.;
484  tabMaxDiff[5]=0.004;
485  tabMaxDiff[6]=1.8;
486  tabMaxDiff[7]=1.9;
487  tabMaxDiff[8]=4.;
488 
489  cutEntriesDiscard=500.; //It's impossible to have a decent pi0 peak with less than 500 entries in the histo. Shy peaks start to appear around 800 entries, very few are found below 1000.
490  cutAmpDiscard=8.001;
491 
492  //CUSTOMIZE customize :
493 
494  //Pass0 on DCAL :
495  /*cutMin[0]=10.;
496  cutMin[0]=70.; //Check made later.
497  cutMin[1]=128.;
498  cutMin[2]=8.0; //Default = 7.0.
499  cutMin[3]=-50.;
500  cutMin[4]=-1.00;
501  cutMin[5]=-0.008;
502  cutMin[6]=500.;
503  cutMin[7]=0.;
504  cutMin[8]=200.;
505  cutMin[8]=1500.; //Check made later.
506  cutMin[9]=500.;
507  cutMax[0]=950.;
508  cutMax[1]=153.;
509  cutMax[2]=24.;
510  cutMax[3]=400.;
511  cutMax[4]=2.3;
512  cutMax[5]=0.0022;
513  cutMax[6]=43000.;
514  cutMax[7]=3.6;
515  cutMax[8]=13500.;
516  cutMax[9]=40000.;*/
517 
518  //Pass0 (w/ time cuts) on DCAL :
519 // cutMin[0]=40.;
520 // cutMin[1]=130.;
521 // cutMin[2]=8.0;
522 // cutMin[3]=-25.;
523 // cutMin[4]=-1.20;
524 // cutMin[5]=-0.006;
525 // cutMin[6]=1000.;
526 // cutMin[7]=0.3;
527 // cutMin[8]=450.;
528 // cutMin[9]=250.;
529 // cutMin[10]=0.15;
530 // cutMin[11]=0.15;
531 // cutMin[12]=0.15;
532 // cutMax[0]=1000.;
533 // cutMax[1]=140.;
534 // cutMax[2]=20.;
535 // cutMax[3]=250.;
536 // cutMax[4]=2.0;
537 // cutMax[5]=0.0022;
538 // cutMax[6]=32000.;
539 // cutMax[7]=3.6;
540 // cutMax[8]=12000.;
541 // cutMax[9]=21000.;
542 // cutMax[10]=4.7;
543 // cutMax[11]=9.;
544 // cutMax[12]=4.0;
545 
546 //Pass0 (w/ time cuts) on EMCAL :
547  /*cutMin[0]=40.;
548  cutMin[1]=124.;
549  cutMin[2]=8.0;
550  cutMin[3]=-25.;
551  cutMin[4]=-1.0;
552  cutMin[5]=-0.004;
553  cutMin[6]=1000.;
554  cutMin[7]=0.3;
555  cutMin[8]=400.;
556  cutMin[9]=250.;
557  cutMin[10]=0.15;
558  cutMin[11]=0.15;
559  cutMin[12]=0.15;
560  cutMax[0]=800.;
561  cutMax[1]=142.;
562  cutMax[2]=20.;
563  cutMax[3]=200.;
564  cutMax[4]=1.5;
565  cutMax[5]=0.0022;
566  cutMax[6]=30000.;
567  cutMax[7]=3.6;
568  cutMax[8]=10000.;
569  cutMax[9]=18000.;
570  cutMax[10]=4.7;
571  cutMax[11]=9.;
572  cutMax[12]=4.0;*/
573 
574  //Pass0 on third-SMs :
575  /*cutMin[0]=10.;
576  cutMin[1]=133.; //Default = 128.
577  cutMin[2]=11.0; //Default = 7.0.
578  cutMin[3]=-50.;
579  cutMin[4]=-1.20;
580  cutMin[5]=-0.008;
581  cutMin[6]=500.;
582  cutMin[7]=0.;
583  cutMin[8]=200.;
584  cutMin[9]=500.;
585  cutMax[0]=500.;
586  cutMax[1]=155.;
587  cutMax[2]=32.;
588  cutMax[3]=220.;
589  cutMax[4]=2.3;
590  cutMax[5]=0.0022;
591  cutMax[6]=30000.;
592  cutMax[7]=3.6;
593  cutMax[8]=8500.;
594  cutMax[9]=35000.;*/
595 
596  //Pass1 on DCAL and third-SMs :
597  /*cutMin[0]=40.;
598  cutMin[1]=128.;
599  cutMin[2]=7.0;
600  cutMin[3]=-50.;
601  cutMin[4]=-1.20;
602  cutMin[5]=-0.006;
603  cutMin[6]=2000.;
604  cutMin[7]=0.3;
605  cutMin[8]=900.;
606  cutMin[9]=500.;
607  cutMax[0]=1030.;
608  cutMax[1]=142.;
609  cutMax[2]=20.;
610  cutMax[3]=300.;
611  cutMax[4]=2.3;
612  cutMax[5]=0.0022;
613  cutMax[6]=38000.;
614  cutMax[7]=3.6;
615  cutMax[8]=13000.;
616  cutMax[9]=25000.;*/
617 
618  //Pass2 on DCAL and third-SMs :
619  /*cutMin[0]=20.;
620  cutMin[1]=128.;
621  cutMin[2]=7.0;
622  cutMin[3]=-50.;
623  cutMin[4]=-1.20;
624  cutMin[5]=-0.006;
625  cutMin[6]=1000.;
626  cutMin[7]=0.3;
627  cutMin[8]=450.;
628  cutMin[9]=250.;
629  cutMax[0]=1030.;
630  cutMax[1]=142.;
631  cutMax[2]=20.;
632  cutMax[3]=300.;
633  cutMax[4]=2.3;
634  cutMax[5]=0.0022;
635  cutMax[6]=38000.;
636  cutMax[7]=3.6;
637  cutMax[8]=13000.;
638  cutMax[9]=25000.;*/
639 
640  //Pass3 on DCAL and third-SMs :
641  /*cutMin[0]=40.;
642  cutMin[1]=128.;
643  cutMin[2]=7.0;
644  cutMin[3]=-25.;
645  cutMin[4]=-1.20;
646  cutMin[5]=-0.006;
647  cutMin[6]=1000.;
648  cutMin[7]=0.3;
649  cutMin[8]=450.;
650  cutMin[9]=250.;
651  cutMin[10]=0.15;
652  cutMin[11]=0.15;
653  cutMin[12]=0.15;
654  cutMax[0]=900.;
655  cutMax[1]=142.;
656  cutMax[2]=20.;
657  cutMax[3]=230.;
658  cutMax[4]=1.8;
659  cutMax[5]=0.0022;
660  cutMax[6]=32000.;
661  cutMax[7]=3.6;
662  cutMax[8]=10800.;
663  cutMax[9]=20000.;
664  cutMax[10]=4.7;
665  cutMax[11]=9.;
666  cutMax[12]=4.0;*/
667 
668  //Pass4 on DCAL and EMCAL third-SMs :
669  /*cutMin[0]=40.;
670  cutMin[1]=128.;
671  cutMin[2]=8.0;
672  cutMin[3]=-25.;
673  cutMin[4]=-1.20;
674  cutMin[5]=-0.006;
675  cutMin[6]=1000.;
676  cutMin[7]=0.3;
677  cutMin[8]=450.;
678  cutMin[9]=250.;
679  cutMin[10]=0.15;
680  cutMin[11]=0.15;
681  cutMin[12]=0.15;
682  cutMax[0]=900.;
683  cutMax[1]=142.;
684  cutMax[2]=20.;
685  cutMax[3]=230.;
686  cutMax[4]=1.8;
687  cutMax[5]=0.0022;
688  cutMax[6]=32000.;
689  cutMax[7]=3.6;
690  cutMax[8]=11000.;
691  cutMax[9]=20000.;
692  cutMax[10]=4.7;
693  cutMax[11]=9.;
694  cutMax[12]=4.0;*/
695 
696  //Pass5 (last diagnostic) on DCAL and EMCAL third-SMs :
697  cutMin[0]=40.;
698  cutMin[1]=130.;
699  cutMin[2]=8.0;
700  cutMin[3]=-25.;
701  cutMin[4]=-1.20;
702  cutMin[5]=-0.006;
703  cutMin[6]=1000.;
704  cutMin[7]=0.3;
705  cutMin[8]=450.;
706  cutMin[9]=250.;
707  cutMin[10]=0.15;
708  cutMin[11]=0.15;
709  cutMin[12]=0.15;
710  cutMax[0]=1000.;
711  cutMax[1]=140.;
712  cutMax[2]=20.;
713  cutMax[3]=250.;
714  cutMax[4]=2.0;
715  cutMax[5]=0.0022;
716  cutMax[6]=32000.;
717  cutMax[7]=3.6;
718  cutMax[8]=12000.;
719  cutMax[9]=21000.;
720  cutMax[10]=4.7;
721  cutMax[11]=9.;
722  cutMax[12]=4.0;
723 
724 
725  //LHC15i for special trigger study :
726  /*cutMin[0]=20.;
727  cutMin[1]=128.;
728  cutMin[2]=7.0;
729  cutMin[3]=-40.;
730  cutMin[4]=-0.4;
731  cutMin[5]=-0.003;
732  cutMin[6]=1000.;
733  cutMin[7]=0.3;
734  cutMin[8]=450.;
735  cutMin[9]=250.;
736  cutMin[10]=0.;
737  cutMax[0]=400.;
738  cutMax[1]=142.;
739  cutMax[2]=20.;
740  cutMax[3]=100.;
741  cutMax[4]=1.;
742  cutMax[5]=0.001;
743  cutMax[6]=20000.;
744  cutMax[7]=3.6;
745  cutMax[8]=5000.;
746  cutMax[9]=15000.;
747  cutMax[10]=3.5;*/
748 
749  //LHC15j Special trigger for special trigger study :
750  /*cutMin[0]=20.;
751  cutMin[1]=128.;
752  cutMin[2]=7.0;
753  cutMin[3]=-40.;
754  cutMin[4]=-0.4;
755  cutMin[5]=-0.002;
756  cutMin[6]=1000.;
757  cutMin[7]=0.3;
758  cutMin[8]=450.;
759  cutMin[9]=250.;
760  cutMin[10]=0.;
761  cutMax[0]=100.;
762  cutMax[1]=142.;
763  cutMax[2]=20.;
764  cutMax[3]=60.;
765  cutMax[4]=0.8;
766  cutMax[5]=0.001;
767  cutMax[6]=10000.;
768  cutMax[7]=3.6;
769  cutMax[8]=3000.;
770  cutMax[9]=10000.;
771  cutMax[10]=3.5;*/
772 
773  //LHC15i for left shoulder :
774  /*cutMin[0]=20.;
775  cutMin[1]=132.;
776  cutMin[2]=9.0;
777  cutMin[3]=-50.;
778  cutMin[4]=-1.20;
779  cutMin[5]=-0.006;
780  cutMin[6]=1000.;
781  cutMin[7]=0.3;
782  cutMin[8]=450.;
783  cutMin[9]=250.;
784  cutMin[10]=0.;
785  cutMax[0]=1030.; //changed
786  cutMax[1]=138.;
787  cutMax[2]=20.;
788  cutMax[3]=300.; //changed
789  cutMax[4]=2.3;
790  cutMax[5]=0.0022;
791  cutMax[6]=38000.;
792  cutMax[7]=3.6;
793  cutMax[8]=13000.;
794  cutMax[9]=25000.;
795  cutMax[10]=2.0;*/
796 
797 
798 
799  //*****************************************
800  // Define pT bins :
801  //*****************************************
802 
803  //CUSTOMIZE customize : (if necessary) :
804  int nbPtBins;
805  nbPtBins=21; //Number of bins in pT
806 
807  //Table with borders between pT bins :
808  double *tabPtBins;
809  tabPtBins = new double[nbPtBins-1];
810  tabPtBins[0]=1.0;//ok pour energy cut = 0.5
811  tabPtBins[1]=1.2;
812  tabPtBins[2]=1.4;
813  tabPtBins[3]=1.6;
814  tabPtBins[4]=1.8;
815  tabPtBins[5]=2.0;
816  tabPtBins[6]=2.2;
817  tabPtBins[7]=2.4;
818  tabPtBins[8]=2.6;
819  tabPtBins[9]=2.8;
820  tabPtBins[10]=3.0;
821  tabPtBins[11]=3.3;
822  tabPtBins[12]=3.6;
823  tabPtBins[13]=3.9;
824  tabPtBins[14]=4.2;
825  tabPtBins[15]=4.6;
826  tabPtBins[16]=5.0;
827  tabPtBins[17]=5.4;
828  tabPtBins[18]=5.8;
829  tabPtBins[19]=6.2;
830 
831 
832 
833 
834 
835 
836 
837  //*****************************************
838  // Get histoes from input file :
839  //*****************************************
840 
841  //CUSTOMIZE customize : (if necessary) :
842  //TList *l05 = (TList *) f05->Get("Pi0Calibration_TrigCEMC7");
843  //TList *l05 = (TList *) f05->Get("Pi0Calibration_TrigCINT");
844  //TList *l05 = (TList *) f05->Get("pi0calib");
845  //TList *l05 = (TList *) f05->Get("Pi0Calibration_TrigCEMC");
846  TList *l05 = (TList *) f05->Get("Pi0Calibration_Trig");
847  //TList *l05 = (TList *) f05->Get("Pi0Calibration_TrigEMC");
848  if (l05 == NULL)
849  {printf("\n\nNull pointer to TList.\n");
850  printf("Try with this other name instead :\n");
851  return;
852  }
853 
854  const int kNbZones=7;
855  TH2F **hAllM_05_SM,**hAllM_05_SM_masked,***hAllM_05_SM_Zones,**hAllM_05_Zones;
856  hAllM_05_SM = new TH2F*[kNbSMtot];
857  hAllM_05_SM_masked = new TH2F*[kNbSMtot];
858  hAllM_05_SM_Zones = new TH2F**[kNbSMtot];
859  hAllM_05_Zones = new TH2F*[kNbZones];
860  TH2F *hAllM_05 = (TH2F *) l05->FindObject("hmgg");
861  TH2F *hAllM_05_masked = (TH2F *)hAllM_05->Clone("hmgg_masked");
862  for (j=0;j<kNbZones;j++)
863  {hAllM_05_Zones[j] = (TH2F *)hAllM_05->Clone(Form("hmgg_Zone%d",j+1));
864  }
865  for (i=0;i<kNbSMtot;i++)
866  {hAllM_05_SM[i] = (TH2F *) l05->FindObject(Form("hmgg_SM%d",i));
867  hAllM_05_SM_masked[i] = (TH2F *) l05->FindObject(Form("hmgg_SM%d_MaskFrame",i));
868  hAllM_05_SM_Zones[i] = new TH2F*[kNbZones];
869  for (j=0;j<kNbZones;j++)
870  {hAllM_05_SM_Zones[i][j] = (TH2F *) l05->FindObject(Form("hmgg_SM%d_Zone%d",i,j+1));
871  }
872  }
873  /*hAllM_05_SM[0] = (TH2F *) l05->FindObject("hmgg_SM0");
874  hAllM_05_SM[1] = (TH2F *) l05->FindObject("hmgg_SM1");
875  hAllM_05_SM[2] = (TH2F *) l05->FindObject("hmgg_SM2");
876  hAllM_05_SM[3] = (TH2F *) l05->FindObject("hmgg_SM3");
877  hAllM_05_SM[4] = (TH2F *) l05->FindObject("hmgg_SM4");
878  hAllM_05_SM[5] = (TH2F *) l05->FindObject("hmgg_SM5");
879  hAllM_05_SM[6] = (TH2F *) l05->FindObject("hmgg_SM6");
880  hAllM_05_SM[7] = (TH2F *) l05->FindObject("hmgg_SM7");
881  hAllM_05_SM[8] = (TH2F *) l05->FindObject("hmgg_SM8");
882  hAllM_05_SM[9] = (TH2F *) l05->FindObject("hmgg_SM9");
883  hAllM_05_SM_masked[0] = (TH2F *) l05->FindObject("hmgg_SM0_MaskFrame");
884  hAllM_05_SM_masked[1] = (TH2F *) l05->FindObject("hmgg_SM1_MaskFrame");
885  hAllM_05_SM_masked[2] = (TH2F *) l05->FindObject("hmgg_SM2_MaskFrame");
886  hAllM_05_SM_masked[3] = (TH2F *) l05->FindObject("hmgg_SM3_MaskFrame");
887  hAllM_05_SM_masked[4] = (TH2F *) l05->FindObject("hmgg_SM4_MaskFrame");
888  hAllM_05_SM_masked[5] = (TH2F *) l05->FindObject("hmgg_SM5_MaskFrame");
889  hAllM_05_SM_masked[6] = (TH2F *) l05->FindObject("hmgg_SM6_MaskFrame");
890  hAllM_05_SM_masked[7] = (TH2F *) l05->FindObject("hmgg_SM7_MaskFrame");
891  hAllM_05_SM_masked[8] = (TH2F *) l05->FindObject("hmgg_SM8_MaskFrame");
892  hAllM_05_SM_masked[9] = (TH2F *) l05->FindObject("hmgg_SM9_MaskFrame");*/
893 
894  TH1F *hNevts = (TH1F*)l05->FindObject("hNEvents");
895  printf("\n\nNumber of events in histo hNEvents : %d, nb of entries %d (%d Mevts).\n\n",(int)hNevts->GetBinContent(1),(int)hNevts->GetEntries(),(int)(hNevts->GetEntries()/1000000.));
896 
897  hAllM_05->Reset();
898  hAllM_05_masked->Reset();
899  for (j=0;j<kNbZones;j++)
900  {hAllM_05_Zones[j]->Reset();
901  }
902  for (i=0;i<kNbSMtot;i++)
903  {if (tabChoiceCalos[SMdetType[i]] == 1)
904  {hAllM_05->Add(hAllM_05_SM[i]);
905  hAllM_05_masked->Add(hAllM_05_SM_masked[i]);
906  for (j=0;j<kNbZones;j++)
907  {hAllM_05_Zones[j]->Add(hAllM_05_SM_Zones[i][j]);
908  }
909  }
910  }
911 
912 
913 
914 
915 
916 
917 
918  //*****************************************
919  // Instanciate pT histoes and graphs :
920  //*****************************************
921 
922  TH1F **hAllMPerSM,**hMassDistrPerSMPerPtPerZone;
923  hAllMPerSM = new TH1F*[3*(nbPtBins+1)*(kNbSMtot+1)];
924  hMassDistrPerSMPerPtPerZone = new TH1F*[kNbZones*(nbPtBins+1)*(kNbSMtot+1)];
925  // pT bin "nbPtBins" : pT-integrated. SM bin "kNbSMtot" : integrated over SMs.
926  for (i=0;i<(kNbSMtot+1);i++)
927  {for (j=0;j<(nbPtBins+1);j++)
928  {for (k=0;k<3;k++)
929  {hAllMPerSM[(3*(nbPtBins+1))*i+3*j+k] = new TH1F(Form("hAllMPerSM%d_pT%d_%d",i,j,k),Form("hAllMPerSM%d_pT%d_%d",i,j,k),hAllM_05->GetNbinsX(),hAllM_05->GetXaxis()->GetXmin(),hAllM_05->GetXaxis()->GetXmax());
930  hAllMPerSM[(3*(nbPtBins+1))*i+3*j+k]->SetXTitle("#pi^{0} inv mass (MeV)");
931  hAllMPerSM[(3*(nbPtBins+1))*i+3*j+k]->SetYTitle("Counts");
932  //hAllMPerSM[(3*(nbPtBins+1))*i+3*j+k]->SetStats(0);
933  hAllMPerSM[(3*(nbPtBins+1))*i+3*j+k]->SetLineColor(colorIndexStruct[k]);
934  }
935  for (k=0;k<kNbZones;k++)
936  {hMassDistrPerSMPerPtPerZone[(kNbZones*(nbPtBins+1))*i+kNbZones*j+k] = new TH1F(Form("hMassDistrPerSMPerPtPerZone_SM%d_pT%d_Zone%d",i,j,k),Form("hMassDistrPerSMPerPtPerZone%d_pT%d_Zone%d",i,j,k),hAllM_05->GetNbinsX(),hAllM_05->GetXaxis()->GetXmin(),hAllM_05->GetXaxis()->GetXmax());
937  hMassDistrPerSMPerPtPerZone[(kNbZones*(nbPtBins+1))*i+kNbZones*j+k]->SetXTitle("#pi^{0} inv mass (MeV)");
938  hMassDistrPerSMPerPtPerZone[(kNbZones*(nbPtBins+1))*i+kNbZones*j+k]->SetYTitle("Counts");
939  hMassDistrPerSMPerPtPerZone[(kNbZones*(nbPtBins+1))*i+kNbZones*j+k]->SetLineColor(colorIndexZones[k]);
940  }
941  }
942  }
943 
944  double *tabGraphX,*tabGraphYmass,*tabGraphYsig,*tabGraphYnumber,*tabGraphYnumberRatio,*tabErrGraphX,*tabErrGraphYmass,*tabErrGraphYsig,*tabErrGraphYnumber,*tabErrGraphYnumberRatio;
945  double *tabTmpGraphYmass,*tabTmpGraphYsig,*tabTmpGraphYnumber,*tabTmpGraphYnumberRatio,*tabTmpErrGraphYmass,*tabTmpErrGraphYsig,*tabTmpErrGraphYnumber,*tabTmpErrGraphYnumberRatio;
946  double cmptPtMoyLow,cmptPtMoyHigh;
947  double pTmoyLow,pTmoyHigh;
948 
949  tabGraphX = new double[nbPtBins];
950  tabGraphYmass = new double[kNbZones*nbPtBins];
951  tabGraphYsig = new double[kNbZones*nbPtBins];
952  tabGraphYnumber = new double[kNbZones*nbPtBins];
953  tabGraphYnumberRatio = new double[((int)(kNbZones/2))*(kNbZones-1)*nbPtBins];
954  tabErrGraphX = new double[nbPtBins];
955  tabErrGraphYmass = new double[kNbZones*nbPtBins];
956  tabErrGraphYsig = new double[kNbZones*nbPtBins];
957  tabErrGraphYnumber = new double[kNbZones*nbPtBins];
958  tabErrGraphYnumberRatio = new double[((int)(kNbZones/2))*(kNbZones-1)*nbPtBins];
959  tabTmpGraphYmass = new double[nbPtBins];
960  tabTmpGraphYsig = new double[nbPtBins];
961  tabTmpGraphYnumber = new double[nbPtBins];
962  tabTmpGraphYnumberRatio = new double[nbPtBins];
963  tabTmpErrGraphYmass = new double[nbPtBins];
964  tabTmpErrGraphYsig = new double[nbPtBins];
965  tabTmpErrGraphYnumber = new double[nbPtBins];
966  tabTmpErrGraphYnumberRatio = new double[nbPtBins];
967 
968  TGraphErrors **tgeMass,**tgeSig,**tgeNumber,**tgeNumberRatio,**tgeMassZones,**tgeSigZones,**tgeNumberZones,**tgeNumberRatioZones;
969  tgeMass = new TGraphErrors*[3*(kNbSMtot+1)];
970  tgeSig = new TGraphErrors*[3*(kNbSMtot+1)];
971  tgeNumber = new TGraphErrors*[3*(kNbSMtot+1)];
972  tgeNumberRatio = new TGraphErrors*[3*(kNbSMtot+1)];
973  tgeMassZones = new TGraphErrors*[kNbZones*(kNbSMtot+1)];
974  tgeSigZones = new TGraphErrors*[kNbZones*(kNbSMtot+1)];
975  tgeNumberZones = new TGraphErrors*[kNbZones*(kNbSMtot+1)];
976  tgeNumberRatioZones = new TGraphErrors*[((int)(kNbZones/2))*(kNbZones-1)*(kNbSMtot+1)];
977 
978 
979 
980 
981 
982 
983  //*****************************************
984  // Instanciate other histoes :
985  //*****************************************
986 
987  TH2F **hSpace;
988  TH2F **hSpaceIntg;
989  TH2F **hSpaceCuts;
990  TH2F **hSpaceCoeff;
991  TH2F **hSpaceDiff;
992  TH2F **hSpaceFitErr;
993  TH2F **hSpaceEntriesDiscard;
994  TH2F **hSpaceEntriesDiscardHack;
995  hSpace = new TH2F*[kNbFitParams*kNbSMtot];
996  hSpaceIntg = new TH2F*[kNbExtraParams*kNbSMtot];
997  hSpaceCuts = new TH2F*[5*kNbSMtot];
998  hSpaceCoeff = new TH2F*[1*kNbSMtot];
999  hSpaceDiff = new TH2F*[kNbTotParams*kNbSMtot];
1000  hSpaceFitErr = new TH2F*[1*kNbSMtot];
1001  hSpaceEntriesDiscard = new TH2F*[1*kNbSMtot];
1002  hSpaceEntriesDiscardHack = new TH2F*[1*kNbSMtot];
1003  for (i=0;i<kNbSMtot;i++)
1004  {for (j=0;j<kNbFitParams;j++)
1005  {hSpace[kNbFitParams*i+j] = new TH2F(Form("hSpace_SM%d_%d",i,j),Form("hSpace_SM%d_%d",i,j),kNbColMax,-0.5,kNbColMax-0.5,kNbRowMax,-0.5,kNbRowMax-0.5);
1006  hSpace[kNbFitParams*i+j]->SetXTitle("Column");
1007  hSpace[kNbFitParams*i+j]->SetYTitle("Row");
1008  hSpace[kNbFitParams*i+j]->SetStats(0);
1009  hSpace[kNbFitParams*i+j]->SetContour(30);
1010  }
1011  for (j=0;j<kNbExtraParams;j++)
1012  {hSpaceIntg[kNbExtraParams*i+j] = new TH2F(Form("hSpaceIntg_SM%d_%d",i,j),Form("hSpaceIntg_SM%d_%d",i,j),kNbColMax,-0.5,kNbColMax-0.5,kNbRowMax,-0.5,kNbRowMax-0.5);
1013  hSpaceIntg[kNbExtraParams*i+j]->SetXTitle("Column");
1014  hSpaceIntg[kNbExtraParams*i+j]->SetYTitle("Row");
1015  hSpaceIntg[kNbExtraParams*i+j]->SetStats(0);
1016  hSpaceIntg[kNbExtraParams*i+j]->SetContour(30);
1017  }
1018  for (j=0;j<5;j++)
1019  {hSpaceCuts[5*i+j] = new TH2F(Form("hSpaceCuts_SM%d_%d",i,j),Form("hSpaceCuts_SM%d_%d",i,j),kNbColMax,-0.5,kNbColMax-0.5,kNbRowMax,-0.5,kNbRowMax-0.5);
1020  hSpaceCuts[5*i+j]->SetXTitle("Column");
1021  hSpaceCuts[5*i+j]->SetYTitle("Row");
1022  hSpaceCuts[5*i+j]->SetStats(0);
1023  hSpaceCuts[5*i+j]->SetContour(30);
1024  }
1025  for (j=0;j<1;j++)
1026  {hSpaceCoeff[1*i+j] = new TH2F(Form("hSpaceCoeff_SM%d_%d",i,j),Form("hSpaceCoeff_SM%d_%d",i,j),kNbColMax,-0.5,kNbColMax-0.5,kNbRowMax,-0.5,kNbRowMax-0.5);
1027  hSpaceCoeff[1*i+j]->SetXTitle("Column");
1028  hSpaceCoeff[1*i+j]->SetYTitle("Row");
1029  hSpaceCoeff[1*i+j]->SetStats(0);
1030  hSpaceCoeff[1*i+j]->SetContour(30);
1031  hSpaceFitErr[1*i+j] = new TH2F(Form("hSpaceFitErr_SM%d_%d",i,j),Form("hSpaceFitErr_SM%d_%d",i,j),kNbColMax,-0.5,kNbColMax-0.5,kNbRowMax,-0.5,kNbRowMax-0.5);
1032  hSpaceFitErr[1*i+j]->SetXTitle("Column");
1033  hSpaceFitErr[1*i+j]->SetYTitle("Row");
1034  hSpaceFitErr[1*i+j]->SetStats(0);
1035  hSpaceFitErr[1*i+j]->SetContour(30);
1036  hSpaceEntriesDiscard[1*i+j] = new TH2F(Form("hSpaceEntriesDiscard_SM%d_%d",i,j),Form("hSpaceEntriesDiscard_SM%d_%d",i,j),kNbColMax,-0.5,kNbColMax-0.5,kNbRowMax,-0.5,kNbRowMax-0.5);
1037  hSpaceEntriesDiscard[1*i+j]->SetXTitle("Column");
1038  hSpaceEntriesDiscard[1*i+j]->SetYTitle("Row");
1039  hSpaceEntriesDiscard[1*i+j]->SetStats(0);
1040  hSpaceEntriesDiscard[1*i+j]->SetContour(30);
1041  hSpaceEntriesDiscardHack[1*i+j] = new TH2F(Form("hSpaceEntriesDiscardHack_SM%d_%d",i,j),Form("hSpaceEntriesDiscardHack_SM%d_%d",i,j),kNbColMax,-0.5,kNbColMax-0.5,kNbRowMax,-0.5,kNbRowMax-0.5);
1042  hSpaceEntriesDiscardHack[1*i+j]->SetStats(0);
1043  hSpaceEntriesDiscardHack[1*i+j]->Fill(-1,5.); //Plot must have an entry to plot some text, thus to change the text size ! But putting the entry out of the drawable range also works.
1044  hSpaceEntriesDiscardHack[1*i+j]->SetMarkerSize(1.5);
1045  }
1046  for (j=0;j<kNbTotParams;j++)
1047  {hSpaceDiff[kNbTotParams*i+j] = new TH2F(Form("hSpaceDiff_SM%d_%d",i,j),Form("hSpaceDiff_SM%d_%d",i,j),kNbColMax,-0.5,kNbColMax-0.5,kNbRowMax,-0.5,kNbRowMax-0.5);
1048  hSpaceDiff[kNbTotParams*i+j]->SetXTitle("Column");
1049  hSpaceDiff[kNbTotParams*i+j]->SetYTitle("Row");
1050  hSpaceDiff[kNbTotParams*i+j]->SetStats(0);
1051  hSpaceDiff[kNbTotParams*i+j]->SetContour(30);
1052  }
1053  }
1054  TH1F *hAllDistribNbEntries;
1055  hAllDistribNbEntries = new TH1F("hAllDistribNbEntries","hAllDistribNbEntries",100,0.,nbEntriesMax);
1056  hAllDistribNbEntries->SetXTitle("Nb of entries");
1057  hAllDistribNbEntries->SetYTitle("Counts");
1058  hAllDistribNbEntries->SetStats(0);
1059  TH2F *hAllDistribNbEntriesCorrel;
1060  hAllDistribNbEntriesCorrel = new TH2F("hAllDistribNbEntriesCorrel","hAllDistribNbEntriesCorrel",100,tabMin[6],tabMax[6]/4.,100,0.,nbEntriesMax/4.);
1061  hAllDistribNbEntriesCorrel->SetXTitle("I");
1062  hAllDistribNbEntriesCorrel->SetYTitle("Nb of entries");
1063  hAllDistribNbEntriesCorrel->SetStats(0);
1064  TH1F **hAllDistrib;
1065  TH1F **hAllDistribDistance;
1066  TH1F **hAllDistribDistance2;
1067  TH1F *hAllDistribMass;
1068  TH1F *hAllOldDistribMass;
1069  TH1F *hMassPerSM;
1070  TH1F *hMassOldPerSM;
1071  TH1F **hAllDistribMassPerSM;
1072  TH1F **hAllOldDistribMassPerSM;
1073  TH1F **hAllDistribIntg;
1074  TH2F **hAllSpaceEMCAL;
1075  TH2F **hAllSpaceEMCALIntg;
1076  TH2F **hAllSpaceEMCALCoeff;
1077  TH2F **hAllSpaceEMCALDistance;
1078  TH2F **hAllSpaceEMCALDiff;
1079  TH2F **hAllSpaceDCAL;
1080  TH2F **hAllSpaceDCALIntg;
1081  TH2F **hAllSpaceDCALCoeff;
1082  TH2F **hAllSpaceDCALDistance;
1083  TH2F **hAllSpaceDCALDiff;
1084  TH1F **hAllOldDistrib;
1085  TH1F **hAllDiff;
1086  TH1F **hAllDiffAllTw;
1087  hAllDistribMassPerSM = new TH1F*[kNbSMtot];
1088  hAllOldDistribMassPerSM = new TH1F*[kNbSMtot];
1089  hAllDistrib = new TH1F*[kNbFitParams];
1090  hAllDistribDistance = new TH1F*[3];
1091  hAllDistribDistance2 = new TH1F*[2*2];
1092  hAllDistribIntg = new TH1F*[kNbExtraParams];
1093  hAllSpaceEMCAL = new TH2F*[kNbFitParams];
1094  hAllSpaceEMCALIntg = new TH2F*[kNbExtraParams];
1095  hAllSpaceEMCALCoeff = new TH2F*[1];
1096  hAllSpaceEMCALDistance = new TH2F*[3];
1097  hAllSpaceEMCALDiff = new TH2F*[kNbTotParams];
1098  hAllSpaceDCAL = new TH2F*[kNbFitParams];
1099  hAllSpaceDCALIntg = new TH2F*[kNbExtraParams];
1100  hAllSpaceDCALCoeff = new TH2F*[1];
1101  hAllSpaceDCALDistance = new TH2F*[3];
1102  hAllSpaceDCALDiff = new TH2F*[kNbTotParams];
1103  hAllOldDistrib = new TH1F*[kNbFitParams+kNbExtraParams];
1104  hAllDiff = new TH1F*[kNbTotParams];
1105  hAllDiffAllTw = new TH1F*[kNbTotParams];
1106 
1107 
1108  for (j=0;j<kNbSMtot;j++)
1109  {hAllDistribMassPerSM[j] = new TH1F(Form("hAllDistribMassPerSM_%d",j),Form("hAllDistribMassPerSM_%d",j),150,mPDG-10.,mPDG+10.);
1110  hAllDistribMassPerSM[j]->SetXTitle(Form("#pi^{0} inv mass (MeV) SM %d",j));
1111  hAllDistribMassPerSM[j]->SetYTitle("Counts");
1112  hAllDistribMassPerSM[j]->SetStats(0);
1113  hAllOldDistribMassPerSM[j] = new TH1F(Form("hAllOldDistribMassPerSM%d",j),Form("hAllOldDistribMassPerSM%d",j),150,mPDG-10.,mPDG+10.);
1114  hAllOldDistribMassPerSM[j]->SetXTitle(Form("#pi^{0} inv mass (MeV) SM %d",j));
1115  hAllOldDistribMassPerSM[j]->SetYTitle("Counts");
1116  hAllOldDistribMassPerSM[j]->SetStats(0);
1117  }
1118  for (j=0;j<kNbFitParams;j++)
1119  {hAllSpaceEMCAL[j] = new TH2F(Form("hAllSpaceEMCAL_%d",j),Form("hAllSpaceEMCAL_%d",j),2*kNbColMax,-0.5,2.*kNbColMax-0.5,(int)((kNbSMEMCAL+1)/2)*kNbRowEMCAL+(int)((kNbSMEMCALthird+1)/2)*kNbRowEMCALthird,-0.5,(int)((kNbSMEMCAL+1)/2)*kNbRowEMCAL+(int)((kNbSMEMCALthird+1)/2)*kNbRowEMCALthird-0.5);
1120  hAllSpaceEMCAL[j]->SetXTitle("Column");
1121  hAllSpaceEMCAL[j]->SetYTitle("Row");
1122  hAllSpaceEMCAL[j]->SetStats(0);
1123  hAllSpaceEMCAL[j]->SetContour(30);
1124  hAllSpaceDCAL[j] = new TH2F(Form("hAllSpaceDCAL_%d",j),Form("hAllSpaceDCAL_%d",j),2*kNbColMax,-0.5,2.*kNbColMax-0.5,(int)((kNbSMDCAL+1)/2)*kNbRowDCAL+(int)((kNbSMDCALthird+1)/2)*kNbRowDCALthird,-0.5,(int)((kNbSMDCAL+1)/2)*kNbRowDCAL+(int)((kNbSMDCALthird+1)/2)*kNbRowDCALthird-0.5);
1125  hAllSpaceDCAL[j]->SetXTitle("Column");
1126  hAllSpaceDCAL[j]->SetYTitle("Row");
1127  hAllSpaceDCAL[j]->SetStats(0);
1128  hAllSpaceDCAL[j]->SetContour(30);
1129  hAllDistrib[j] = new TH1F(Form("hAllDistrib_%d",j),Form("hAllDistrib_%d",j),100,tabMin[j],tabMax[j]);
1130  hAllDistrib[j]->SetXTitle(Form("%s",varName[j]));
1131  hAllDistrib[j]->SetYTitle("Counts");
1132  hAllDistrib[j]->SetStats(0);
1133  }
1134  for (j=0;j<3;j++)
1135  {hAllDistribDistance[j] = new TH1F(Form("hAllDistribDistance_%d",j),Form("hAllDistribDistance_%d",j),100,0.,10.);
1136  hAllDistribDistance[j]->SetXTitle("(#mu_{fit}-#mu_{PDG})/#sigma");
1137  hAllDistribDistance[j]->SetYTitle("Counts");
1138  hAllDistribDistance[j]->SetStats(0);
1139  }
1140  for (j=0;j<2;j++)
1141  {hAllDistribDistance2[2*j+0] = new TH1F(Form("hAllDistribDistance2_%d_0",j),Form("hAllDistribDistance2_%d_0",j),100,0.,5.);
1142  hAllDistribDistance2[2*j+0]->SetXTitle("#sigma_{#mu} (stat) (%)");
1143  hAllDistribDistance2[2*j+0]->SetYTitle("Counts");
1144  hAllDistribDistance2[2*j+0]->SetStats(0);
1145  hAllDistribDistance2[2*j+1] = new TH1F(Form("hAllDistribDistance2_%d_1",j),Form("hAllDistribDistance2_%d_1",j),100,0.,0.2);
1146  hAllDistribDistance2[2*j+1]->SetXTitle("|#mu_{fit}-#mu_{PDG}|/#mu_{PDG}");
1147  hAllDistribDistance2[2*j+1]->SetYTitle("Counts");
1148  hAllDistribDistance2[2*j+1]->SetStats(0);
1149  }
1150  hAllDistribMass = new TH1F("hAllDistribMass","hAllDistribMass",200,mPDG-25.,mPDG+25.);
1151  hAllDistribMass->SetXTitle("#pi^{0} inv mass (MeV)");
1152  hAllDistribMass->SetYTitle("Counts");
1153  hAllDistribMass->SetStats(0);
1154  hAllOldDistribMass = new TH1F("hAllOldDistribMass","hAllOldDistribMass",200,mPDG-25.,mPDG+25.);
1155  hAllOldDistribMass->SetXTitle("#pi^{0} inv mass (MeV)");
1156  hAllOldDistribMass->SetYTitle("Counts");
1157  hAllOldDistribMass->SetStats(0);
1158  hMassPerSM = new TH1F("hMassPerSM","hMassPerSM",kNbSMtot,-0.5,kNbSMtot-0.5);
1159  hMassPerSM->SetXTitle("SM number");
1160  hMassPerSM->SetYTitle("#pi^{0} inv mass (MeV)");
1161  hMassPerSM->SetStats(0);
1162  hMassOldPerSM = new TH1F("hMassOldPerSM","hMassOldPerSM",kNbSMtot,-0.42,kNbSMtot-0.42); //Move a bit so as to plot together with hMassPerSM.
1163  hMassOldPerSM->SetXTitle("SM number");
1164  hMassOldPerSM->SetYTitle("#pi^{0} inv mass (MeV)");
1165  hMassOldPerSM->SetStats(0);
1166  for (j=0;j<kNbExtraParams;j++)
1167  {hAllSpaceEMCALIntg[j] = new TH2F(Form("hAllSpaceEMCALIntg_%d",j),Form("hAllSpaceEMCALIntg_%d",j),2*kNbColMax,-0.5,2.*kNbColMax-0.5,(int)((kNbSMEMCAL+1)/2)*kNbRowEMCAL+(int)((kNbSMEMCALthird+1)/2)*kNbRowEMCALthird,-0.5,(int)((kNbSMEMCAL+1)/2)*kNbRowEMCAL+(int)((kNbSMEMCALthird+1)/2)*kNbRowEMCALthird-0.5);
1168  hAllSpaceEMCALIntg[j]->SetXTitle("Column");
1169  hAllSpaceEMCALIntg[j]->SetYTitle("Row");
1170  hAllSpaceEMCALIntg[j]->SetStats(0);
1171  hAllSpaceEMCALIntg[j]->SetContour(30);
1172  hAllSpaceDCALIntg[j] = new TH2F(Form("hAllSpaceDCALIntg_%d",j),Form("hAllSpaceDCALIntg_%d",j),2*kNbColMax,-0.5,2.*kNbColMax-0.5,(int)((kNbSMDCAL+1)/2)*kNbRowDCAL+(int)((kNbSMDCALthird+1)/2)*kNbRowDCALthird,-0.5,(int)((kNbSMDCAL+1)/2)*kNbRowDCAL+(int)((kNbSMDCALthird+1)/2)*kNbRowDCALthird-0.5);
1173  hAllSpaceDCALIntg[j]->SetXTitle("Column");
1174  hAllSpaceDCALIntg[j]->SetYTitle("Row");
1175  hAllSpaceDCALIntg[j]->SetStats(0);
1176  hAllSpaceDCALIntg[j]->SetContour(30);
1177  hAllDistribIntg[j] = new TH1F(Form("hAllDistribIntg_%d",j),Form("hAllDistribIntg_%d",j),100,tabMin[j+kNbFitParams],tabMax[j+kNbFitParams]);
1178  hAllDistribIntg[j]->SetXTitle(Form("%s",varName[j+kNbFitParams]));
1179  hAllDistribIntg[j]->SetYTitle("Counts");
1180  hAllDistribIntg[j]->SetStats(0);
1181  }
1182  for (j=0;j<1;j++)
1183  {hAllSpaceEMCALCoeff[j] = new TH2F(Form("hAllSpaceEMCALCoeff%d",j),Form("hAllSpaceEMCALCoeff%d",j),2*kNbColMax,-0.5,2.*kNbColMax-0.5,(int)((kNbSMEMCAL+1)/2)*kNbRowEMCAL+(int)((kNbSMEMCALthird+1)/2)*kNbRowEMCALthird,-0.5,(int)((kNbSMEMCAL+1)/2)*kNbRowEMCAL+(int)((kNbSMEMCALthird+1)/2)*kNbRowEMCALthird-0.5);
1184  hAllSpaceEMCALCoeff[j]->SetXTitle("Column");
1185  hAllSpaceEMCALCoeff[j]->SetYTitle("Row");
1186  hAllSpaceEMCALCoeff[j]->SetStats(0);
1187  hAllSpaceEMCALCoeff[j]->SetContour(30);
1188  hAllSpaceDCALCoeff[j] = new TH2F(Form("hAllSpaceDCALCoeff%d",j),Form("hAllSpaceDCALCoeff%d",j),2*kNbColMax,-0.5,2.*kNbColMax-0.5,(int)((kNbSMDCAL+1)/2)*kNbRowDCAL+(int)((kNbSMDCALthird+1)/2)*kNbRowDCALthird,-0.5,(int)((kNbSMDCAL+1)/2)*kNbRowDCAL+(int)((kNbSMDCALthird+1)/2)*kNbRowDCALthird-0.5);
1189  hAllSpaceDCALCoeff[j]->SetXTitle("Column");
1190  hAllSpaceDCALCoeff[j]->SetYTitle("Row");
1191  hAllSpaceDCALCoeff[j]->SetStats(0);
1192  hAllSpaceDCALCoeff[j]->SetContour(30);
1193  }
1194  for (j=0;j<3;j++)
1195  {hAllSpaceEMCALDistance[j] = new TH2F(Form("hAllSpaceEMCALDistance%d",j),Form("hAllSpaceEMCALDistance%d",j),2*kNbColMax,-0.5,2.*kNbColMax-0.5,(int)((kNbSMEMCAL+1)/2)*kNbRowEMCAL+(int)((kNbSMEMCALthird+1)/2)*kNbRowEMCALthird,-0.5,(int)((kNbSMEMCAL+1)/2)*kNbRowEMCAL+(int)((kNbSMEMCALthird+1)/2)*kNbRowEMCALthird-0.5);
1196  hAllSpaceEMCALDistance[j]->SetXTitle("Column");
1197  hAllSpaceEMCALDistance[j]->SetYTitle("Row");
1198  hAllSpaceEMCALDistance[j]->SetStats(0);
1199  hAllSpaceEMCALDistance[j]->SetContour(30);
1200  hAllSpaceDCALDistance[j] = new TH2F(Form("hAllSpaceDCALDistance%d",j),Form("hAllSpaceDCALDistance%d",j),2*kNbColMax,-0.5,2.*kNbColMax-0.5,(int)((kNbSMDCAL+1)/2)*kNbRowDCAL+(int)((kNbSMDCALthird+1)/2)*kNbRowDCALthird,-0.5,(int)((kNbSMDCAL+1)/2)*kNbRowDCAL+(int)((kNbSMDCALthird+1)/2)*kNbRowDCALthird-0.5);
1201  hAllSpaceDCALDistance[j]->SetXTitle("Column");
1202  hAllSpaceDCALDistance[j]->SetYTitle("Row");
1203  hAllSpaceDCALDistance[j]->SetStats(0);
1204  hAllSpaceDCALDistance[j]->SetContour(30);
1205  }
1206  for (j=0;j<kNbFitParams+kNbExtraParams;j++)
1207  {hAllOldDistrib[j] = new TH1F(Form("hAllOldDistrib_%d",j),Form("hAllOldDistrib_%d",j),100,tabMin[j],tabMax[j]);
1208  hAllOldDistrib[j]->SetXTitle(Form("%s",varName[j]));
1209  hAllOldDistrib[j]->SetYTitle("Counts");
1210  hAllOldDistrib[j]->SetStats(0);
1211  }
1212  for (j=0;j<kNbTotParams;j++)
1213  {hAllSpaceEMCALDiff[j] = new TH2F(Form("hAllSpaceEMCALDiff%d",j),Form("hAllSpaceEMCALDiff%d",j),2*kNbColMax,-0.5,2.*kNbColMax-0.5,(int)((kNbSMEMCAL+1)/2)*kNbRowEMCAL+(int)((kNbSMEMCALthird+1)/2)*kNbRowEMCALthird,-0.5,(int)((kNbSMEMCAL+1)/2)*kNbRowEMCAL+(int)((kNbSMEMCALthird+1)/2)*kNbRowEMCALthird-0.5);
1214  hAllSpaceEMCALDiff[j]->SetXTitle("Column");
1215  hAllSpaceEMCALDiff[j]->SetYTitle("Row");
1216  hAllSpaceEMCALDiff[j]->SetStats(0);
1217  hAllSpaceEMCALDiff[j]->SetContour(30);
1218  hAllSpaceDCALDiff[j] = new TH2F(Form("hAllSpaceDCALDiff%d",j),Form("hAllSpaceDCALDiff%d",j),2*kNbColMax,-0.5,2.*kNbColMax-0.5,(int)((kNbSMDCAL+1)/2)*kNbRowDCAL+(int)((kNbSMDCALthird+1)/2)*kNbRowDCALthird,-0.5,(int)((kNbSMDCAL+1)/2)*kNbRowDCAL+(int)((kNbSMDCALthird+1)/2)*kNbRowDCALthird-0.5);
1219  hAllSpaceDCALDiff[j]->SetXTitle("Column");
1220  hAllSpaceDCALDiff[j]->SetYTitle("Row");
1221  hAllSpaceDCALDiff[j]->SetStats(0);
1222  hAllSpaceDCALDiff[j]->SetContour(30);
1223  hAllDiff[j] = new TH1F(Form("hAllDiff%d",j),Form("hAllDiff%d",j),100,tabMinDiff[j],tabMaxDiff[j]);
1224  hAllDiff[j]->SetXTitle(Form("Ratio var_%d",j));
1225  hAllDiff[j]->SetYTitle("Counts");
1226  hAllDiff[j]->SetStats(0);
1227  hAllDiffAllTw[j] = new TH1F(Form("hAllDiffAllTw%d",j),Form("hAllDiffAllTw%d",j),100,tabMinDiff[j],tabMaxDiff[j]);
1228  hAllDiffAllTw[j]->SetXTitle(Form("Ratio var_%d",j));
1229  hAllDiffAllTw[j]->SetYTitle("Counts");
1230  hAllDiffAllTw[j]->SetStats(0);
1231  }
1232 
1233  TH2F *hCorrelMuVsA = new TH2F("hCorrelMuVsA","hCorrelMuVsA",100,tabMin[0],tabMax[0],100,tabMin[1],tabMax[1]);
1234  hCorrelMuVsA->SetXTitle("A");
1235  hCorrelMuVsA->SetYTitle("Mu");
1236  hCorrelMuVsA->SetStats(0);
1237  hCorrelMuVsA->SetContour(30);
1238  TH2F *hCorrelSigVsA = new TH2F("hCorrelSigVsA","hCorrelSigVsA",100,tabMin[0],tabMax[0],100,tabMin[2],tabMax[2]);
1239  hCorrelSigVsA->SetXTitle("A");
1240  hCorrelSigVsA->SetYTitle("Sig");
1241  hCorrelSigVsA->SetStats(0);
1242  hCorrelSigVsA->SetContour(30);
1243  TH2F *hCorrelSigVsMu = new TH2F("hCorrelSigVsMu","hCorrelSigVsMu",100,tabMin[1],tabMax[1],100,tabMin[2],tabMax[2]);
1244  hCorrelSigVsMu->SetXTitle("Mu");
1245  hCorrelSigVsMu->SetYTitle("Sig");
1246  hCorrelSigVsMu->SetStats(0);
1247  hCorrelSigVsMu->SetContour(30);
1248  TH2F *hCorrelBVsA = new TH2F("hCorrelBVsA","hCorrelBVsA",100,tabMin[3],tabMax[3],100,tabMin[4],tabMax[4]);
1249  hCorrelBVsA->SetXTitle("C");
1250  hCorrelBVsA->SetYTitle("B");
1251  hCorrelBVsA->SetStats(0);
1252  hCorrelBVsA->SetContour(30);
1253  TH2F *hCorrelCVsA = new TH2F("hCorrelCVsA","hCorrelCVsA",100,tabMin[3],tabMax[3],100,tabMin[5],tabMax[5]);
1254  hCorrelCVsA->SetXTitle("C");
1255  hCorrelCVsA->SetYTitle("A");
1256  hCorrelCVsA->SetStats(0);
1257  hCorrelCVsA->SetContour(30);
1258  TH2F *hCorrelCVsB = new TH2F("hCorrelCVsB","hCorrelCVsB",100,tabMin[4],tabMax[4],100,tabMin[5],tabMax[5]);
1259  hCorrelCVsB->SetXTitle("B");
1260  hCorrelCVsB->SetYTitle("A");
1261  hCorrelCVsB->SetStats(0);
1262  hCorrelCVsB->SetContour(30);
1263  TH2F *hCorrelISVsI = new TH2F("hCorrelISVsI","hCorrelISVsI",100,tabMin[6],tabMax[6],100,tabMin[9],tabMax[9]);
1264  hCorrelISVsI->SetXTitle("I");
1265  hCorrelISVsI->SetYTitle("IS");
1266  hCorrelISVsI->SetStats(0);
1267  hCorrelISVsI->SetContour(30);
1268  TH2F *hCorrelSVsI = new TH2F("hCorrelSVsI","hCorrelSVsI",100,tabMin[6],tabMax[6],100,tabMin[8],tabMax[8]);
1269  hCorrelSVsI->SetXTitle("I");
1270  hCorrelSVsI->SetYTitle("S");
1271  hCorrelSVsI->SetStats(0);
1272  hCorrelSVsI->SetContour(30);
1273  TH2F *hCorrelSVsIS = new TH2F("hCorrelSVsIS","hCorrelSVsIS",100,tabMin[9],tabMax[9],100,tabMin[8],tabMax[8]);
1274  hCorrelSVsIS->SetXTitle("IS");
1275  hCorrelSVsIS->SetYTitle("S");
1276  hCorrelSVsIS->SetStats(0);
1277  hCorrelSVsIS->SetContour(30);
1278  TH2F *hCorrelSbincountingVsS = new TH2F("hCorrelSbincountingVsS","hCorrelSbincountingVsS",100,tabMin[8],tabMax[8],100,tabMin[8],tabMax[8]);
1279  hCorrelSbincountingVsS->SetXTitle("S");
1280  hCorrelSbincountingVsS->SetYTitle("S bin counting");
1281  hCorrelSbincountingVsS->SetStats(0);
1282  hCorrelSbincountingVsS->SetContour(30);
1283  TH2F *hCorrelMuVsI = new TH2F("hCorrelMuVsI","hCorrelMuVsI",100,tabMin[6],tabMax[6],100,tabMin[1],tabMax[1]);
1284  hCorrelMuVsI->SetXTitle("I");
1285  hCorrelMuVsI->SetYTitle("Mu");
1286  hCorrelMuVsI->SetStats(0);
1287  hCorrelMuVsI->SetContour(30);
1288  TH2F *hCorrelMuVsS = new TH2F("hCorrelMuVsS","hCorrelMuVsS",100,tabMin[8],tabMax[8],100,tabMin[1],tabMax[1]);
1289  hCorrelMuVsS->SetXTitle("S");
1290  hCorrelMuVsS->SetYTitle("Mu");
1291  hCorrelMuVsS->SetStats(0);
1292  hCorrelMuVsS->SetContour(30);
1293  TH2F *hCorrelSigVsI = new TH2F("hCorrelSigVsI","hCorrelSigVsI",100,tabMin[6],tabMax[6],100,tabMin[2],tabMax[2]);
1294  hCorrelSigVsI->SetXTitle("I");
1295  hCorrelSigVsI->SetYTitle("Sig");
1296  hCorrelSigVsI->SetStats(0);
1297  hCorrelSigVsI->SetContour(30);
1298  TH2F *hCorrelSigVsS = new TH2F("hCorrelSigVsS","hCorrelSigVsS",100,tabMin[8],tabMax[8],100,tabMin[2],tabMax[2]);
1299  hCorrelSigVsS->SetXTitle("S");
1300  hCorrelSigVsS->SetYTitle("Sig");
1301  hCorrelSigVsS->SetStats(0);
1302  hCorrelSigVsS->SetContour(30);
1303  TH2F *hCorrelDvsSig = new TH2F("hCorrelDvsSig","hCorrelDvsSig",100,tabMin[2],tabMax[2],100,0.,5.);
1304  hCorrelDvsSig->SetXTitle("#sigma");
1305  hCorrelDvsSig->SetYTitle("d_{fit}");
1306  hCorrelDvsSig->SetStats(0);
1307  hCorrelDvsSig->SetContour(30);
1308  TH2F *hCorrelCmpD = new TH2F("hCorrelCmpD","hCorrelCmpD",100,0.,5.,100,-1.,5.);
1309  hCorrelCmpD->SetXTitle("d_{fit}");
1310  hCorrelCmpD->SetYTitle("(d_{N}-d_{fit})/d_{fit}");
1311  hCorrelCmpD->SetStats(0);
1312  hCorrelCmpD->SetContour(30);
1313 
1314  TH2F *hAllSpaceEMCALSoverN = new TH2F("hAllSpaceEMCALSoverN","hAllSpaceEMCALSoverN",2*kNbColMax,-0.5,2.*kNbColMax-0.5,(int)((kNbSMEMCAL+1)/2)*kNbRowEMCAL+(int)((kNbSMEMCALthird+1)/2)*kNbRowEMCALthird,-0.5,(int)((kNbSMEMCAL+1)/2)*kNbRowEMCAL+(int)((kNbSMEMCALthird+1)/2)*kNbRowEMCALthird-0.5);
1315  hAllSpaceEMCALSoverN->SetXTitle("Column");
1316  hAllSpaceEMCALSoverN->SetYTitle("Row");
1317  hAllSpaceEMCALSoverN->SetStats(0);
1318  hAllSpaceEMCALSoverN->SetContour(30);
1319  TH2F *hAllSpaceDCALSoverN = new TH2F("hAllSpaceDCALSoverN","hAllSpaceDCALSoverN",2*kNbColMax,-0.5,2.*kNbColMax-0.5,(int)((kNbSMDCAL+1)/2)*kNbRowDCAL+(int)((kNbSMDCALthird+1)/2)*kNbRowDCALthird,-0.5,(int)((kNbSMDCAL+1)/2)*kNbRowDCAL+(int)((kNbSMDCALthird+1)/2)*kNbRowDCALthird-0.5);
1320  hAllSpaceDCALSoverN->SetXTitle("Column");
1321  hAllSpaceDCALSoverN->SetYTitle("Row");
1322  hAllSpaceDCALSoverN->SetStats(0);
1323  hAllSpaceDCALSoverN->SetContour(30);
1324  TH1F *hCoeff = new TH1F("hCoeff","hCoeff",100,0.9,1.1);
1325  hCoeff->SetXTitle("Coeff");
1326  hCoeff->SetYTitle("Counts");
1327  hCoeff->SetStats(0);
1328  TH1F *hCoeffOld = new TH1F("hCoeffOld","hCoeffOld",100,0.9,1.1);
1329  hCoeffOld->SetXTitle("Coeff");
1330  hCoeffOld->SetYTitle("Counts");
1331  hCoeffOld->SetStats(0);
1332  TH1F *hCoeffOldCorr = new TH1F("hCoeffOldCorr","hCoeffOldCorr",100,0.9,1.1);
1333  hCoeffOldCorr->SetXTitle("Coeff");
1334  hCoeffOldCorr->SetYTitle("Counts");
1335  hCoeffOldCorr->SetStats(0);
1336  TH1F *hCoeffOldLarge = new TH1F("hCoeffOldLarge","hCoeffOldLarge",100,0.4,1.8);
1337  hCoeffOldLarge->SetXTitle("Coeff");
1338  hCoeffOldLarge->SetYTitle("Counts");
1339  hCoeffOldLarge->SetStats(0);
1340  TH1F *hCoeffOldCorrLarge = new TH1F("hCoeffOldCorrLarge","hCoeffOldCorrLarge",100,0.4,1.8);
1341  hCoeffOldCorrLarge->SetXTitle("Coeff");
1342  hCoeffOldCorrLarge->SetYTitle("Counts");
1343  hCoeffOldCorrLarge->SetStats(0);
1344  TH1F *hCtrlEvolMu = new TH1F("hCtrlEvolMu","hCtrlEvolMu",100,-3.,3.);
1345  hCtrlEvolMu->SetXTitle("(#mu_{2}-m_{PDG})/(#mu_{1}-m_{PDG})");
1346  hCtrlEvolMu->SetYTitle("Counts");
1347  hCtrlEvolMu->SetStats(0);
1348  TH2F *h2CtrlEvolMu1 = new TH2F("h2CtrlEvolMu1","h2CtrlEvolMu1",200,mPDG-10.,mPDG+20.,100,-3.,3.);
1349  h2CtrlEvolMu1->SetXTitle("#mu_{1}");
1350  h2CtrlEvolMu1->SetYTitle("(#mu_{2}-m_{PDG})/(#mu_{1}-m_{PDG})");
1351  h2CtrlEvolMu1->SetStats(0);
1352  h2CtrlEvolMu1->SetContour(30);
1353  TH2F *h2CtrlEvolMu2 = new TH2F("h2CtrlEvolMu2","h2CtrlEvolMu2",200,-0.1,0.2,200,-0.1,0.2);
1354  h2CtrlEvolMu2->SetXTitle("(#mu_{1}-m_{PDG})/m_{PDG}");
1355  h2CtrlEvolMu2->SetYTitle("(#mu_{1}-#mu_{2})/m_{PDG}");
1356  h2CtrlEvolMu2->SetStats(0);
1357  h2CtrlEvolMu2->SetContour(30);
1358  TH1F *hCtrlEvolCoeff = new TH1F("hCtrlEvolCoeff","hCtrlEvolCoeff",100,-3.,3.);
1359  hCtrlEvolCoeff->SetXTitle("(c_{2}-1)/(c_{1}-1)");
1360  hCtrlEvolCoeff->SetYTitle("Counts");
1361  hCtrlEvolCoeff->SetStats(0);
1362  TH2F *h2CtrlEvolCoeff1 = new TH2F("h2CtrlEvolCoeff1","h2CtrlEvolCoeff1",200,0.8,1.2,100,-3.,3.);
1363  h2CtrlEvolCoeff1->SetXTitle("c_{1}");
1364  h2CtrlEvolCoeff1->SetYTitle("(c_{2}-1)/(c_{1}-1)");
1365  h2CtrlEvolCoeff1->SetStats(0);
1366  h2CtrlEvolCoeff1->SetContour(30);
1367  TH2F *h2CtrlEvolCoeff2 = new TH2F("h2CtrlEvolCoeff2","h2CtrlEvolCoeff2",200,-0.1,0.2,200,-0.1,0.2);
1368  h2CtrlEvolCoeff2->SetXTitle("c_{1}-1");
1369  h2CtrlEvolCoeff2->SetYTitle("c_{1}-c_{2}");
1370  h2CtrlEvolCoeff2->SetStats(0);
1371  h2CtrlEvolCoeff2->SetContour(30);
1372 
1373 
1374 
1375 
1376 
1377 
1378 
1379 
1380  //*****************************************
1381  // Fill in pT histoes and graphs :
1382  //*****************************************
1383 
1384 
1385  //hAllMPerSM[(3*(nbPtBins+1))*iSM+3*iPt+iStruct]
1386 
1387  for (i=0;i<nbPtBins-2;i++)
1388  {tabGraphX[i+1]=tabPtBins[i]+(tabPtBins[i+1]-tabPtBins[i])/2.;
1389  tabErrGraphX[i+1]=(tabPtBins[i+1]-tabPtBins[i])/2.;
1390  }
1391  /*TH1F **hPtInvMass;
1392  hPtInvMass = new TH1F*[nbPtBins];
1393  for (j=0;j<nbPtBins;j++)
1394  {hPtInvMass[j] = new TH1F(Form("hPtInvMass_%d",j),Form("hPtInvMass_%d",j),hAllM_05->GetNbinsX(),hAllM_05->GetXaxis()->GetXmin(),hAllM_05->GetXaxis()->GetXmax());
1395  hPtInvMass[j]->SetXTitle("#pi^{0} inv mass (MeV)");
1396  hPtInvMass[j]->SetYTitle("Counts");
1397  hPtInvMass[j]->SetStats(0);
1398  hPtInvMass[j]->SetEntries(0);
1399  }*/
1400  pTmoyLow=0.;
1401  pTmoyHigh=0.;
1402  cmptPtMoyLow=0;
1403  cmptPtMoyHigh=0;
1404  for (i=0;i<hAllM_05->GetNbinsY();i++)
1405  {for (k=0;k<nbPtBins-1;k++)
1406  {if (hAllM_05->GetYaxis()->GetBinCenter(i+1) < tabPtBins[k]) break;
1407  }
1408  for (j=0;j<hAllM_05->GetNbinsX();j++)
1409  {/*hPtInvMass[k]->Fill(hAllM_05->GetXaxis()->GetBinCenter(j+1),hAllM_05->GetBinContent(j+1,i+1));
1410  hPtInvMass[k]->SetEntries(hPtInvMass[k]->GetEntries()+hAllM_05->GetBinContent(j+1,i+1));*/
1411  hAllMPerSM[(3*(nbPtBins+1))*kNbSMtot+3*k+0]->Fill(hAllM_05->GetXaxis()->GetBinCenter(j+1),hAllM_05->GetBinContent(j+1,i+1));
1412  hAllMPerSM[(3*(nbPtBins+1))*kNbSMtot+3*k+0]->SetEntries(hAllMPerSM[(3*(nbPtBins+1))*kNbSMtot+3*k+0]->GetEntries()+hAllM_05->GetBinContent(j+1,i+1));
1413  hAllMPerSM[(3*(nbPtBins+1))*kNbSMtot+3*nbPtBins+0]->Fill(hAllM_05->GetXaxis()->GetBinCenter(j+1),hAllM_05->GetBinContent(j+1,i+1));
1414  hAllMPerSM[(3*(nbPtBins+1))*kNbSMtot+3*nbPtBins+0]->SetEntries(hAllMPerSM[(3*(nbPtBins+1))*kNbSMtot+3*nbPtBins+0]->GetEntries()+hAllM_05->GetBinContent(j+1,i+1));
1415  hAllMPerSM[(3*(nbPtBins+1))*kNbSMtot+3*k+1]->Fill(hAllM_05->GetXaxis()->GetBinCenter(j+1),hAllM_05_masked->GetBinContent(j+1,i+1));
1416  hAllMPerSM[(3*(nbPtBins+1))*kNbSMtot+3*k+1]->SetEntries(hAllMPerSM[(3*(nbPtBins+1))*kNbSMtot+3*k+1]->GetEntries()+hAllM_05_masked->GetBinContent(j+1,i+1));
1417  hAllMPerSM[(3*(nbPtBins+1))*kNbSMtot+3*nbPtBins+1]->Fill(hAllM_05->GetXaxis()->GetBinCenter(j+1),hAllM_05_masked->GetBinContent(j+1,i+1));
1418  hAllMPerSM[(3*(nbPtBins+1))*kNbSMtot+3*nbPtBins+1]->SetEntries(hAllMPerSM[(3*(nbPtBins+1))*kNbSMtot+3*nbPtBins+1]->GetEntries()+hAllM_05_masked->GetBinContent(j+1,i+1));
1419  hAllMPerSM[(3*(nbPtBins+1))*kNbSMtot+3*k+2]->Fill(hAllM_05->GetXaxis()->GetBinCenter(j+1),hAllM_05->GetBinContent(j+1,i+1)-hAllM_05_masked->GetBinContent(j+1,i+1));
1420  hAllMPerSM[(3*(nbPtBins+1))*kNbSMtot+3*k+2]->SetEntries(hAllMPerSM[(3*(nbPtBins+1))*kNbSMtot+3*k+2]->GetEntries()+hAllM_05->GetBinContent(j+1,i+1)-hAllM_05_masked->GetBinContent(j+1,i+1));
1421  hAllMPerSM[(3*(nbPtBins+1))*kNbSMtot+3*nbPtBins+2]->Fill(hAllM_05->GetXaxis()->GetBinCenter(j+1),hAllM_05->GetBinContent(j+1,i+1)-hAllM_05_masked->GetBinContent(j+1,i+1));
1422  hAllMPerSM[(3*(nbPtBins+1))*kNbSMtot+3*nbPtBins+2]->SetEntries(hAllMPerSM[(3*(nbPtBins+1))*kNbSMtot+3*nbPtBins+2]->GetEntries()+hAllM_05->GetBinContent(j+1,i+1)-hAllM_05_masked->GetBinContent(j+1,i+1));
1423  for (m=0;m<kNbZones;m++)
1424  {hMassDistrPerSMPerPtPerZone[(kNbZones*(nbPtBins+1))*kNbSMtot+kNbZones*k+m]->Fill(hAllM_05->GetXaxis()->GetBinCenter(j+1),hAllM_05_Zones[m]->GetBinContent(j+1,i+1));
1425  hMassDistrPerSMPerPtPerZone[(kNbZones*(nbPtBins+1))*kNbSMtot+kNbZones*k+m]->SetEntries(hMassDistrPerSMPerPtPerZone[(kNbZones*(nbPtBins+1))*kNbSMtot+kNbZones*k+0]->GetEntries()+hAllM_05_Zones[m]->GetBinContent(j+1,i+1));
1426  hMassDistrPerSMPerPtPerZone[(kNbZones*(nbPtBins+1))*kNbSMtot+kNbZones*nbPtBins+m]->Fill(hAllM_05->GetXaxis()->GetBinCenter(j+1),hAllM_05_Zones[m]->GetBinContent(j+1,i+1));
1427  hMassDistrPerSMPerPtPerZone[(kNbZones*(nbPtBins+1))*kNbSMtot+kNbZones*nbPtBins+m]->SetEntries(hMassDistrPerSMPerPtPerZone[(kNbZones*(nbPtBins+1))*kNbSMtot+kNbZones*nbPtBins+0]->GetEntries()+hAllM_05_Zones[m]->GetBinContent(j+1,i+1));
1428  }
1429  for (iSM=0;iSM<kNbSMtot;iSM++)
1430  {hAllMPerSM[(3*(nbPtBins+1))*iSM+3*k+0]->Fill(hAllM_05->GetXaxis()->GetBinCenter(j+1),hAllM_05_SM[iSM]->GetBinContent(j+1,i+1));
1431  hAllMPerSM[(3*(nbPtBins+1))*iSM+3*k+0]->SetEntries(hAllMPerSM[(3*(nbPtBins+1))*iSM+3*k+0]->GetEntries()+hAllM_05_SM[iSM]->GetBinContent(j+1,i+1));
1432  hAllMPerSM[(3*(nbPtBins+1))*iSM+3*nbPtBins+0]->Fill(hAllM_05->GetXaxis()->GetBinCenter(j+1),hAllM_05_SM[iSM]->GetBinContent(j+1,i+1));
1433  hAllMPerSM[(3*(nbPtBins+1))*iSM+3*nbPtBins+0]->SetEntries(hAllMPerSM[(3*(nbPtBins+1))*iSM+3*nbPtBins+0]->GetEntries()+hAllM_05_SM[iSM]->GetBinContent(j+1,i+1));
1434  hAllMPerSM[(3*(nbPtBins+1))*iSM+3*k+1]->Fill(hAllM_05->GetXaxis()->GetBinCenter(j+1),hAllM_05_SM_masked[iSM]->GetBinContent(j+1,i+1));
1435  hAllMPerSM[(3*(nbPtBins+1))*iSM+3*k+1]->SetEntries(hAllMPerSM[(3*(nbPtBins+1))*iSM+3*k+1]->GetEntries()+hAllM_05_SM_masked[iSM]->GetBinContent(j+1,i+1));
1436  hAllMPerSM[(3*(nbPtBins+1))*iSM+3*nbPtBins+1]->Fill(hAllM_05->GetXaxis()->GetBinCenter(j+1),hAllM_05_SM_masked[iSM]->GetBinContent(j+1,i+1));
1437  hAllMPerSM[(3*(nbPtBins+1))*iSM+3*nbPtBins+1]->SetEntries(hAllMPerSM[(3*(nbPtBins+1))*iSM+3*nbPtBins+1]->GetEntries()+hAllM_05_SM_masked[iSM]->GetBinContent(j+1,i+1));
1438  hAllMPerSM[(3*(nbPtBins+1))*iSM+3*k+2]->Fill(hAllM_05->GetXaxis()->GetBinCenter(j+1),hAllM_05_SM[iSM]->GetBinContent(j+1,i+1)-hAllM_05_SM_masked[iSM]->GetBinContent(j+1,i+1));
1439  hAllMPerSM[(3*(nbPtBins+1))*iSM+3*k+2]->SetEntries(hAllMPerSM[(3*(nbPtBins+1))*iSM+3*k+2]->GetEntries()+hAllM_05_SM[iSM]->GetBinContent(j+1,i+1)-hAllM_05_SM_masked[iSM]->GetBinContent(j+1,i+1));
1440  hAllMPerSM[(3*(nbPtBins+1))*iSM+3*nbPtBins+2]->Fill(hAllM_05->GetXaxis()->GetBinCenter(j+1),hAllM_05_SM[iSM]->GetBinContent(j+1,i+1)-hAllM_05_SM_masked[iSM]->GetBinContent(j+1,i+1));
1441  hAllMPerSM[(3*(nbPtBins+1))*iSM+3*nbPtBins+2]->SetEntries(hAllMPerSM[(3*(nbPtBins+1))*iSM+3*nbPtBins+2]->GetEntries()+hAllM_05_SM[iSM]->GetBinContent(j+1,i+1)-hAllM_05_SM_masked[iSM]->GetBinContent(j+1,i+1));
1442  for (m=0;m<kNbZones;m++)
1443  {hMassDistrPerSMPerPtPerZone[(kNbZones*(nbPtBins+1))*iSM+kNbZones*k+m]->Fill(hAllM_05->GetXaxis()->GetBinCenter(j+1),hAllM_05_SM_Zones[iSM][m]->GetBinContent(j+1,i+1));
1444  hMassDistrPerSMPerPtPerZone[(kNbZones*(nbPtBins+1))*iSM+kNbZones*k+m]->SetEntries(hMassDistrPerSMPerPtPerZone[(kNbZones*(nbPtBins+1))*iSM+kNbZones*k+0]->GetEntries()+hAllM_05_SM_Zones[iSM][m]->GetBinContent(j+1,i+1));
1445  hMassDistrPerSMPerPtPerZone[(kNbZones*(nbPtBins+1))*iSM+kNbZones*nbPtBins+m]->Fill(hAllM_05->GetXaxis()->GetBinCenter(j+1),hAllM_05_SM_Zones[iSM][m]->GetBinContent(j+1,i+1));
1446  hMassDistrPerSMPerPtPerZone[(kNbZones*(nbPtBins+1))*iSM+kNbZones*nbPtBins+m]->SetEntries(hMassDistrPerSMPerPtPerZone[(kNbZones*(nbPtBins+1))*iSM+kNbZones*nbPtBins+0]->GetEntries()+hAllM_05_SM_Zones[iSM][m]->GetBinContent(j+1,i+1));
1447  }
1448  }
1449  if ((hAllM_05->GetXaxis()->GetBinCenter(j+1) > mPDG-10.) && (hAllM_05->GetXaxis()->GetBinCenter(j+1) < mPDG+10.))
1450  {if (k == 0)
1451  {cmptPtMoyLow+=hAllM_05->GetBinContent(j+1,i+1);
1452  pTmoyLow+=hAllM_05->GetYaxis()->GetBinCenter(i+1)*hAllM_05->GetBinContent(j+1,i+1);
1453  }
1454  if (k == nbPtBins-1)
1455  {cmptPtMoyHigh+=hAllM_05->GetBinContent(j+1,i+1);
1456  pTmoyHigh+=hAllM_05->GetYaxis()->GetBinCenter(i+1)*hAllM_05->GetBinContent(j+1,i+1);
1457  }
1458  }
1459  }
1460  }
1461  if (cmptPtMoyLow != 0.) pTmoyLow=pTmoyLow/cmptPtMoyLow;
1462  pTmoyHigh=pTmoyHigh/cmptPtMoyHigh;
1463  printf("\nMean pT low = %f, high = %f\n\n",pTmoyLow,pTmoyHigh);
1464  tabGraphX[0]=pTmoyLow;
1465  tabErrGraphX[0]=tabGraphX[1]-tabErrGraphX[1]-pTmoyLow;
1466  tabGraphX[nbPtBins-1]=pTmoyHigh;
1467  tabErrGraphX[nbPtBins-1]=pTmoyHigh-tabGraphX[nbPtBins-2]-tabErrGraphX[nbPtBins-2];
1468 
1469 
1470 
1471 
1472 
1473 
1474 
1475 
1476 
1477 
1478 
1479 
1480  //*****************************************
1481  // Calculate some variables to help later fits convergence :
1482  //*****************************************
1483 
1484 
1485  TH1D *hAllM_05Proj = new TH1D();
1486  hAllM_05Proj = hAllM_05->ProjectionX("hAllM_05Proj",0,-1,"e");
1487  hAllM_05Proj->SetLineColor(colorIndex[1]);
1488 
1489 
1490  //Fitting function
1491  Int_t polN = 2;
1492 
1493  TF1 *fitfun = 0;
1494  TF1 *fitfun3 = 0;
1495  TF1 *fitfunBkgPol2 = 0;
1496  if (polN == 1)
1497  fitfun = new TF1("fitfun",pi0massP1,100,250,5);
1498  else if (polN == 2)
1499  fitfun = new TF1("fitfun",pi0massP2,100,250,6);
1500  fitfun->SetLineColor(kRed);
1501  fitfun->SetLineWidth(2);
1502  fitfun3 = new TF1("fitfun3",pi0massP3,100,250,7);
1503  fitfun3->SetLineColor(kRed);
1504  fitfun3->SetLineWidth(2);
1505 
1506  fitfun->SetParName(0,"A");
1507  fitfun->SetParName(1,"m_{0}");
1508  fitfun->SetParName(2,"#sigma");
1509  fitfun->SetParName(3,"a_{0}");
1510  fitfun->SetParName(4,"a_{1}");
1511  if (polN == 2)
1512  fitfun->SetParName(5,"a_{2}");
1513 
1514  maxGaussAmpl=3.e+6;
1515  fitfun->SetParLimits(0, 8.,maxGaussAmpl);
1516  fitfun->SetParLimits(1, 80.,160.);
1517  fitfun->SetParLimits(2, 2.,35.);
1518  fitfun3->SetParLimits(0, 8.,maxGaussAmpl);
1519  fitfun3->SetParLimits(1, 80.,160.);
1520  fitfun3->SetParLimits(2, 2.,35.);
1521 
1522  fitfunBkgPol2 = new TF1("fitfunBkgPol2","[0] + [1]*x + [2]*x*x",100.,250.);
1523  fitfunBkgPol2->SetLineWidth(1);
1524  fitfunBkgPol2->SetLineColor(kMagenta);
1525 
1526  gStyle->SetOptTitle(0);
1527  hAllM_05Proj->Rebin(rebin);
1528 
1529  hAllM_05Proj->SetXTitle("M_{#gamma,#gamma} (MeV/c^{2})");
1530 
1531  tmpX=210.;
1532  tmpY=hAllM_05Proj->GetBinContent(hAllM_05Proj->FindBin(tmpX));
1533  fitPar4=2.*tmpY/tmpX;
1534  fitPar5=-tmpY/(tmpX*tmpX);
1535  fitfun->SetParameter(0,(double)hAllM_05Proj->GetEntries()/100.);
1536  fitfun->SetParameter(1,mPDG);
1537  fitfun->SetParameter(2,typicalWidth);
1538  fitfun->SetParameter(3,0.);
1539  fitfun->SetParameter(4,fitPar4);
1540  fitfun->SetParameter(5,fitPar5);
1541  printf("Fit start parameters : amplitude %f, b %f, a %f\n\n",fitfun->GetParameter(0),fitfun->GetParameter(4),fitfun->GetParameter(5));
1542  hAllM_05Proj->Fit("fitfun","","",50,250);
1543  fitPar3=fitfun->GetParameter(3);
1544  fitPar4=fitfun->GetParameter(4);
1545  fitPar5=fitfun->GetParameter(5);
1546  nbTot=hAllM_05Proj->GetEntries();
1547  nbSig=fitfun->GetParameter(0);
1548 
1549 
1550 
1551 
1552 
1553 
1554 
1555 
1556 
1557 
1558 
1559  //*****************************************
1560  // Create root and postscript output files :
1561  //*****************************************
1562 
1563  TFile *rootFileOut = new TFile("output_calibPi0.root","RECREATE");
1564  char psfile[100];
1565  sprintf(psfile,"output_calibPi0.ps");
1566  const int cWidth=500;
1567  const int cHeight=(int)(500*(29./21.));
1568  TCanvas *c1 = new TCanvas("c1","EMCal cosmics analysis",cWidth,cHeight);
1569  TPostScript *ps = new TPostScript(psfile,111);
1570 
1571 
1572  hAllM_05Proj->Write();
1573 
1574 
1575 
1576 
1577 
1578 
1579 
1580  //*****************************************
1581  // Draw pT histoes and graphs :
1582  //*****************************************
1583 
1584 
1585  //hAllMPerSM[(3*(nbPtBins+1))*iSM+3*iPt+iStruct]
1586 
1587  // Inv mass plots per pT bin per SM :
1588  printf("\nInv mass plots per pT bin per SM.\n");
1589  linePDGMass->SetLineColor(kBlue);
1590  for (iSM=0;iSM<(kNbSMtot+1);iSM++)
1591  {if ((iSM<kNbSMtot) && (tabChoiceCalos[SMdetType[iSM]] == 0))
1592  {printf("Skip SM %d of type %s.\n",iSM,detTypeString[SMdetType[iSM]]);
1593  continue;
1594  }
1595  for (j=0;j<(int)((double)nbPtBins/8.)+1;j++)
1596  {ps->NewPage();
1597  c1->Clear();
1598  c1->Divide(2,4);
1599  for (i=0;i<8;i++)
1600  {if ((j*8+i) > nbPtBins) break;
1601  c1->cd(i+1);
1602  if ((j*8+i) != nbPtBins) printf("\nNow fitting pT bin %d",j*8+i);
1603  else printf("\nNow fitting all pT");
1604  if (iSM != kNbSMtot) printf(" in SM %d -- nEntries = %f\n",iSM,hAllMPerSM[(3*(nbPtBins+1))*iSM+3*(j*8+i)+0]->GetEntries());
1605  else printf(" for all SMs -- nEntries = %f\n",hAllMPerSM[(3*(nbPtBins+1))*iSM+3*(j*8+i)+0]->GetEntries());
1606  hAllMPerSM[(3*(nbPtBins+1))*iSM+3*(j*8+i)+0]->Draw();
1607  if ((j*8+i) < (nbPtBins-1))
1608  {fitRangeMin=14.28*tabPtBins[j*8+i]+37.15;
1609  if (tabPtBins[j*8+i] > 3.0) fitRangeMin=80.;
1610  fitRangeMax=11.54*tabPtBins[j*8+i]+201.5;
1611  }
1612  else //For the 2 last histoes (last pT bin and pT-integrated)
1613  {fitRangeMin=80.;
1614  fitRangeMax=11.54*tabPtBins[nbPtBins-2]+201.5;
1615  }
1616  for (iStruct=0;iStruct<3;iStruct++)
1617  {fitfun->SetParameter(0,hAllMPerSM[(3*(nbPtBins+1))*iSM+3*(j*8+i)+iStruct]->GetEntries()*(double)nbSig/(double)nbTot);
1618  fitfun->SetParameter(1,mPDG);
1619  fitfun->SetParameter(2,typicalWidth);
1620  fitfun->SetParameter(3,fitPar3*(double)hAllMPerSM[(3*(nbPtBins+1))*iSM+3*(j*8+i)+iStruct]->GetEntries()/(double)nbTot);
1621  fitfun->SetParameter(4,fitPar4*(double)hAllMPerSM[(3*(nbPtBins+1))*iSM+3*(j*8+i)+iStruct]->GetEntries()/(double)nbTot);
1622  fitfun->SetParameter(5,fitPar5*(double)hAllMPerSM[(3*(nbPtBins+1))*iSM+3*(j*8+i)+iStruct]->GetEntries()/(double)nbTot);
1623  //One has to put the histo's drawing options as 3rd argument ; drawing the histoes afterwards doesn't work ! (Only the last one is drawn, because fitting draws it without option SAME).
1624  hAllMPerSM[(3*(nbPtBins+1))*iSM+3*(j*8+i)+iStruct]->Fit("fitfun","R","SAME",fitRangeMin,fitRangeMax);
1625  switch (iStruct)
1626  {case 0 : lineFittedMass->SetLineColor(colorIndexStruct[iStruct]);
1627  lineFittedMass->SetX1(fitfun->GetParameter(1));
1628  lineFittedMass->SetX2(fitfun->GetParameter(1));
1629  lineFittedMass->SetY2(1.05*hAllMPerSM[(3*(nbPtBins+1))*iSM+3*(j*8+i)+0]->GetMaximum());
1630  lineFittedMass->Draw("SAME");
1631  break;
1632  case 1 : lineFittedWidth1->SetLineColor(colorIndexStruct[iStruct]);
1633  lineFittedWidth1->SetX1(fitfun->GetParameter(1));
1634  lineFittedWidth1->SetX2(fitfun->GetParameter(1));
1635  lineFittedWidth1->SetY2(1.05*hAllMPerSM[(3*(nbPtBins+1))*iSM+3*(j*8+i)+0]->GetMaximum());
1636  lineFittedWidth1->Draw("SAME");
1637  break;
1638  case 2 : lineFittedWidth2->SetLineColor(colorIndexStruct[iStruct]);
1639  lineFittedWidth2->SetX1(fitfun->GetParameter(1));
1640  lineFittedWidth2->SetX2(fitfun->GetParameter(1));
1641  lineFittedWidth2->SetY2(1.05*hAllMPerSM[(3*(nbPtBins+1))*iSM+3*(j*8+i)+0]->GetMaximum());
1642  lineFittedWidth2->Draw("SAME");
1643  break;
1644  default : ;
1645  }
1646  if ((j*8+i) < nbPtBins)
1647  {tabGraphYmass[3*(j*8+i)+iStruct]=fitfun->GetParameter(1);
1648  tabGraphYsig[3*(j*8+i)+iStruct]=fitfun->GetParameter(2);
1649  tabGraphYnumber[3*(j*8+i)+iStruct]=fitfun->GetParameter(2)*fitfun->GetParameter(0)*TMath::Sqrt(2.*TMath::Pi())/hAllMPerSM[(3*(nbPtBins+1))*iSM+3*(j*8+i)+iStruct]->GetBinWidth(1);
1650  tabErrGraphYmass[3*(j*8+i)+iStruct]=fitfun->GetParError(1);
1651  tabErrGraphYsig[3*(j*8+i)+iStruct]=fitfun->GetParError(2);
1652  if (fitfun->Integral(mPDG-3.*fitfun->GetParameter(2),mPDG+3.*fitfun->GetParameter(2)) >= 0) tabErrGraphYnumber[3*(j*8+i)+iStruct]=TMath::Sqrt(fitfun->Integral(mPDG-3.*fitfun->GetParameter(2),mPDG+3.*fitfun->GetParameter(2)));
1653  else tabErrGraphYnumber[3*(j*8+i)+iStruct]=0.; //Fit integral can be <0 (due to fitted bkgnd).
1654  }
1655  hAllMPerSM[(3*(nbPtBins+1))*iSM+3*(j*8+i)+iStruct]->Write();
1656  }
1657  if ((j*8+i) < nbPtBins)
1658  {if ((tabGraphYnumber[3*(j*8+i)+1] != 0.) && (tabGraphYnumber[3*(j*8+i)+2] != 0.))
1659  {tabGraphYnumberRatio[3*(j*8+i)+0]=tabGraphYnumber[3*(j*8+i)+2]/tabGraphYnumber[3*(j*8+i)+1];
1660  tabErrGraphYnumberRatio[3*(j*8+i)+0]=tabGraphYnumberRatio[3*(j*8+i)+0]*TMath::Sqrt((tabErrGraphYnumber[3*(j*8+i)+2]/tabGraphYnumber[3*(j*8+i)+2])*(tabErrGraphYnumber[3*(j*8+i)+2]/tabGraphYnumber[3*(j*8+i)+2])+(tabErrGraphYnumber[3*(j*8+i)+1]/tabGraphYnumber[3*(j*8+i)+1])*(tabErrGraphYnumber[3*(j*8+i)+1]/tabGraphYnumber[3*(j*8+i)+1]));
1661  }
1662  else
1663  {tabGraphYnumberRatio[3*(j*8+i)+0]=0.;
1664  tabErrGraphYnumberRatio[3*(j*8+i)+0]=0.;
1665  }
1666  }
1667  linePDGMass->SetY2(1.05*hAllMPerSM[(3*(nbPtBins+1))*iSM+3*(j*8+i)+0]->GetMaximum());
1668  linePDGMass->Draw("SAME");
1669  c1->Update(); //Has to come before the ps->TextNDC, otherwise the text is drawn below the histo (=> invisible).
1670  if (iSM != kNbSMtot) sprintf(txtPS,"Pi0 inv mass in SM %d,",iSM);
1671  else sprintf(txtPS,"Pi0 inv mass in all SMs,");
1672  if ((j*8+i) != nbPtBins) sprintf(txtPS,"%s %4.2f < pT < %4.2f GeV",txtPS,tabGraphX[j*8+i]-tabErrGraphX[j*8+i],tabGraphX[j*8+i]+tabErrGraphX[j*8+i]);
1673  else sprintf(txtPS,"%s pT-integrated",txtPS);
1674  ps->TextNDC(0.3,0.93,txtPS);
1675  }
1676  c1->Update();
1677  }
1678  for (iStruct=0;iStruct<3;iStruct++)
1679  {for (iPt=0;iPt<nbPtBins;iPt++)
1680  {tabTmpGraphYmass[iPt]=tabGraphYmass[3*iPt+iStruct];
1681  tabTmpErrGraphYmass[iPt]=tabErrGraphYmass[3*iPt+iStruct];
1682  tabTmpGraphYsig[iPt]=tabGraphYsig[3*iPt+iStruct];
1683  tabTmpErrGraphYsig[iPt]=tabErrGraphYsig[3*iPt+iStruct];
1684  tabTmpGraphYnumber[iPt]=tabGraphYnumber[3*iPt+iStruct];
1685  tabTmpErrGraphYnumber[iPt]=tabErrGraphYnumber[3*iPt+iStruct];
1686  tabTmpGraphYnumberRatio[iPt]=tabGraphYnumberRatio[3*iPt+iStruct];
1687  tabTmpErrGraphYnumberRatio[iPt]=tabErrGraphYnumberRatio[3*iPt+iStruct];
1688  }
1689  tgeMass[3*iSM+iStruct] = new TGraphErrors(nbPtBins,tabGraphX,tabTmpGraphYmass,tabErrGraphX,tabTmpErrGraphYmass);
1690  tgeSig[3*iSM+iStruct] = new TGraphErrors(nbPtBins,tabGraphX,tabTmpGraphYsig,tabErrGraphX,tabTmpErrGraphYsig);
1691  tgeNumber[3*iSM+iStruct] = new TGraphErrors(nbPtBins,tabGraphX,tabTmpGraphYnumber,tabErrGraphX,tabTmpErrGraphYnumber);
1692  tgeNumberRatio[3*iSM+iStruct] = new TGraphErrors(nbPtBins,tabGraphX,tabTmpGraphYnumberRatio,tabErrGraphX,tabTmpErrGraphYnumberRatio);
1693  tgeMass[3*iSM+iStruct]->SetName(Form("tgeMass_SM%d_%d",iSM,iStruct));
1694  tgeSig[3*iSM+iStruct]->SetName(Form("tgeSig_SM%d_%d",iSM,iStruct));
1695  tgeNumber[3*iSM+iStruct]->SetName(Form("tgeNumber_SM%d_%d",iSM,iStruct));
1696  tgeNumberRatio[3*iSM+iStruct]->SetName(Form("tgeNumberRatio_SM%d_%d",iSM,iStruct));
1697  tgeMass[3*iSM+iStruct]->SetLineColor(colorIndexStruct[iStruct]);
1698  tgeSig[3*iSM+iStruct]->SetLineColor(colorIndexStruct[iStruct]);
1699  tgeNumber[3*iSM+iStruct]->SetLineColor(colorIndexStruct[iStruct]);
1700  tgeNumberRatio[3*iSM+iStruct]->SetLineColor(colorIndexStruct[iStruct]);
1701  tgeMass[3*iSM+iStruct]->GetHistogram()->SetXTitle("#pi^{0} p_{#perp} (GeV)");
1702  tgeMass[3*iSM+iStruct]->GetHistogram()->SetYTitle("Fitted #pi^{0} inv mass (MeV)");
1703  tgeMass[3*iSM+iStruct]->GetHistogram()->SetMinimum(120.);
1704  tgeMass[3*iSM+iStruct]->GetHistogram()->SetMaximum(150.);
1705  tgeSig[3*iSM+iStruct]->GetHistogram()->SetXTitle("#pi^{0} p_{#perp} (GeV)");
1706  tgeSig[3*iSM+iStruct]->GetHistogram()->SetYTitle("Fitted #pi^{0} width (MeV)");
1707  tgeSig[3*iSM+iStruct]->GetHistogram()->SetMinimum(7.5);
1708  tgeSig[3*iSM+iStruct]->GetHistogram()->SetMaximum(22.);
1709  tgeNumber[3*iSM+iStruct]->GetHistogram()->SetXTitle("#pi^{0} p_{#perp} (GeV)");
1710  tgeNumber[3*iSM+iStruct]->GetHistogram()->SetYTitle("Number of #pi^{0} (counts)");
1711  tgeNumberRatio[3*iSM+iStruct]->GetHistogram()->SetXTitle("#pi^{0} p_{#perp} (GeV)");
1712  tgeNumberRatio[3*iSM+iStruct]->GetHistogram()->SetYTitle("Ratios of numbers of #pi^{0}");
1713  }
1714  }
1715 
1716  for (iSM=0;iSM<(kNbSMtot+1);iSM++)
1717  {if ((iSM<kNbSMtot) && (tabChoiceCalos[SMdetType[iSM]] == 0))
1718  {printf("Skip SM %d of type %s.\n",iSM,detTypeString[SMdetType[iSM]]);
1719  continue;
1720  }
1721  for (j=0;j<(int)((double)nbPtBins/8.)+1;j++)
1722  {ps->NewPage();
1723  c1->Clear();
1724  c1->Divide(2,4);
1725  for (i=0;i<8;i++)
1726  {if ((j*8+i) > nbPtBins) break;
1727  c1->cd(i+1);
1728  if ((j*8+i) != nbPtBins) printf("\nNow fitting pT bin %d",j*8+i);
1729  else printf("\nNow fitting all pT");
1730  if (iSM != kNbSMtot) printf(" in SM %d -- nEntries = %f\n",iSM,hMassDistrPerSMPerPtPerZone[(kNbZones*(nbPtBins+1))*iSM+kNbZones*(j*8+i)+0]->GetEntries());
1731  else printf(" for all SMs -- nEntries = %f\n",hMassDistrPerSMPerPtPerZone[(kNbZones*(nbPtBins+1))*iSM+kNbZones*(j*8+i)+0]->GetEntries());
1732  hMassDistrPerSMPerPtPerZone[(kNbZones*(nbPtBins+1))*iSM+kNbZones*(j*8+i)+3]->Draw(); //3rd of these histoes is the highest.
1733  if ((j*8+i) < (nbPtBins-1))
1734  {fitRangeMin=14.28*tabPtBins[j*8+i]+37.15;
1735  if (tabPtBins[j*8+i] > 3.0) fitRangeMin=80.;
1736  fitRangeMax=11.54*tabPtBins[j*8+i]+201.5;
1737  }
1738  else //For the 2 last histoes (last pT bin and pT-integrated)
1739  {fitRangeMin=80.;
1740  fitRangeMax=11.54*tabPtBins[nbPtBins-2]+201.5;
1741  }
1742  for (iStruct=0;iStruct<kNbZones;iStruct++)
1743  {fitfun->SetParameter(0,hMassDistrPerSMPerPtPerZone[(kNbZones*(nbPtBins+1))*iSM+kNbZones*(j*8+i)+iStruct]->GetEntries()*(double)nbSig/(double)nbTot);
1744  fitfun->SetParameter(1,mPDG);
1745  fitfun->SetParameter(2,typicalWidth);
1746  fitfun->SetParameter(3,fitPar3*(double)hMassDistrPerSMPerPtPerZone[(kNbZones*(nbPtBins+1))*iSM+kNbZones*(j*8+i)+iStruct]->GetEntries()/(double)nbTot);
1747  fitfun->SetParameter(4,fitPar4*(double)hMassDistrPerSMPerPtPerZone[(kNbZones*(nbPtBins+1))*iSM+kNbZones*(j*8+i)+iStruct]->GetEntries()/(double)nbTot);
1748  fitfun->SetParameter(5,fitPar5*(double)hMassDistrPerSMPerPtPerZone[(kNbZones*(nbPtBins+1))*iSM+kNbZones*(j*8+i)+iStruct]->GetEntries()/(double)nbTot);
1749  //One has to put the histo's drawing options as 3rd argument ; drawing the histoes afterwards doesn't work ! (Only the last one is drawn, because fitting draws it without option SAME).
1750  hMassDistrPerSMPerPtPerZone[(kNbZones*(nbPtBins+1))*iSM+kNbZones*(j*8+i)+iStruct]->Fit("fitfun","R","SAME",fitRangeMin,fitRangeMax);
1751  if ((j*8+i) < nbPtBins)
1752  {tabGraphYmass[kNbZones*(j*8+i)+iStruct]=fitfun->GetParameter(1);
1753  tabGraphYsig[kNbZones*(j*8+i)+iStruct]=fitfun->GetParameter(2);
1754  tabGraphYnumber[kNbZones*(j*8+i)+iStruct]=fitfun->GetParameter(2)*fitfun->GetParameter(0)*TMath::Sqrt(2.*TMath::Pi())/hMassDistrPerSMPerPtPerZone[(kNbZones*(nbPtBins+1))*iSM+kNbZones*(j*8+i)+iStruct]->GetBinWidth(1);
1755  tabErrGraphYmass[kNbZones*(j*8+i)+iStruct]=fitfun->GetParError(1);
1756  tabErrGraphYsig[kNbZones*(j*8+i)+iStruct]=fitfun->GetParError(2);
1757  if (fitfun->Integral(mPDG-3.*fitfun->GetParameter(2),mPDG+3.*fitfun->GetParameter(2)) >= 0) tabErrGraphYnumber[kNbZones*(j*8+i)+iStruct]=TMath::Sqrt(fitfun->Integral(mPDG-3.*fitfun->GetParameter(2),mPDG+3.*fitfun->GetParameter(2)));
1758  else tabErrGraphYnumber[kNbZones*(j*8+i)+iStruct]=0.; //Fit integral can be <0 (due to fitted bkgnd).
1759  }
1760  hMassDistrPerSMPerPtPerZone[(kNbZones*(nbPtBins+1))*iSM+kNbZones*(j*8+i)+iStruct]->Write();
1761  }
1762  if ((j*8+i) < nbPtBins)
1763  {if ((tabGraphYnumber[kNbZones*(j*8+i)+0] != 0.) && (tabGraphYnumber[kNbZones*(j*8+i)+1] != 0.))
1764  {tabGraphYnumberRatio[((int)(kNbZones/2))*(kNbZones-1)*(j*8+i)+0]=tabGraphYnumber[kNbZones*(j*8+i)+1]/tabGraphYnumber[kNbZones*(j*8+i)+0];
1765  tabErrGraphYnumberRatio[((int)(kNbZones/2))*(kNbZones-1)*(j*8+i)+0]=tabGraphYnumberRatio[((int)(kNbZones/2))*(kNbZones-1)*(j*8+i)+0]*TMath::Sqrt((tabErrGraphYnumber[kNbZones*(j*8+i)+1]/tabGraphYnumber[kNbZones*(j*8+i)+1])*(tabErrGraphYnumber[kNbZones*(j*8+i)+1]/tabGraphYnumber[kNbZones*(j*8+i)+1])+(tabErrGraphYnumber[kNbZones*(j*8+i)+0]/tabGraphYnumber[kNbZones*(j*8+i)+0])*(tabErrGraphYnumber[kNbZones*(j*8+i)+0]/tabGraphYnumber[kNbZones*(j*8+i)+0]));
1766  }
1767  else
1768  {tabGraphYnumberRatio[((int)(kNbZones/2))*(kNbZones-1)*(j*8+i)+0]=0.;
1769  tabErrGraphYnumberRatio[((int)(kNbZones/2))*(kNbZones-1)*(j*8+i)+0]=0.;
1770  }
1771  if ((tabGraphYnumber[kNbZones*(j*8+i)+2] != 0.) && (tabGraphYnumber[kNbZones*(j*8+i)+3] != 0.))
1772  {tabGraphYnumberRatio[((int)(kNbZones/2))*(kNbZones-1)*(j*8+i)+1]=tabGraphYnumber[kNbZones*(j*8+i)+3]/tabGraphYnumber[kNbZones*(j*8+i)+2];
1773  tabErrGraphYnumberRatio[((int)(kNbZones/2))*(kNbZones-1)*(j*8+i)+1]=tabGraphYnumberRatio[((int)(kNbZones/2))*(kNbZones-1)*(j*8+i)+2]*TMath::Sqrt((tabErrGraphYnumber[kNbZones*(j*8+i)+3]/tabGraphYnumber[kNbZones*(j*8+i)+3])*(tabErrGraphYnumber[kNbZones*(j*8+i)+3]/tabGraphYnumber[kNbZones*(j*8+i)+3])+(tabErrGraphYnumber[kNbZones*(j*8+i)+2]/tabGraphYnumber[kNbZones*(j*8+i)+2])*(tabErrGraphYnumber[kNbZones*(j*8+i)+2]/tabGraphYnumber[kNbZones*(j*8+i)+2]));
1774  }
1775  else
1776  {tabGraphYnumberRatio[((int)(kNbZones/2))*(kNbZones-1)*(j*8+i)+1]=0.;
1777  tabErrGraphYnumberRatio[((int)(kNbZones/2))*(kNbZones-1)*(j*8+i)+1]=0.;
1778  }
1779  if ((tabGraphYnumber[kNbZones*(j*8+i)+4] != 0.) && (tabGraphYnumber[kNbZones*(j*8+i)+5] != 0.))
1780  {tabGraphYnumberRatio[((int)(kNbZones/2))*(kNbZones-1)*(j*8+i)+2]=tabGraphYnumber[kNbZones*(j*8+i)+5]/tabGraphYnumber[kNbZones*(j*8+i)+4];
1781  tabErrGraphYnumberRatio[((int)(kNbZones/2))*(kNbZones-1)*(j*8+i)+2]=tabGraphYnumberRatio[((int)(kNbZones/2))*(kNbZones-1)*(j*8+i)+4]*TMath::Sqrt((tabErrGraphYnumber[kNbZones*(j*8+i)+5]/tabGraphYnumber[kNbZones*(j*8+i)+5])*(tabErrGraphYnumber[kNbZones*(j*8+i)+5]/tabGraphYnumber[kNbZones*(j*8+i)+5])+(tabErrGraphYnumber[kNbZones*(j*8+i)+4]/tabGraphYnumber[kNbZones*(j*8+i)+4])*(tabErrGraphYnumber[kNbZones*(j*8+i)+4]/tabGraphYnumber[kNbZones*(j*8+i)+4]));
1782  }
1783  else
1784  {tabGraphYnumberRatio[((int)(kNbZones/2))*(kNbZones-1)*(j*8+i)+2]=0.;
1785  tabErrGraphYnumberRatio[((int)(kNbZones/2))*(kNbZones-1)*(j*8+i)+2]=0.;
1786  }
1787  if ((tabGraphYnumber[kNbZones*(j*8+i)+5] != 0.) && (tabGraphYnumber[kNbZones*(j*8+i)+6] != 0.))
1788  {tabGraphYnumberRatio[((int)(kNbZones/2))*(kNbZones-1)*(j*8+i)+3]=tabGraphYnumber[kNbZones*(j*8+i)+6]/tabGraphYnumber[kNbZones*(j*8+i)+5];
1789  tabErrGraphYnumberRatio[((int)(kNbZones/2))*(kNbZones-1)*(j*8+i)+3]=tabGraphYnumberRatio[((int)(kNbZones/2))*(kNbZones-1)*(j*8+i)+5]*TMath::Sqrt((tabErrGraphYnumber[kNbZones*(j*8+i)+6]/tabGraphYnumber[kNbZones*(j*8+i)+6])*(tabErrGraphYnumber[kNbZones*(j*8+i)+6]/tabGraphYnumber[kNbZones*(j*8+i)+6])+(tabErrGraphYnumber[kNbZones*(j*8+i)+5]/tabGraphYnumber[kNbZones*(j*8+i)+5])*(tabErrGraphYnumber[kNbZones*(j*8+i)+5]/tabGraphYnumber[kNbZones*(j*8+i)+5]));
1790  }
1791  else
1792  {tabGraphYnumberRatio[((int)(kNbZones/2))*(kNbZones-1)*(j*8+i)+3]=0.;
1793  tabErrGraphYnumberRatio[((int)(kNbZones/2))*(kNbZones-1)*(j*8+i)+3]=0.;
1794  }
1795  if ((tabGraphYnumber[kNbZones*(j*8+i)+4] != 0.) && (tabGraphYnumber[kNbZones*(j*8+i)+6] != 0.))
1796  {tabGraphYnumberRatio[((int)(kNbZones/2))*(kNbZones-1)*(j*8+i)+4]=tabGraphYnumber[kNbZones*(j*8+i)+6]/tabGraphYnumber[kNbZones*(j*8+i)+4];
1797  tabErrGraphYnumberRatio[((int)(kNbZones/2))*(kNbZones-1)*(j*8+i)+4]=tabGraphYnumberRatio[((int)(kNbZones/2))*(kNbZones-1)*(j*8+i)+4]*TMath::Sqrt((tabErrGraphYnumber[kNbZones*(j*8+i)+6]/tabGraphYnumber[kNbZones*(j*8+i)+6])*(tabErrGraphYnumber[kNbZones*(j*8+i)+6]/tabGraphYnumber[kNbZones*(j*8+i)+6])+(tabErrGraphYnumber[kNbZones*(j*8+i)+4]/tabGraphYnumber[kNbZones*(j*8+i)+4])*(tabErrGraphYnumber[kNbZones*(j*8+i)+4]/tabGraphYnumber[kNbZones*(j*8+i)+4]));
1798  }
1799  else
1800  {tabGraphYnumberRatio[((int)(kNbZones/2))*(kNbZones-1)*(j*8+i)+4]=0.;
1801  tabErrGraphYnumberRatio[((int)(kNbZones/2))*(kNbZones-1)*(j*8+i)+4]=0.;
1802  }
1803  }
1804  linePDGMass->SetY2(1.05*hMassDistrPerSMPerPtPerZone[(kNbZones*(nbPtBins+1))*iSM+kNbZones*(j*8+i)+0]->GetMaximum());
1805  linePDGMass->Draw("SAME");
1806  c1->Update(); //Has to come before the ps->TextNDC, otherwise the text is drawn below the histo (=> invisible).
1807  if (iSM != kNbSMtot) sprintf(txtPS,"Pi0 inv mass in SM %d,",iSM);
1808  else sprintf(txtPS,"Pi0 inv mass in all SMs,");
1809  if ((j*8+i) != nbPtBins) sprintf(txtPS,"%s %4.2f < pT < %4.2f GeV",txtPS,tabGraphX[j*8+i]-tabErrGraphX[j*8+i],tabGraphX[j*8+i]+tabErrGraphX[j*8+i]);
1810  else sprintf(txtPS,"%s pT-integrated",txtPS);
1811  ps->TextNDC(0.3,0.93,txtPS);
1812  }
1813  c1->Update();
1814  }
1815  for (iStruct=0;iStruct<kNbZones;iStruct++)
1816  {for (iPt=0;iPt<nbPtBins;iPt++)
1817  {tabTmpGraphYmass[iPt]=tabGraphYmass[kNbZones*iPt+iStruct];
1818  tabTmpErrGraphYmass[iPt]=tabErrGraphYmass[kNbZones*iPt+iStruct];
1819  tabTmpGraphYsig[iPt]=tabGraphYsig[kNbZones*iPt+iStruct];
1820  tabTmpErrGraphYsig[iPt]=tabErrGraphYsig[kNbZones*iPt+iStruct];
1821  tabTmpGraphYnumber[iPt]=tabGraphYnumber[kNbZones*iPt+iStruct];
1822  tabTmpErrGraphYnumber[iPt]=tabErrGraphYnumber[kNbZones*iPt+iStruct];
1823  }
1824  tgeMassZones[kNbZones*iSM+iStruct] = new TGraphErrors(nbPtBins,tabGraphX,tabTmpGraphYmass,tabErrGraphX,tabTmpErrGraphYmass);
1825  tgeSigZones[kNbZones*iSM+iStruct] = new TGraphErrors(nbPtBins,tabGraphX,tabTmpGraphYsig,tabErrGraphX,tabTmpErrGraphYsig);
1826  tgeNumberZones[kNbZones*iSM+iStruct] = new TGraphErrors(nbPtBins,tabGraphX,tabTmpGraphYnumber,tabErrGraphX,tabTmpErrGraphYnumber);
1827  tgeMassZones[kNbZones*iSM+iStruct]->SetName(Form("tgeMassZones_SM%d_%d",iSM,iStruct));
1828  tgeSigZones[kNbZones*iSM+iStruct]->SetName(Form("tgeSigZones_SM%d_%d",iSM,iStruct));
1829  tgeNumberZones[kNbZones*iSM+iStruct]->SetName(Form("tgeNumberZones_SM%d_%d",iSM,iStruct));
1830  tgeMassZones[kNbZones*iSM+iStruct]->SetLineColor(colorIndexZones[iStruct]);
1831  tgeSigZones[kNbZones*iSM+iStruct]->SetLineColor(colorIndexZones[iStruct]);
1832  tgeNumberZones[kNbZones*iSM+iStruct]->SetLineColor(colorIndexZones[iStruct]);
1833  tgeMassZones[kNbZones*iSM+iStruct]->GetHistogram()->SetXTitle("#pi^{0} p_{#perp} (GeV)");
1834  tgeMassZones[kNbZones*iSM+iStruct]->GetHistogram()->SetYTitle("Fitted #pi^{0} inv mass (MeV)");
1835  tgeMassZones[kNbZones*iSM+iStruct]->GetHistogram()->SetMinimum(120.);
1836  tgeMassZones[kNbZones*iSM+iStruct]->GetHistogram()->SetMaximum(150.);
1837  tgeSigZones[kNbZones*iSM+iStruct]->GetHistogram()->SetXTitle("#pi^{0} p_{#perp} (GeV)");
1838  tgeSigZones[kNbZones*iSM+iStruct]->GetHistogram()->SetYTitle("Fitted #pi^{0} width (MeV)");
1839  tgeSigZones[kNbZones*iSM+iStruct]->GetHistogram()->SetMinimum(7.5);
1840  tgeSigZones[kNbZones*iSM+iStruct]->GetHistogram()->SetMaximum(22.);
1841  tgeNumberZones[kNbZones*iSM+iStruct]->GetHistogram()->SetXTitle("#pi^{0} p_{#perp} (GeV)");
1842  tgeNumberZones[kNbZones*iSM+iStruct]->GetHistogram()->SetYTitle("Number of #pi^{0} (counts)");
1843  }
1844  for (iStruct=0;iStruct<((int)(kNbZones/2))*(kNbZones-1);iStruct++)
1845  {for (iPt=0;iPt<nbPtBins;iPt++)
1846  {tabTmpGraphYnumberRatio[iPt]=tabGraphYnumberRatio[((int)(kNbZones/2))*(kNbZones-1)*iPt+iStruct];
1847  tabTmpErrGraphYnumberRatio[iPt]=tabErrGraphYnumberRatio[((int)(kNbZones/2))*(kNbZones-1)*iPt+iStruct];
1848  }
1849  tgeNumberRatioZones[((int)(kNbZones/2))*(kNbZones-1)*iSM+iStruct] = new TGraphErrors(nbPtBins,tabGraphX,tabTmpGraphYnumberRatio,tabErrGraphX,tabTmpErrGraphYnumberRatio);
1850  tgeNumberRatioZones[((int)(kNbZones/2))*(kNbZones-1)*iSM+iStruct]->SetName(Form("tgeNumberRatioZones_SM%d_%d",iSM,iStruct));
1851  tgeNumberRatioZones[((int)(kNbZones/2))*(kNbZones-1)*iSM+iStruct]->SetLineColor(colorIndexRatiosZones[iStruct]);
1852  tgeNumberRatioZones[((int)(kNbZones/2))*(kNbZones-1)*iSM+iStruct]->GetHistogram()->SetXTitle("#pi^{0} p_{#perp} (GeV)");
1853  tgeNumberRatioZones[((int)(kNbZones/2))*(kNbZones-1)*iSM+iStruct]->GetHistogram()->SetYTitle("Ratios of numbers of #pi^{0}");
1854  }
1855  }
1856 
1857  //pT vs mInv TH2F graphs for all SMs :
1858  ps->NewPage();
1859  c1->Clear();
1860  c1->Divide(2,2);
1861  c1->cd(1);
1862  gPad->SetLogz();
1863  hAllM_05->SetContour(30);
1864  hAllM_05->Draw("COLZ");
1865  c1->Update();
1866  sprintf(txtPS,"Pi0 inv mass vs pT, all SMs");
1867  ps->TextNDC(0.2,0.94,txtPS);
1868  hAllM_05->Write();
1869  c1->cd(2);
1870  gPad->SetLogz();
1871  hAllM_05_masked->SetContour(30);
1872  hAllM_05_masked->Draw("COLZ");
1873  c1->Update();
1874  sprintf(txtPS,"Pi0 inv mass vs pT, all SMs");
1875  ps->TextNDC(0.2,0.94,txtPS);
1876  hAllM_05_masked->Write();
1877  c1->Update();
1878 
1879  // Peak characteristics vs pT, for all SMs :
1880  printf("\nPeak characteristics vs pT.\n");
1881  ps->NewPage();
1882  c1->Clear();
1883  c1->Divide(2,2);
1884  c1->cd(1);
1885  tgeNumber[3*kNbSMtot+0]->SetName("tgeNumber_ALLSM");
1886  tgeNumber[3*kNbSMtot+1]->SetName("tgeNumber_ALLSM1");
1887  tgeNumber[3*kNbSMtot+2]->SetName("tgeNumber_ALLSM2");
1888  tgeNumber[3*kNbSMtot+0]->Draw("AL");
1889  tgeNumber[3*kNbSMtot+0]->GetHistogram()->SetMinimum(0.);
1890  tgeNumber[3*kNbSMtot+0]->Draw("AL");
1891  tgeNumber[3*kNbSMtot+1]->Draw("SAME");
1892  tgeNumber[3*kNbSMtot+2]->Draw("SAME");
1893  c1->Update();
1894  sprintf(txtPS,"Integral of gaussian fit wrt pT, all SMs");
1895  ps->TextNDC(0.2,0.94,txtPS);
1896  for (iStruct=0;iStruct<3;iStruct++) tgeNumber[3*kNbSMtot+iStruct]->Write();
1897  c1->cd(2);
1898  tgeNumberRatio[3*kNbSMtot+0]->SetName("tgeNumberRatio_ALLSM");
1899  tgeNumberRatio[3*kNbSMtot+1]->SetName("tgeNumberRatio_ALLSM1");
1900  tgeNumberRatio[3*kNbSMtot+2]->SetName("tgeNumberRatio_ALLSM2");
1901  tgeNumberRatio[3*kNbSMtot+0]->Draw("AL");
1902  tgeNumberRatio[3*kNbSMtot+0]->GetHistogram()->SetMinimum(0.0);
1903  tgeNumberRatio[3*kNbSMtot+0]->GetHistogram()->SetMaximum(0.6);
1904  tgeNumberRatio[3*kNbSMtot+0]->Draw("AL");
1905  for (iStruct=0;iStruct<3;iStruct++) tgeNumberRatio[3*kNbSMtot+iStruct]->Write();
1906  c1->cd(3);
1907  TLine *lineMassH = new TLine(tgeMass[3*kNbSMtot+0]->GetXaxis()->GetXmin(),mPDG,tgeMass[3*kNbSMtot+0]->GetXaxis()->GetXmax(),mPDG);
1908  lineMassH->SetLineColor(kMagenta);
1909  tgeMass[3*kNbSMtot+0]->Draw("AL");
1910  tgeMass[3*kNbSMtot+1]->Draw("L SAME");
1911  tgeMass[3*kNbSMtot+2]->Draw("L SAME");
1912  lineMassH->Draw();
1913  c1->Update();
1914  sprintf(txtPS,"Mean of gaussian fit wrt pT, all SMs");
1915  ps->TextNDC(0.2,0.94,txtPS);
1916  for (iStruct=0;iStruct<3;iStruct++) tgeMass[3*kNbSMtot+iStruct]->Write();
1917  c1->cd(4);
1918  tgeSig[3*kNbSMtot+0]->Draw("AL");
1919  tgeSig[3*kNbSMtot+1]->Draw("L SAME");
1920  tgeSig[3*kNbSMtot+2]->Draw("L SAME");
1921  c1->Update();
1922  sprintf(txtPS,"Width of gaussian fit wrt pT, all SMs");
1923  ps->TextNDC(0.2,0.94,txtPS);
1924  for (iStruct=0;iStruct<3;iStruct++) tgeSig[3*kNbSMtot+iStruct]->Write();
1925  c1->Update();
1926 
1927  // Peak characteristics vs pT, per SM :
1928  for (iSM=0;iSM<kNbSMtot;iSM++)
1929  {if (tabChoiceCalos[SMdetType[iSM]] == 0)
1930  {printf("Skip SM %d of type %s.\n",iSM,detTypeString[SMdetType[iSM]]);
1931  continue;
1932  }
1933  ps->NewPage();
1934  c1->Clear();
1935  c1->Divide(2,2);
1936  c1->cd(1);
1937  tgeNumber[3*iSM+0]->Draw("AL");
1938  tgeNumber[3*iSM+0]->GetHistogram()->SetMinimum(0.);
1939  tgeNumber[3*iSM+0]->Draw("AL");
1940  tgeNumber[3*iSM+1]->Draw("L SAME");
1941  tgeNumber[3*iSM+2]->Draw("L SAME");
1942  c1->Update();
1943  sprintf(txtPS,"Integral of gaussian fit wrt pT, SM %d",iSM);
1944  ps->TextNDC(0.2,0.94,txtPS);
1945  for (iStruct=0;iStruct<3;iStruct++) tgeNumber[3*iSM+iStruct]->Write();
1946  c1->cd(2);
1947  tgeNumberRatio[3*iSM+0]->Draw("AL");
1948  tgeNumberRatio[3*iSM+0]->GetHistogram()->SetMinimum(0.0);
1949  tgeNumberRatio[3*iSM+0]->GetHistogram()->SetMaximum(0.6);
1950  tgeNumberRatio[3*iSM+0]->Draw("AL");
1951  for (iStruct=0;iStruct<3;iStruct++) tgeNumberRatio[3*iSM+iStruct]->Write();
1952  c1->cd(3);
1953  lineMassH->SetX1(tgeMass[3*iSM+0]->GetXaxis()->GetXmin());
1954  lineMassH->SetX2(tgeMass[3*iSM+0]->GetXaxis()->GetXmax());
1955  lineMassH->SetLineColor(kMagenta);
1956  tgeMass[3*iSM+0]->Draw("AL");
1957  tgeMass[3*iSM+1]->Draw("L SAME");
1958  tgeMass[3*iSM+2]->Draw("L SAME");
1959  lineMassH->Draw();
1960  c1->Update();
1961  sprintf(txtPS,"Mean of gaussian fit wrt pT, SM %d",iSM);
1962  ps->TextNDC(0.2,0.94,txtPS);
1963  for (iStruct=0;iStruct<3;iStruct++) tgeMass[3*iSM+iStruct]->Write();
1964  c1->cd(4);
1965  tgeSig[3*iSM+0]->Draw("AL");
1966  tgeSig[3*iSM+1]->Draw("L SAME");
1967  tgeSig[3*iSM+2]->Draw("L SAME");
1968  c1->Update();
1969  sprintf(txtPS,"Width of gaussian fit wrt pT, SM %d",iSM);
1970  ps->TextNDC(0.2,0.94,txtPS);
1971  for (iStruct=0;iStruct<3;iStruct++) tgeSig[3*iSM+iStruct]->Write();
1972  c1->Update();
1973  }
1974 
1975  // Peak characteristics in zones vs pT, for all SMs :
1976  printf("\nPeak characteristics vs pT for specific zones.\n");
1977  ps->NewPage();
1978  c1->Clear();
1979  c1->Divide(2,2);
1980  c1->cd(1);
1981  for (iStruct=0;iStruct<kNbZones;iStruct++) tgeNumberZones[kNbZones*kNbSMtot+iStruct]->SetName(Form("tgeNumberZones_ALLSM%d",iStruct));
1982  tgeNumberZones[kNbZones*kNbSMtot+3]->Draw("AL"); //3rd of these histoes is the highest.
1983  tgeNumberZones[kNbZones*kNbSMtot+3]->GetHistogram()->SetMinimum(0.);
1984  tgeNumberZones[kNbZones*kNbSMtot+3]->Draw("AL"); //3rd of these histoes is the highest.
1985  for (iStruct=0;iStruct<kNbZones;iStruct++) tgeNumberZones[kNbZones*kNbSMtot+iStruct]->Draw("SAME");
1986  c1->Update();
1987  sprintf(txtPS,"Integral of gaussian fit wrt pT, all SMs");
1988  ps->TextNDC(0.2,0.94,txtPS);
1989  for (iStruct=0;iStruct<kNbZones;iStruct++) tgeNumberZones[kNbZones*kNbSMtot+iStruct]->Write();
1990  c1->cd(2);
1991  for (iStruct=0;iStruct<5;iStruct++) tgeNumberRatioZones[((int)(kNbZones/2))*(kNbZones-1)*kNbSMtot+iStruct]->SetName(Form("tgeNumberRatioZones_ALLSM%d",iStruct));
1992  tgeNumberRatioZones[((int)(kNbZones/2))*(kNbZones-1)*kNbSMtot+0]->Draw("AL");
1993  tgeNumberRatioZones[((int)(kNbZones/2))*(kNbZones-1)*kNbSMtot+0]->GetHistogram()->SetMinimum(0.0);
1994  tgeNumberRatioZones[((int)(kNbZones/2))*(kNbZones-1)*kNbSMtot+0]->GetHistogram()->SetMaximum(4.5);
1995  tgeNumberRatioZones[((int)(kNbZones/2))*(kNbZones-1)*kNbSMtot+0]->Draw("AL");
1996  for (iStruct=1;iStruct<5;iStruct++) tgeNumberRatioZones[((int)(kNbZones/2))*(kNbZones-1)*kNbSMtot+iStruct]->Draw("L SAME");
1997  for (iStruct=0;iStruct<5;iStruct++) tgeNumberRatioZones[((int)(kNbZones/2))*(kNbZones-1)*kNbSMtot+iStruct]->Write();
1998  c1->cd(3);
1999  lineMassH->SetLineColor(kMagenta);
2000  tgeMassZones[kNbZones*kNbSMtot+0]->Draw("AL");
2001  for (iStruct=1;iStruct<kNbZones;iStruct++) tgeMassZones[kNbZones*kNbSMtot+iStruct]->Draw("L SAME");
2002  lineMassH->Draw();
2003  c1->Update();
2004  sprintf(txtPS,"Mean of gaussian fit wrt pT, all SMs");
2005  ps->TextNDC(0.2,0.94,txtPS);
2006  for (iStruct=0;iStruct<kNbZones;iStruct++) tgeMassZones[kNbZones*kNbSMtot+iStruct]->Write();
2007  c1->cd(4);
2008  tgeSigZones[kNbZones*kNbSMtot+0]->Draw("AL");
2009  for (iStruct=1;iStruct<kNbZones;iStruct++) tgeSigZones[kNbZones*kNbSMtot+iStruct]->Draw("L SAME");
2010  c1->Update();
2011  sprintf(txtPS,"Width of gaussian fit wrt pT, all SMs");
2012  ps->TextNDC(0.2,0.94,txtPS);
2013  for (iStruct=0;iStruct<kNbZones;iStruct++) tgeSigZones[kNbZones*kNbSMtot+iStruct]->Write();
2014  c1->Update();
2015 
2016  // Peak characteristics in zones vs pT, per SM :
2017  for (iSM=0;iSM<kNbSMtot;iSM++)
2018  {if (tabChoiceCalos[SMdetType[iSM]] == 0)
2019  {printf("Skip SM %d of type %s.\n",iSM,detTypeString[SMdetType[iSM]]);
2020  continue;
2021  }
2022  ps->NewPage();
2023  c1->Clear();
2024  c1->Divide(2,2);
2025  c1->cd(1);
2026  tgeNumberZones[kNbZones*iSM+3]->Draw("AL"); //3rd of these histoes is the highest.
2027  tgeNumberZones[kNbZones*iSM+3]->GetHistogram()->SetMinimum(0.);
2028  tgeNumberZones[kNbZones*iSM+3]->Draw("AL"); //3rd of these histoes is the highest.
2029  for (iStruct=0;iStruct<kNbZones;iStruct++) tgeNumberZones[kNbZones*iSM+iStruct]->Draw("L SAME");
2030  c1->Update();
2031  sprintf(txtPS,"Integral of gaussian fit wrt pT, SM %d",iSM);
2032  ps->TextNDC(0.2,0.94,txtPS);
2033  for (iStruct=0;iStruct<kNbZones;iStruct++) tgeNumberZones[kNbZones*iSM+iStruct]->Write();
2034  c1->cd(2);
2035  tgeNumberRatioZones[((int)(kNbZones/2))*(kNbZones-1)*iSM+0]->Draw("AL");
2036  tgeNumberRatioZones[((int)(kNbZones/2))*(kNbZones-1)*iSM+0]->GetHistogram()->SetMinimum(0.0);
2037  tgeNumberRatioZones[((int)(kNbZones/2))*(kNbZones-1)*iSM+0]->GetHistogram()->SetMaximum(4.5);
2038  tgeNumberRatioZones[((int)(kNbZones/2))*(kNbZones-1)*iSM+0]->Draw("AL");
2039  for (iStruct=1;iStruct<5;iStruct++) tgeNumberRatioZones[((int)(kNbZones/2))*(kNbZones-1)*iSM+iStruct]->Draw("L SAME");
2040  for (iStruct=0;iStruct<5;iStruct++) tgeNumberRatioZones[((int)(kNbZones/2))*(kNbZones-1)*iSM+iStruct]->Write();
2041  c1->cd(3);
2042  lineMassH->SetX1(tgeMass[3*iSM+0]->GetXaxis()->GetXmin());
2043  lineMassH->SetX2(tgeMass[3*iSM+0]->GetXaxis()->GetXmax());
2044  lineMassH->SetLineColor(kMagenta);
2045  tgeMassZones[kNbZones*iSM+0]->Draw("AL");
2046  for (iStruct=1;iStruct<kNbZones;iStruct++) tgeMassZones[kNbZones*iSM+iStruct]->Draw("L SAME");
2047  lineMassH->Draw();
2048  c1->Update();
2049  sprintf(txtPS,"Mean of gaussian fit wrt pT, SM %d",iSM);
2050  ps->TextNDC(0.2,0.94,txtPS);
2051  for (iStruct=0;iStruct<kNbZones;iStruct++) tgeMassZones[kNbZones*iSM+iStruct]->Write();
2052  c1->cd(4);
2053  tgeSigZones[kNbZones*iSM+0]->Draw("AL");
2054  for (iStruct=1;iStruct<kNbZones;iStruct++) tgeSigZones[kNbZones*iSM+iStruct]->Draw("L SAME");
2055  c1->Update();
2056  sprintf(txtPS,"Width of gaussian fit wrt pT, SM %d",iSM);
2057  ps->TextNDC(0.2,0.94,txtPS);
2058  for (iStruct=0;iStruct<kNbZones;iStruct++) tgeSigZones[kNbZones*iSM+iStruct]->Write();
2059  c1->Update();
2060  }
2061 
2062 
2063 
2064 
2065 
2066 
2067 
2068 
2069 
2070 
2071 
2072  //*****************************************
2073  // Loop over all towers :
2074  // Book histoes and calculate calibration coefficient :
2075  //*****************************************
2076 
2077 
2078  linePDGMass->SetLineColor(kSpring+4);
2079  lineFittedMass->SetLineColor(kMagenta);
2080  lineFittedWidth1->SetLineColor(kMagenta-10);
2081  lineFittedWidth2->SetLineColor(kMagenta-10);
2082  linePreviousFittedMass->SetLineColor(kMagenta);
2083  linePreviousFittedWidth1->SetLineColor(kMagenta-10);
2084  linePreviousFittedWidth2->SetLineColor(kMagenta-10);
2085  linePreviousDesiredMass->SetLineColor(kOrange+7);
2086  linePreviousUntrustedFit->SetLineColor(kOrange+7);
2087  linePreviousDesiredMass->SetLineWidth(2.);
2088  linePreviousUntrustedFit->SetLineWidth(2.);
2089  gStyle->SetOptStat(11); //Just name and nb entries.
2090 
2091  n=0;
2092  cmptEntriesDiscard=0;
2093  cmptAmpDiscard=0;
2094  cmptMasked=0;
2095  cmptEdge=0;
2096  printf("\n\nNow looping over towers.\nConsider %d towers, total gaussian amplitude %f.\nChanging gaussian amplitude par limit from %f to ",nbTowersConsideredTot,nbSig,maxGaussAmpl);
2097  maxGaussAmpl=50.*nbSig/(double)nbTowersConsideredTot;
2098  maxIntgAmpl=10.*nbTot/(double)nbTowersConsideredTot;
2099  printf("%f\n",maxGaussAmpl);
2100  fitfun->SetParLimits(0,8.,maxGaussAmpl);
2101  for(Int_t sm = 0; sm < kNbSMtot; sm++) //Loop on SM's.
2102  {if (tabChoiceCalos[SMdetType[sm]] == 0)
2103  {printf("Skip SM %d of type %s.\n",sm,detTypeString[SMdetType[sm]]);
2104  continue;
2105  }
2106  if (testChoice == 2)
2107  {if (!((sm == 0) || (sm == kNbSMEMCAL) || (sm == kNbSMEMCAL+kNbSMEMCALthird) || (sm == kNbSMEMCAL+kNbSMEMCALthird+kNbSMDCAL))) continue;
2108  }
2109  printf("\nSM %d : columns ",sm);
2110  fflush(stdout);
2111  for(Int_t c = kNbColMinEff ; c < TMath::Min(kNbColMaxEff,kTabNbCol[SMdetType[sm]]); c+=1) //Loop on columns.
2112  {printf("%d ",c);
2113  fflush(stdout);
2114  for(Int_t r = 0 ; r < kTabNbRow[SMdetType[sm]]; r+=1) //Loop on rows.
2115  {if (((r%12) == 0) && (testChoice != 3))
2116  {c1->Update();
2117  ps->NewPage();
2118  c1->Clear();
2119  c1->Divide(3,4);
2120  n=0;
2121  }
2122  n++;
2123  cEff=c+kTabColOffset[sm]; //Column number used for (col,row) histoes must be pushed by 16 for DCAL SMs. //But don't use it in the end, because is the single-SM (col,row) plots are shifted by 16 to match the "visual view", then it's more difficult to find a tower which is everywhere in this code referenced by its offline coordinates (not shifted by 16). Thus shift only in hAllSpace* histoes in the end.
2124  if (testChoice != 3) c1->cd(n);
2125  //Read the values stored at the previous iteration :
2126  fscanf(txtFileParamsIn," %d %d %d %d ",&sm2,&c2,&r2,&cmpt2);
2127  for (k=0;k<kNbFitParams+kNbExtraParamsToBeRead;k++) fscanf(txtFileParamsIn,"%d ",flag2+k);
2128  //for (k=0;k<kNbTotParams-1;k++) fscanf(txtFileParamsIn,"%le ",param2+k); //Change to the following line, so as to be able to read files with fewer parameters written. NB : file always has 1 more than the sum : the calib coeff.
2129  for (k=0;k<kNbFitParams+kNbExtraParamsToBeRead;k++) fscanf(txtFileParamsIn,"%le ",param2+k);
2130  fscanf(txtFileParamsIn,"%le\n",param2+(kNbTotParams-1)); //To be sure to read the \n
2131  fscanf(txtFileCalibIn," %d %d %d %d %lf\n",&cmpt3,&sm3,&c3,&r3,&coeff3);
2132  tmpFlag=0;
2133  if (sm != sm3) tmpFlag++;
2134  if (c != c3) tmpFlag++;
2135  if (r != r3) tmpFlag++;
2136  if ((tmpFlag > 0) && (testChoice != 1)) //Shows up when one doesn't loop over all columns of a SM, and looks at more than the 1st SM.
2137  {if (testChoice == 0)
2138  {printf("$$$ Problem sync input files : (%d,%d,%d) vs (%d,%d,%d) vs (%d,%d,%d)\n",sm,c,r,sm2,c2,r2,sm3,c3,r3);
2139  }
2140  }
2141  discardFlag=0;
2142  if (coeff3 < 0)
2143  {//Store the value of coeff3 "as a flag", then restore the value it should have as a coefficient :
2144  discardFlag=(int)coeff3;
2145  coeff3=1.00;
2146  }
2147  //Get the histogram and setup the fit function :
2148  TH1F *h05 = (TH1F *) l05->FindObject(Form("%d_%d_%d",sm,c,r));
2149  h05->SetLineColor(colorIndex[1]);
2150  h05->Rebin(rebin);
2151  h05->SetXTitle("M_{#gamma,#gamma} (MeV/c^{2})");
2152  if (h05->GetEntries() != 0) hAllDistribNbEntries->Fill(h05->GetEntries());
2153  fitfun->SetParameter(0,h05->GetEntries()*(double)nbSig/(double)nbTot);
2154  if (fitfun->GetParameter(0) < 8.)
2155  {fitfun->SetParameter(0,8.); //With the new root version (today = Oct 5th 2012), this produces a run-time error "Error in ROOT::Math::ParameterSettings>: Invalid lower/upper bounds - ignoring the bounds" for the towers (80 for the 4 old SMs) with low number of entries. Caused by starting value of param outside the parameter limits set above.
2156  //Now 07 Oct 2015, the error message changed to "lower/upper bounds outside current parameter value. The value will be set to (low+up)/2". Since it occurs for only 5 towers and doesn't prevent for a correct analysis, we just ignore.
2157  }
2158  fitfun->SetParameter(1,mPDG);
2159  fitfun->SetParameter(2,typicalWidth);
2160  fitfun->SetParameter(3,fitPar3*(double)h05->GetEntries()/(double)nbTot);
2161  fitfun->SetParameter(4,fitPar4*(double)h05->GetEntries()/(double)nbTot);
2162  fitfun->SetParameter(5,fitPar5*(double)h05->GetEntries()/(double)nbTot);
2163  intgN=h05->Integral(1,h05->GetNbinsX());
2164  //When the histogram has entries, do the fit and calculate various khi2's :
2165  if (intgN != 0) // if intgN!=0
2166  {h05->Fit("fitfun","Q","",50,300);
2167  fitfunBkgPol2->SetParameter(0,fitfun->GetParameter(3));
2168  fitfunBkgPol2->SetParameter(1,fitfun->GetParameter(4));
2169  fitfunBkgPol2->SetParameter(2,fitfun->GetParameter(5));
2170  fitResultMean=fitfun->GetParameter(1);
2171  fitResultSigma=fitfun->GetParameter(2);
2172  cmptNDF=0;
2173  fitKhi2SmallRange=0.;
2174  for (iBin=h05->FindBin(fitResultMean-fitResultSigma);iBin<h05->FindBin(fitResultMean+fitResultSigma)+1;iBin++)
2175  {if (h05->GetBinContent(iBin) == 0.) continue;
2176  if (h05->GetBinError(iBin) == 0.)
2177  {printf("## Weird bin %d (center %f) for tower (%d,%d,%d) : null error but content is %f : skip.\n",iBin,h05->GetBinCenter(iBin),sm,c,r,h05->GetBinContent(iBin));
2178  continue;
2179  }
2180  fitKhi2SmallRange+=pow(h05->GetBinContent(iBin)-fitfun->Eval(h05->GetBinCenter(iBin)),2)/pow(h05->GetBinError(iBin),2);
2181  cmptNDF++;
2182  }
2183  if (cmptNDF != 0) fitKhi2SmallRange=fitKhi2SmallRange/cmptNDF;
2184  else fitKhi2SmallRange=0.;
2185  cmptNDF=0;
2186  fitKhi2PeakLeft=0.;
2187  for (iBin=h05->FindBin(fitResultMean-3.*fitResultSigma);iBin<h05->FindBin(fitResultMean)+1;iBin++)
2188  {if (h05->GetBinContent(iBin) == 0.) continue;
2189  if (h05->GetBinError(iBin) == 0.)
2190  {printf("## Weird bin %d (center %f) for tower (%d,%d,%d) : null error but content is %f : skip.\n",iBin,h05->GetBinCenter(iBin),sm,c,r,h05->GetBinContent(iBin));
2191  continue;
2192  }
2193  fitKhi2PeakLeft+=pow(h05->GetBinContent(iBin)-fitfun->Eval(h05->GetBinCenter(iBin)),2)/pow(h05->GetBinError(iBin),2);
2194  cmptNDF++;
2195  }
2196  if (cmptNDF != 0) fitKhi2PeakLeft=fitKhi2PeakLeft/cmptNDF;
2197  else fitKhi2PeakLeft=0.;
2198  cmptNDF=0;
2199  fitKhi2PeakRight=0.;
2200  for (iBin=h05->FindBin(fitResultMean);iBin<h05->FindBin(fitResultMean+3.*fitResultSigma)+1;iBin++)
2201  {if (h05->GetBinContent(iBin) == 0.) continue;
2202  if (h05->GetBinError(iBin) == 0.)
2203  {printf("## Weird bin %d (center %f) for tower (%d,%d,%d) : null error but content is %f : skip.\n",iBin,h05->GetBinCenter(iBin),sm,c,r,h05->GetBinContent(iBin));
2204  continue;
2205  }
2206  fitKhi2PeakRight+=pow(h05->GetBinContent(iBin)-fitfun->Eval(h05->GetBinCenter(iBin)),2)/pow(h05->GetBinError(iBin),2);
2207  cmptNDF++;
2208  }
2209  if (cmptNDF != 0) fitKhi2PeakRight=fitKhi2PeakRight/cmptNDF;
2210  else fitKhi2PeakRight=0.;
2211  } //end if intgN!=0
2212  else //Do not fit if noisy/masked (empty) tower.
2213  {fitfun->SetParameter(0,-10.);
2214  fitfun->SetParameter(1,0.);
2215  fitfun->SetParameter(2,0.);
2216  fitResultMean=0.;
2217  fitResultSigma=0.;
2218  fitfun->SetChisquare(0.);
2219  cmptNDF=0;
2220  fitKhi2SmallRange=0.;
2221  fitKhi2PeakLeft=0.;
2222  fitKhi2PeakRight=0.;
2223  cmptMasked++;
2224  hSpaceEntriesDiscard[1*sm+0]->SetBinContent(c+1,r+1,4);
2225  } //end else (i.e. intgN==0).
2226  //Calculate the number of pi0's, by doing the integral of the gaussian peak, and by subtracting the bkg to the histogram integral (bin-counting) :
2227  if (h05->GetBinWidth(1) != 0.) intgS=fitResultSigma*fitfun->GetParameter(0)*TMath::Sqrt(2.*3.1415926535)/h05->GetBinWidth(1);
2228  else {printf("Zero width, put arbitrarily intgS to 0 for tower (%d;%d;%d).\n",sm,c,r); intgS=0.;}
2229  intgSbincounting=0.;
2230  for (iBin=h05->FindBin(fitResultMean-3.*fitResultSigma);iBin<h05->FindBin(fitResultMean+3.*fitResultSigma)+1;iBin++) intgSbincounting+=h05->GetBinContent(iBin)-fitfunBkgPol2->Eval(h05->GetBinCenter(iBin));
2231  //Calculate the calibration coefficient :
2232  coeff=pow(fitResultMean/mPDG,coeffPower);
2233 
2234  //Draw the inv mass plot together with the fit and several indicators (mass lines, flags,...), book histograms with the fit parameters :
2235  if (testChoice != 3)
2236  //if ((isFirstIteration == 0) && (testChoice != 3)) //Choose this if running DCAL with this has the code break.
2237  {h05->Write();
2238  h05->SetAxisRange(50.,250.,"X");
2239  h05->SetMinimum(0.);
2240  h05->SetStats();
2241  h05->Draw("HE");
2242  c1->Update();//Needed to get the pointer to the stat box, otherwise the pointer is null (the stat box is added to the list of object only when the histo is drawn, which, in compiled code, happens only when the canvas is updated).
2243  ptrPaveStat = (TPaveStats*)h05->FindObject("stats");
2244  ptrPaveStat->SetTextSize(0.04);
2245  //printf("%f %f %f %f\n",ptrPaveStat->GetX1NDC(),ptrPaveStat->GetX2NDC(),ptrPaveStat->GetY1NDC(),ptrPaveStat->GetY2NDC());
2246  //Default values are : 0.780 0.980 0.855 0.935.
2247  ptrPaveStat->SetX1NDC(0.75);
2248  ptrPaveStat->SetX2NDC(1.0);
2249  ptrPaveStat->SetY2NDC(0.95);
2250  fitfunBkgPol2->Draw("SAME");
2251  maxHisto=h05->GetMaximum()*(1+gStyle->GetHistTopMargin());
2252  //This comes from http://roottalk.root.cern.narkive.com/h0eAzqAn/taxis-strange-behaviour
2253  //h05->GetMaximum() is not satisfactory (the upper edge of the histo is not the max, and is not even always 1.05*max. Besides, since we are plotting in a subrange of the histo, the max of the histo may stand outside of the plotted range, and therefore the upper axis limit is not calculated wrt the histo's GetMaximum() anymore).
2254  //The Y axis really has only 1 bin, and its UpEdge is equal to GetXmax, even after the histo is plotted.
2255  //linePDGMass->SetY2(1.05*h05->GetMaximum());
2256  //printf("%f %f %f %d %d %f\n",h05->GetMaximum(),h05->GetYaxis()->GetXmax(),h05->GetMaximum()*(1+gStyle->GetHistTopMargin()),h05->GetYaxis()->GetNbins(),h05->GetYaxis()->GetLast(),h05->GetYaxis()->GetBinUpEdge(h05->GetYaxis()->GetLast()));
2257  linePDGMass->SetY2(1.05*maxHisto);
2258  linePDGMass->Draw("SAME");
2259  lineFittedMass->SetX1(fitResultMean);
2260  lineFittedMass->SetX2(fitResultMean);
2261  //lineFittedMass->SetY2(1.05*h05->GetMaximum());
2262  lineFittedMass->SetY2(0.85*maxHisto);
2263  lineFittedMass->Draw("SAME");
2264  lineFittedWidth1->SetX1(fitResultMean-2.*fitResultSigma);
2265  lineFittedWidth1->SetX2(fitResultMean-2.*fitResultSigma);
2266  //lineFittedWidth1->SetY2(0.8*h05->GetMaximum());
2267  lineFittedWidth1->SetY2(0.75*maxHisto);
2268  lineFittedWidth1->Draw("SAME");
2269  lineFittedWidth2->SetX1(fitResultMean+2.*fitResultSigma);
2270  lineFittedWidth2->SetX2(fitResultMean+2.*fitResultSigma);
2271  //lineFittedWidth2->SetY2(0.8*h05->GetMaximum());
2272  lineFittedWidth2->SetY2(0.75*maxHisto);
2273  lineFittedWidth2->Draw("SAME");
2274  paveUncertStatus->SetX1NDC(0.92); //We have to set them here again, apparently because root needs the plot to be drawn before it knows what NDCs mean.
2275  paveUncertStatus->SetX2NDC(1.0);
2276  paveUncertStatus->SetY1NDC(0.83);
2277  paveUncertStatus->SetY2NDC(0.75);
2278  paveMassStatus->SetX1NDC(0.94); //We have to set them here again, apparently because root needs the plot to be drawn before it knows what NDCs mean.
2279  paveMassStatus->SetX2NDC(0.98);
2280  paveMassStatus->SetY1NDC(0.81);
2281  paveMassStatus->SetY2NDC(0.77);
2282  paveUncertStatus->SetFillColor(kWhite);
2283  paveMassStatus->SetFillColor(kWhite);
2284  if (intgS > 0)
2285  {valStatUncert=TMath::Sqrt(pow(paramFitStatUncert_b,2) + pow(paramFitStatUncert_a/TMath::Sqrt(intgS),2)); //This is the relative statistical uncertainty on the mean, in %.
2286  //First check that the uncertainty on the mass is lower than the decalibration specifications :
2287  if (valStatUncert > uncertKSpec*uncertSpec)
2288  {paveUncertStatus->SetFillColor(kRed);
2289  hSpaceCuts[5*sm+2]->Fill(c,r,4.);
2290  }
2291  else
2292  {paveUncertStatus->SetFillColor(kGreen+1);
2293  hSpaceCuts[5*sm+2]->Fill(c,r,1.9);
2294  }
2295  //Then check that the mass difference with the PDG is lower than uncertDist times the tolerated decalibration.
2296  if (TMath::Abs(fitResultMean-mPDG)/mPDG > uncertDist*uncertSpec)
2297  {paveMassStatus->SetFillColor(kRed);
2298  hSpaceCuts[5*sm+4]->Fill(c,r,4.);
2299  }
2300  else
2301  {paveMassStatus->SetFillColor(kGreen+1);
2302  hSpaceCuts[5*sm+4]->Fill(c,r,1.9);
2303  }
2304  hAllDistribDistance[2]->Fill(TMath::Abs(fitResultMean-mPDG)/(fitResultMean*valStatUncert));
2305  hSpaceCuts[5*sm+1]->Fill(c,r,100.*valStatUncert);
2306  hAllDistribDistance2[2*0+0]->Fill(100.*valStatUncert);
2307  if ((discardFlag >= 0) || (discardFlag <= -10)) hAllDistribDistance2[2*1+0]->Fill(100.*valStatUncert);
2308  hSpaceCuts[5*sm+3]->Fill(c,r,TMath::Abs(fitResultMean-mPDG)/mPDG);
2309  hAllDistribDistance2[2*0+1]->Fill(TMath::Abs(fitResultMean-mPDG)/mPDG);
2310  if ((discardFlag >= 0) || (discardFlag <= -10)) hAllDistribDistance2[2*1+1]->Fill(TMath::Abs(fitResultMean-mPDG)/mPDG);
2311  }
2312  paveUncertStatus->Draw("SAME");
2313  paveMassStatus->Draw("SAME");
2314  linePreviousFittedMass->SetX1(param2[1]);
2315  linePreviousFittedMass->SetX2(param2[1]);
2316  linePreviousFittedMass->SetY1(0.85*maxHisto);
2317  linePreviousFittedMass->SetY2(1.05*maxHisto);
2318  linePreviousFittedMass->Draw("SAME");
2319  linePreviousFittedWidth1->SetX1(param2[1]-2.*param2[2]);
2320  linePreviousFittedWidth1->SetX2(param2[1]-2.*param2[2]);
2321  linePreviousFittedWidth1->SetY1(0.85*maxHisto);
2322  linePreviousFittedWidth1->SetY2(maxHisto);
2323  linePreviousFittedWidth1->Draw("SAME");
2324  linePreviousFittedWidth2->SetX1(param2[1]+2.*param2[2]);
2325  linePreviousFittedWidth2->SetX2(param2[1]+2.*param2[2]);
2326  linePreviousFittedWidth2->SetY1(0.85*maxHisto);
2327  linePreviousFittedWidth2->SetY2(maxHisto);
2328  linePreviousFittedWidth2->Draw("SAME");
2329  linePreviousDesiredMass->SetX1(mPDG*pow(coeff3,1./coeffPowerPrev));
2330  linePreviousDesiredMass->SetX2(mPDG*pow(coeff3,1./coeffPowerPrev));
2331  linePreviousDesiredMass->SetY1(0.95*maxHisto);
2332  linePreviousDesiredMass->SetY2(1.05*maxHisto);
2333  linePreviousDesiredMass->Draw("SAME");
2334  if (coeff3 == 1.)
2335  {linePreviousUntrustedFit->SetX1(mPDG-20.);
2336  linePreviousUntrustedFit->SetX2(mPDG+20.);
2337  linePreviousUntrustedFit->SetY1(maxHisto);
2338  linePreviousUntrustedFit->SetY2(maxHisto);
2339  linePreviousUntrustedFit->Draw("SAME");
2340  }
2341  }//end if testChoice!=3
2342 
2343  //Book histograms with the integrals and khi2's :
2344  for (j=0;j<kNbFitParams;j++) hSpace[kNbFitParams*sm+j]->Fill(c,r,fitfun->GetParameter(j));
2345  hSpaceIntg[kNbExtraParams*sm+0]->Fill(c,r,intgN);
2346  if (fitfun->GetNDF() > 0)
2347  {intgKhi2=fitfun->GetChisquare()/(double)fitfun->GetNDF();
2348  hSpaceIntg[kNbExtraParams*sm+1]->Fill(c,r,intgKhi2);
2349  }
2350  else
2351  {if (intgN > 6) printf("\n#### Weird NDF in tower (%d,%d,%d) : khi2 %f NDF %f\n",sm,c,r,fitfun->GetChisquare(),(double)fitfun->GetNDF()); //NDF is 0 if more fit parameters (6) than filled bins. Don't want to calculate the nb of filled bins, so just check the number of entries.
2352  intgKhi2=0.;
2353  }
2354  hSpaceIntg[kNbExtraParams*sm+2]->Fill(c,r,intgS);
2355  hSpaceIntg[kNbExtraParams*sm+3]->Fill(c,r,intgN-intgS);
2356  hSpaceIntg[kNbExtraParams*sm+4]->Fill(c,r,fitKhi2SmallRange);
2357  hSpaceIntg[kNbExtraParams*sm+5]->Fill(c,r,fitKhi2PeakLeft);
2358  hSpaceIntg[kNbExtraParams*sm+6]->Fill(c,r,fitKhi2PeakRight);
2359  hSpaceFitErr[1*sm+0]->Fill(c,r,fitfun->GetParError(1));
2360  //Check if tower passes some quality cuts :
2361  cmpt=0;
2362  for (k=0;k<kNbFitParams+kNbExtraParams;k++) flag[k]=0;
2363  for (k=0;k<kNbFitParams;k++)
2364  {if (fitfun->GetParameter(k) < cutMin[k]) flag[k]++;
2365  if (fitfun->GetParameter(k) > cutMax[k]) flag[k]++;
2366  }
2367  if (intgN < cutMin[6]) flag[6]++;
2368  if (intgN > cutMax[6]) flag[6]++;
2369  if (intgKhi2 < cutMin[7]) flag[7]++;
2370  if (intgKhi2 > cutMax[7]) flag[7]++;
2371  if (intgS < cutMin[8]) flag[8]++;
2372  if (intgS > cutMax[8]) flag[8]++;
2373  if (fitKhi2SmallRange < cutMin[10]) flag[10]++;
2374  if (fitKhi2SmallRange > cutMax[10]) flag[10]++;
2375  for (k=0;k<kNbFitParams+kNbExtraParams;k++)
2376  {if (flag[k] != 0) cmpt++;
2377  }
2378  //Add coloured flags on the plot for the fit parameters :
2379  if (testChoice != 3)
2380  {for (k=0;k<kNbFitParams;k++)
2381  {paveCutsStatus[k]->SetX1NDC(0.92+0.04*(int)(k/3));
2382  paveCutsStatus[k]->SetX2NDC(0.96+0.04*(int)(k/3));
2383  paveCutsStatus[k]->SetY1NDC(0.63-0.04*(k%3));
2384  paveCutsStatus[k]->SetY2NDC(0.67-0.04*(k%3));
2385  paveCutsStatus[k]->SetFillColor(19); //kGray is too dark and they haven't created a lighter version.
2386  if (flag[k] != 0) paveCutsStatus[k]->SetFillColor(kRed);
2387  //paveCutsStatus[k]->SetFillColor(k+2);
2388  //paveCutsStatus[k]->SetBorderSize(2);
2389  //paveCutsStatus[k]->SetLineColor(1);
2390  //paveCutsStatus[k]->SetLineWidth(4); //Don't manage to have this work (draw a square with a border).
2391  paveCutsStatus[k]->Draw("SAME");
2392  }
2393  c1->Update(); //For the TLine's and TPave's. Nothing else is drawn beyond this line.
2394  }
2395 
2396  //Decide the output to the files as a function of whether the cuts were passed or not :
2397  flagBorderTower=1;
2398  if (c == 0) flagBorderTower=flagBorderTower*kCalibrateLastBorderCol;
2399  if (c == kTabNbCol[SMdetType[sm]]-1)
2400  {if (SMdetType[sm] == kDCAL) flagBorderTower=flagBorderTower*kCalibrateLastBorderCol;
2401  else flagBorderTower=flagBorderTower*kCalibrateMidRapBorderCol;
2402  }
2403  if (r == 0)
2404  {if ((sm < 2) || ((sm >= kNbSMEMCAL+kNbSMEMCALthird) && (sm < kNbSMEMCAL+kNbSMEMCALthird+2))) flagBorderTower=flagBorderTower*kCalibrateLastBorderRow;
2405  else flagBorderTower=flagBorderTower*kCalibrateTouchingBorderRow;
2406  }
2407  if (r == kTabNbRow[SMdetType[sm]]-1)
2408  {if (((sm >= kNbSMEMCAL+kNbSMEMCALthird-2) && (sm < kNbSMEMCAL+kNbSMEMCALthird)) || (sm >= kNbSMtot-2)) flagBorderTower=flagBorderTower*kCalibrateLastBorderRow;
2409  else flagBorderTower=flagBorderTower*kCalibrateTouchingBorderRow;
2410  }
2411  if (flagBorderTower == 0) //This tower is on one of the edges that we don't want to calibrate.
2412  {//Use _coeffs flag 4. Put calib coeff -9 to flag them as "don't want to look".
2413  cmptEdge++;
2414  txtFileCalibOut << "4 " << sm << " " << c << " " << r << " -9" << endl;
2415  }//Remaining towers are to be looked at.
2416  else if (discardFlag < 0) //Decided at the previous iteration that we don't want to look at his tower anymore.
2417  {//Just copy the same _coeffs flag "cmpt3", and put calib coeff 1.00.
2418  txtFileCalibOut << cmpt3 << " " << sm << " " << c << " " << r << " " << discardFlag << endl;
2419  }//Remaining towers are to be looked at.
2420  else if (cmpt == 0) //This tower is a good tower.
2421  {//Use _coeffs flag 0. Put _params flag "cmpt" -1.
2422  cmpt=-1;
2423  txtFileCalibOut << "0 " << sm << " " << c << " " << r << " " << coeff << endl;
2424  hSpaceCoeff[1*sm+0]->Fill(c,r,coeff);
2425  hCoeff->Fill(coeff);
2426  }//Remaining towers failed at least one cut.
2427  else if (intgN == 0) //Empty tower (was noisy/masked) (no counts in histo).
2428  {//Put _params flag "cmpt" 0.
2429  cmpt=0; //Doesn't show up in hSpaceCuts anyway
2430  txtFileCalibOut << "0 " << sm << " " << c << " " << r << " 1" << endl;
2431  }//Remaining towers failed at least a cut and are not empty.
2432  else if (h05->GetEntries() > cutEntriesDiscard) //Normal number of entries.
2433  {//Use _coeffs flag 1. Keep _params flag "cmpt" = nb of failed quality cuts.
2434  txtFileCalibOut << "1 " << sm << " " << c << " " << r << " " << coeff << " //Signif=";
2435  //txtFileCalibOut << "1 " << sm << " " << c << " " << r << " " << coeff << " //Signif=";
2436  //txtFileCalibOut << intgS/(4.*10.*(fitfun->GetParameter(3)+mPDG*fitfun->GetParameter(4)+fitfun->GetParameter(5)*(mPDG*mPDG+4.*10.*10./3.))) << " //Dist="; //Ca c'est S/N, now S/sqrt(S+N) :
2437  if (fitfun->Integral(mPDG-2.*10.,mPDG+2.*10.) > 0)
2438  txtFileCalibOut << intgS/TMath::Sqrt(fitfun->Integral(mPDG-2.*10.,mPDG+2.*10.)) << " //Dist=";
2439  else txtFileCalibOut << 0.00 << " //Dist=";
2440  if (fitfun->GetParError(1) != 0.)
2441  txtFileCalibOut << TMath::Abs(fitfun->GetParameter(1)-mPDG)/fitfun->GetParError(1) << " //Amp=";
2442  else txtFileCalibOut << 9999999999. << " //Amp=";
2443  if (flag[0] != 0) txtFileCalibOut << "**";
2444  txtFileCalibOut << fitfun->GetParameter(0) << " //Mu=";
2445  if (flag[1] != 0) txtFileCalibOut << "**";
2446  txtFileCalibOut << fitfun->GetParameter(1) << " //Sig=";
2447  if (flag[2] != 0) txtFileCalibOut << "**";
2448  txtFileCalibOut << fitfun->GetParameter(2) << " //c=";
2449  if (flag[3] != 0) txtFileCalibOut << "**";
2450  txtFileCalibOut << fitfun->GetParameter(3) << " //b=";
2451  if (flag[4] != 0) txtFileCalibOut << "**";
2452  txtFileCalibOut << fitfun->GetParameter(4) << " //a=";
2453  if (flag[5] != 0) txtFileCalibOut << "**";
2454  txtFileCalibOut << fitfun->GetParameter(5) << " //I=";
2455  if (flag[6] != 0) txtFileCalibOut << "**";
2456  txtFileCalibOut << intgN << " //KhiSqNdf=";
2457  if (flag[7] != 0) txtFileCalibOut << "**";
2458  txtFileCalibOut << intgKhi2 << " //S=";
2459  if (flag[8] != 0) txtFileCalibOut << "**";
2460  txtFileCalibOut << intgS << " //Khi2Peak=";
2461  if (flag[10] != 0) txtFileCalibOut << "**";
2462  txtFileCalibOut << fitKhi2SmallRange;
2463  txtFileCalibOut << endl;
2464  }//Remaining towers failed the cuts because they have a small number of entries.
2465  else //Too low number of entries : problem with this tower. Put automatically calib coeff to 1.00 and drop its coords in txt and ps.
2466  {//Use _coeffs flag 2. Keep _params flag "cmpt" = nb of failed quality cuts.
2467  txtFileCalibOut << "2 " << sm << " " << c << " " << r << " " << "1.00" << endl;
2468  cmptEntriesDiscard++;
2469  hSpaceEntriesDiscard[1*sm+0]->SetBinContent(c+1,r+1,0.8);
2470  }
2471 
2472  //Now we are back in the general loop for all the towers.
2473  //Write the value of all parameters to the parameter file :
2474  fprintf(txtFileParamsOut,"%d %d %d %d ",sm,c,r,cmpt);
2475  for (k=0;k<kNbFitParams+kNbExtraParams;k++) fprintf(txtFileParamsOut,"%d ",flag[k]);
2476  for (k=0;k<kNbFitParams;k++) fprintf(txtFileParamsOut,"%e ",fitfun->GetParameter(k));
2477  fprintf(txtFileParamsOut,"%e %e %e %e %e %e %e %e\n",intgN,intgKhi2,intgS,intgN-intgS,fitKhi2SmallRange,fitKhi2PeakLeft,fitKhi2PeakRight,coeff);
2478  //Fill in histograms :
2479  for (k=0;k<kNbFitParams+kNbExtraParamsToBeRead;k++) hAllOldDistrib[k]->Fill(param2[k]);
2480  hAllOldDistribMass->Fill(param2[1]);
2481  hAllOldDistribMassPerSM[sm]->Fill(param2[1]);
2482  hCoeffOld->Fill(param2[kNbTotParams-1]);
2483  hCoeffOldLarge->Fill(param2[kNbTotParams-1]);
2484  hCoeffOldCorr->Fill(coeff3);
2485  hCoeffOldCorrLarge->Fill(coeff3);
2486  if ((isFirstIteration == 0) && (coeff3 == 1.00) && (hSpaceEntriesDiscard[1*sm+0]->GetBinContent(c+1,r+1) == 0.)) hSpaceEntriesDiscard[1*sm+0]->SetBinContent(c+1,r+1,1.9);
2487  //Difference between both histoes : param2[kNbTotParams-1] is the raw coeff, while coeff3 comes from the "clean" coeff file (hand-corrected).
2488  hSpaceCuts[5*sm+0]->Fill(c,r,cmpt);
2489  hCorrelMuVsA->Fill(fitfun->GetParameter(0),fitfun->GetParameter(1));
2490  hCorrelSigVsA->Fill(fitfun->GetParameter(0),fitfun->GetParameter(2));
2491  hCorrelSigVsMu->Fill(fitfun->GetParameter(1),fitfun->GetParameter(2));
2492  hCorrelBVsA->Fill(fitfun->GetParameter(3),fitfun->GetParameter(4));
2493  hCorrelCVsA->Fill(fitfun->GetParameter(3),fitfun->GetParameter(5));
2494  hCorrelCVsB->Fill(fitfun->GetParameter(4),fitfun->GetParameter(5));
2495  hCorrelISVsI->Fill(intgN,intgN-intgS);
2496  hCorrelSVsI->Fill(intgN,intgS);
2497  hCorrelSVsIS->Fill(intgN-intgS,intgS);
2498  hCorrelSbincountingVsS->Fill(intgS,intgSbincounting);
2499  hCorrelMuVsI->Fill(intgN,fitfun->GetParameter(1));
2500  hCorrelMuVsS->Fill(intgS,fitfun->GetParameter(1));
2501  hCorrelSigVsI->Fill(intgN,fitfun->GetParameter(2));
2502  hCorrelSigVsS->Fill(intgS,fitfun->GetParameter(2));
2503  if (h05->GetEntries() != 0) hAllDistribNbEntriesCorrel->Fill(intgN,h05->GetEntries());
2504  for (k=0;k<3;k++)
2505  {if (param2[k] != 0.) hAllDiffAllTw[k]->Fill(fitfun->GetParameter(k)/param2[k]);
2506  }
2507  for (k=3;k<6;k++) hAllDiffAllTw[k]->Fill(fitfun->GetParameter(k)-param2[k]);
2508  if (param2[6] != 0.) hAllDiffAllTw[6]->Fill(intgN/param2[6]);
2509  if (param2[7] != 0.) hAllDiffAllTw[7]->Fill(intgKhi2/param2[7]);
2510  if (param2[8] != 0.) hAllDiffAllTw[8]->Fill(intgS/param2[8]);
2511  if (param2[9] != 0.) hAllDiffAllTw[9]->Fill((intgN-intgS)/param2[9]);
2512  if (coeff3 != 1.)
2513  {hCtrlEvolCoeff->Fill((coeff-1.)/(coeff3-1.));
2514  h2CtrlEvolCoeff1->Fill(coeff3,(coeff-1.)/(coeff3-1.));
2515  }
2516  h2CtrlEvolCoeff2->Fill(coeff3-1.,coeff3-coeff);
2517  if ((cmpt == -1) && (cmpt2 == -1)) //Book only if we are sure the tower is valid. NB : most of the discarded towers are valid too...
2518  {if (param2[1] != mPDG)
2519  {hCtrlEvolMu->Fill((fitfun->GetParameter(1)-mPDG)/(param2[1]-mPDG));
2520  h2CtrlEvolMu1->Fill(param2[1],(fitfun->GetParameter(1)-mPDG)/(param2[1]-mPDG));
2521  }
2522  h2CtrlEvolMu2->Fill((param2[1]-mPDG)/mPDG,(param2[1]-fitfun->GetParameter(1))/mPDG);
2523  for (k=0;k<3;k++)
2524  {if (param2[k] != 0.)
2525  {hSpaceDiff[kNbTotParams*sm+k]->Fill(c,r,fitfun->GetParameter(k)/param2[k]);
2526  hAllDiff[k]->Fill(fitfun->GetParameter(k)/param2[k]);
2527  }
2528  }
2529  for (k=3;k<6;k++)
2530  {hSpaceDiff[kNbTotParams*sm+k]->Fill(c,r,fitfun->GetParameter(k)-param2[k]);
2531  hAllDiff[k]->Fill(fitfun->GetParameter(k)-param2[k]);
2532  }
2533  if (param2[6] != 0.)
2534  {hSpaceDiff[kNbTotParams*sm+6]->Fill(c,r,intgN/param2[6]);
2535  hAllDiff[6]->Fill(intgN/param2[6]);
2536  }
2537  if (param2[7] != 0.)
2538  {hSpaceDiff[kNbTotParams*sm+7]->Fill(c,r,intgKhi2/param2[7]);
2539  hAllDiff[7]->Fill(intgKhi2/param2[7]);
2540  }
2541  if (param2[8] != 0.)
2542  {hSpaceDiff[kNbTotParams*sm+8]->Fill(c,r,intgS/param2[8]);
2543  hAllDiff[8]->Fill(intgS/param2[8]);
2544  }
2545  if (param2[9] != 0.)
2546  {hSpaceDiff[kNbTotParams*sm+9]->Fill(c,r,(intgN-intgS)/param2[9]);
2547  hAllDiff[9]->Fill((intgN-intgS)/param2[9]);
2548  }
2549  }
2550  }//End loop on rows.
2551  }//End loop on columns.
2552 
2553  c1->Update();
2554 
2555  printf("\n");
2556 
2557  }//End loop on SM's.
2558  gStyle->SetOptStat(1111); //Back to the standard style (name, nb entries, mean, RMS).
2559 
2560 
2561 
2562 
2563 
2564 
2565 
2566 
2567 
2568 
2569 
2570 
2571 
2572  //*****************************************
2573  // Draw all remaining histoes :
2574  //*****************************************
2575 
2576  printf("\n\nThere are %d masked/empty/dead towers.\n\nList of the %d towers of which calib coeff has automatically been put to 1.00 because nbEntries < %d :\n",cmptMasked,cmptEntriesDiscard,(int)cutEntriesDiscard);
2577  fflush(stdout);
2578  gSystem->Exec(Form("less %s | grep -E '^2 ' | sed 's/^2 //g' | sed 's/ 1.0$//g'",txtFileCalibOutName.Data()));
2579 
2580  printf("\n\nList of the %d towers of which calib coeff has automatically been put to 1.0 because %f <Amp < %f :\n",cmptAmpDiscard,8.,cutAmpDiscard);
2581  fflush(stdout);
2582  gSystem->Exec(Form("less %s | grep -E '^3 ' | sed 's/^3 //g' | sed 's/ 1.0$//g'",txtFileCalibOutName.Data()));
2583 
2584  printf("\n\nList of the %d towers of which calib coeff has automatically been put to 1.0 because it's on a SM edge :\n",cmptEdge);
2585  fflush(stdout);
2586  gSystem->Exec(Form("less %s | grep -E '^4 ' | sed 's/^4 //g' | sed 's/ -9$//g'",txtFileCalibOutName.Data()));
2587 
2588  printf("\n\nStart drawing final plots...\n\n");
2589 
2590 
2591  //Spatial distribution per SM :
2592  for (i=0;i<kNbSMtot;i++)
2593  {if ((i<kNbSMtot) && (tabChoiceCalos[SMdetType[i]] == 0))
2594  {printf("Skip SM %d of type %s.\n",i,detTypeString[SMdetType[i]]);
2595  continue;
2596  }
2597  ps->NewPage();
2598  c1->Clear();
2599  c1->Divide(2,(int)((kNbFitParams+1)/2));
2600  hSpace[kNbFitParams*i+0]->SetMinimum(0.);
2601  if (hSpace[kNbFitParams*i+0]->GetMaximum() > 3.0*tabMax[0]) hSpace[kNbFitParams*i+0]->SetMaximum(3.0*tabMax[0]);
2602  nbTot=hSpace[kNbFitParams*i+1]->GetMaximum();
2603  for (k=0;k<hSpace[kNbFitParams*i+1]->GetNbinsX();k++)
2604  {for (j=0;j<hSpace[kNbFitParams*i+1]->GetNbinsY();j++)
2605  {if ((hSpace[kNbFitParams*i+1]->GetBinContent(k+1,j+1) < nbTot) && (hSpace[kNbFitParams*i+1]->GetBinContent(k+1,j+1) > 0)) nbTot=hSpace[kNbFitParams*i+1]->GetBinContent(k+1,j+1);
2606  }
2607  }
2608  hSpace[kNbFitParams*i+1]->SetMinimum(0.98*nbTot);
2609  if (hSpace[kNbFitParams*i+1]->GetMaximum() > 190.) hSpace[kNbFitParams*i+1]->SetMaximum(190.);
2610  hSpace[kNbFitParams*i+2]->SetMinimum(tabMin[2]);
2611  if (hSpace[kNbFitParams*i+3]->GetMaximum() > 3.0*tabMax[0]) hSpace[kNbFitParams*i+3]->SetMaximum(3.0*tabMax[0]);
2612  if (hSpace[kNbFitParams*i+4]->GetMaximum() > 3.0*tabMax[0]) hSpace[kNbFitParams*i+4]->SetMaximum(3.0*tabMax[0]);
2613  if (hSpace[kNbFitParams*i+5]->GetMaximum() > 3.0*tabMax[0]) hSpace[kNbFitParams*i+5]->SetMaximum(3.0*tabMax[0]);
2614  for (j=0;j<kNbFitParams;j++)
2615  {c1->cd(j+1);
2616  k=(j%2)*(int)((j+5)/2)+(1-(j%2))*(int)(j/2);
2617  hSpace[kNbFitParams*i+k]->Draw("COLZ");
2618  hSpaceEntriesDiscard[1*i+0]->SetMarkerColor(kWhite); //This changes also the text color for the Draw("TEXT") !!
2619  //Also changes size and color of test in ps->TextNDC !! => SetTxtColor necessary. But no function to set the font...
2620  //NB : SetMarkerColor has the same effect if placed when the histo is instanciated.
2621  hSpaceEntriesDiscard[1*i+0]->Draw("TEXT SAME");
2622  //c1->Update();
2623  //hSpaceEntriesDiscard[1*i+0]->SetMarkerSize(3);
2624  hSpaceEntriesDiscardHack[1*i+0]->Draw("TEXT SAME");
2625  //gStyle->SetTextSize(0.5);
2626  //hSpaceEntriesDiscard[1*i+0]->UseCurrentStyle();
2627  c1->Update();
2628  sprintf(txtPS,"%s for SM %d",varNameLong[k],i);
2629  //H mettre a la fin, sinon est overwrite par le plot (=> disparait).
2630  //The histo hSpaceEntriesDiscardHack is needed to have the figures of hSpaceEntriesDiscard plotted in small font, while the ps text (TextNDC) is plotted in readable font size.
2631  ps->SetTextColor(1);
2632  ps->TextNDC(0.2,0.94,txtPS);
2633  hSpace[kNbFitParams*i+k]->Write();
2634  }
2635  c1->Update();
2636 
2637  for (j=0;j<kNbExtraParams;j++)
2638  {hSpaceIntg[kNbExtraParams*i+j]->Write();
2639  }
2640  //if (hSpaceIntg[kNbExtraParams*i+0]->GetMaximum() > maxIntgAmpl) hSpaceIntg[kNbExtraParams*i+0]->SetMaximum(maxIntgAmpl);
2641  //Take the previous line out, to be able to catch the noisy towers.
2642  //if (hSpaceIntg[kNbExtraParams*i+1]->GetMaximum() > maxIntgAmpl) hSpaceIntg[kNbExtraParams*i+1]->SetMaximum(maxIntgAmpl);
2643  //Take the previous line out, because now that histo stores the khi2.
2644  hSpaceIntg[kNbExtraParams*i+0]->SetMinimum(0.);
2645  hSpaceIntg[kNbExtraParams*i+1]->SetMinimum(0.);
2646  hSpaceIntg[kNbExtraParams*i+2]->SetMinimum(0.);
2647  hSpaceIntg[kNbExtraParams*i+3]->SetMinimum(0.);
2648  if (hSpaceIntg[kNbExtraParams*i+2]->GetMaximum() > 3.0*tabMax[8]) hSpaceIntg[kNbExtraParams*i+2]->SetMaximum(3.0*tabMax[8]);
2649  ps->NewPage();
2650  c1->Clear();
2651  c1->Divide(2,3);
2652  c1->cd(1);
2653  hSpaceIntg[kNbExtraParams*i+0]->Draw("COLZ");
2654  hSpaceEntriesDiscard[1*i+0]->Draw("TEXT SAME");
2655  c1->Update();
2656  hSpaceEntriesDiscardHack[1*i+0]->Draw("TEXT SAME");
2657  c1->Update();
2658  sprintf(txtPS,"%s for SM %d",varNameLong[0+kNbFitParams],i);
2659  ps->SetTextColor(1);
2660  ps->TextNDC(0.2,0.94,txtPS);
2661  c1->Update();
2662  c1->cd(3);
2663  hSpaceIntg[kNbExtraParams*i+2]->Draw("COLZ");
2664  hSpaceEntriesDiscard[1*i+0]->Draw("TEXT SAME");
2665  c1->Update();
2666  hSpaceEntriesDiscardHack[1*i+0]->Draw("TEXT SAME");
2667  c1->Update();
2668  sprintf(txtPS,"%s for SM %d",varNameLong[2+kNbFitParams],i);
2669  ps->SetTextColor(1);
2670  ps->TextNDC(0.2,0.94,txtPS);
2671  c1->Update();
2672  c1->cd(5);
2673  hSpaceIntg[kNbExtraParams*i+3]->Draw("COLZ");
2674  hSpaceEntriesDiscard[1*i+0]->Draw("TEXT SAME");
2675  c1->Update();
2676  hSpaceEntriesDiscardHack[1*i+0]->Draw("TEXT SAME");
2677  c1->Update();
2678  sprintf(txtPS,"%s for SM %d",varNameLong[3+kNbFitParams],i);
2679  ps->SetTextColor(1);
2680  ps->TextNDC(0.2,0.94,txtPS);
2681  c1->Update();
2682  hSpaceIntg[kNbExtraParams*i+0]->SetMaximum(1.5*tabMax[kNbFitParams+0]);
2683  c1->cd(2);
2684  hSpaceIntg[kNbExtraParams*i+0]->Draw("COLZ");
2685  hSpaceEntriesDiscard[1*i+0]->Draw("TEXT SAME");
2686  c1->Update();
2687  sprintf(txtPS,"%s for SM %d (zoomed)",varNameLong[0+kNbFitParams],i);
2688  ps->TextNDC(0.2,0.94,txtPS);
2689  c1->Update();
2690 
2691  ps->NewPage();
2692  c1->Clear();
2693  c1->Divide(2,3);
2694  c1->cd(1);
2695  hSpaceIntg[kNbExtraParams*i+1]->Draw("COLZ");
2696  hSpaceEntriesDiscard[1*i+0]->Draw("TEXT SAME");
2697  c1->Update();
2698  hSpaceEntriesDiscardHack[1*i+0]->Draw("TEXT SAME");
2699  c1->Update();
2700  sprintf(txtPS,"%s for SM %d",varNameLong[1+kNbFitParams],i);
2701  ps->SetTextColor(1);
2702  ps->TextNDC(0.2,0.94,txtPS);
2703  c1->Update();
2704  c1->cd(3);
2705  hSpaceIntg[kNbExtraParams*i+4]->Draw("COLZ");
2706  hSpaceEntriesDiscard[1*i+0]->Draw("TEXT SAME");
2707  c1->Update();
2708  hSpaceEntriesDiscardHack[1*i+0]->Draw("TEXT SAME");
2709  c1->Update();
2710  sprintf(txtPS,"%s for SM %d",varNameLong[4+kNbFitParams],i);
2711  ps->SetTextColor(1);
2712  ps->TextNDC(0.2,0.94,txtPS);
2713  c1->Update();
2714  hSpaceIntg[kNbExtraParams*i+1]->SetMaximum(5.0);
2715  hSpaceIntg[kNbExtraParams*i+4]->SetMaximum(5.0);
2716  hSpaceIntg[kNbExtraParams*i+5]->SetMaximum(5.0);
2717  hSpaceIntg[kNbExtraParams*i+6]->SetMaximum(5.0);
2718  c1->cd(2);
2719  hSpaceIntg[kNbExtraParams*i+1]->Draw("COLZ");
2720  hSpaceEntriesDiscard[1*i+0]->Draw("TEXT SAME");
2721  c1->Update();
2722  sprintf(txtPS,"%s for SM %d (zoomed)",varNameLong[1+kNbFitParams],i);
2723  ps->TextNDC(0.2,0.94,txtPS);
2724  c1->cd(4);
2725  hSpaceIntg[kNbExtraParams*i+4]->Draw("COLZ");
2726  hSpaceEntriesDiscard[1*i+0]->Draw("TEXT SAME");
2727  c1->Update();
2728  sprintf(txtPS,"%s for SM %d (zoomed)",varNameLong[4+kNbFitParams],i);
2729  ps->TextNDC(0.2,0.94,txtPS);
2730  c1->cd(5);
2731  hSpaceIntg[kNbExtraParams*i+5]->Draw("COLZ");
2732  hSpaceEntriesDiscard[1*i+0]->Draw("TEXT SAME");
2733  c1->Update();
2734  hSpaceEntriesDiscardHack[1*i+0]->Draw("TEXT SAME");
2735  c1->Update();
2736  sprintf(txtPS,"%s for SM %d",varNameLong[5+kNbFitParams],i);
2737  ps->SetTextColor(1);
2738  ps->TextNDC(0.2,0.94,txtPS);
2739  c1->cd(6);
2740  hSpaceIntg[kNbExtraParams*i+6]->Draw("COLZ");
2741  hSpaceEntriesDiscard[1*i+0]->Draw("TEXT SAME");
2742  c1->Update();
2743  hSpaceEntriesDiscardHack[1*i+0]->Draw("TEXT SAME");
2744  c1->Update();
2745  sprintf(txtPS,"%s for SM %d",varNameLong[6+kNbFitParams],i);
2746  ps->SetTextColor(1);
2747  ps->TextNDC(0.2,0.94,txtPS);
2748  c1->Update();
2749 
2750  ps->NewPage();
2751  c1->Clear();
2752  c1->Divide(2,3);
2753  c1->cd(1);
2754  hSpaceCuts[5*i+1]->SetMinimum(0.);
2755  hSpaceCuts[5*i+1]->SetMaximum(2.);
2756  hSpaceCuts[5*i+1]->Draw("COLZ");
2757  c1->Update();
2758  sprintf(txtPS,"Stat uncert on mean for SM %d",i);
2759  ps->TextNDC(0.2,0.94,txtPS);
2760  hSpaceCuts[5*i+1]->Write();
2761  c1->Update();
2762  c1->cd(2);
2763  hSpaceCuts[5*i+2]->SetMinimum(0.);
2764  hSpaceCuts[5*i+2]->SetMaximum(5.05);
2765  hSpaceCuts[5*i+2]->Draw("COLZ");
2766  c1->Update();
2767  sprintf(txtPS,"Stat uncert on mean for SM %d",i);
2768  ps->TextNDC(0.2,0.94,txtPS);
2769  hSpaceCuts[5*i+2]->Write();
2770  c1->Update();
2771  c1->cd(3);
2772  hSpaceCuts[5*i+3]->SetMinimum(0.);
2773  hSpaceCuts[5*i+3]->SetMaximum(0.08);
2774  hSpaceCuts[5*i+3]->Draw("COLZ");
2775  c1->Update();
2776  sprintf(txtPS,"Relative distance to mPDG for SM %d",i);
2777  ps->TextNDC(0.2,0.94,txtPS);
2778  hSpaceCuts[5*i+3]->Write();
2779  c1->Update();
2780  c1->cd(4);
2781  hSpaceCuts[5*i+4]->SetMinimum(0.);
2782  hSpaceCuts[5*i+4]->SetMaximum(5.05);
2783  hSpaceCuts[5*i+4]->Draw("COLZ");
2784  c1->Update();
2785  sprintf(txtPS,"Relative distance to mPDG for SM %d",i);
2786  ps->TextNDC(0.2,0.94,txtPS);
2787  hSpaceCuts[5*i+4]->Write();
2788  c1->Update();
2789  c1->cd(6);
2790  hSpaceCuts[5*i+0]->SetMinimum(0.);
2791  hSpaceCuts[5*i+0]->SetMaximum(kNbFitParams+4);
2792  hSpaceCuts[5*i+0]->Draw("COLZ");
2793  hSpaceEntriesDiscard[1*i+0]->Draw("TEXT SAME");
2794  c1->Update();
2795  sprintf(txtPS,"Untrusted fits for SM %d",i);
2796  ps->TextNDC(0.2,0.94,txtPS);
2797  hSpaceCuts[5*i+0]->Write();
2798  c1->Update();
2799  }
2800 
2801 
2802  //Now put all spatial distribs together to have a full calorimeter real view :
2803  //The way the loops are imbricated is not easily readable but should be the fastest for processing.
2804  for (j=0;j<kNbFitParams;j++)
2805  {for (i=0;i<kNbSMEMCAL+kNbSMEMCALthird;i++)
2806  {if ((i%2) == 0) shiftCol=0;
2807  else shiftCol=kNbColMax;
2808  shiftRow=(int)(i/2)*kNbRowMax;
2809  for (iCol=0;iCol<kTabNbCol[SMdetType[i]];iCol++)
2810  {for (iRow=0;iRow<kTabNbRow[SMdetType[i]];iRow++)
2811  {hAllSpaceEMCAL[j]->SetBinContent(iCol+1+shiftCol,iRow+1+shiftRow,hSpace[kNbFitParams*i+j]->GetBinContent(iCol+1,iRow+1));
2812  //Book in 1-D histoes only if tower not masked/empty ; no way to know it at this stage except that mean and sigma are both 0 :
2813  if ((hSpace[kNbFitParams*i+1]->GetBinContent(iCol+1,iRow+1) != 0.) && (hSpace[kNbFitParams*i+2]->GetBinContent(iCol+1,iRow+1) != 0.)) hAllDistrib[j]->Fill(hSpace[kNbFitParams*i+j]->GetBinContent(iCol+1,iRow+1));
2814  if (j == 1)
2815  {hAllDistribMass->Fill(hSpace[kNbFitParams*i+j]->GetBinContent(iCol+1,iRow+1));
2816  hAllDistribMassPerSM[i]->Fill(hSpace[kNbFitParams*i+j]->GetBinContent(iCol+1,iRow+1));
2817  }
2818  }
2819  }
2820  }
2821  }
2822  for (j=0;j<kNbFitParams;j++)
2823  {for (i=kNbSMEMCAL+kNbSMEMCALthird;i<kNbSMtot;i++)
2824  {if ((i%2) == 0) shiftCol=0;
2825  else shiftCol=kNbColMax+kTabColOffset[i];
2826  shiftRow=(int)((i-(kNbSMEMCAL+kNbSMEMCALthird))/2)*kNbRowMax;
2827  for (iCol=0;iCol<kTabNbCol[SMdetType[i]];iCol++)
2828  {for (iRow=0;iRow<kTabNbRow[SMdetType[i]];iRow++)
2829  {hAllSpaceDCAL[j]->SetBinContent(iCol+1+shiftCol,iRow+1+shiftRow,hSpace[kNbFitParams*i+j]->GetBinContent(iCol+1,iRow+1));
2830  //Book in 1-D histoes only if tower not masked/empty ; no way to know it at this stage except that mean and sigma are both 0 :
2831  if ((hSpace[kNbFitParams*i+1]->GetBinContent(iCol+1,iRow+1) != 0.) && (hSpace[kNbFitParams*i+2]->GetBinContent(iCol+1,iRow+1) != 0.)) hAllDistrib[j]->Fill(hSpace[kNbFitParams*i+j]->GetBinContent(iCol+1,iRow+1));
2832  if (j == 1)
2833  {hAllDistribMass->Fill(hSpace[kNbFitParams*i+j]->GetBinContent(iCol+1,iRow+1));
2834  hAllDistribMassPerSM[i]->Fill(hSpace[kNbFitParams*i+j]->GetBinContent(iCol+1,iRow+1));
2835  }
2836  }
2837  }
2838  }
2839  }
2840  for (j=0;j<kNbExtraParams;j++)
2841  {for (i=0;i<kNbSMEMCAL+kNbSMEMCALthird;i++)
2842  {if ((i%2) == 0) shiftCol=0;
2843  else shiftCol=kNbColMax;
2844  shiftRow=(int)(i/2)*kNbRowMax;
2845  for (iCol=0;iCol<kTabNbCol[SMdetType[i]];iCol++)
2846  {for (iRow=0;iRow<kTabNbRow[SMdetType[i]];iRow++)
2847  {hAllSpaceEMCALIntg[j]->SetBinContent(iCol+1+shiftCol,iRow+1+shiftRow,hSpaceIntg[kNbExtraParams*i+j]->GetBinContent(iCol+1,iRow+1));
2848  //Book in 1-D histoes only if tower not masked/empty ; no way to know it at this stage except that mean and sigma are both 0 :
2849  if ((hSpace[kNbFitParams*i+1]->GetBinContent(iCol+1,iRow+1) != 0.) && (hSpace[kNbFitParams*i+2]->GetBinContent(iCol+1,iRow+1) != 0.)) hAllDistribIntg[j]->Fill(hSpaceIntg[kNbExtraParams*i+j]->GetBinContent(iCol+1,iRow+1));
2850  }
2851  }
2852  }
2853  }
2854  for (j=0;j<kNbExtraParams;j++)
2855  {for (i=kNbSMEMCAL+kNbSMEMCALthird;i<kNbSMtot;i++)
2856  {if ((i%2) == 0) shiftCol=0;
2857  else shiftCol=kNbColMax+kTabColOffset[i];
2858  shiftRow=(int)((i-(kNbSMEMCAL+kNbSMEMCALthird))/2)*kNbRowMax;
2859  for (iCol=0;iCol<kTabNbCol[SMdetType[i]];iCol++)
2860  {for (iRow=0;iRow<kTabNbRow[SMdetType[i]];iRow++)
2861  {hAllSpaceDCALIntg[j]->SetBinContent(iCol+1+shiftCol,iRow+1+shiftRow,hSpaceIntg[kNbExtraParams*i+j]->GetBinContent(iCol+1,iRow+1));
2862  //Book in 1-D histoes only if tower not masked/empty ; no way to know it at this stage except that mean and sigma are both 0 :
2863  if ((hSpace[kNbFitParams*i+1]->GetBinContent(iCol+1,iRow+1) != 0.) && (hSpace[kNbFitParams*i+2]->GetBinContent(iCol+1,iRow+1) != 0.)) hAllDistribIntg[j]->Fill(hSpaceIntg[kNbExtraParams*i+j]->GetBinContent(iCol+1,iRow+1));
2864  }
2865  }
2866  }
2867  }
2868  for (j=0;j<1;j++)
2869  {for (i=0;i<kNbSMEMCAL+kNbSMEMCALthird;i++)
2870  {if ((i%2) == 0) shiftCol=0;
2871  else shiftCol=kNbColMax;
2872  shiftRow=(int)(i/2)*kNbRowMax;
2873  for (iCol=0;iCol<kTabNbCol[SMdetType[i]];iCol++)
2874  {for (iRow=0;iRow<kTabNbRow[SMdetType[i]];iRow++)
2875  {hAllSpaceEMCALCoeff[j]->SetBinContent(iCol+1+shiftCol,iRow+1+shiftRow,hSpaceCoeff[1*i+j]->GetBinContent(iCol+1,iRow+1));
2876  }
2877  }
2878  }
2879  }
2880  for (j=0;j<1;j++)
2881  {for (i=kNbSMEMCAL+kNbSMEMCALthird;i<kNbSMtot;i++)
2882  {if ((i%2) == 0) shiftCol=0;
2883  else shiftCol=kNbColMax+kTabColOffset[i];
2884  shiftRow=(int)((i-(kNbSMEMCAL+kNbSMEMCALthird))/2)*kNbRowMax;
2885  for (iCol=0;iCol<kTabNbCol[SMdetType[i]];iCol++)
2886  {for (iRow=0;iRow<kTabNbRow[SMdetType[i]];iRow++)
2887  {hAllSpaceDCALCoeff[j]->SetBinContent(iCol+1+shiftCol,iRow+1+shiftRow,hSpaceCoeff[1*i+j]->GetBinContent(iCol+1,iRow+1));
2888  }
2889  }
2890  }
2891  }
2892  for (i=0;i<kNbSMEMCAL+kNbSMEMCALthird;i++)
2893  {if ((i%2) == 0) shiftCol=0;
2894  else shiftCol=kNbColMax;
2895  shiftRow=(int)(i/2)*kNbRowMax;
2896  for (iCol=0;iCol<kTabNbCol[SMdetType[i]];iCol++)
2897  {for (iRow=0;iRow<kTabNbRow[SMdetType[i]];iRow++)
2898  {//hAllSpaceEMCALDistance[0] = dist_N = (mu_fit - mPDG)/(sig_fit/sqrt(intgS))
2899  //hAllSpaceEMCALDistance[1] = dist_fit = (mu_fit - mPDG) / (fit uncertainty on mu_fit)
2900  //hAllSpaceEMCALDistance[2] = (dist_N - dist_fit) / dist_fit
2901  if ((hAllSpaceEMCAL[2]->GetBinContent(iCol+1+shiftCol,iRow+1+shiftRow) == 0.) && (hAllSpaceEMCAL[1]->GetBinContent(iCol+1+shiftCol,iRow+1+shiftRow) == 0.)) continue; //A noisy tower, do nothing.
2902  hAllSpaceEMCALDistance[1]->SetBinContent(iCol+1+shiftCol,iRow+1+shiftRow,TMath::Abs(hAllSpaceEMCAL[1]->GetBinContent(iCol+1+shiftCol,iRow+1+shiftRow)-mPDG)/hSpaceFitErr[1*i+0]->GetBinContent(iCol+1,iRow+1));
2903  if (hAllSpaceEMCALIntg[2]->GetBinContent(iCol+1+shiftCol,iRow+1+shiftRow) != 0.) hAllSpaceEMCALDistance[0]->SetBinContent(iCol+1+shiftCol,iRow+1+shiftRow,TMath::Abs(hAllSpaceEMCAL[1]->GetBinContent(iCol+1+shiftCol,iRow+1+shiftRow)-mPDG)/(hAllSpaceEMCAL[2]->GetBinContent(iCol+1+shiftCol,iRow+1+shiftRow)/TMath::Sqrt(hAllSpaceEMCALIntg[2]->GetBinContent(iCol+1+shiftCol,iRow+1+shiftRow))));
2904  else hAllSpaceEMCALDistance[0]->SetBinContent(iCol+1+shiftCol,iRow+1+shiftRow,49.);
2905  if (hAllSpaceEMCALDistance[1]->GetBinContent(iCol+1+shiftCol,iRow+1+shiftRow) != 0.) hAllSpaceEMCALDistance[2]->SetBinContent(iCol+1+shiftCol,iRow+1+shiftRow,(hAllSpaceEMCALDistance[0]->GetBinContent(iCol+1+shiftCol,iRow+1+shiftRow)-hAllSpaceEMCALDistance[1]->GetBinContent(iCol+1+shiftCol,iRow+1+shiftRow))/hAllSpaceEMCALDistance[1]->GetBinContent(iCol+1+shiftCol,iRow+1+shiftRow));
2906  hAllDistribDistance[0]->Fill(hAllSpaceEMCALDistance[0]->GetBinContent(iCol+1+shiftCol,iRow+1+shiftRow));
2907  hAllDistribDistance[1]->Fill(hAllSpaceEMCALDistance[1]->GetBinContent(iCol+1+shiftCol,iRow+1+shiftRow));
2908  hCorrelDvsSig->Fill(hAllSpaceEMCAL[2]->GetBinContent(iCol+1+shiftCol,iRow+1+shiftRow),hAllSpaceEMCALDistance[1]->GetBinContent(iCol+1+shiftCol,iRow+1+shiftRow));
2909  hCorrelCmpD->Fill(hAllSpaceEMCALDistance[1]->GetBinContent(iCol+1+shiftCol,iRow+1+shiftRow),hAllSpaceEMCALDistance[2]->GetBinContent(iCol+1+shiftCol,iRow+1+shiftRow));
2910  }
2911  }
2912  }
2913  for (i=kNbSMEMCAL+kNbSMEMCALthird;i<kNbSMtot;i++)
2914  {if ((i%2) == 0) shiftCol=0;
2915  else shiftCol=kNbColMax+kTabColOffset[i];
2916  shiftRow=(int)((i-(kNbSMEMCAL+kNbSMEMCALthird))/2)*kNbRowMax;
2917  for (iCol=0;iCol<kTabNbCol[SMdetType[i]];iCol++)
2918  {for (iRow=0;iRow<kTabNbRow[SMdetType[i]];iRow++)
2919  {//hAllSpaceDCALDistance[0] = dist_N = (mu_fit - mPDG)/(sig_fit/sqrt(intgS))
2920  //hAllSpaceDCALDistance[1] = dist_fit = (mu_fit - mPDG) / (fit uncertainty on mu_fit)
2921  //hAllSpaceDCALDistance[2] = (dist_N - dist_fit) / dist_fit
2922  if ((hAllSpaceDCAL[2]->GetBinContent(iCol+1+shiftCol,iRow+1+shiftRow) == 0.) && (hAllSpaceDCAL[1]->GetBinContent(iCol+1+shiftCol,iRow+1+shiftRow) == 0.)) continue; //A noisy tower, do nothing.
2923  hAllSpaceDCALDistance[1]->SetBinContent(iCol+1+shiftCol,iRow+1+shiftRow,TMath::Abs(hAllSpaceDCAL[1]->GetBinContent(iCol+1+shiftCol,iRow+1+shiftRow)-mPDG)/hSpaceFitErr[1*i+0]->GetBinContent(iCol+1,iRow+1));
2924  if (hAllSpaceDCALIntg[2]->GetBinContent(iCol+1+shiftCol,iRow+1+shiftRow) != 0.) hAllSpaceDCALDistance[0]->SetBinContent(iCol+1+shiftCol,iRow+1+shiftRow,TMath::Abs(hAllSpaceDCAL[1]->GetBinContent(iCol+1+shiftCol,iRow+1+shiftRow)-mPDG)/(hAllSpaceDCAL[2]->GetBinContent(iCol+1+shiftCol,iRow+1+shiftRow)/TMath::Sqrt(hAllSpaceDCALIntg[2]->GetBinContent(iCol+1+shiftCol,iRow+1+shiftRow))));
2925  else hAllSpaceDCALDistance[0]->SetBinContent(iCol+1+shiftCol,iRow+1+shiftRow,49.);
2926  if (hAllSpaceDCALDistance[1]->GetBinContent(iCol+1+shiftCol,iRow+1+shiftRow) != 0.) hAllSpaceDCALDistance[2]->SetBinContent(iCol+1+shiftCol,iRow+1+shiftRow,(hAllSpaceDCALDistance[0]->GetBinContent(iCol+1+shiftCol,iRow+1+shiftRow)-hAllSpaceDCALDistance[1]->GetBinContent(iCol+1+shiftCol,iRow+1+shiftRow))/hAllSpaceDCALDistance[1]->GetBinContent(iCol+1+shiftCol,iRow+1+shiftRow));
2927  hAllDistribDistance[0]->Fill(hAllSpaceDCALDistance[0]->GetBinContent(iCol+1+shiftCol,iRow+1+shiftRow));
2928  hAllDistribDistance[1]->Fill(hAllSpaceDCALDistance[1]->GetBinContent(iCol+1+shiftCol,iRow+1+shiftRow));
2929  hCorrelDvsSig->Fill(hAllSpaceDCAL[2]->GetBinContent(iCol+1+shiftCol,iRow+1+shiftRow),hAllSpaceDCALDistance[1]->GetBinContent(iCol+1+shiftCol,iRow+1+shiftRow));
2930  hCorrelCmpD->Fill(hAllSpaceDCALDistance[1]->GetBinContent(iCol+1+shiftCol,iRow+1+shiftRow),hAllSpaceDCALDistance[2]->GetBinContent(iCol+1+shiftCol,iRow+1+shiftRow));
2931  }
2932  }
2933  }
2934  for (j=0;j<kNbTotParams;j++)
2935  {for (i=0;i<kNbSMEMCAL+kNbSMEMCALthird;i++)
2936  {if ((i%2) == 0) shiftCol=0;
2937  else shiftCol=kNbColMax;
2938  shiftRow=(int)(i/2)*kNbRowMax;
2939  for (iCol=0;iCol<kTabNbCol[SMdetType[i]];iCol++)
2940  {for (iRow=0;iRow<kTabNbRow[SMdetType[i]];iRow++)
2941  {hAllSpaceEMCALDiff[j]->SetBinContent(iCol+1+shiftCol,iRow+1+shiftRow,hSpaceDiff[kNbTotParams*i+j]->GetBinContent(iCol+1,iRow+1));
2942  }
2943  }
2944  }
2945  }
2946  for (j=0;j<kNbTotParams;j++)
2947  {for (i=kNbSMEMCAL+kNbSMEMCALthird;i<kNbSMtot;i++)
2948  {if ((i%2) == 0) shiftCol=0;
2949  else shiftCol=kNbColMax+kTabColOffset[i];
2950  shiftRow=(int)((i-(kNbSMEMCAL+kNbSMEMCALthird))/2)*kNbRowMax;
2951  for (iCol=0;iCol<kTabNbCol[SMdetType[i]];iCol++)
2952  {for (iRow=0;iRow<kTabNbRow[SMdetType[i]];iRow++)
2953  {hAllSpaceDCALDiff[j]->SetBinContent(iCol+1+shiftCol,iRow+1+shiftRow,hSpaceDiff[kNbTotParams*i+j]->GetBinContent(iCol+1,iRow+1));
2954  }
2955  }
2956  }
2957  }
2958 
2959  if (choiceNoEMCAL != 0)
2960  {ps->NewPage();
2961  c1->Clear();
2962  c1->Divide(2,(int)((kNbFitParams+1)/2));
2963  hAllSpaceEMCAL[0]->SetMinimum(0.);
2964  hAllSpaceEMCAL[0]->SetMaximum(1.2*tabMax[0]);
2965  hAllSpaceEMCAL[1]->SetMinimum(tabMin[1]+30.);
2966  hAllSpaceEMCAL[1]->SetMaximum(tabMax[1]-10.);
2967  hAllSpaceEMCAL[2]->SetMinimum(tabMin[2]+5.);
2968  hAllSpaceEMCAL[2]->SetMaximum(tabMax[2]-5.);
2969  for (j=0;j<kNbFitParams;j++)
2970  {c1->cd(j+1);
2971  k=(j%2)*(int)((j+5)/2)+(1-(j%2))*(int)(j/2);
2972  hAllSpaceEMCAL[k]->Draw("COLZ");
2973  lineSMborderVEMCAL->Draw("SAME");
2974  for (int jm=0;jm<(int)((kNbSMEMCAL+1)/2);jm++) lineSMborderHEMCAL[jm]->Draw("SAME");
2975  c1->Update();
2976  sprintf(txtPS,"%s for all SMs",varNameLong[k]);
2977  ps->TextNDC(0.2,0.94,txtPS);
2978  hAllSpaceEMCAL[k]->Write();
2979  //if(k==1)hAllSpaceEMCAL[k]->SaveAs("MeanGaussianFitAllSM.root");
2980  }
2981  c1->Update();
2982 
2983  for (j=0;j<kNbExtraParams;j++)
2984  {hAllSpaceEMCALIntg[j]->Write();
2985  }
2986  //if (hAllSpaceEMCALIntg[0]->GetMaximum() > maxIntgAmpl) hAllSpaceEMCALIntg[0]->SetMaximum(maxIntgAmpl);
2987  //Take the previous line out, to be able to catch the noisy towers.
2988  //if (hAllSpaceEMCALIntg[1]->GetMaximum() > maxIntgAmpl) hAllSpaceEMCALIntg[1]->SetMaximum(maxIntgAmpl);
2989  //Take the previous line out, because now that histo stores the khi2.
2990  hAllSpaceEMCALIntg[0]->SetMinimum(0.);
2991  hAllSpaceEMCALIntg[1]->SetMinimum(0.);
2992  hAllSpaceEMCALIntg[2]->SetMaximum(1.2*tabMax[8]);
2993  hAllSpaceEMCALIntg[3]->SetMinimum(0.);
2994  ps->NewPage();
2995  c1->Clear();
2996  c1->Divide(2,3);
2997  c1->cd(1);
2998  hAllSpaceEMCALIntg[0]->Draw("COLZ");
2999  lineSMborderVEMCAL->Draw("SAME");
3000  for (int jm=0;jm<(int)((kNbSMEMCAL+1)/2);jm++) lineSMborderHEMCAL[jm]->Draw("SAME");
3001  c1->Update();
3002  sprintf(txtPS,"%s for all SMs",varNameLong[0+kNbFitParams]);
3003  ps->TextNDC(0.2,0.94,txtPS);
3004  c1->cd(3);
3005  hAllSpaceEMCALIntg[2]->Draw("COLZ");
3006  lineSMborderVEMCAL->Draw("SAME");
3007  for (int jm=0;jm<(int)((kNbSMEMCAL+1)/2);jm++) lineSMborderHEMCAL[jm]->Draw("SAME");
3008  c1->Update();
3009  sprintf(txtPS,"%s for all SMs",varNameLong[2+kNbFitParams]);
3010  ps->TextNDC(0.2,0.94,txtPS);
3011  c1->cd(5);
3012  hAllSpaceEMCALIntg[3]->Draw("COLZ");
3013  lineSMborderVEMCAL->Draw("SAME");
3014  for (int jm=0;jm<(int)((kNbSMEMCAL+1)/2);jm++) lineSMborderHEMCAL[jm]->Draw("SAME");
3015  c1->Update();
3016  sprintf(txtPS,"%s for all SMs",varNameLong[3+kNbFitParams]);
3017  ps->TextNDC(0.2,0.94,txtPS);
3018  c1->Update();
3019  hAllSpaceEMCALIntg[0]->SetMaximum(1.2*tabMax[kNbFitParams+0]);
3020  c1->cd(2);
3021  hAllSpaceEMCALIntg[0]->Draw("COLZ");
3022  lineSMborderVEMCAL->Draw("SAME");
3023  for (int jm=0;jm<(int)((kNbSMEMCAL+1)/2);jm++) lineSMborderHEMCAL[jm]->Draw("SAME");
3024  c1->Update();
3025  sprintf(txtPS,"%s for all SMs (zoomed)",varNameLong[2+kNbFitParams]);
3026  ps->TextNDC(0.2,0.94,txtPS);
3027  c1->Update();
3028 
3029  ps->NewPage();
3030  c1->Clear();
3031  c1->Divide(2,3);
3032  c1->cd(1);
3033  hAllSpaceEMCALIntg[1]->Draw("COLZ");
3034  lineSMborderVEMCAL->Draw("SAME");
3035  for (int jm=0;jm<(int)((kNbSMEMCAL+1)/2);jm++) lineSMborderHEMCAL[jm]->Draw("SAME");
3036  c1->Update();
3037  sprintf(txtPS,"%s for all SMs",varNameLong[1+kNbFitParams]);
3038  ps->TextNDC(0.2,0.94,txtPS);
3039  c1->cd(3);
3040  hAllSpaceEMCALIntg[4]->Draw("COLZ");
3041  lineSMborderVEMCAL->Draw("SAME");
3042  for (int jm=0;jm<(int)((kNbSMEMCAL+1)/2);jm++) lineSMborderHEMCAL[jm]->Draw("SAME");
3043  c1->Update();
3044  sprintf(txtPS,"%s for all SMs",varNameLong[4+kNbFitParams]);
3045  ps->TextNDC(0.2,0.94,txtPS);
3046  c1->Update();
3047  hAllSpaceEMCALIntg[1]->SetMaximum(4.0);
3048  hAllSpaceEMCALIntg[4]->SetMaximum(4.0);
3049  c1->cd(2);
3050  hAllSpaceEMCALIntg[1]->Draw("COLZ");
3051  lineSMborderVEMCAL->Draw("SAME");
3052  for (int jm=0;jm<(int)((kNbSMEMCAL+1)/2);jm++) lineSMborderHEMCAL[jm]->Draw("SAME");
3053  c1->Update();
3054  sprintf(txtPS,"%s for all SMs (zoomed)",varNameLong[1+kNbFitParams]);
3055  ps->TextNDC(0.2,0.94,txtPS);
3056  c1->cd(4);
3057  hAllSpaceEMCALIntg[4]->Draw("COLZ");
3058  lineSMborderVEMCAL->Draw("SAME");
3059  for (int jm=0;jm<(int)((kNbSMEMCAL+1)/2);jm++) lineSMborderHEMCAL[jm]->Draw("SAME");
3060  c1->Update();
3061  sprintf(txtPS,"%s for all SMs (zoomed)",varNameLong[4+kNbFitParams]);
3062  ps->TextNDC(0.2,0.94,txtPS);
3063  c1->cd(5);
3064  hAllSpaceEMCALSoverN->Divide(hAllSpaceEMCALIntg[2],hAllSpaceEMCALIntg[3]);
3065  nbTot=hAllSpaceEMCALSoverN->GetMaximum();
3066  for (i=0;i<hAllSpaceEMCALSoverN->GetNbinsX();i++)
3067  {for (j=0;j<hAllSpaceEMCALSoverN->GetNbinsY();j++)
3068  {if ((hAllSpaceEMCALSoverN->GetBinContent(i+1,j+1) < nbTot) && (hAllSpaceEMCALSoverN->GetBinContent(i+1,j+1) > 0)) nbTot=hAllSpaceEMCALSoverN->GetBinContent(i+1,j+1);
3069  }
3070  }
3071  hAllSpaceEMCALSoverN->SetMinimum(0.98*nbTot);
3072  hAllSpaceEMCALSoverN->Draw("COLZ");
3073  lineSMborderVEMCAL->Draw("SAME");
3074  for (int jm=0;jm<(int)((kNbSMEMCAL+1)/2);jm++) lineSMborderHEMCAL[jm]->Draw("SAME");
3075  c1->Update();
3076  sprintf(txtPS,"Signal to noise ratio for all SMs");
3077  ps->TextNDC(0.2,0.94,txtPS);
3078  hAllSpaceEMCALSoverN->Write();
3079  c1->Update();
3080  c1->cd(6);
3081  hAllSpaceEMCALSoverN->SetMaximum(2.);
3082  hAllSpaceEMCALSoverN->Draw("COLZ");
3083  lineSMborderVEMCAL->Draw("SAME");
3084  for (int jm=0;jm<(int)((kNbSMEMCAL+1)/2);jm++) lineSMborderHEMCAL[jm]->Draw("SAME");
3085  c1->Update();
3086  sprintf(txtPS,"Signal to noise ratio for all SMs (zoomed)");
3087  ps->TextNDC(0.2,0.94,txtPS);
3088  c1->Update();
3089  }
3090 
3091  if (choiceNoDCAL != 0)
3092  {ps->NewPage();
3093  c1->Clear();
3094  c1->Divide(2,(int)((kNbFitParams+1)/2));
3095  hAllSpaceDCAL[0]->SetMinimum(0.);
3096  hAllSpaceDCAL[0]->SetMaximum(1.2*tabMax[0]);
3097  hAllSpaceDCAL[1]->SetMinimum(tabMin[1]+30.);
3098  hAllSpaceDCAL[1]->SetMaximum(tabMax[1]-10.);
3099  hAllSpaceDCAL[2]->SetMinimum(tabMin[2]+5.);
3100  hAllSpaceDCAL[2]->SetMaximum(tabMax[2]-5.);
3101  for (j=0;j<kNbFitParams;j++)
3102  {c1->cd(j+1);
3103  k=(j%2)*(int)((j+5)/2)+(1-(j%2))*(int)(j/2);
3104  hAllSpaceDCAL[k]->Draw("COLZ");
3105  lineSMborderVDCALthird->Draw("SAME");
3106  lineSMborderVDCAL1->Draw("SAME");
3107  lineSMborderVDCAL2->Draw("SAME");
3108  for (int jm=0;jm<(int)((kNbSMDCAL+1)/2);jm++) lineSMborderHDCAL[jm]->Draw("SAME");
3109  c1->Update();
3110  sprintf(txtPS,"%s for all SMs",varNameLong[k]);
3111  ps->TextNDC(0.2,0.94,txtPS);
3112  hAllSpaceDCAL[k]->Write();
3113  //if(k==1)hAllSpaceDCAL[k]->SaveAs("MeanGaussianFitAllSM.root");
3114  }
3115  c1->Update();
3116 
3117  for (j=0;j<kNbExtraParams;j++)
3118  {hAllSpaceDCALIntg[j]->Write();
3119  }
3120  //if (hAllSpaceDCALIntg[0]->GetMaximum() > maxIntgAmpl) hAllSpaceDCALIntg[0]->SetMaximum(maxIntgAmpl);
3121  //Take the previous line out, to be able to catch the noisy towers.
3122  //if (hAllSpaceDCALIntg[1]->GetMaximum() > maxIntgAmpl) hAllSpaceDCALIntg[1]->SetMaximum(maxIntgAmpl);
3123  //Take the previous line out, because now that histo stores the khi2.
3124  hAllSpaceDCALIntg[0]->SetMinimum(0.);
3125  hAllSpaceDCALIntg[1]->SetMinimum(0.);
3126  hAllSpaceDCALIntg[2]->SetMaximum(1.2*tabMax[8]);
3127  hAllSpaceDCALIntg[3]->SetMinimum(0.);
3128  ps->NewPage();
3129  c1->Clear();
3130  c1->Divide(2,3);
3131  c1->cd(1);
3132  hAllSpaceDCALIntg[0]->Draw("COLZ");
3133  lineSMborderVDCALthird->Draw("SAME");
3134  lineSMborderVDCAL1->Draw("SAME");
3135  lineSMborderVDCAL2->Draw("SAME");
3136  for (int jm=0;jm<(int)((kNbSMDCAL+1)/2);jm++) lineSMborderHDCAL[jm]->Draw("SAME");
3137  c1->Update();
3138  sprintf(txtPS,"%s for all SMs",varNameLong[0+kNbFitParams]);
3139  ps->TextNDC(0.2,0.94,txtPS);
3140  c1->Update();
3141  c1->cd(3);
3142  hAllSpaceDCALIntg[2]->Draw("COLZ");
3143  lineSMborderVDCALthird->Draw("SAME");
3144  lineSMborderVDCAL1->Draw("SAME");
3145  lineSMborderVDCAL2->Draw("SAME");
3146  for (int jm=0;jm<(int)((kNbSMDCAL+1)/2);jm++) lineSMborderHDCAL[jm]->Draw("SAME");
3147  c1->Update();
3148  sprintf(txtPS,"%s for all SMs",varNameLong[2+kNbFitParams]);
3149  ps->TextNDC(0.2,0.94,txtPS);
3150  c1->Update();
3151  c1->cd(5);
3152  hAllSpaceDCALIntg[3]->Draw("COLZ");
3153  lineSMborderVDCALthird->Draw("SAME");
3154  lineSMborderVDCAL1->Draw("SAME");
3155  lineSMborderVDCAL2->Draw("SAME");
3156  for (int jm=0;jm<(int)((kNbSMDCAL+1)/2);jm++) lineSMborderHDCAL[jm]->Draw("SAME");
3157  c1->Update();
3158  sprintf(txtPS,"%s for all SMs",varNameLong[3+kNbFitParams]);
3159  ps->TextNDC(0.2,0.94,txtPS);
3160  c1->Update();
3161  hAllSpaceDCALIntg[0]->SetMaximum(1.2*tabMax[kNbFitParams+0]);
3162  c1->cd(2);
3163  hAllSpaceDCALIntg[0]->Draw("COLZ");
3164  lineSMborderVDCALthird->Draw("SAME");
3165  lineSMborderVDCAL1->Draw("SAME");
3166  lineSMborderVDCAL2->Draw("SAME");
3167  for (int jm=0;jm<(int)((kNbSMDCAL+1)/2);jm++) lineSMborderHDCAL[jm]->Draw("SAME");
3168  c1->Update();
3169  sprintf(txtPS,"%s for all SMs (zoomed)",varNameLong[0+kNbFitParams]);
3170  ps->TextNDC(0.2,0.94,txtPS);
3171  c1->Update();
3172 
3173  ps->NewPage();
3174  c1->Clear();
3175  c1->Divide(2,3);
3176  c1->cd(1);
3177  hAllSpaceDCALIntg[1]->Draw("COLZ");
3178  lineSMborderVDCALthird->Draw("SAME");
3179  lineSMborderVDCAL1->Draw("SAME");
3180  lineSMborderVDCAL2->Draw("SAME");
3181  for (int jm=0;jm<(int)((kNbSMDCAL+1)/2);jm++) lineSMborderHDCAL[jm]->Draw("SAME");
3182  c1->Update();
3183  sprintf(txtPS,"%s for all SMs",varNameLong[1+kNbFitParams]);
3184  ps->TextNDC(0.2,0.94,txtPS);
3185  c1->cd(3);
3186  hAllSpaceDCALIntg[4]->Draw("COLZ");
3187  lineSMborderVDCALthird->Draw("SAME");
3188  lineSMborderVDCAL1->Draw("SAME");
3189  lineSMborderVDCAL2->Draw("SAME");
3190  for (int jm=0;jm<(int)((kNbSMDCAL+1)/2);jm++) lineSMborderHDCAL[jm]->Draw("SAME");
3191  c1->Update();
3192  sprintf(txtPS,"%s for all SMs",varNameLong[4+kNbFitParams]);
3193  ps->TextNDC(0.2,0.94,txtPS);
3194  c1->Update();
3195  hAllSpaceDCALIntg[1]->SetMaximum(4.0);
3196  hAllSpaceDCALIntg[4]->SetMaximum(4.0);
3197  c1->cd(2);
3198  hAllSpaceDCALIntg[1]->Draw("COLZ");
3199  lineSMborderVDCALthird->Draw("SAME");
3200  lineSMborderVDCAL1->Draw("SAME");
3201  lineSMborderVDCAL2->Draw("SAME");
3202  for (int jm=0;jm<(int)((kNbSMDCAL+1)/2);jm++) lineSMborderHDCAL[jm]->Draw("SAME");
3203  c1->Update();
3204  sprintf(txtPS,"%s for all SMs (zoomed)",varNameLong[1+kNbFitParams]);
3205  ps->TextNDC(0.2,0.94,txtPS);
3206  c1->cd(4);
3207  hAllSpaceDCALIntg[4]->Draw("COLZ");
3208  lineSMborderVDCALthird->Draw("SAME");
3209  lineSMborderVDCAL1->Draw("SAME");
3210  lineSMborderVDCAL2->Draw("SAME");
3211  for (int jm=0;jm<(int)((kNbSMDCAL+1)/2);jm++) lineSMborderHDCAL[jm]->Draw("SAME");
3212  c1->Update();
3213  sprintf(txtPS,"%s for all SMs (zoomed)",varNameLong[4+kNbFitParams]);
3214  ps->TextNDC(0.2,0.94,txtPS);
3215  c1->cd(5);
3216  hAllSpaceDCALSoverN->Divide(hAllSpaceDCALIntg[2],hAllSpaceDCALIntg[3]);
3217  nbTot=hAllSpaceDCALSoverN->GetMaximum();
3218  for (i=0;i<hAllSpaceDCALSoverN->GetNbinsX();i++)
3219  {for (j=0;j<hAllSpaceDCALSoverN->GetNbinsY();j++)
3220  {if ((hAllSpaceDCALSoverN->GetBinContent(i+1,j+1) < nbTot) && (hAllSpaceDCALSoverN->GetBinContent(i+1,j+1) > 0)) nbTot=hAllSpaceDCALSoverN->GetBinContent(i+1,j+1);
3221  }
3222  }
3223  hAllSpaceDCALSoverN->SetMinimum(0.98*nbTot);
3224  /*printf("Min %f max %f\n",hAllSpaceDCALSoverN->GetMinimum(),hAllSpaceDCALSoverN->GetMaximum());
3225  for (int ccc=0;ccc<2*48;ccc++)
3226  {for (int rrr=0;rrr<3.33*24;rrr++)
3227  {printf("Col row %d %d value %e",ccc,rrr,hAllSpaceDCALSoverN->GetBinContent(ccc+1,rrr+1));
3228  if (hAllSpaceDCALSoverN->GetBinContent(ccc+1,rrr+1) > 10000.) printf("***********");
3229  printf("\n");
3230  }
3231  }*/
3232  hAllSpaceDCALSoverN->Draw("COLZ");
3233  lineSMborderVDCALthird->Draw("SAME");
3234  lineSMborderVDCAL1->Draw("SAME");
3235  lineSMborderVDCAL2->Draw("SAME");
3236  for (int jm=0;jm<(int)((kNbSMDCAL+1)/2);jm++) lineSMborderHDCAL[jm]->Draw("SAME");
3237  c1->Update();
3238  sprintf(txtPS,"Signal to noise ratio for all SMs");
3239  ps->TextNDC(0.2,0.94,txtPS);
3240  hAllSpaceDCALSoverN->Write();
3241  c1->Update();
3242  c1->cd(6);
3243  hAllSpaceDCALSoverN->SetMaximum(2.);
3244  hAllSpaceDCALSoverN->Draw("COLZ");
3245  lineSMborderVDCALthird->Draw("SAME");
3246  lineSMborderVDCAL1->Draw("SAME");
3247  lineSMborderVDCAL2->Draw("SAME");
3248  for (int jm=0;jm<(int)((kNbSMDCAL+1)/2);jm++) lineSMborderHDCAL[jm]->Draw("SAME");
3249  c1->Update();
3250  sprintf(txtPS,"Signal to noise ratio for all SMs (zoomed)");
3251  ps->TextNDC(0.2,0.94,txtPS);
3252  hAllSpaceDCALSoverN->Write();
3253  c1->Update();
3254  }
3255 
3256 
3257  //Inv mass distrib per SM :
3258  TF1 *gaussMass1 = new TF1("gaussMass1","gaus(0)",130.,140.);
3259  TF1 *gaussMass2 = new TF1("gaussMass2","gaus(0)",130.,140.);
3260  gaussMass1->SetParLimits(0,1.,10000.);
3261  gaussMass1->SetParLimits(1,125.,145.);
3262  gaussMass1->SetParLimits(2,0.01,20.);
3263  gaussMass2->SetParLimits(0,1.,10000.);
3264  gaussMass2->SetParLimits(1,125.,145.);
3265  gaussMass2->SetParLimits(2,0.01,20.);
3266  gaussMass1->SetParameter(0,300.);
3267  gaussMass1->SetParameter(1,135.);
3268  gaussMass1->SetParameter(2,1.5);
3269  gaussMass2->SetParameter(0,300.);
3270  gaussMass2->SetParameter(1,135.);
3271  gaussMass2->SetParameter(2,1.5);
3272  gaussMass1->SetLineColor(kViolet+8);
3273  gaussMass2->SetLineColor(kPink+8);
3274  gaussMass1->SetLineWidth(1);
3275  gaussMass2->SetLineWidth(1);
3276  linePDGMass->SetLineColor(kTeal-5);
3277  double tabPeakMeanPerSM[kNbSMtot],tabPeakSigmaPerSM[kNbSMtot],tabPeakKhi2PerSM[kNbSMtot];
3278  double tabPeakOldMeanPerSM[kNbSMtot],tabPeakOldSigmaPerSM[kNbSMtot],tabPeakOldKhi2PerSM[kNbSMtot];
3279 
3280  if (choiceNoEMCAL != 0)
3281  {ps->NewPage();
3282  c1->Clear();
3283  c1->Divide(2,5);
3284  for (i=0;i<kNbSMEMCAL;i++)
3285  {c1->cd(i+1);
3286  gPad->SetLogy();
3287  hAllDistribMassPerSM[i]->Fit(gaussMass1,"BRM 0"); //H option "0" (a fortiori "N" marche aussi), sinon screws up le ps file (pages ou canvas vides inseres).
3288  tabPeakMeanPerSM[i]=gaussMass1->GetParameter(1);
3289  tabPeakSigmaPerSM[i]=gaussMass1->GetParameter(2);
3290  if (gaussMass1->GetNDF() != 0.) tabPeakKhi2PerSM[i]=gaussMass1->GetChisquare()/gaussMass1->GetNDF();
3291  else tabPeakKhi2PerSM[i]=0.;
3292  hAllDistribMassPerSM[i]->SetLineColor(4);
3293  hAllDistribMassPerSM[i]->Draw();
3294  hAllDistribMassPerSM[i]->Write();
3295  gaussMass1->Draw("SAME");
3296  linePDGMass->SetY2(1.05*hAllDistribMassPerSM[i]->GetMaximum());
3297  linePDGMass->Draw("SAME");
3298  hAllOldDistribMassPerSM[i]->Fit(gaussMass2,"BRM 0"); //H option "0" (a fortiori "N" marche aussi), sinon screws up le ps file (pages ou canvas vides inseres).
3299  tabPeakOldMeanPerSM[i]=gaussMass2->GetParameter(1);
3300  tabPeakOldSigmaPerSM[i]=gaussMass2->GetParameter(2);
3301  if (gaussMass2->GetNDF() != 0.) tabPeakOldKhi2PerSM[i]=gaussMass2->GetChisquare()/gaussMass2->GetNDF();
3302  else tabPeakOldKhi2PerSM[i]=0.;
3303  hAllOldDistribMassPerSM[i]->SetLineColor(2);
3304  hAllOldDistribMassPerSM[i]->Draw("SAME");
3305  hAllOldDistribMassPerSM[i]->Write();
3306  gaussMass2->Draw("SAME");
3307  linePDGMass->SetY2(1.05*hAllOldDistribMassPerSM[i]->GetMaximum());
3308  linePDGMass->Draw("SAME");
3309  c1->RedrawAxis();
3310  c1->Update();
3311  }
3312  c1->Update();
3313  }
3314 
3315  if (choiceNoDCAL != 0)
3316  {ps->NewPage();
3317  c1->Clear();
3318  c1->Divide(2,5);
3319  for (i=kNbSMEMCAL;i<kNbSMtot;i++)
3320  {c1->cd(i+1-kNbSMEMCAL);
3321  gPad->SetLogy();
3322  hAllDistribMassPerSM[i]->Fit(gaussMass1,"BRM 0"); //H option "0" (a fortiori "N" marche aussi), sinon screws up le ps file (pages ou canvas vides inseres).
3323  tabPeakMeanPerSM[i]=gaussMass1->GetParameter(1);
3324  tabPeakSigmaPerSM[i]=gaussMass1->GetParameter(2);
3325  if (gaussMass1->GetNDF() != 0.) tabPeakKhi2PerSM[i]=gaussMass1->GetChisquare()/gaussMass1->GetNDF();
3326  else tabPeakKhi2PerSM[i]=0.;
3327  hAllDistribMassPerSM[i]->SetLineColor(4);
3328  hAllDistribMassPerSM[i]->Draw();
3329  hAllDistribMassPerSM[i]->Write();
3330  gaussMass1->Draw("SAME");
3331  linePDGMass->SetY2(1.05*hAllDistribMassPerSM[i]->GetMaximum());
3332  linePDGMass->Draw("SAME");
3333  hAllOldDistribMassPerSM[i]->Fit(gaussMass2,"BRM 0"); //H option "0" (a fortiori "N" marche aussi), sinon screws up le ps file (pages ou canvas vides inseres).
3334  tabPeakOldMeanPerSM[i]=gaussMass2->GetParameter(1);
3335  tabPeakOldSigmaPerSM[i]=gaussMass2->GetParameter(2);
3336  if (gaussMass2->GetNDF() != 0.) tabPeakOldKhi2PerSM[i]=gaussMass2->GetChisquare()/gaussMass2->GetNDF();
3337  else tabPeakOldKhi2PerSM[i]=0.;
3338  hAllOldDistribMassPerSM[i]->SetLineColor(2);
3339  hAllOldDistribMassPerSM[i]->Draw("SAME");
3340  hAllOldDistribMassPerSM[i]->Write();
3341  gaussMass2->Draw("SAME");
3342  linePDGMass->SetY2(1.05*hAllOldDistribMassPerSM[i]->GetMaximum());
3343  linePDGMass->Draw("SAME");
3344  c1->RedrawAxis();
3345  c1->Update();
3346  }
3347  c1->Update();
3348  }
3349 
3350  printf("\n");
3351  for (i=0;i<kNbSMtot;i++)
3352  {printf("Mass distr in SM %d : new : %6.2f sig %4.2f MeV, khi2 = %4.2f vs old : %6.2f sig %4.2f MeV, khi2 = %4.2f\n",i,tabPeakMeanPerSM[i],tabPeakSigmaPerSM[i],tabPeakKhi2PerSM[i],tabPeakOldMeanPerSM[i],tabPeakOldSigmaPerSM[i],tabPeakOldKhi2PerSM[i]);
3353  hMassPerSM->SetBinContent(i+1,tabPeakMeanPerSM[i]);
3354  hMassPerSM->SetBinError(i+1,tabPeakOldSigmaPerSM[i]);
3355  hMassOldPerSM->SetBinContent(i+1,tabPeakOldMeanPerSM[i]);
3356  hMassOldPerSM->SetBinError(i+1,tabPeakOldSigmaPerSM[i]);
3357  }
3358  printf("-----------------------------------------------------\n");
3359 
3360  //Correction factors distribs :
3361  ps->NewPage();
3362  c1->Clear();
3363  c1->Divide(2,4);
3364  c1->cd(1);
3365  hCoeff->SetLineColor(4);
3366  hCoeffOldCorr->SetLineColor(2);
3367  hCoeffOld->SetLineColor(kOrange+7);
3368  gPad->SetLogy();
3369  hCoeff->Draw();
3370  if (isFirstIteration == 0)
3371  {hCoeffOld->Draw("SAME");
3372  hCoeffOldCorr->Draw("SAME");
3373  }
3374  hCoeff->Write();
3375  hCoeffOld->Write();
3376  hCoeffOldCorr->Write();
3377  if (isFirstIteration == 0)
3378  {c1->cd(3);
3379  hCoeffOldCorrLarge->SetLineColor(2);
3380  hCoeffOldLarge->SetLineColor(kOrange+7);
3381  gPad->SetLogy();
3382  hCoeffOldLarge->Draw();
3383  hCoeffOldCorrLarge->Draw("SAME");
3384  hCoeffOldLarge->Write();
3385  hCoeffOldCorrLarge->Write();
3386  }
3387  c1->cd(4);
3388  gaussMass1->SetParameter(0,300.);
3389  gaussMass1->SetParameter(1,135.);
3390  gaussMass1->SetParameter(2,1.5);
3391  gaussMass2->SetParameter(0,300.);
3392  gaussMass2->SetParameter(1,135.);
3393  gaussMass2->SetParameter(2,1.5);
3394  hAllDistribMass->Fit(gaussMass1,"BRM 0"); //H option "0" (a fortiori "N" marche aussi), sinon screws up le ps file (pages ou canvas vides inseres).
3395  if (isFirstIteration == 0) hAllOldDistribMass->Fit(gaussMass2,"BRM 0"); //Et H option "I", sinon converge vers n'importe-quoi (avec "L" aussi, et dans tous les cas en settant a 10000 l'error des empty bins aussi).
3396  //Si on met option I, cette version de root breake (probleme de librairie). Mais now ca marche sans l'option I (as expected), => OK.
3397  printf("\nTower mass distribution : new : %f sig %f MeV, khi2 = %f\n",gaussMass1->GetParameter(1),gaussMass1->GetParameter(2),gaussMass1->GetChisquare()/gaussMass1->GetNDF());
3398  if (isFirstIteration == 0) printf(" old : %f sig %f MeV, khi2 = %f\n\n",gaussMass2->GetParameter(1),gaussMass2->GetParameter(2),gaussMass2->GetChisquare()/gaussMass2->GetNDF());
3399  hAllDistribMass->SetLineColor(4);
3400  hAllDistribMass->Draw();
3401  hAllDistribMass->Write();
3402  gaussMass1->Draw("SAME");
3403  linePDGMass->SetLineColor(kTeal-5);
3404  linePDGMass->SetY2(1.05*hAllDistribMass->GetMaximum());
3405  linePDGMass->Draw("SAME");
3406  c1->Update();
3407  if (isFirstIteration == 0)
3408  {c1->cd(2);
3409  hAllOldDistribMass->SetLineColor(2);
3410  hAllOldDistribMass->Draw();
3411  hAllOldDistribMass->Write();
3412  gaussMass2->Draw("SAME");
3413  linePDGMass->SetY2(1.05*hAllOldDistribMass->GetMaximum());
3414  linePDGMass->Draw("SAME");
3415  c1->Update();
3416  }
3417  c1->cd(6);
3418  hMassPerSM->SetLineColor(4);
3419  hMassOldPerSM->SetLineColor(2);
3420  hMassPerSM->SetMaximum(mPDG+2.5);
3421  hMassPerSM->SetMinimum(mPDG-2.5);
3422  hMassPerSM->Draw();
3423  hMassPerSM->Write();
3424  if (isFirstIteration == 0) hMassOldPerSM->Draw("SAME");
3425  hMassOldPerSM->Write();
3426  lineMassH->SetX1(hMassPerSM->GetXaxis()->GetXmin());
3427  lineMassH->SetX2(hMassPerSM->GetXaxis()->GetXmax());
3428  lineMassH->SetLineColor(kTeal-5);
3429  lineMassH->Draw("SAME");
3430  c1->Update();
3431  if (choiceNoEMCAL != 0)
3432  {c1->cd(7);
3433  nbTot=hAllSpaceEMCALCoeff[0]->GetMaximum();
3434  for (i=0;i<hAllSpaceEMCALCoeff[0]->GetNbinsX();i++)
3435  {for (j=0;j<hAllSpaceEMCALCoeff[0]->GetNbinsY();j++)
3436  {if ((hAllSpaceEMCALCoeff[0]->GetBinContent(i+1,j+1) < nbTot) && (hAllSpaceEMCALCoeff[0]->GetBinContent(i+1,j+1) != 0)) nbTot=hAllSpaceEMCALCoeff[0]->GetBinContent(i+1,j+1);
3437  }
3438  }
3439  hAllSpaceEMCALCoeff[0]->SetMinimum(0.98*nbTot);
3440  hAllSpaceEMCALCoeff[0]->Draw("COLZ");
3441  lineSMborderVEMCAL->Draw("SAME");
3442  for (int jm=0;jm<(int)((kNbSMEMCAL+1)/2);jm++) lineSMborderHEMCAL[jm]->Draw("SAME");
3443  }
3444  hAllSpaceEMCALCoeff[0]->Write();
3445  if (choiceNoDCAL != 0)
3446  {c1->cd(8);
3447  nbTot=hAllSpaceDCALCoeff[0]->GetMaximum();
3448  for (i=0;i<hAllSpaceDCALCoeff[0]->GetNbinsX();i++)
3449  {for (j=0;j<hAllSpaceDCALCoeff[0]->GetNbinsY();j++)
3450  {if ((hAllSpaceDCALCoeff[0]->GetBinContent(i+1,j+1) < nbTot) && (hAllSpaceDCALCoeff[0]->GetBinContent(i+1,j+1) != 0)) nbTot=hAllSpaceDCALCoeff[0]->GetBinContent(i+1,j+1);
3451  }
3452  }
3453  hAllSpaceDCALCoeff[0]->SetMinimum(0.98*nbTot);
3454  hAllSpaceDCALCoeff[0]->Draw("COLZ");
3455  lineSMborderVDCALthird->Draw("SAME");
3456  lineSMborderVDCAL1->Draw("SAME");
3457  lineSMborderVDCAL2->Draw("SAME");
3458  for (int jm=0;jm<(int)((kNbSMDCAL+1)/2);jm++) lineSMborderHDCAL[jm]->Draw("SAME");
3459  }
3460  hAllSpaceDCALCoeff[0]->Write();
3461  c1->Update();
3462  printf("-----------------------------------------------------\n");
3463 
3464 
3465  //Add also distribs of distance to mPDG in err bars
3466  ps->NewPage();
3467  c1->Clear();
3468  c1->Divide(2,3);
3469  c1->cd(1);
3470  hAllSpaceEMCALDistance[0]->SetMinimum(0.);
3471  hAllSpaceEMCALDistance[0]->SetMaximum(10.);
3472  hAllSpaceEMCALDistance[0]->Draw("COLZ");
3473  lineSMborderVEMCAL->Draw("SAME");
3474  for (int jm=0;jm<(int)((kNbSMEMCAL+1)/2);jm++) lineSMborderHEMCAL[jm]->Draw("SAME");
3475  hAllSpaceEMCALDistance[0]->Write();
3476  c1->cd(3);
3477  hAllSpaceEMCALDistance[1]->SetMinimum(0.);
3478  hAllSpaceEMCALDistance[1]->SetMaximum(10.);
3479  hAllSpaceEMCALDistance[1]->Draw("COLZ");
3480  lineSMborderVEMCAL->Draw("SAME");
3481  for (int jm=0;jm<(int)((kNbSMEMCAL+1)/2);jm++) lineSMborderHEMCAL[jm]->Draw("SAME");
3482  hAllSpaceEMCALDistance[1]->Write();
3483  c1->cd(5);
3484  hAllSpaceEMCALDistance[2]->SetMinimum(-1.);
3485  hAllSpaceEMCALDistance[2]->SetMaximum(4.);
3486  hAllSpaceEMCALDistance[2]->Draw("COLZ");
3487  lineSMborderVEMCAL->Draw("SAME");
3488  for (int jm=0;jm<(int)((kNbSMEMCAL+1)/2);jm++) lineSMborderHEMCAL[jm]->Draw("SAME");
3489  hAllSpaceEMCALDistance[2]->Write();
3490  c1->cd(2);
3491  hAllSpaceDCALDistance[0]->SetMinimum(0.);
3492  hAllSpaceDCALDistance[0]->SetMaximum(10.);
3493  hAllSpaceDCALDistance[0]->Draw("COLZ");
3494  lineSMborderVDCALthird->Draw("SAME");
3495  lineSMborderVDCAL1->Draw("SAME");
3496  lineSMborderVDCAL2->Draw("SAME");
3497  for (int jm=0;jm<(int)((kNbSMDCAL+1)/2);jm++) lineSMborderHDCAL[jm]->Draw("SAME");
3498  hAllSpaceDCALDistance[0]->Write();
3499  c1->cd(4);
3500  hAllSpaceDCALDistance[1]->SetMinimum(0.);
3501  hAllSpaceDCALDistance[1]->SetMaximum(10.);
3502  hAllSpaceDCALDistance[1]->Draw("COLZ");
3503  lineSMborderVDCALthird->Draw("SAME");
3504  lineSMborderVDCAL1->Draw("SAME");
3505  lineSMborderVDCAL2->Draw("SAME");
3506  for (int jm=0;jm<(int)((kNbSMDCAL+1)/2);jm++) lineSMborderHDCAL[jm]->Draw("SAME");
3507  hAllSpaceDCALDistance[1]->Write();
3508  c1->cd(6);
3509  hAllSpaceDCALDistance[2]->SetMinimum(-1.);
3510  hAllSpaceDCALDistance[2]->SetMaximum(4.);
3511  hAllSpaceDCALDistance[2]->Draw("COLZ");
3512  lineSMborderVDCALthird->Draw("SAME");
3513  lineSMborderVDCAL1->Draw("SAME");
3514  lineSMborderVDCAL2->Draw("SAME");
3515  for (int jm=0;jm<(int)((kNbSMDCAL+1)/2);jm++) lineSMborderHDCAL[jm]->Draw("SAME");
3516  hAllSpaceDCALDistance[2]->Write();
3517  c1->Update();
3518 
3519  ps->NewPage();
3520  c1->Clear();
3521  c1->Divide(2,3);
3522  c1->cd(1);
3523  TF1 *fGauss = new TF1("fGauss","gaus(0)",0.,4.);
3524  TF1 *fGauss2 = new TF1("fGauss2","gaus(0)",0.,4.);
3525  fGauss->SetParameter(0,100.);
3526  fGauss->SetParameter(1,0.);
3527  fGauss->SetParameter(2,1.);
3528  fGauss->SetLineWidth(1);
3529  fGauss->SetLineColor(kOrange-6);
3530  fGauss2->SetParameter(0,100.);
3531  fGauss2->FixParameter(1,0.);
3532  fGauss2->SetParameter(2,1.);
3533  fGauss2->SetLineWidth(1);
3534  fGauss2->SetLineColor(kTeal-7);
3535  hAllDistribDistance[0]->SetLineColor(kRed);
3536  hAllDistribDistance[1]->SetLineColor(kGreen+2);
3537  hAllDistribDistance[2]->SetLineColor(kBlue);
3538  hAllDistribDistance[1]->Fit(fGauss,"BR");
3539  hAllDistribDistance[1]->Fit(fGauss2,"BR");
3540  printf("\nDistrib tower normalized distances : mu = %5.3f, sig = %5.3f, khi2/ndf = %f\n",fGauss->GetParameter(1),fGauss->GetParameter(2),fGauss->GetChisquare()/(double)TMath::Max((double)fGauss->GetNDF(),0.0000000001));
3541  printf(" with 0 mean : mu = %5.3f, sig = %5.3f, khi2/ndf = %f\n\n",fGauss2->GetParameter(1),fGauss2->GetParameter(2),fGauss2->GetChisquare()/(double)TMath::Max((double)fGauss2->GetNDF(),0.0000000001));
3542  hAllDistribDistance[2]->Draw();
3543  hAllDistribDistance[1]->Draw("SAME");
3544  fGauss->Draw("SAME");
3545  fGauss2->Draw("SAME");
3546  hAllDistribDistance[0]->Draw("SAME");
3547  hAllDistribDistance[0]->Write();
3548  hAllDistribDistance[1]->Write();
3549  hAllDistribDistance[2]->Write();
3550  c1->cd(3);
3551  hCorrelDvsSig->Draw("COLZ");
3552  hCorrelDvsSig->Write();
3553  c1->cd(5);
3554  hCorrelCmpD->Draw("COLZ");
3555  hCorrelCmpD->Write();
3556  c1->cd(2);
3557  gPad->SetLogy();
3558  hAllDistribDistance2[2*0+0]->Draw();
3559  hAllDistribDistance2[2*1+0]->SetLineColor(kGreen+2);
3560  hAllDistribDistance2[2*1+0]->Draw("SAME");
3561  lineMax->SetX1(100.*uncertKSpec*uncertSpec);
3562  lineMax->SetX2(100.*uncertKSpec*uncertSpec);
3563  lineMax->SetY1(0.);
3564  lineMax->SetY2(hAllDistribDistance2[2*0+0]->GetMaximum());
3565  lineMax->Draw("SAME");
3566  hAllDistribDistance2[2*0+0]->Write();
3567  hAllDistribDistance2[2*1+0]->Write();
3568  c1->Update();
3569  c1->cd(4);
3570  gPad->SetLogy();
3571  TF1 *fExpectedUncertDistrib = new TF1("fExpectedUncertDistrib","gaus",0.,hAllDistribDistance2[2*0+1]->GetXaxis()->GetXmax());
3572  fExpectedUncertDistrib->SetParameter(0,(2.*nbTowersConsideredTot*hAllDistribDistance2[2*0+1]->GetBinWidth(1))/(uncertSpec*TMath::Sqrt(2.*TMath::Pi()))); //Factor of 2 because of the absolute value.
3573  fExpectedUncertDistrib->SetParameter(1,0.);
3574  fExpectedUncertDistrib->SetParameter(2,uncertSpec);
3575  hAllDistribDistance2[2*0+1]->Draw();
3576  hAllDistribDistance2[2*1+1]->SetLineColor(kGreen+2);
3577  hAllDistribDistance2[2*1+1]->Draw("SAME");
3578  fExpectedUncertDistrib->Draw("SAME");
3579  lineMax->SetX1(uncertDist*uncertSpec);
3580  lineMax->SetX2(uncertDist*uncertSpec);
3581  lineMax->SetY1(0.);
3582  lineMax->SetY2(hAllDistribDistance2[2*0+1]->GetMaximum());
3583  lineMax->Draw("SAME");
3584  hAllDistribDistance2[2*0+1]->Write();
3585  hAllDistribDistance2[2*1+1]->Write();
3586  fExpectedUncertDistrib->Write();
3587  c1->Update();
3588 
3589 
3590  //Control of convergence
3591  if (isFirstIteration == 0)
3592  {ps->NewPage();
3593  c1->Clear();
3594  c1->Divide(2,3);
3595  c1->cd(1);
3596  hCtrlEvolMu->Draw();
3597  hCtrlEvolMu->Write();
3598  c1->cd(3);
3599  h2CtrlEvolMu1->Draw("COLZ");
3600  h2CtrlEvolMu1->Write();
3601  c1->cd(5);
3602  TLine *bissec = new TLine(h2CtrlEvolMu2->GetYaxis()->GetXmin(),h2CtrlEvolMu2->GetYaxis()->GetXmin(),h2CtrlEvolMu2->GetYaxis()->GetXmax(),h2CtrlEvolMu2->GetYaxis()->GetXmax());
3603  TLine *bi2ssec = new TLine(h2CtrlEvolMu2->GetYaxis()->GetXmin()/2.,h2CtrlEvolMu2->GetYaxis()->GetXmin(),h2CtrlEvolMu2->GetYaxis()->GetXmax()/2.,h2CtrlEvolMu2->GetYaxis()->GetXmax());
3604  TLine *axeX = new TLine(h2CtrlEvolMu2->GetXaxis()->GetXmin(),0.,h2CtrlEvolMu2->GetXaxis()->GetXmax(),0.);
3605  TLine *axeY = new TLine(0.,h2CtrlEvolMu2->GetYaxis()->GetXmin(),0.,h2CtrlEvolMu2->GetYaxis()->GetXmax());
3606  h2CtrlEvolMu2->Draw("COLZ");
3607  bissec->Draw("SAME");
3608  bi2ssec->Draw("SAME");
3609  axeX->Draw("SAME");
3610  axeY->Draw("SAME");
3611  h2CtrlEvolMu2->Write();
3612  c1->cd(2);
3613  hCtrlEvolCoeff->Draw();
3614  hCtrlEvolCoeff->Write();
3615  c1->cd(4);
3616  h2CtrlEvolCoeff1->Draw("COLZ");
3617  h2CtrlEvolCoeff1->Write();
3618  c1->cd(6);
3619  TLine *bissec2 = new TLine(h2CtrlEvolCoeff2->GetYaxis()->GetXmin(),h2CtrlEvolCoeff2->GetYaxis()->GetXmin(),h2CtrlEvolCoeff2->GetYaxis()->GetXmax(),h2CtrlEvolCoeff2->GetYaxis()->GetXmax());
3620  TLine *bi2ssec2 = new TLine(h2CtrlEvolCoeff2->GetYaxis()->GetXmin()/2.,h2CtrlEvolCoeff2->GetYaxis()->GetXmin(),h2CtrlEvolCoeff2->GetYaxis()->GetXmax()/2.,h2CtrlEvolCoeff2->GetYaxis()->GetXmax());
3621  TLine *axeX2 = new TLine(h2CtrlEvolCoeff2->GetXaxis()->GetXmin(),0.,h2CtrlEvolCoeff2->GetXaxis()->GetXmax(),0.);
3622  TLine *axeY2 = new TLine(0.,h2CtrlEvolCoeff2->GetYaxis()->GetXmin(),0.,h2CtrlEvolCoeff2->GetYaxis()->GetXmax());
3623  h2CtrlEvolCoeff2->Draw("COLZ");
3624  bissec2->Draw("SAME");
3625  bi2ssec2->Draw("SAME");
3626  axeX2->Draw("SAME");
3627  axeY2->Draw("SAME");
3628  h2CtrlEvolCoeff2->Write();
3629  c1->Update();
3630  }
3631 
3632 
3633  //1-dimensional distribs :
3634  ps->NewPage();
3635  c1->Clear();
3636  c1->Divide(2,(int)((kNbFitParams+1)/2));
3637  for (j=0;j<kNbFitParams;j++)
3638  {c1->cd(j+1);
3639  k=(j%2)*(int)((j+5)/2)+(1-(j%2))*(int)(j/2);
3640  gPad->SetLogy();
3641  hAllDistrib[k]->SetLineColor(4);
3642  hAllOldDistrib[k]->SetLineColor(2);
3643  hAllDistrib[k]->Draw();
3644  hAllOldDistrib[k]->Draw("SAME");
3645  lineMin->SetX1(cutMin[k]);
3646  lineMin->SetX2(cutMin[k]);
3647  lineMin->SetY1(0.);
3648  lineMin->SetY2(hAllDistrib[k]->GetMaximum());
3649  lineMax->SetX1(cutMax[k]);
3650  lineMax->SetX2(cutMax[k]);
3651  lineMax->SetY1(0.);
3652  lineMax->SetY2(hAllDistrib[k]->GetMaximum());
3653  lineMin->Draw("SAME");
3654  lineMax->Draw("SAME");
3655  if (k == 1)
3656  {linePDGMass->SetY2(1.5*hAllDistrib[k]->GetMaximum());
3657  linePDGMass->Draw("SAME");
3658  }
3659  c1->RedrawAxis();
3660  c1->Update(); //Car sinon, update les parametres du TLine de tous les plots avec ceux du dernier plot trac\'e.
3661  hAllDistrib[k]->Write();
3662  hAllOldDistrib[k]->Write();
3663  }
3664  c1->Update();
3665 
3666  ps->NewPage();
3667  c1->Clear();
3668  c1->Divide(2,3);
3669  for (j=0;j<kNbExtraParams;j++)
3670  {hAllDistribIntg[j]->SetLineColor(4);
3671  hAllDistribIntg[j]->Write();
3672  if (j < kNbExtraParamsToBeRead)
3673  {hAllOldDistrib[j+kNbFitParams]->SetLineColor(2);
3674  hAllOldDistrib[j+kNbFitParams]->Write();
3675  }
3676  }
3677  c1->cd(1);
3678  gPad->SetLogy();
3679  hAllDistribIntg[0]->Draw();
3680  hAllOldDistrib[0+kNbFitParams]->Draw("SAME");
3681  lineMin->SetX1(cutMin[0+kNbFitParams]);
3682  lineMin->SetX2(cutMin[0+kNbFitParams]);
3683  lineMin->SetY1(0.);
3684  lineMin->SetY2(hAllDistribIntg[0]->GetMaximum());
3685  lineMax->SetX1(cutMax[0+kNbFitParams]);
3686  lineMax->SetX2(cutMax[0+kNbFitParams]);
3687  lineMax->SetY1(0.);
3688  lineMax->SetY2(hAllDistribIntg[0]->GetMaximum());
3689  lineMin->Draw("SAME");
3690  lineMax->Draw("SAME");
3691  c1->RedrawAxis();
3692  c1->Update(); //Car sinon, update les parametres du TLine de tous les plots avec ceux du dernier plot trac\'e.
3693  c1->cd(2);
3694  //That histo is not filled with the towers with 0 entries.
3695  hAllDistribNbEntries->SetLineColor(4);
3696  hAllDistribNbEntries->Draw();
3697  lineMin->SetX1(cutEntriesDiscard);
3698  lineMin->SetX2(cutEntriesDiscard);
3699  lineMin->SetY1(0.);
3700  lineMin->SetY2(hAllDistribNbEntries->GetMaximum());
3701  lineMin->Draw("SAME");
3702  hAllDistribNbEntries->Write();
3703  hAllDistribNbEntriesCorrel->Write();
3704  c1->RedrawAxis();
3705  c1->Update();
3706  c1->cd(3);
3707  gPad->SetLogy();
3708  hAllDistribIntg[2]->Draw();
3709  hAllOldDistrib[2+kNbFitParams]->Draw("SAME");
3710  lineMin->SetX1(cutMin[2+kNbFitParams]);
3711  lineMin->SetX2(cutMin[2+kNbFitParams]);
3712  lineMin->SetY1(0.);
3713  lineMin->SetY2(hAllDistribIntg[2]->GetMaximum());
3714  lineMax->SetX1(cutMax[2+kNbFitParams]);
3715  lineMax->SetX2(cutMax[2+kNbFitParams]);
3716  lineMax->SetY1(0.);
3717  lineMax->SetY2(hAllDistribIntg[2]->GetMaximum());
3718  lineMin->Draw("SAME");
3719  lineMax->Draw("SAME");
3720  c1->RedrawAxis();
3721  c1->Update(); //Car sinon, update les parametres du TLine de tous les plots avec ceux du dernier plot trac\'e.
3722  c1->cd(4);
3723  gPad->SetLogy();
3724  hAllDistribIntg[3]->Draw();
3725  hAllOldDistrib[3+kNbFitParams]->Draw("SAME");
3726  lineMin->SetX1(cutMin[3+kNbFitParams]);
3727  lineMin->SetX2(cutMin[3+kNbFitParams]);
3728  lineMin->SetY1(0.);
3729  lineMin->SetY2(hAllDistribIntg[3]->GetMaximum());
3730  lineMax->SetX1(cutMax[3+kNbFitParams]);
3731  lineMax->SetX2(cutMax[3+kNbFitParams]);
3732  lineMax->SetY1(0.);
3733  lineMax->SetY2(hAllDistribIntg[3]->GetMaximum());
3734  lineMin->Draw("SAME");
3735  lineMax->Draw("SAME");
3736  c1->RedrawAxis();
3737  c1->Update(); //Car sinon, update les parametres du TLine de tous les plots avec ceux du dernier plot trac\'e.
3738 
3739  ps->NewPage();
3740  c1->Clear();
3741  c1->Divide(2,3);
3742  c1->cd(1);
3743  gPad->SetLogy();
3744  hAllDistribIntg[1]->Draw();
3745  hAllOldDistrib[1+kNbFitParams]->Draw("SAME");
3746  lineMin->SetX1(cutMin[1+kNbFitParams]);
3747  lineMin->SetX2(cutMin[1+kNbFitParams]);
3748  lineMin->SetY1(0.);
3749  lineMin->SetY2(hAllDistribIntg[1]->GetMaximum());
3750  lineMax->SetX1(cutMax[1+kNbFitParams]);
3751  lineMax->SetX2(cutMax[1+kNbFitParams]);
3752  lineMax->SetY1(0.);
3753  lineMax->SetY2(hAllDistribIntg[1]->GetMaximum());
3754  lineMin->Draw("SAME");
3755  lineMax->Draw("SAME");
3756  c1->RedrawAxis();
3757  c1->Update(); //Car sinon, update les parametres du TLine de tous les plots avec ceux du dernier plot trac\'e.
3758  c1->cd(2);
3759  gPad->SetLogy();
3760  hAllDistribIntg[4]->Draw();
3761  hAllOldDistrib[4+kNbFitParams]->Draw("SAME");
3762  lineMin->SetX1(cutMin[4+kNbFitParams]);
3763  lineMin->SetX2(cutMin[4+kNbFitParams]);
3764  lineMin->SetY1(0.);
3765  lineMin->SetY2(hAllDistribIntg[4]->GetMaximum());
3766  lineMax->SetX1(cutMax[4+kNbFitParams]);
3767  lineMax->SetX2(cutMax[4+kNbFitParams]);
3768  lineMax->SetY1(0.);
3769  lineMax->SetY2(hAllDistribIntg[4]->GetMaximum());
3770  lineMin->Draw("SAME");
3771  lineMax->Draw("SAME");
3772  c1->RedrawAxis();
3773  c1->Update(); //Car sinon, update les parametres du TLine de tous les plots avec ceux du dernier plot trac\'e.
3774  c1->cd(3);
3775  gPad->SetLogy();
3776  hAllDistribIntg[5]->Draw();
3777  //hAllOldDistrib[5+kNbFitParams]->Draw("SAME");
3778  lineMin->SetX1(cutMin[5+kNbFitParams]);
3779  lineMin->SetX2(cutMin[5+kNbFitParams]);
3780  lineMin->SetY1(0.);
3781  lineMin->SetY2(hAllDistribIntg[5]->GetMaximum());
3782  lineMax->SetX1(cutMax[5+kNbFitParams]);
3783  lineMax->SetX2(cutMax[5+kNbFitParams]);
3784  lineMax->SetY1(0.);
3785  lineMax->SetY2(hAllDistribIntg[5]->GetMaximum());
3786  lineMin->Draw("SAME");
3787  lineMax->Draw("SAME");
3788  c1->RedrawAxis();
3789  c1->Update(); //Car sinon, update les parametres du TLine de tous les plots avec ceux du dernier plot trac\'e.
3790  c1->cd(4);
3791  gPad->SetLogy();
3792  hAllDistribIntg[6]->Draw();
3793  //hAllOldDistrib[6+kNbFitParams]->Draw("SAME");
3794  lineMin->SetX1(cutMin[6+kNbFitParams]);
3795  lineMin->SetX2(cutMin[6+kNbFitParams]);
3796  lineMin->SetY1(0.);
3797  lineMin->SetY2(hAllDistribIntg[6]->GetMaximum());
3798  lineMax->SetX1(cutMax[6+kNbFitParams]);
3799  lineMax->SetX2(cutMax[6+kNbFitParams]);
3800  lineMax->SetY1(0.);
3801  lineMax->SetY2(hAllDistribIntg[6]->GetMaximum());
3802  lineMin->Draw("SAME");
3803  lineMax->Draw("SAME");
3804  c1->RedrawAxis();
3805  c1->Update(); //Car sinon, update les parametres du TLine de tous les plots avec ceux du dernier plot trac\'e.
3806  c1->cd(5);
3807  gPad->SetLogy();
3808  hAllDistribIntg[5]->SetLineColor(kViolet-5);
3809  hAllDistribIntg[6]->SetLineColor(kAzure+9);
3810  hAllDistribIntg[5]->Rebin(2);
3811  hAllDistribIntg[6]->Rebin(2);
3812  hAllDistribIntg[4]->Scale(0.5);
3813  hAllDistribIntg[6]->Draw();
3814  hAllDistribIntg[5]->Draw("SAME");
3815  hAllDistribIntg[4]->Draw("SAME");
3816  lineMin->SetX1(1.0);
3817  lineMin->SetX2(1.0);
3818  lineMin->SetY1(0.);
3819  lineMin->SetY2(hAllDistribIntg[6]->GetMaximum());
3820  lineMin->Draw("SAME");
3821  c1->RedrawAxis();
3822  c1->Update();
3823 
3824  //Masked/empty towers, and towers of which calib coeff has been automatically put to 1.0 for lack of stat :
3825  if (choiceNoEMCAL != 0)
3826  {ps->NewPage();
3827  c1->Clear();
3828  c1->Divide(2,5);
3829  for (i=0;i<kNbSMEMCAL;i++)
3830  {c1->cd(i+1);
3831  //Red = masked/empty tower ; blue = lack of stat.
3832  hSpaceEntriesDiscard[1*i+0]->SetMinimum(0.);
3833  hSpaceEntriesDiscard[1*i+0]->SetMaximum(5.05);
3834  hSpaceEntriesDiscard[1*i+0]->Draw("COLZ");
3835  hSpaceEntriesDiscard[1*i+0]->Write();
3836  c1->RedrawAxis();
3837  }
3838  c1->Update();
3839  }
3840 
3841  if (choiceNoDCAL != 0)
3842  {ps->NewPage();
3843  c1->Clear();
3844  c1->Divide(2,5);
3845  for (i=kNbSMEMCAL;i<kNbSMtot;i++)
3846  {c1->cd(i+1-kNbSMEMCAL);
3847  //Red = masked/empty tower ; blue = lack of stat.
3848  hSpaceEntriesDiscard[1*i+0]->SetMinimum(0.);
3849  hSpaceEntriesDiscard[1*i+0]->SetMaximum(5.05);
3850  hSpaceEntriesDiscard[1*i+0]->Draw("COLZ");
3851  hSpaceEntriesDiscard[1*i+0]->Write();
3852  c1->RedrawAxis();
3853  }
3854  c1->Update();
3855  }
3856 
3857 
3858  //Correlations by group of 3 :
3859  ps->NewPage();
3860  c1->Clear();
3861  c1->Divide(2,3);
3862  c1->cd(1);
3863  hCorrelMuVsA->Draw("COLZ");
3864  c1->cd(3);
3865  hCorrelSigVsA->Draw("COLZ");
3866  c1->cd(5);
3867  hCorrelSigVsMu->Draw("COLZ");
3868  c1->cd(2);
3869  hCorrelBVsA->Draw("COLZ");
3870  c1->cd(4);
3871  hCorrelCVsA->Draw("COLZ");
3872  c1->cd(6);
3873  hCorrelCVsB->Draw("COLZ");
3874  hCorrelMuVsA->Write();
3875  hCorrelSigVsA->Write();
3876  hCorrelSigVsMu->Write();
3877  hCorrelBVsA->Write();
3878  hCorrelCVsA->Write();
3879  hCorrelCVsB->Write();
3880  c1->Update();
3881 
3882  ps->NewPage();
3883  c1->Clear();
3884  c1->Divide(2,4);
3885  c1->cd(1);
3886  hCorrelISVsI->Draw("COLZ");
3887  c1->cd(3);
3888  hCorrelSVsI->Draw("COLZ");
3889  c1->cd(5);
3890  hCorrelSVsIS->Draw("COLZ");
3891  c1->cd(7);
3892  hCorrelSbincountingVsS->Draw("COLZ");
3893  TLine *bissecCorrel = new TLine(hCorrelSbincountingVsS->GetYaxis()->GetXmin(),hCorrelSbincountingVsS->GetYaxis()->GetXmin(),hCorrelSbincountingVsS->GetYaxis()->GetXmax(),hCorrelSbincountingVsS->GetYaxis()->GetXmax());
3894  bissecCorrel->Draw("SAME");
3895  c1->cd(2);
3896  hCorrelMuVsI->Draw("COLZ");
3897  c1->cd(4);
3898  hCorrelMuVsS->Draw("COLZ");
3899  c1->cd(6);
3900  hCorrelSigVsI->Draw("COLZ");
3901  c1->cd(8);
3902  hCorrelSigVsS->Draw("COLZ");
3903  hCorrelISVsI->Write();
3904  hCorrelSVsI->Write();
3905  hCorrelSVsIS->Write();
3906  hCorrelSbincountingVsS->Write();
3907  hCorrelMuVsI->Write();
3908  hCorrelMuVsS->Write();
3909  hCorrelSigVsI->Write();
3910  hCorrelSigVsS->Write();
3911  c1->Update();
3912 
3913 
3914  //Changes wrt previous pass (space-like) :
3915  if (isFirstIteration == 0)
3916  {if (choiceNoEMCAL != 0)
3917  {ps->NewPage();
3918  c1->Clear();
3919  c1->Divide(2,3);
3920  for (j=0;j<6;j++)
3921  {c1->cd(j+1);
3922  k=(j%2)*(int)((j+5)/2)+(1-(j%2))*(int)(j/2);
3923  nbTot=hAllSpaceEMCALDiff[k]->GetMaximum();
3924  for (i=0;i<hAllSpaceEMCALDiff[k]->GetNbinsX();i++)
3925  {for (int jm=0;jm<hAllSpaceEMCALDiff[k]->GetNbinsY();jm++)
3926  {if ((hAllSpaceEMCALDiff[k]->GetBinContent(i+1,jm+1) < nbTot) && (hAllSpaceEMCALDiff[k]->GetBinContent(i+1,jm+1) != 0)) nbTot=hAllSpaceEMCALDiff[k]->GetBinContent(i+1,jm+1);
3927  }
3928  }
3929  if ((j%2) == 0) hAllSpaceEMCALDiff[k]->SetMinimum(0.98*nbTot);
3930  hAllSpaceEMCALDiff[k]->Draw("COLZ");
3931  lineSMborderVEMCAL->Draw("SAME");
3932  for (int jm=0;jm<(int)((kNbSMEMCAL+1)/2);jm++) lineSMborderHEMCAL[jm]->Draw("SAME");
3933  hAllSpaceEMCALDiff[k]->Write();
3934  }
3935  c1->Update();
3936 
3937  ps->NewPage();
3938  c1->Clear();
3939  c1->Divide(2,3);
3940  for (j=0;j<4;j++)
3941  {c1->cd(j+1);
3942  if (j == 3) c1->cd(j+2);
3943  nbTot=hAllSpaceEMCALDiff[j+6]->GetMaximum();
3944  for (i=0;i<hAllSpaceEMCALDiff[j+6]->GetNbinsX();i++)
3945  {for (int jm=0;jm<hAllSpaceEMCALDiff[j+6]->GetNbinsY();jm++)
3946  {if ((hAllSpaceEMCALDiff[j+6]->GetBinContent(i+1,jm+1) < nbTot) && (hAllSpaceEMCALDiff[j+6]->GetBinContent(i+1,jm+1) != 0)) nbTot=hAllSpaceEMCALDiff[j+6]->GetBinContent(i+1,jm+1);
3947  }
3948  }
3949  hAllSpaceEMCALDiff[j+6]->SetMinimum(0.98*nbTot);
3950  hAllSpaceEMCALDiff[j+6]->Draw("COLZ");
3951  lineSMborderVEMCAL->Draw("SAME");
3952  for (int jm=0;jm<(int)((kNbSMEMCAL+1)/2);jm++) lineSMborderHEMCAL[jm]->Draw("SAME");
3953  hAllSpaceEMCALDiff[j+6]->Write();
3954  }
3955  c1->Update();
3956  }
3957 
3958  if (choiceNoDCAL != 0)
3959  {ps->NewPage();
3960  c1->Clear();
3961  c1->Divide(2,3);
3962  for (j=0;j<6;j++)
3963  {c1->cd(j+1);
3964  k=(j%2)*(int)((j+5)/2)+(1-(j%2))*(int)(j/2);
3965  nbTot=hAllSpaceDCALDiff[k]->GetMaximum();
3966  for (i=0;i<hAllSpaceDCALDiff[k]->GetNbinsX();i++)
3967  {for (int jm=0;jm<hAllSpaceDCALDiff[k]->GetNbinsY();jm++)
3968  {if ((hAllSpaceDCALDiff[k]->GetBinContent(i+1,jm+1) < nbTot) && (hAllSpaceDCALDiff[k]->GetBinContent(i+1,jm+1) != 0)) nbTot=hAllSpaceDCALDiff[k]->GetBinContent(i+1,jm+1);
3969  }
3970  }
3971  if ((j%2) == 0) hAllSpaceDCALDiff[k]->SetMinimum(0.98*nbTot);
3972  hAllSpaceDCALDiff[k]->Draw("COLZ");
3973  lineSMborderVDCALthird->Draw("SAME");
3974  lineSMborderVDCAL1->Draw("SAME");
3975  lineSMborderVDCAL2->Draw("SAME");
3976  for (int jm=0;jm<(int)((kNbSMDCAL+1)/2);jm++) lineSMborderHDCAL[jm]->Draw("SAME");
3977  hAllSpaceDCALDiff[k]->Write();
3978  }
3979  c1->Update();
3980 
3981  ps->NewPage();
3982  c1->Clear();
3983  c1->Divide(2,3);
3984  for (j=0;j<4;j++)
3985  {c1->cd(j+1);
3986  if (j == 3) c1->cd(j+2);
3987  nbTot=hAllSpaceDCALDiff[j+6]->GetMaximum();
3988  for (i=0;i<hAllSpaceDCALDiff[j+6]->GetNbinsX();i++)
3989  {for (int jm=0;jm<hAllSpaceDCALDiff[j+6]->GetNbinsY();jm++)
3990  {if ((hAllSpaceDCALDiff[j+6]->GetBinContent(i+1,jm+1) < nbTot) && (hAllSpaceDCALDiff[j+6]->GetBinContent(i+1,jm+1) != 0)) nbTot=hAllSpaceDCALDiff[j+6]->GetBinContent(i+1,jm+1);
3991  }
3992  }
3993  hAllSpaceDCALDiff[j+6]->SetMinimum(0.98*nbTot);
3994  hAllSpaceDCALDiff[j+6]->Draw("COLZ");
3995  lineSMborderVDCALthird->Draw("SAME");
3996  lineSMborderVDCAL1->Draw("SAME");
3997  lineSMborderVDCAL2->Draw("SAME");
3998  for (int jm=0;jm<(int)((kNbSMDCAL+1)/2);jm++) lineSMborderHDCAL[jm]->Draw("SAME");
3999  hAllSpaceDCALDiff[j+6]->Write();
4000  }
4001  c1->Update();
4002  }
4003 
4004  //Changes wrt previous pass (1-D) :
4005  ps->NewPage();
4006  c1->Clear();
4007  c1->Divide(2,3);
4008  for (j=0;j<6;j++)
4009  {c1->cd(j+1);
4010  k=(j%2)*(int)((j+5)/2)+(1-(j%2))*(int)(j/2);
4011  gPad->SetLogy();
4012  hAllDiff[k]->SetLineColor(kAzure-8);
4013  hAllDiff[k]->SetFillColor(kAzure-9);
4014  hAllDiffAllTw[k]->SetLineColor(kBlue+1);
4015  hAllDiffAllTw[k]->Draw();
4016  hAllDiff[k]->Draw("SAME");
4017  hAllDiffAllTw[k]->Draw("SAME");
4018  hAllDiff[k]->Write();
4019  hAllDiffAllTw[k]->Write();
4020  c1->RedrawAxis();
4021  }
4022  c1->Update();
4023 
4024  ps->NewPage();
4025  c1->Clear();
4026  c1->Divide(2,3);
4027  for (j=0;j<4;j++)
4028  {c1->cd(j+1);
4029  if (j == 3) c1->cd(j+2);
4030  gPad->SetLogy();
4031  hAllDiff[j+6]->SetLineColor(kAzure-8);
4032  hAllDiff[j+6]->SetFillColor(kAzure-9);
4033  hAllDiffAllTw[j+6]->SetLineColor(kBlue+1);
4034  hAllDiffAllTw[j+6]->Draw();
4035  hAllDiff[j+6]->Draw("SAME");
4036  hAllDiffAllTw[j+6]->Draw("SAME");
4037  hAllDiff[j+6]->Write();
4038  hAllDiffAllTw[j+6]->Write();
4039  c1->RedrawAxis();
4040  }
4041  c1->Update();
4042  }
4043 
4044 
4045  ps->Close();
4046 
4047  txtFileCalibOut.close();
4048  fclose(txtFileParamsOut);
4049  fclose(txtFileParamsIn);
4050  fclose(txtFileCalibIn);
4051  rootFileOut->Close();
4052 
4053  printf("Fini...\n");
4054 
4055 
4056  return;
4057  }
4058 
4059 
4060 
4061 
4062 
4063 
4064 
4065 
4066 //-----------------------------------------------------------------------------
4068 {
4069  if (par[2] == 0.) printf("Unvalid (=zero) gaussian width.\n");
4070  Double_t gaus;
4071  if (par[2] != 0.) gaus = par[0] * TMath::Exp( -(x[0]-par[1])*(x[0]-par[1]) /
4072  (2*par[2]*par[2]) );
4073  else gaus = 99999999.;
4074  Double_t back = par[3] + par[4]*x[0] + par[5]*x[0]*x[0] + par[6]*x[0]*x[0]*x[0];
4075  return gaus+back;
4076 }
4077 
4078 
4079 
4080 
4081 
4082 
4083 
4084 
4085 
4086 
4087 //-----------------------------------------------------------------------------
4089 {
4090  if (par[2] == 0.) printf("Unvalid (=zero) gaussian width.\n");
4091  Double_t gaus;
4092  if (par[2] != 0.) gaus = par[0] * TMath::Exp( -(x[0]-par[1])*(x[0]-par[1]) /
4093  (2*par[2]*par[2]) );
4094  else gaus = 99999999.;
4095  Double_t back = par[3] + par[4]*x[0] + par[5]*x[0]*x[0];
4096  return gaus+back;
4097 }
4098 
4099 
4100 
4101 
4102 
4103 
4104 
4105 
4106 
4107 
4108 //-----------------------------------------------------------------------------
4110 {
4111  Double_t gaus = par[0] * TMath::Exp( -(x[0]-par[1])*(x[0]-par[1]) /
4112  (2*par[2]*par[2]) );
4113  Double_t back = par[3] + par[4]*x[0];
4114  return gaus+back;
4115 }
4116 
4117 
4118 
4119 
4120 
4121 
4122 
4123 
4124 
4125 
4126 
4127 
const int kNbSMtot
const int kTabNbRow[4]
const int kNbSMEMCAL
const int kNbColOffsetDCAL
double Double_t
Definition: External.C:58
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
Definition: External.C:236
Double_t pi0massP3(Double_t *x, Double_t *par)
const int kNbSMEMCALthird
const int kNbFitParams
const int kNbRowEMCAL
TSystem * gSystem
const int kNbColDCAL
const int kNbSMDCALthird
TCanvas * c
Definition: TestFitELoss.C:172
char SMnumber[][100]
Double_t pi0massP1(Double_t *x, Double_t *par)
const int kNbRowDCAL
char SMP2Name[][100]
const int kNbColEMCALthird
int Int_t
Definition: External.C:63
const int kNbRowEMCALthird
const int kTabNbCol[4]
Definition: External.C:212
const int kNbTotParams
Double_t pi0massP2(Double_t *x, Double_t *par)
const int kNbExtraParamsToBeRead
const int kNbSMDCAL
const int kTabNbSM[4]
const int kNbColMax
const int kNbColDCALthird
Int_t rebin
const int kNbColEMCAL
void Pi0CalibInvMassAnalysis3(int choice=0b0110)
int SMdetType[]
const int kNbRowMax
int detTypeType[]
const int kNbRowDCALthird
const int kNbExtraParams
char detTypeString[][100]