Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
JetKinematicCheck.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file JetKinematicCheck.cc
1 //____________________________________________________________________________..
2 
3 #include "JetKinematicCheck.h"
4 
8 
10 #include <phool/getClass.h>
11 
12 #include <g4jets/JetMap.h>
13 #include <g4jets/Jetv1.h>
14 
15 
17 
18 #include <calobase/RawTower.h>
19 #include <calobase/RawTowerContainer.h>
20 #include <calobase/RawTowerGeom.h>
21 #include <calobase/RawTowerGeomContainer.h>
22 
24 
25 
26 #include <TFile.h>
27 #include <TH3D.h>
28 #include <TH2D.h>
29 #include <TH1D.h>
30 #include <TPad.h>
31 #include <TLegend.h>
32 #include <cmath>
33 #include <string>
34 #include<vector>
35 
36 //____________________________________________________________________________..
37 JetKinematicCheck::JetKinematicCheck(const std::string& recojetnameR02, const std::string& recojetnameR04, const std::string& outputfilename):
38 SubsysReco("JetKinematicCheck")
39  , m_recoJetNameR02(recojetnameR02)
40  , m_recoJetNameR04(recojetnameR04)
41  , m_outputFileName(outputfilename)
42  , m_etaRange(-1.1, 1.1)
43  , m_ptRange(10, 100)
44 
45 {
46  std::cout << "JetKinematicCheck::JetKinematicCheck(const std::string &name) Calling ctor" << std::endl;
47 }
48 
49 //____________________________________________________________________________..
51 {
52  std::cout << "JetKinematicCheck::~JetKinematicCheck() Calling dtor" << std::endl;
53 }
54 
55 //centrality labels
56 std::vector<std::string>JetKinematicCheck::GetCentLabels()
57 {
58 
59  std::vector<std::string> cent_labels = { "Inclusive", "0-10%", "10-20%","20-30%","30-40%", "40-50%",
60  "50-60%", "60-70%", "70-80%", "80-90%", "90-100%"};
61  return cent_labels;
62 }
63 
64 //marker colors
66 {
67  std::vector<int> colors = { kBlack, kRed, kBlue, kGreen+2, kViolet, kCyan,
68  kOrange, kPink+2, kMagenta, kTeal+3, kRed+3};
69  return colors;
70 }
71 
72 
73 
74 //____________________________________________________________________________..
76 {
77 
79 
80  jet_spectra_r02 = new TH2D("h_spectra_r02", "", 15, 10, 100, 10, 0, 100);
81  jet_spectra_r02->GetXaxis()->SetTitle("p_{T} [GeV/c]");
82  jet_spectra_r04 = new TH2D("h_spectra_r04", "", 15, 10, 100, 10, 0, 100);
83  jet_spectra_r04->GetXaxis()->SetTitle("p_{T} [GeV/c]");
84  jet_eta_phi_r02 = new TH3D("h_eta_phi_r02","", 24, -1.1, 1.1, 64, -M_PI, M_PI, 10, 0, 100);
85  jet_eta_phi_r02->GetXaxis()->SetTitle("#eta");
86  jet_eta_phi_r02->GetYaxis()->SetTitle("#Phi");
87  jet_eta_phi_r04 = new TH3D("h_eta_phi_r04","", 24, -1.1, 1.1, 64, -M_PI, M_PI, 10, 0, 100);
88  jet_eta_phi_r04->GetXaxis()->SetTitle("#eta");
89  jet_eta_phi_r04->GetYaxis()->SetTitle("#Phi");
90 
91  std::cout << "JetKinematicCheck::Init(PHCompositeNode *topNode) Initializing" << std::endl;
93 }
94 
95 
96 //____________________________________________________________________________..
98 {
99  std::cout << "JetKinematicCheck::InitRun(PHCompositeNode *topNode) Initializing for Run XXX" << std::endl;
101 }
102 
103 
104 //____________________________________________________________________________..
106 {
107 
108  std::vector<std::string> m_recoJetName_array = {m_recoJetNameR02, m_recoJetNameR04};
109 
110  m_radii = {0.2, 0.4};
111  int n_radii = m_radii.size();
112 
113  for(int i = 0; i < n_radii; i++){
114 
115  std::string recoJetName = m_recoJetName_array[i];
116 
117  // interface to reco jets
118  JetMap* jets = findNode::getClass<JetMap>(topNode, recoJetName);
119  if (!jets)
120  {
121  std::cout
122  << "MyJetAnalysis::process_event - Error can not find DST Reco JetMap node "
123  << m_recoJetNameR04 << std::endl;
124  exit(-1);
125  }
126 
127  //centrality
128  CentralityInfo* cent_node = findNode::getClass<CentralityInfo>(topNode, "CentralityInfo");
129  if (!cent_node)
130  {
131  std::cout
132  << "MyJetAnalysis::process_event - Error can not find centrality node "
133  << std::endl;
134  exit(-1);
135  }
136 
137  //get the event centrality
138  m_centrality = cent_node->get_centile(CentralityInfo::PROP::mbd_NS);
139 
140  for (JetMap::Iter iter = jets->begin(); iter != jets->end(); ++iter)
141  {
142 
143  Jet* jet = iter->second;
144 
145  bool eta_cut = (jet->get_eta() >= m_etaRange.first) and (jet->get_eta() <= m_etaRange.second);
146  bool pt_cut = (jet->get_pt() >= m_ptRange.first) and (jet->get_pt() <= m_ptRange.second);
147  if ((not eta_cut) or (not pt_cut)) continue;
148  if(jet->get_pt() < 1) continue; // to remove noise jets
149 
150  if(i == 0){
151  jet_spectra_r02->Fill(jet->get_pt(), m_centrality);
152  jet_eta_phi_r02->Fill(jet->get_eta(), jet->get_phi(), m_centrality);
153 
154  }
155 
156  else if(i == 1){
157  jet_spectra_r04->Fill(jet->get_pt(), m_centrality);
158  jet_eta_phi_r04->Fill(jet->get_eta(), jet->get_phi(), m_centrality);
159  }
160  }
161  }
162  std::cout << "JetKinematicCheck::process_event(PHCompositeNode *topNode) Processing Event" << std::endl;
164 }
165 
166 int count = 0;
167 
168 //____________________________________________________________________________..
170 {
171  std::cout << "JetKinematicCheck::ResetEvent(PHCompositeNode *topNode) Resetting internal structures, prepare for next event" << std::endl;
172 
173  std:: cout << count << std::endl;
174  count++;
175 
176 
178 }
179 
180 //____________________________________________________________________________..
182 {
183  std::cout << "JetKinematicCheck::EndRun(const int runnumber) Ending Run for Run " << runnumber << std::endl;
185 }
186 
187 //____________________________________________________________________________..
189 {
190 
191  std::cout << "JetKinematicCheck::End - Output to " << m_outputFileName << std::endl;
193 
194  jet_spectra_r02->Write();
195  jet_spectra_r04->Write();
196  jet_eta_phi_r02->Write();
197  jet_eta_phi_r04->Write();
198 
199  auto cent_labels = GetCentLabels();
200  auto colors = GetMarkerColors();
201  ncent = cent_labels.size();
202 
203  //projecting jet_spectra =_r02
204  for(int i = 0; i < ncent; i++){
205  TLegend *leg1 = new TLegend(.7,.9,.9,1);
206  leg1->SetFillStyle(0);
207  leg1->SetBorderSize(0);
208  leg1->SetTextSize(0.06);
209  leg1->AddEntry((TObject*)0, Form("%2.0f < p_{T} < %2.0f [GeV/c]", m_ptRange.first, m_ptRange.second),"");
210  leg1->AddEntry((TObject*)0, Form("%1.1f < #eta < %1.1f", m_etaRange.first, m_etaRange.second),"");
211  //for inclusive in centrality
212  if(i==0){
213  jet_spectra_r02_proj[i] = (TH1F*)jet_spectra_r02->ProjectionX(Form("Jet_Spectra_R02_%s",cent_labels[i].c_str()));
214  jet_spectra_r02_proj[i]->SetMarkerStyle(kFullCircle);
215  jet_spectra_r02_proj[i]->SetMarkerColor(colors[i]);
216  jet_spectra_r02_proj[i]->SetLineColor(colors[i]);
217  jet_spectra_r02_proj[i]->SetTitle(Form("Jet Spectra R02 [%s]", cent_labels[i].c_str()));
218  jet_spectra_r02_proj[i]->GetYaxis()->SetTitle("Entries");
219  jet_spectra_r02_proj[i]->GetListOfFunctions()->Add(leg1);
220  jet_spectra_r02_proj[i]->SetStats(0);
221  jet_spectra_r02_proj[i]->Write();
222  }
223  //for all other centrality
224  else{
225  jet_spectra_r02_proj[i] = (TH1F*)jet_spectra_r02->ProjectionX(Form("Jet_Spectra_R02_%s",cent_labels[i].c_str()), i, i);
226  jet_spectra_r02_proj[i]->SetMarkerStyle(kFullCircle);
227  jet_spectra_r02_proj[i]->SetMarkerColor(colors[i]);
228  jet_spectra_r02_proj[i]->SetLineColor(colors[i]);
229  jet_spectra_r02_proj[i]->SetTitle(Form("Jet Spectra R02 [%s]", cent_labels[i].c_str()));
230  jet_spectra_r02_proj[i]->GetYaxis()->SetTitle("Entries");
231  jet_spectra_r02_proj[i]->GetListOfFunctions()->Add(leg1);
232  jet_spectra_r02_proj[i]->SetStats(0);
233  jet_spectra_r02_proj[i]->Write();
234  }
235  }
236 
237 
238  //projecting jet_spectra_r04
239  for(int i = 0; i < ncent; i++){
240  TLegend *leg2 = new TLegend(.7,.9,.9,1);
241  leg2->SetFillStyle(0);
242  leg2->SetBorderSize(0);
243  leg2->SetTextSize(0.06);
244  leg2->AddEntry((TObject*)0, Form("%2.0f < p_{T} < %2.0f [GeV/c]", m_ptRange.first, m_ptRange.second),"");
245  leg2->AddEntry((TObject*)0, Form("%1.1f < #eta < %1.1f", m_etaRange.first, m_etaRange.second),"");
246  if(i==0){
247  jet_spectra_r04_proj[i] = (TH1F*)jet_spectra_r04->ProjectionX(Form("Jet_Spectra_R04_%s",cent_labels[i].c_str()));
248  jet_spectra_r04_proj[i]->SetMarkerStyle(kFullCircle);
249  jet_spectra_r04_proj[i]->SetMarkerColor(colors[i]);
250  jet_spectra_r04_proj[i]->SetLineColor(colors[i]);
251  jet_spectra_r04_proj[i]->SetTitle(Form("Jet Spectra R04 [%s]", cent_labels[i].c_str()));
252  jet_spectra_r04_proj[i]->GetYaxis()->SetTitle("Entries");
253  jet_spectra_r04_proj[i]->GetListOfFunctions()->Add(leg2);
254  jet_spectra_r04_proj[i]->SetStats(0);
255  jet_spectra_r04_proj[i]->Write();
256  }
257  else{
258  jet_spectra_r04_proj[i] = (TH1F*)jet_spectra_r04->ProjectionX(Form("Jet_Spectra_R04_%s",cent_labels[i].c_str()), i, i);
259  jet_spectra_r04_proj[i]->SetMarkerStyle(kFullCircle);
260  jet_spectra_r04_proj[i]->SetMarkerColor(colors[i]);
261  jet_spectra_r04_proj[i]->SetLineColor(colors[i]);
262  jet_spectra_r04_proj[i]->SetTitle(Form("Jet Spectra R04 [%s]", cent_labels[i].c_str()));
263  jet_spectra_r04_proj[i]->GetYaxis()->SetTitle("Entries");
264  jet_spectra_r04_proj[i]->GetListOfFunctions()->Add(leg2);
265  jet_spectra_r04_proj[i]->SetStats(0);
266  jet_spectra_r04_proj[i]->Write();
267  }
268  }
269 
270  //projecting jet_eta_phi_r02
271  for(int i = 0; i < ncent; i++){
272  TLegend *leg3 = new TLegend(.7,.9,.9,1);
273  leg3->SetFillStyle(0);
274  leg3->SetBorderSize(0);
275  leg3->SetTextSize(0.06);
276  leg3->AddEntry((TObject*)0, Form("%2.0f < p_{T} < %2.0f [GeV/c]", m_ptRange.first, m_ptRange.second),"");
277  leg3->AddEntry((TObject*)0, Form("%1.1f < #eta < %1.1f", m_etaRange.first, m_etaRange.second),"");
278  //for inclusive in centrality
279  if(i==0){
280  jet_eta_phi_r02_proj[i] = new TH2D;
281  jet_eta_phi_r02_proj[i] = (TH2D*)jet_eta_phi_r02->Project3D("yx");
282  jet_eta_phi_r02_proj[i]->SetStats(0);
283  jet_eta_phi_r02_proj[i]->SetTitle(Form("Jet Eta-Phi R02 [%s]", cent_labels[i].c_str()));
284  jet_eta_phi_r02_proj[i]->GetListOfFunctions()->Add(leg3);
285  jet_eta_phi_r02_proj[i]->Write(Form("Jet_Eta_Phi_R02_%s", cent_labels[i].c_str()));
286  }
287  //for all other centrality
288  else{
289  jet_eta_phi_r02->GetZaxis()->SetRange(i, i);
290  jet_eta_phi_r02_proj[i] = new TH2D;
291  jet_eta_phi_r02_proj[i] = (TH2D*)jet_eta_phi_r02->Project3D("yx");
292  jet_eta_phi_r02_proj[i]->SetStats(0);
293  jet_eta_phi_r02_proj[i]->SetTitle(Form("Jet Eta-Phi R02 [%s]", cent_labels[i].c_str()));
294  jet_eta_phi_r02_proj[i]->GetListOfFunctions()->Add(leg3);
295  jet_eta_phi_r02_proj[i]->Write(Form("Jet_Eta_Phi_R02_%s", cent_labels[i].c_str()));
296  }
297  }
298 
299 
300 
301  //projecting jet_eta_phi_r04
302  for(int i = 0; i < ncent; i++){
303  TLegend *leg4 = new TLegend(.7,.9,.9,1);
304  leg4->SetFillStyle(0);
305  leg4->SetBorderSize(0);
306  leg4->SetTextSize(0.06);
307  leg4->AddEntry((TObject*)0, Form("%2.0f < p_{T} < %2.0f [GeV/c]", m_ptRange.first, m_ptRange.second),"");
308  leg4->AddEntry((TObject*)0, Form("%1.1f < #eta < %1.1f", m_etaRange.first, m_etaRange.second),"");
309  if(i==0){
310  jet_eta_phi_r04_proj[i] = new TH2D;
311  jet_eta_phi_r04_proj[i] = (TH2D*)jet_eta_phi_r04->Project3D("yx");
312  jet_eta_phi_r04_proj[i]->SetStats(0);
313  jet_eta_phi_r04_proj[i]->SetTitle(Form("Jet Eta-Phi R04 [%s]", cent_labels[i].c_str()));
314  jet_eta_phi_r04_proj[i]->GetListOfFunctions()->Add(leg4);
315  jet_eta_phi_r04_proj[i]->Write(Form("Jet_Eta_Phi_R04_%s", cent_labels[i].c_str()));
316  }
317  else{
318  jet_eta_phi_r04->GetZaxis()->SetRange(i, i);
319  jet_eta_phi_r04_proj[i] = new TH2D;
320  jet_eta_phi_r04_proj[i] = (TH2D*)jet_eta_phi_r04->Project3D("yx");
321  jet_eta_phi_r04_proj[i]->SetStats(0);
322  jet_eta_phi_r04_proj[i]->SetTitle(Form("Jet Eta-Phi R04 [%s]", cent_labels[i].c_str()));
323  jet_eta_phi_r04_proj[i]->GetListOfFunctions()->Add(leg4);
324  jet_eta_phi_r04_proj[i]->Write(Form("Jet_Eta_Phi_R04_%s", cent_labels[i].c_str()));
325  }
326  }
327 
328 
329  std::cout << "JetKinematicCheck::End(PHCompositeNode *topNode) This is the End..." << std::endl;
331 }
332 
333 //____________________________________________________________________________..
335 {
336  std::cout << "JetKinematicCheck::Reset(PHCompositeNode *topNode) being Reset" << std::endl;
338 }
339 
340 //____________________________________________________________________________..
341 void JetKinematicCheck::Print(const std::string &what) const
342 {
343  std::cout << "JetKinematicCheck::Print(const std::string &what) const Printing info for " << what << std::endl;
344 }