StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
plotBKstarGamma.C
1 // Macro to create validation plots for testing PHOTOS for
2 // B0 -> K*0' gamma, K*0' -> K+ pi- nGamma, where n = 0,1,2,...
3 // Uses the ROOT files created by genRootDecayChain program
4 
5 #include <string>
6 using std::string;
7 
8 void initHist(TH1D* theHist) {
9 
10  theHist->SetDirectory(0);
11 
12  theHist->SetTitleOffset(1.1, "Y");
13  theHist->SetLineWidth(2);
14  TAxis* xAxis = theHist->GetXaxis();
15  xAxis->SetLabelSize(0.05);
16  xAxis->SetTitleSize(0.05);
17  TAxis* yAxis = theHist->GetYaxis();
18  yAxis->SetLabelSize(0.05);
19  yAxis->SetTitleSize(0.05);
20 
21 }
22 
23 void plotBKstarGamma(string inFileName = "BKstarGamma.root") {
24 
25  TFile* theFile = new TFile(inFileName.c_str(), "read");
26  TTree* theTree = dynamic_cast<TTree*>(theFile->Get("Data"));
27 
28  // Create plots of K*0' mass, momentum of 1st and FSR gammas,
29  // mtm of K+, pi-, and the multiplicity of photons
30  TH1D* KstMHist = new TH1D("KstMHist", "", 100, 0.0, 5.0);
31  KstMHist->SetXTitle("K^{*0'} mass (GeV/c^{2})");
32  KstMHist->SetYTitle("Frequency/50 (MeV/c^{2})");
33  initHist(KstMHist);
34 
35  TH1D* gamPHist = new TH1D("gamPHist", "", 100, 0.0, 3.0);
36  gamPHist->SetXTitle("1st #gamma mtm (GeV/c)");
37  gamPHist->SetYTitle("Frequency/30 (MeV/c^{2})");
38  initHist(gamPHist);
39 
40  TH1D* FSRPHist = new TH1D("FSRPHist", "", 100, 0.0, 2.0);
41  FSRPHist->SetXTitle("FSR #gamma mtm (GeV/c)");
42  FSRPHist->SetYTitle("Frequency/20 (MeV/c)");
43  initHist(FSRPHist);
44 
45  TH1D* KPHist = new TH1D("KPHist", "", 100, 0.0, 3.0);
46  KPHist->SetXTitle("K^{+} mtm (GeV/c)");
47  KPHist->SetYTitle("Frequency/30 (MeV/c)");
48  initHist(KPHist);
49 
50  TH1D* piPHist = new TH1D("piPHist", "", 100, 0.0, 3.0);
51  piPHist->SetXTitle("#pi^{-} mtm (GeV/c)");
52  piPHist->SetYTitle("Frequency/30 (MeV/c)");
53  initHist(piPHist);
54 
55  TH1D* gamNHist = new TH1D("gamNHist", "", 6, 0, 6);
56  gamNHist->SetXTitle("Number of photons");
57  gamNHist->SetYTitle("Fraction of events");
58  initHist(gamNHist);
59 
60  // Setup the TTree variables
61  int eventId(0), PDGId(0), pVtx(0), daug(0);
62  double pL(0.0), m(0.0);
63  theTree->SetBranchStatus("*", 0);
64 
65  theTree->SetBranchStatus("eventId", 1);
66  theTree->SetBranchStatus("PDGId", 1);
67  theTree->SetBranchStatus("daug", 1);
68  theTree->SetBranchStatus("pVtx", 1);
69  theTree->SetBranchStatus("pL", 1);
70  theTree->SetBranchStatus("m", 1);
71  theTree->SetBranchAddress("eventId", &eventId);
72  theTree->SetBranchAddress("PDGId", &PDGId);
73  theTree->SetBranchAddress("pVtx", &pVtx);
74  theTree->SetBranchAddress("daug", &daug);
75  theTree->SetBranchAddress("pL", &pL);
76  theTree->SetBranchAddress("m", &m);
77 
78  int nEntries = theTree->GetEntries();
79  int i(0);
80 
81  int oldEvent(-1);
82  int nPhotons(0);
83  int nEvents = theTree->GetMaximum("eventId") + 1;
84 
85  for (i = 0; i < nEntries; i++) {
86 
87  theTree->GetEntry(i);
88 
89  if (oldEvent != eventId) {
90 
91  // We have a new event
92  // Fill the photon multiplicity histogram
93  gamNHist->Fill(nPhotons*1.0);
94 
95  // Reset photon counter
96  nPhotons = 0;
97 
98  // Set the old event index to the current one
99  oldEvent = eventId;
100 
101  }
102 
103  if (PDGId == 100313) {
104  // K*0' mass distribution
105  KstMHist->Fill(m);
106  }
107 
108  if (PDGId == 22) {
109 
110  if (pVtx == 0 && daug == 2) {
111  // 1st photon momentum
112  gamPHist->Fill(pL);
113  } else {
114  // Other FSR photon momentum
115  FSRPHist->Fill(pL);
116  }
117 
118  // Increment the photon counter
119  nPhotons++;
120 
121  }
122 
123  if (PDGId == 321) {
124  KPHist->Fill(pL);
125  }
126 
127  if (PDGId == -211) {
128  piPHist->Fill(pL);
129  }
130 
131  }
132 
133  // Create the plots
134 
135  gROOT->SetStyle("Plain");
136  gStyle->SetOptStat(0);
137  TCanvas* theCanvas = new TCanvas("theCanvas", "", 1200, 1100);
138  theCanvas->UseCurrentStyle();
139 
140  theCanvas->Divide(2,3);
141 
142  // Same normalisation number for all plots (except FSR momenta)
143  double scale = 1.0/(nEvents*1.0);
144 
145  // K*0' mass
146  theCanvas->cd(1);
147  gPad->SetLogy(0);
148  KstMHist->Scale(scale);
149  KstMHist->SetMaximum(0.16);
150  KstMHist->Draw();
151 
152  // 1st photon momentum
153  theCanvas->cd(2);
154  gPad->SetLogy(1);
155  gamPHist->Scale(scale);
156  gamPHist->SetMaximum(0.5);
157  gamPHist->Draw();
158 
159  // K+ momentum
160  theCanvas->cd(3);
161  KPHist->Scale(scale);
162  KPHist->SetMaximum(0.025);
163  KPHist->Draw();
164 
165  // FSR photon momenta
166  theCanvas->cd(4);
167  gPad->SetLogy(1);
168  // Scale is equal to the area of the histogram, since there may
169  // be events with more than one FSR photon
170  double scale1(1.0);
171  double FSRIntegral = FSRPHist->Integral();
172  if (FSRIntegral > 0.0) {scale1 = 1.0/FSRIntegral;}
173  FSRPHist->Scale(scale1);
174  FSRPHist->SetMaximum(1.0);
175  FSRPHist->Draw();
176 
177  // pi- momentum
178  theCanvas->cd(5);
179  piPHist->Scale(scale);
180  piPHist->SetMaximum(0.025);
181  piPHist->Draw();
182 
183  // Photon multiplicity
184  theCanvas->cd(6);
185  gamNHist->Scale(scale);
186  gamNHist->SetMaximum(1.0);
187  gamNHist->Draw();
188 
189  theCanvas->cd(1);
190  TLatex latex;
191  latex.SetNDC();
192  latex.SetTextSize(0.045);
193  latex.DrawLatex(0.1, 0.95, "B0 #rightarrow K^{*0'} #gamma, K^{*0'} #rightarrow K^{+} #pi^{-} with PHOTOS");
194 
195  theCanvas->Print("plotBKstarGamma.eps");
196  //theCanvas->Print("plotBKstarGamma.png");
197 
198 
199 }