AliPhysics  eb0e5d9 (eb0e5d9)
ComparePi0CalibResults.C
Go to the documentation of this file.
1 #include <signal.h>
2 //#include <sys/time.h>
3 #include <stdio.h>
4 #include <vector>
5 #include <iostream>
6 #include <fstream>
7 #include <string>
8 #include <iosfwd>
9 #include <iostream>
10 #include <numeric>
11 #include <queue>
12 #include <set>
13 #include <sstream>
14 
15 #include <map>
16 #include <utility>
17 #include <iterator>
18 
19 
20 #include <TApplication.h>
21 #include <TChain.h>
22 #include <TF1.h>
23 #include <TH1F.h>
24 #include <TH2F.h>
25 #include <TFile.h>
26 #include <TCanvas.h>
27 #include <TFrame.h>
28 #include <TPostScript.h>
29 #include <TLine.h>
30 #include <TGaxis.h>
31 #include <TStyle.h>
32 #include <TGraphErrors.h>
33 #include <TMath.h>
34 #include <TMatrixF.h>
35 #include <TText.h>
36 
37 
38 //#include "/cebaf/faivre/recherche/utilities/defineMyPalette2011.C"
39 
40 
41 namespace std {} using namespace std;
42 
43 
45 char detTypeString[][100]={"EMCAL","EMCALthird","DCAL","DCALthird"};
46 
47 // see http://dsilverm.web.cern.ch/dsilverm/fee/addrP2.html
48 char SMP2Name[][100]={"SMA0","SMC0","SMA1","SMC1","SMA2","SMC2","SMA3","SMC3","SMA4","SMC4","SMA5","SMC5","SMA9","SMC9","SMA10","SMC10","SMA11","SMC11","SMA12","SMC12"};
50 
51 
65 //
68 
73 {int i,j,iRun,iSM,iCol,iRow,cmptPlots;
74  char name1[150],name2[150];
75  TFile *rootFileIn1,*rootFileIn2;
76 
77  const int kNbColEMCAL=48;
78  const int kNbRowEMCAL=24;
79  const int kNbSMEMCAL=10;
80  const int kNbColEMCALthird=kNbColEMCAL;
81  const int kNbRowEMCALthird=(int)(kNbRowEMCAL/3);
82  const int kNbSMEMCALthird=2;
83  const int kNbColDCAL=32;
84  const int kNbRowDCAL=kNbRowEMCAL;
85  const int kNbSMDCAL=6;
88  const int kNbSMDCALthird=2;
89  const int kNbSMtot=kNbSMEMCAL+kNbSMEMCALthird+kNbSMDCAL+kNbSMDCALthird;
90  const int kTabNbCol[4]={kNbColEMCAL,kNbColEMCALthird,kNbColDCAL,kNbColDCALthird};
91  const int kTabNbRow[4]={kNbRowEMCAL,kNbRowEMCALthird,kNbRowDCAL,kNbRowDCALthird};
92  const int kTabNbSM[4]={kNbSMEMCAL,kNbSMEMCALthird,kNbSMDCAL,kNbSMDCALthird};
93  const int kNbColMax=kNbColEMCAL;
94  const int kNbRowMax=kNbRowEMCAL;
95 
96  //defineMyPalette2011(30,5);
97 
98  TH1F *hInvMass1[kNbSMtot][kNbColMax][kNbRowMax];
99  TH1F *hInvMass2[kNbSMtot][kNbColMax][kNbRowMax];
100 
101  FILE *outFile;
102  char fchNameBase[200],fchNameRoot[200],fchNamePs[200],fchNameOut[200];
103  sprintf(fchNameBase,"output_comparePi0CalibResults%s",ident.Data());
104  sprintf(fchNameRoot,"%s.root",fchNameBase);
105  sprintf(fchNamePs,"%s.ps",fchNameBase);
106  sprintf(fchNameOut,"%s.out",fchNameBase);
107  outFile=fopen(fchNameOut,"w");
108 
109 
110  const int cWidth=500;
111  const int cHeight=(int)(500*(30./21.));
112  TCanvas *c1 = new TCanvas("c1","EMCal cosmics analysis",cWidth,cHeight);
113  TPostScript *ps = new TPostScript(fchNamePs,111);
114 
115  sprintf(name1,"/cebaf/cebaf/EMCAL/calibPi0_run2/calibPi0_4_with2015data/TestLowMassPeakTowers/output_BadMapNoMask/output_calibPi0.root");
116  sprintf(name2,"/cebaf/cebaf/EMCAL/calibPi0_run2/calibPi0_4_with2015data/TestLowMassPeakTowers/output_BadMapMask/output_calibPi0.root");
117  rootFileIn1 = new TFile(name1,"READONLY");
118  rootFileIn2 = new TFile(name2,"READONLY");
119 
120  for (iSM=0;iSM<kNbSMtot;iSM++)
121  //for (iSM=0;iSM<2;iSM++)
122  {if (iSM == 0) continue;
123  if (iSM == 2) continue;
124  if (iSM == 4) continue;
125  if (iSM == 5) continue;
126  if (iSM == 6) continue;
127  if (iSM == 7) continue;
128  if (iSM == 8) continue;
129  if (iSM == 9) continue;
130  if (iSM == 10) continue;
131  if (iSM == 11) continue;
132  if (iSM == 18) continue;
133  if (iSM == 19) continue;
134  for (iCol=0;iCol<kTabNbCol[SMdetType[iSM]];iCol++)
135  {for (iRow=0;iRow<kTabNbRow[SMdetType[iSM]];iRow++)
136  {hInvMass1[iSM][iCol][iRow] = (TH1F*)rootFileIn1->Get(Form("%d_%d_%d",iSM,iCol,iRow));
137  }
138  }
139  }
140 
141  TFile *rootFileOut = new TFile(fchNameRoot,"RECREATE");
142  cmptPlots=0;
143  ps->NewPage();
144  c1->Clear();
145  c1->Divide(3,4);
146  for (iSM=0;iSM<kNbSMtot;iSM++)
147  //for (iSM=0;iSM<2;iSM++)
148  {printf("Beginning SM %d.\n",iSM);
149  if (iSM == 0) continue;
150  if (iSM == 2) continue;
151  if (iSM == 4) continue;
152  if (iSM == 5) continue;
153  if (iSM == 6) continue;
154  if (iSM == 7) continue;
155  if (iSM == 8) continue;
156  if (iSM == 9) continue;
157  if (iSM == 10) continue;
158  if (iSM == 11) continue;
159  if (iSM == 18) continue;
160  if (iSM == 19) continue;
161  for (iCol=0;iCol<kTabNbCol[SMdetType[iSM]];iCol++)
162  {for (iRow=0;iRow<kTabNbRow[SMdetType[iSM]];iRow++)
163  {hInvMass2[iSM][iCol][iRow] = (TH1F*)rootFileIn2->Get(Form("%d_%d_%d",iSM,iCol,iRow));
164  cmptPlots++;
165  if (!hInvMass2[iSM][iCol][iRow]) continue;
166  hInvMass2[iSM][iCol][iRow]->Divide(hInvMass1[iSM][iCol][iRow]);
167  c1->cd(cmptPlots);
168  hInvMass2[iSM][iCol][iRow]->SetMaximum(1.1);
169  hInvMass2[iSM][iCol][iRow]->SetMinimum(0.0);
170  hInvMass2[iSM][iCol][iRow]->SetAxisRange(50.,250.,"X");
171  hInvMass2[iSM][iCol][iRow]->Draw();
172  hInvMass2[iSM][iCol][iRow]->Write();
173  if (cmptPlots == 3*4)
174  {c1->Update();
175  ps->NewPage();
176  c1->Clear();
177  c1->Divide(3,4);
178  cmptPlots=0;
179  }
180  }
181  }
182  }
183 
184 
185 
186 
187 
188  TLine *lineSMborderVEMCAL = new TLine(kNbColEMCAL-0.5,-0.5,kNbColEMCAL-0.5,(int)((kNbSMEMCAL+1)/2)*kNbRowEMCAL+(int)((kNbSMEMCALthird+1)/2)*kNbRowEMCALthird-0.5);
189  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);
190  TLine *lineSMborderVDCAL1 = new TLine(kNbColDCAL-0.5,-0.5,kNbColDCAL-0.5,(int)((kNbSMDCAL+1)/2)*kNbRowDCAL-0.5);
191  TLine *lineSMborderVDCAL2 = new TLine(2*kNbColEMCAL-kNbColDCAL-0.5,-0.5,2*kNbColEMCAL-kNbColDCAL-0.5,(int)((kNbSMDCAL+1)/2)*kNbRowDCAL-0.5);
192  TLine **lineSMborderHEMCAL,**lineSMborderHDCAL;
193  lineSMborderHEMCAL = new TLine*[(int)((kNbSMEMCAL+1)/2)];
194  lineSMborderHDCAL = new TLine*[(int)((kNbSMDCAL+1)/2)];
195  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);
196  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);
197 
198 
199  printf("Drawing done.\n");
200 
201 
202  ps->Close();
203  printf("Closed ps file.\n");
204  rootFileOut->Close();
205  printf("Closed root file.\n");
206  fclose(outFile);
207  printf("Closed txt file, quit root.\n");
208 
209  return;
210  }
211 
212 
213 
214 
215 
216 
217 
const int kNbColEMCALthird
const int kTabNbCol[4]
char detTypeString[][100]
const int kNbRowMax
const int kNbSMtot
const int kNbSMEMCAL
const int kNbRowEMCAL
int SMdetType[]
const int kNbRowDCAL
const int kNbRowDCALthird
void ComparePi0CalibResults(TString ident="")
const int kNbColMax
const int kNbSMEMCALthird
const int kNbColDCAL
char SMP2Name[][100]
const int kTabNbRow[4]
const int kNbColEMCAL
const int kNbSMDCALthird
const int kNbRowEMCALthird
const int kNbSMDCAL
const int kTabNbSM[4]
const int kNbColDCALthird