Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
JetSeedCount.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file JetSeedCount.cc
1 #include <iostream>
2 #include "JetSeedCount.h"
3 
6 
8 #include <phool/getClass.h>
9 
10 #include <g4jets/JetMap.h>
11 #include <g4jets/Jetv1.h>
12 
14 #include <ffaobjects/EventHeader.h>
16 
17 #include <calobase/RawTower.h>
18 #include <calobase/RawTowerContainer.h>
19 #include <calobase/RawTowerGeom.h>
20 #include <calobase/RawTowerGeomContainer.h>
21 
23 
24 //#include <TTree.h>
25 #include <TCanvas.h>
26 #include <TH2.h>
27 
28 JetSeedCount::JetSeedCount(const std::string& recojetname, const std::string& truthjetname, const std::string& outputfilename):
29  SubsysReco("JetSeedCount_" + recojetname + " " + truthjetname)
30  , m_recoJetName(recojetname)
31  , m_truthJetName(truthjetname)
32  , m_outputFileName(outputfilename)
33  , m_etaRange(-1,1)
34  , m_ptRange(5, 100)
35 {
36  //std::cout << "JetSeedCount::JetSeedCount(const std::string &name) Calling ctor" << std::endl;
37 }
38 
40 {
41  //std::cout << "JetSeedCount::~JetSeedCount() Calling dtor" << std::endl;
42 }
43 
44 //____________________________________________________________________________..
46 {
47  std::cout << "JetSeedCount::Init(PHCompositeNode *topNode) Initializing" << std::endl;
48  std::cout << "Opening output file named " << m_outputFileName << std::endl;
50 
52 }
53 
54 //____________________________________________________________________________..
56 {
57  std::cout << "JetSeedCount::InitRun(PHCompositeNode *topNode) Initializing for Run XXX" << std::endl;
59 }
60 
61 //____________________________________________________________________________..
63 {
64  //std::cout << "JetSeedCount::process_event(PHCompositeNode *topNode) Processing Event" << std::endl;
65  ++m_event;
66  /*
67  if((m_event % 100) == 0){
68  std::cout << "Event number = " << m_event << std::endl;
69  }
70 
71  JetMap* jets = findNode::getClass<JetMap>(topNode, m_recoJetName);
72  if(!jets){
73  std::cout << "JetSeedCount::process_event - Error can not find jets" << std::endl;
74  exit(-1);
75  }
76  */
77 
78  // Calling Raw Jet Seeds
79  JetMap* seedjetsraw = findNode::getClass<JetMap>(topNode, "AntiKt_TowerInfo_HIRecoSeedsRaw_r02");
80  if (!seedjetsraw){
81  std::cout << "JetSeedCount::process_event - Error can not find DST raw seed jets" << std::endl;
82  exit(-1);
83  }
84 
85  // Calling Sub jet Seeds
86  JetMap* seedjetssub = findNode::getClass<JetMap>(topNode, "AntiKt_TowerInfo_HIRecoSeedsSub_r02");
87  if (!seedjetssub){
88  std::cout << "JetSeedCount::process_event - Error can not find DST sub seed jets" << std::endl;
89  exit(-1);
90  }
91 
92  // Calling Centrality Info
93  CentralityInfo* cent_node = findNode::getClass<CentralityInfo>(topNode, "CentralityInfo");
94  if (!cent_node){
95  std::cout << "JetSeedCount::process_event - Error can not find CentralityInfo" << std::endl;
96  exit(-1);
97  }
98 
99  // Saving Centrality Info
100  //float cent_epd = cent_node->get_centile(CentralityInfo::PROP::epd_NS);
101  float cent_mbd = cent_node->get_centile(CentralityInfo::PROP::mbd_NS);
102 
103  m_centrality.push_back(cent_mbd);
104  //m_centrality_diff.push_back(cent_mbd);
105  //std::cout << cent_node->get_centile(CentralityInfo::PROP::mbd_NS) << std::endl;
106 
107  //Raw Seed Count
108  m_seed_raw = 0;
109  for (JetMap::Iter iter = seedjetsraw->begin(); iter != seedjetsraw->end(); ++iter){
110  Jet* jet = iter->second;
111  int passesCut = jet->get_property(Jet::PROPERTY::prop_SeedItr);
112  if (passesCut == 1){
113  m_rawenergy.push_back(jet->get_e());
114  m_rawcent.push_back(cent_mbd);
115  m_seed_raw++;
116  }
117  }
118  m_raw_counts.push_back(m_seed_raw);
119 
120  //Sub Seed Count
121  m_seed_sub = 0;
122  for (JetMap::Iter iter = seedjetssub->begin(); iter != seedjetssub->end(); ++iter){
123  Jet* jet = iter->second;
124  int passesCut = jet->get_property(Jet::PROPERTY::prop_SeedItr);
125  if (passesCut == 2){
126  m_subenergy.push_back(jet->get_e());
127  m_subcent.push_back(cent_mbd);
128  m_seed_sub++;
129  }
130  }
131 
132  //Checks
133  /*
134  if(m_seed_raw < m_seed_sub){
135  std::cout<<"Event " << m_event << " has more raw seeds then sub seeds" << std::endl;
136  std::cout<<"This Event has " << m_seed_raw << " raw seeds and " << m_seed_sub << " sub seeds" << std::endl;
137  std::cout<<"The Centrality of this Event is " << cent_mbd << std::endl;
138  }
139 
140  if(m_seed_sub > 10){
141  std::cout<<"Event " << m_event << " has more than 10 sub seeds" << std::endl;
142  std::cout<<"This Event has " << m_seed_raw << " raw seeds and " << m_seed_sub << " sub seeds" << std::endl;
143  //std::cout<<"The Centrality of this Event is " << cent_mbd << std::endl;
144  }
145  */
146  m_sub_counts.push_back(m_seed_sub);
148 }
149 
150 
151 //____________________________________________________________________________..
153 {
154  //std::cout << "JetSeedCount::ResetEvent(PHCompositeNode *topNode) Resetting internal structures, prepare for next event" << std::endl;
156 }
157 
158 //____________________________________________________________________________..
160 {
161  //std::cout << "JetSeedCount::EndRun(const int runnumber) Ending Run for Run " << runnumber << std::endl;
163 }
164 
165 //____________________________________________________________________________..
167 {
168  std::cout << "JetSeedCount::End(PHCompositeNode *topNode) This is the End..." << std::endl;
170 
171  // Saving Histos
172  TH1F *hRawSeedCount = new TH1F("hRawSeedCount", "Raw Seed Count per Event", 100, 0.00, 50.00);
173  hRawSeedCount->GetXaxis()->SetTitle("Raw Seed Count per Event");
174  hRawSeedCount->GetYaxis()->SetTitle("Number of Entries");
175  for (int j = 0; j < (int)m_raw_counts.size(); j++){
176  hRawSeedCount->Fill(m_raw_counts.at(j));
177  }
178 
179  TH1F *hSubSeedCount = new TH1F("hSubSeedCount", "Sub Seed Count per Event", 100, 0.00, 50.00);
180  hSubSeedCount->GetXaxis()->SetTitle("Sub Seed Count per Event");
181  hSubSeedCount->GetYaxis()->SetTitle("Number of Entries");
182  for (int j = 0; j < (int)m_sub_counts.size(); j++){
183  hSubSeedCount->Fill(m_sub_counts.at(j));
184  }
185 
186  TH2F *hRawSeedEnergyVsCent = new TH2F("hRawSeedEnergyVsCent", "Raw Seed Energy Vs Centrality", 10.00, 0.00, 100.00, 100, 0.00, 50.00);
187  hRawSeedEnergyVsCent->GetXaxis()->SetTitle("Centrality");
188  hRawSeedEnergyVsCent->GetYaxis()->SetTitle("RawSeedEnergy");
189  for (int j = 0; j < (int)m_rawenergy.size(); j++){
190  hRawSeedEnergyVsCent->Fill(m_rawcent.at(j), m_rawenergy.at(j));
191  }
192 
193  TH2F *hSubSeedEnergyVsCent = new TH2F("hSubSeedEnergyVsCent", "Sub Seed Energy Vs Centrality", 10.00, 0.00, 100.00, 100, 0.00, 50.00);
194  hSubSeedEnergyVsCent->GetXaxis()->SetTitle("Centrality");
195  hSubSeedEnergyVsCent->GetYaxis()->SetTitle("SubSeedEnergy");
196  for (int j = 0; j < (int)m_subenergy.size(); j++){
197  hSubSeedEnergyVsCent->Fill(m_subcent.at(j), m_subenergy.at(j));
198  }
199  /*
200  TH1F *hCentEpd = new TH1F("hCentEpd", "hCentEpd", 10, 0.00, 100.00);
201  hCentEpd->GetXaxis()->SetTitle("Centrality (Epd)");
202  hCentEpd->GetYaxis()->SetTitle("Number of Entries");
203  for (int j = 0; j < (int)m_centrality.size(); j++){
204  hCentEpd->Fill(m_centrality.at(j));
205  }
206  */
207  TH1F *hCentMbd = new TH1F("hCentMbd", "hCentMbd", 10, 0.00, 100.00);
208  hCentMbd->GetXaxis()->SetTitle("Centrality (Mbd)");
209  hCentMbd->GetYaxis()->SetTitle("Number of Entries");
210  for (int j = 0; j < (int)m_centrality.size(); j++){
211  hCentMbd->Fill(m_centrality.at(j));
212  }
213 
214  TH2F *hRawSeedVsCent = new TH2F("hRawSeedVsCent", "Raw Seed Vs Centrality", 10, 0.00, 100.00, 10, 0.00, 100.00);
215  hRawSeedVsCent->GetXaxis()->SetTitle("Centrality");
216  hRawSeedVsCent->GetYaxis()->SetTitle("Raw Seed Count");
217  //std::cout << (int)m_centrality.size() << std::endl;
218  for (int j = 0; j < (int)m_raw_counts.size(); j++){
219  //std::cout << m_centrality.at(j) << " " << m_raw_counts.at(j) << std::endl;
220  hRawSeedVsCent->Fill(m_centrality.at(j), m_raw_counts.at(j));
221  }
222 
223  /*
224  TH2F *hCentEpdVsCentMbd = new TH2F("hCentEpdVsCentMbd", "Cent Epd Vs Cent Mbd", 10, 0.00, 100.00, 10, 0.00, 100.00);
225  hCentEpdVsCentMbd->GetXaxis()->SetTitle("Centrality Epd");
226  hCentEpdVsCentMbd->GetYaxis()->SetTitle("Centrality Mbd");
227  for (int j = 0; j < (int)m_centrality.size(); j++){
228  //std::cout << m_centrality.at(j) << " " << m_sub_counts.at(j) << std::endl;
229  hCentEpdVsCentMbd->Fill(m_centrality.at(j), m_centrality_diff.at(j));
230  }
231  */
232 
233  TH2F *hSubSeedVsCent = new TH2F("hSubSeedVsCent", "Sub Seed Vs Centrality", 10, 0.00, 100.00, 100, 0.00, 100.00);
234  hSubSeedVsCent->GetXaxis()->SetTitle("Centrality");
235  hSubSeedVsCent->GetYaxis()->SetTitle("Sub Seed Count");
236  for (int j = 0; j < (int)m_sub_counts.size(); j++){
237  //std::cout << m_centrality.at(j) << " " << m_sub_counts.at(j) << std::endl;
238  hSubSeedVsCent->Fill(m_centrality.at(j), m_sub_counts.at(j));
239  }
240 
241  hRawSeedCount->Write();
242  hSubSeedCount->Write();
243  hRawSeedEnergyVsCent->Write();
244  hSubSeedEnergyVsCent->Write();
245  hCentMbd->Write();
246  //hCentEpd->Write();
247  hRawSeedVsCent->Write();
248  hSubSeedVsCent->Write();
249  //hCentEpdVsCentMbd->Write();
250 
252 
253 }
254 
255 //____________________________________________________________________________..
257 {
258  //std::cout << "JetSeedCount::Reset(PHCompositeNode *topNode) being Reset" << std::endl;
260 }
261 
262 //____________________________________________________________________________..
263 void JetSeedCount::Print(const std::string &what) const
264 {
265  //std::cout << "JetSeedCount::Print(const std::string &what) const Printing info for " << what << std::endl;
266 }