Hall-D Software  alpha
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
HistMacro_ppi0gamma.C
Go to the documentation of this file.
1 // hnamepath: /ppi0gamma_preco_2FCAL/Hist_InvariantMass_Pi0/InvariantMass
2 // hnamepath: /ppi0gamma_preco_2FCAL/Hist_InvariantMass_Omega_PostKinFitCut/InvariantMass
3 // hnamepath: /ppi0gamma_preco_2BCAL/Hist_InvariantMass_Pi0/InvariantMass
4 // hnamepath: /ppi0gamma_preco_2BCAL/Hist_InvariantMass_Omega_PostKinFitCut/InvariantMass
5 // hnamepath: /ppi0gamma_preco_FCAL-BCAL/Hist_InvariantMass_Pi0/InvariantMass
6 // hnamepath: /ppi0gamma_preco_FCAL-BCAL/Hist_InvariantMass_Omega_PostKinFitCut/InvariantMass
7 // hnamepath: /ppi0gamma_preco_any_kinfit/Hist_MissingMassSquared/MissingMassSquared
8 // hnamepath: /ppi0gamma_preco_any_kinfit/Hist_MissingMassSquared_PostKinFitCut/MissingMassSquared
9 // hnamepath: /ppi0gamma_preco_any_kinfit/Hist_InvariantMass_Pi0/InvariantMass
10 // hnamepath: /ppi0gamma_preco_any_kinfit/Hist_InvariantMass_Pi0_PostKinFitCut/InvariantMass
11 // hnamepath: /ppi0gamma_preco_any_kinfit/Hist_KinFitResults/ConfidenceLevel
12 // hnamepath: /ppi0gamma_preco_any_kinfit/Hist_InvariantMass_Omega_PostKinFitCut/InvariantMass
13 // hnamepath: /ppi0gamma_preco_any_kinfit/Hist_InvariantMass_Omega_KinFit_PostKinFitCut/InvariantMass
14 
15 
16 { TDirectory *locInitDirectory = gDirectory;
17  TDirectory *locReactionDirectory_2FCAL = (TDirectory*)locInitDirectory->FindObjectAny("ppi0gamma_preco_2FCAL");
18  TDirectory *locReactionDirectory_2BCAL = (TDirectory*)locInitDirectory->FindObjectAny("ppi0gamma_preco_2BCAL");
19  TDirectory *locReactionDirectory_Both = (TDirectory*)locInitDirectory->FindObjectAny("ppi0gamma_preco_FCAL-BCAL");
20  TDirectory *locReactionDirectory_Any = (TDirectory*)locInitDirectory->FindObjectAny("ppi0gamma_preco_any");
21  TDirectory *locReactionDirectory_KinFit = (TDirectory*)locInitDirectory->FindObjectAny("ppi0gamma_preco_any_kinfit");
22  if((locReactionDirectory_2FCAL == NULL) || (locReactionDirectory_2BCAL == NULL) || (locReactionDirectory_Both == NULL))
23  return;
24  if((locReactionDirectory_Any == NULL) || (locReactionDirectory_KinFit == NULL))
25  return;
26 
27  //Get/Make Canvas
28  TCanvas *locCanvas = NULL;
29  if(TVirtualPad::Pad() == NULL)
30  locCanvas = new TCanvas("ppi0gamma", "ppi0gamma", 1200, 800); //for testing
31  else
32  locCanvas = gPad->GetCanvas();
33  locCanvas->Divide(3, 2);
34 
35  // Get overall normalization to number of triggers
36  TH1D* locHist_NumEvents = (TH1D*) locReactionDirectory_KinFit->Get("NumEventsSurvivedAction");
37  double n_triggers = locHist_NumEvents->GetBinContent(1);
38 
39  double n_omega_kinfit;
40  double omega_mass = 0;
41  double omega_width= 0;
42 
43  TH1I* locHist_Pi0_2FCAL = (TH1I*)locReactionDirectory_2FCAL->Get("Hist_InvariantMass_Pi0/InvariantMass");
44  TH1I* locHist_Omega_2FCAL = (TH1I*)locReactionDirectory_2FCAL->Get("Hist_InvariantMass_Omega_PostKinFitCut/InvariantMass");
45 
46  TH1I* locHist_Pi0_2BCAL = (TH1I*)locReactionDirectory_2BCAL->Get("Hist_InvariantMass_Pi0/InvariantMass");
47  TH1I* locHist_Omega_2BCAL = (TH1I*)locReactionDirectory_2BCAL->Get("Hist_InvariantMass_Omega_PostKinFitCut/InvariantMass");
48 
49  TH1I* locHist_Pi0_Both = (TH1I*)locReactionDirectory_Both->Get("Hist_InvariantMass_Pi0/InvariantMass");
50  TH1I* locHist_Omega_Both = (TH1I*)locReactionDirectory_Both->Get("Hist_InvariantMass_Omega_PostKinFitCut/InvariantMass");
51 
52  TH1I* locHist_MM2 = (TH1I*)locReactionDirectory_KinFit->Get("Hist_MissingMassSquared/MissingMassSquared");
53  TH1I* locHist_MM2_KinFitCut = (TH1I*)locReactionDirectory_KinFit->Get("Hist_MissingMassSquared_PostKinFitCut/MissingMassSquared");
54 
55  TH1I* locHist_Pi0 = (TH1I*)locReactionDirectory_KinFit->Get("Hist_InvariantMass_Pi0/InvariantMass");
56  TH1I* locHist_Pi0_KinFitCut = (TH1I*)locReactionDirectory_KinFit->Get("Hist_InvariantMass_Pi0_PostKinFitCut/InvariantMass");
57 
58  TH1I* locHist_KinFitConLev = (TH1I*)locReactionDirectory_KinFit->Get("Hist_KinFitResults/ConfidenceLevel");
59 
60  TH1I* locHist_Omega_KinFitCut = (TH1I*)locReactionDirectory_KinFit->Get("Hist_InvariantMass_Omega_PostKinFitCut/InvariantMass");
61  TH1I* locHist_KinFitOmega_KinFitCut = (TH1I*)locReactionDirectory_KinFit->Get("Hist_InvariantMass_Omega_KinFit_PostKinFitCut/InvariantMass");
62 
63  //Draw
64  int locNumRebin = 5;
65 
66  //pi0 for 3 cases (all on top of each other)
67  locCanvas->cd(1);
68  gPad->SetTicks();
69  gPad->SetGrid();
70  if((locHist_Pi0_2FCAL != NULL) && (locHist_Pi0_2BCAL != NULL) && (locHist_Pi0_Both != NULL))
71  {
72  locHist_Pi0_2FCAL->Rebin(locNumRebin);
73  locHist_Pi0_2BCAL->Rebin(locNumRebin);
74  locHist_Pi0_Both->Rebin(locNumRebin);
75 
76  double locMaxHeight = locHist_Pi0_2FCAL->GetBinContent(locHist_Pi0_2FCAL->GetMaximumBin());
77  double locOtherHeight = locHist_Pi0_2BCAL->GetBinContent(locHist_Pi0_2BCAL->GetMaximumBin());
78  if(locOtherHeight > locMaxHeight)
79  locMaxHeight = locOtherHeight;
80  locOtherHeight = locHist_Pi0_Both->GetBinContent(locHist_Pi0_Both->GetMaximumBin());
81  if(locOtherHeight > locMaxHeight)
82  locMaxHeight = locOtherHeight;
83 
84  locHist_Pi0_2FCAL->SetTitle("Measured");
85  locHist_Pi0_2FCAL->GetXaxis()->SetTitleSize(0.05);
86  locHist_Pi0_2FCAL->GetYaxis()->SetTitle("");
87  locHist_Pi0_2FCAL->GetXaxis()->SetLabelSize(0.05);
88  locHist_Pi0_2FCAL->GetYaxis()->SetLabelSize(0.05);
89  locHist_Pi0_2FCAL->SetLineColor(kRed);
90  locHist_Pi0_2FCAL->SetLineWidth(2);
91  locHist_Pi0_2FCAL->GetYaxis()->SetRangeUser(0.0, 1.05*locMaxHeight);
92  locHist_Pi0_2FCAL->Draw();
93 
94  locHist_Pi0_2BCAL->GetXaxis()->SetTitleSize(0.05);
95  locHist_Pi0_2BCAL->GetYaxis()->SetTitle("");
96  locHist_Pi0_2BCAL->GetXaxis()->SetLabelSize(0.05);
97  locHist_Pi0_2BCAL->GetYaxis()->SetLabelSize(0.05);
98  locHist_Pi0_2BCAL->SetLineColor(kBlue);
99  locHist_Pi0_2BCAL->SetLineWidth(2);
100  locHist_Pi0_2BCAL->GetYaxis()->SetRangeUser(0.0, 1.05*locMaxHeight);
101  locHist_Pi0_2BCAL->Draw("SAME");
102 
103  locHist_Pi0_Both->GetXaxis()->SetTitleSize(0.05);
104  locHist_Pi0_Both->GetYaxis()->SetTitle("");
105  locHist_Pi0_Both->GetXaxis()->SetLabelSize(0.05);
106  locHist_Pi0_Both->GetYaxis()->SetLabelSize(0.05);
107  locHist_Pi0_Both->SetLineColor(kBlack);
108  locHist_Pi0_Both->SetLineWidth(2);
109  locHist_Pi0_Both->GetYaxis()->SetRangeUser(0.0, 1.05*locMaxHeight);
110  locHist_Pi0_Both->Draw("SAME");
111 
112  TLegend *locLegend = new TLegend(0.14, 0.70, 0.39, 0.86); //botleft x/y, topright x/y
113  locLegend->SetHeader("Legend");
114  locLegend->AddEntry(locHist_Pi0_2FCAL, "2#gamma in FCAL", "F");
115  locLegend->AddEntry(locHist_Pi0_2BCAL, "2#gamma in BCAL", "F");
116  locLegend->AddEntry(locHist_Pi0_Both, "1 #gamma in Each", "F");
117  locLegend->Draw();
118  }
119 
120  //con lev
121  locCanvas->cd(2);
122  gPad->SetTicks();
123  gPad->SetGrid();
124  if(locHist_KinFitConLev != NULL)
125  {
126  locHist_KinFitConLev->GetXaxis()->SetTitle("Confidence Level");
127  locHist_KinFitConLev->GetXaxis()->SetTitleSize(0.05);
128  locHist_KinFitConLev->GetYaxis()->SetTitle("");
129  locHist_KinFitConLev->GetXaxis()->SetLabelSize(0.05);
130  locHist_KinFitConLev->GetYaxis()->SetLabelSize(0.05);
131  locHist_KinFitConLev->SetFillColor(kTeal + 1);
132  locHist_KinFitConLev->Draw();
133  gPad->SetLogy();
134  }
135 
136  //mm2
137  locCanvas->cd(3);
138  gPad->SetTicks();
139  gPad->SetGrid();
140  if((locHist_MM2 != NULL) && (locHist_MM2_KinFitCut != NULL))
141  {
142  locHist_MM2->Rebin(locNumRebin);
143  locHist_MM2->GetXaxis()->SetRangeUser(-0.05, 0.05);
144  locHist_MM2->GetXaxis()->SetTitleSize(0.045);
145  locHist_MM2->GetYaxis()->SetTitle("");
146  locHist_MM2->GetXaxis()->SetLabelSize(0.045);
147  locHist_MM2->GetYaxis()->SetLabelSize(0.05);
148  locHist_MM2->SetFillColor(kRed - 7);
149  locHist_MM2->GetYaxis()->SetRangeUser(0.0, 1.05*locHist_MM2->GetBinContent(locHist_MM2->GetMaximumBin()));
150  locHist_MM2->Draw();
151 
152  locHist_MM2_KinFitCut->Rebin(locNumRebin);
153  locHist_MM2_KinFitCut->GetXaxis()->SetTitleSize(0.05);
154  locHist_MM2_KinFitCut->GetYaxis()->SetTitle("");
155  locHist_MM2_KinFitCut->GetXaxis()->SetLabelSize(0.05);
156  locHist_MM2_KinFitCut->GetYaxis()->SetLabelSize(0.05);
157  locHist_MM2_KinFitCut->SetFillColor(kAzure + 1);
158  locHist_MM2_KinFitCut->Draw("SAME");
159 
160  TLegend *locLegend = new TLegend(0.14, 0.74, 0.39, 0.86); //botleft x/y, topright x/y
161  locLegend->SetHeader("Legend");
162  locLegend->AddEntry(locHist_MM2, "No KinFit Cut", "F");
163  locLegend->AddEntry(locHist_MM2_KinFitCut, "KinFit Cut", "F");
164  locLegend->Draw();
165  }
166 
167  //pi0 before/after kinfit
168  locCanvas->cd(4);
169  gPad->SetTicks();
170  gPad->SetGrid();
171  if((locHist_Pi0 != NULL) && (locHist_Pi0_KinFitCut != NULL))
172  {
173  locHist_Pi0->Rebin(locNumRebin);
174  locHist_Pi0->GetXaxis()->SetRangeUser(-0.05, 0.05);
175  locHist_Pi0->GetXaxis()->SetTitleSize(0.045);
176  locHist_Pi0->GetYaxis()->SetTitle("");
177  locHist_Pi0->GetXaxis()->SetLabelSize(0.045);
178  locHist_Pi0->GetYaxis()->SetLabelSize(0.05);
179  locHist_Pi0->SetFillColor(kRed - 7);
180  locHist_Pi0->GetYaxis()->SetRangeUser(0.0, 1.05*locHist_Pi0->GetBinContent(locHist_Pi0->GetMaximumBin()));
181  locHist_Pi0->Draw();
182 
183  locHist_Pi0_KinFitCut->Rebin(locNumRebin);
184  locHist_Pi0_KinFitCut->GetXaxis()->SetTitleSize(0.05);
185  locHist_Pi0_KinFitCut->GetYaxis()->SetTitle("");
186  locHist_Pi0_KinFitCut->GetXaxis()->SetLabelSize(0.05);
187  locHist_Pi0_KinFitCut->GetYaxis()->SetLabelSize(0.05);
188  locHist_Pi0_KinFitCut->SetFillColor(kAzure + 1);
189  locHist_Pi0_KinFitCut->Draw("SAME");
190 
191  TLegend *locLegend = new TLegend(0.14, 0.74, 0.39, 0.86); //botleft x/y, topright x/y
192  locLegend->SetHeader("Legend");
193  locLegend->AddEntry(locHist_Pi0, "No KinFit Cut", "F");
194  locLegend->AddEntry(locHist_Pi0_KinFitCut, "KinFit Cut", "F");
195  locLegend->Draw();
196  }
197 
198  //compare omega kinfit / measured after kinfit cut
199  locCanvas->cd(5);
200  gPad->SetTicks();
201  gPad->SetGrid();
202  if((locHist_KinFitOmega_KinFitCut != NULL) && (locHist_Omega_KinFitCut != NULL))
203  {
204  locHist_Omega_KinFitCut->Rebin(2*locNumRebin);
205  locHist_KinFitOmega_KinFitCut->Rebin(2*locNumRebin);
206 
207  double locMaxHeight = locHist_Omega_KinFitCut->GetBinContent(locHist_Omega_KinFitCut->GetMaximumBin());
208  double locOtherHeight = locHist_KinFitOmega_KinFitCut->GetBinContent(locHist_KinFitOmega_KinFitCut->GetMaximumBin());
209  if(locOtherHeight > locMaxHeight)
210  locMaxHeight = locOtherHeight;
211 
212  locHist_Omega_KinFitCut->SetTitle("Post KinFit Cut");
213  locHist_Omega_KinFitCut->GetXaxis()->SetTitleSize(0.05);
214  locHist_Omega_KinFitCut->GetYaxis()->SetTitle("");
215  locHist_Omega_KinFitCut->GetXaxis()->SetLabelSize(0.05);
216  locHist_Omega_KinFitCut->GetYaxis()->SetLabelSize(0.05);
217  locHist_Omega_KinFitCut->SetLineColor(kRed);
218  locHist_Omega_KinFitCut->SetLineWidth(2);
219  locHist_Omega_KinFitCut->GetYaxis()->SetRangeUser(0.0, 1.05*locMaxHeight);
220  locHist_Omega_KinFitCut->Draw("SAME");
221 
222  locHist_KinFitOmega_KinFitCut->GetXaxis()->SetTitleSize(0.05);
223  locHist_KinFitOmega_KinFitCut->GetYaxis()->SetTitle("");
224  locHist_KinFitOmega_KinFitCut->GetXaxis()->SetLabelSize(0.05);
225  locHist_KinFitOmega_KinFitCut->GetYaxis()->SetLabelSize(0.05);
226  locHist_KinFitOmega_KinFitCut->SetLineColor(kBlue);
227  locHist_KinFitOmega_KinFitCut->SetLineWidth(2);
228  locHist_KinFitOmega_KinFitCut->GetYaxis()->SetRangeUser(0.0, 1.05*locMaxHeight);
229  locHist_KinFitOmega_KinFitCut->Draw("SAME");
230 
231  TLegend *locLegend = new TLegend(0.14, 0.74, 0.39, 0.86); //botleft x/y, topright x/y
232  locLegend->SetHeader("Legend");
233  locLegend->AddEntry(locHist_Omega_KinFitCut, "Measured", "F");
234  locLegend->AddEntry(locHist_KinFitOmega_KinFitCut, "KinFit", "F");
235  locLegend->Draw();
236 
237  n_omega_kinfit = locHist_Omega_KinFitCut->Integral(100./locNumRebin, 400./locNumRebin);
238 
239  // Determine Mass and Width
240  TF1 *fomega = new TF1("fomega", "gaus(0)+pol0(4)", 0.65, 0.9);
241  fomega->SetParameter(1,0.782);
242  fomega->SetParameter(2,0.03);
243  fomega->SetParameter(4,locHist_KinFitOmega_KinFitCut->GetBinContent(1));
244  locHist_KinFitOmega_KinFitCut->Fit("fomega", "Q0");
245  omega_mass = fomega->GetParameter(1);
246  omega_width = fomega->GetParameter(2);
247 
248  }
249 
250  //measured omega for 3 cases (on top of each other)
251  locCanvas->cd(6);
252  gPad->SetTicks();
253  gPad->SetGrid();
254  if((locHist_Omega_2FCAL != NULL) && (locHist_Omega_2BCAL != NULL) && (locHist_Omega_Both != NULL))
255  {
256  locHist_Omega_2FCAL->Rebin(2*locNumRebin);
257  locHist_Omega_2BCAL->Rebin(2*locNumRebin);
258  locHist_Omega_Both->Rebin(2*locNumRebin);
259 
260  double locMaxHeight = locHist_Omega_2FCAL->GetBinContent(locHist_Omega_2FCAL->GetMaximumBin());
261  double locOtherHeight = locHist_Omega_2BCAL->GetBinContent(locHist_Omega_2BCAL->GetMaximumBin());
262  if(locOtherHeight > locMaxHeight)
263  locMaxHeight = locOtherHeight;
264  locOtherHeight = locHist_Omega_Both->GetBinContent(locHist_Omega_Both->GetMaximumBin());
265  if(locOtherHeight > locMaxHeight)
266  locMaxHeight = locOtherHeight;
267 
268  locHist_Omega_2FCAL->SetTitle("Post KinFit Cut");
269  locHist_Omega_2FCAL->GetXaxis()->SetTitleSize(0.05);
270  locHist_Omega_2FCAL->GetYaxis()->SetTitle("");
271  locHist_Omega_2FCAL->GetXaxis()->SetLabelSize(0.05);
272  locHist_Omega_2FCAL->GetYaxis()->SetLabelSize(0.05);
273  locHist_Omega_2FCAL->SetLineColor(kRed);
274  locHist_Omega_2FCAL->SetLineWidth(2);
275  locHist_Omega_2FCAL->GetYaxis()->SetRangeUser(0.0, 1.05*locMaxHeight);
276  locHist_Omega_2FCAL->Draw();
277 
278  locHist_Omega_2BCAL->GetXaxis()->SetTitleSize(0.05);
279  locHist_Omega_2BCAL->GetYaxis()->SetTitle("");
280  locHist_Omega_2BCAL->GetXaxis()->SetLabelSize(0.05);
281  locHist_Omega_2BCAL->GetYaxis()->SetLabelSize(0.05);
282  locHist_Omega_2BCAL->SetLineColor(kBlue);
283  locHist_Omega_2BCAL->SetLineWidth(2);
284  locHist_Omega_2BCAL->GetYaxis()->SetRangeUser(0.0, 1.05*locMaxHeight);
285  locHist_Omega_2BCAL->Draw("SAME");
286 
287  locHist_Omega_Both->GetXaxis()->SetTitleSize(0.05);
288  locHist_Omega_Both->GetYaxis()->SetTitle("");
289  locHist_Omega_Both->GetXaxis()->SetLabelSize(0.05);
290  locHist_Omega_Both->GetYaxis()->SetLabelSize(0.05);
291  locHist_Omega_Both->SetLineColor(kBlack);
292  locHist_Omega_Both->SetLineWidth(2);
293  locHist_Omega_Both->GetYaxis()->SetRangeUser(0.0, 1.05*locMaxHeight);
294  locHist_Omega_Both->Draw("SAME");
295 
296  TLegend *locLegend = new TLegend(0.14, 0.70, 0.39, 0.86); //botleft x/y, topright x/y
297  locLegend->SetHeader("Legend");
298  locLegend->AddEntry(locHist_Omega_2FCAL, "2#gamma in FCAL", "F");
299  locLegend->AddEntry(locHist_Omega_2BCAL, "2#gamma in BCAL", "F");
300  locLegend->AddEntry(locHist_Omega_Both, "1 #gamma in Each", "F");
301  locLegend->Draw();
302  }
303 
304  // Print the mass, width and number of reconstructed omegas per trigger (Fitted values)
305  locCanvas->cd(2);
306  if(locHist_KinFitConLev != NULL){
307  TLatex tx;
308  tx.SetTextAlign(11);
309  tx.SetTextSize(0.06);
310  char text[100];
311  sprintf(text, "Post KinFit");
312  tx.DrawLatex(0.1, locHist_KinFitConLev->GetMaximum()/4., text);
313  sprintf(text, "M(#omega) = %0.3f GeV/c^{2}", omega_mass);
314  tx.DrawLatex(0.1, locHist_KinFitConLev->GetMaximum()/16., text);
315  sprintf(text, "#Gamma(#omega) = %0.3f GeV/c^{2}", omega_width);
316  tx.DrawLatex(0.1, locHist_KinFitConLev->GetMaximum()/64., text);
317  sprintf(text, "N(#omega) = %0.2f / 1k Trigger", n_omega_kinfit/n_triggers*1000);
318  tx.DrawLatex(0.1, locHist_KinFitConLev->GetMaximum()/256., text);
319  }
320 }
321 
sprintf(text,"Post KinFit Cut")
TDirectory * locReactionDirectory_Any
TLatex tx
TDirectory * locReactionDirectory_2FCAL
TDirectory * locReactionDirectory_Both
TDirectory * locReactionDirectory_KinFit
TDirectory * locInitDirectory
TDirectory * locReactionDirectory_2BCAL
TCanvas * locCanvas
char text[100]