Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
UEvsEtaCentrality.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file UEvsEtaCentrality.cc
1 //____________________________________________________________________________..
2 //
3 // This is a template for a Fun4All SubsysReco module with all methods from the
4 // $OFFLINE_MAIN/include/fun4all/SubsysReco.h baseclass
5 // You do not have to implement all of them, you can just remove unused methods
6 // here and in UEvsEtaCentrality.h.
7 //
8 // UEvsEtaCentrality(const std::string &name = "UEvsEtaCentrality")
9 // everything is keyed to UEvsEtaCentrality, duplicate names do work but it makes
10 // e.g. finding culprits in logs difficult or getting a pointer to the module
11 // from the command line
12 //
13 // UEvsEtaCentrality::~UEvsEtaCentrality()
14 // this is called when the Fun4AllServer is deleted at the end of running. Be
15 // mindful what you delete - you do loose ownership of object you put on the node tree
16 //
17 // int UEvsEtaCentrality::Init(PHCompositeNode *topNode)
18 // This method is called when the module is registered with the Fun4AllServer. You
19 // can create historgrams here or put objects on the node tree but be aware that
20 // modules which haven't been registered yet did not put antyhing on the node tree
21 //
22 // int UEvsEtaCentrality::InitRun(PHCompositeNode *topNode)
23 // This method is called when the first event is read (or generated). At
24 // this point the run number is known (which is mainly interesting for raw data
25 // processing). Also all objects are on the node tree in case your module's action
26 // depends on what else is around. Last chance to put nodes under the DST Node
27 // We mix events during readback if branches are added after the first event
28 //
29 // int UEvsEtaCentrality::process_event(PHCompositeNode *topNode)
30 // called for every event. Return codes trigger actions, you find them in
31 // $OFFLINE_MAIN/include/fun4all/Fun4AllReturnCodes.h
32 // everything is good:
33 // return Fun4AllReturnCodes::EVENT_OK
34 // abort event reconstruction, clear everything and process next event:
35 // return Fun4AllReturnCodes::ABORT_EVENT;
36 // proceed but do not save this event in output (needs output manager setting):
37 // return Fun4AllReturnCodes::DISCARD_EVENT;
38 // abort processing:
39 // return Fun4AllReturnCodes::ABORT_RUN
40 // all other integers will lead to an error and abort of processing
41 //
42 // int UEvsEtaCentrality::ResetEvent(PHCompositeNode *topNode)
43 // If you have internal data structures (arrays, stl containers) which needs clearing
44 // after each event, this is the place to do that. The nodes under the DST node are cleared
45 // by the framework
46 //
47 // int UEvsEtaCentrality::EndRun(const int runnumber)
48 // This method is called at the end of a run when an event from a new run is
49 // encountered. Useful when analyzing multiple runs (raw data). Also called at
50 // the end of processing (before the End() method)
51 //
52 // int UEvsEtaCentrality::End(PHCompositeNode *topNode)
53 // This is called at the end of processing. It needs to be called by the macro
54 // by Fun4AllServer::End(), so do not forget this in your macro
55 //
56 // int UEvsEtaCentrality::Reset(PHCompositeNode *topNode)
57 // not really used - it is called before the dtor is called
58 //
59 // void UEvsEtaCentrality::Print(const std::string &what) const
60 // Called from the command line - useful to print information when you need it
61 //
62 //____________________________________________________________________________..
63 
64 #include "UEvsEtaCentrality.h"
65 
67 #include <fun4all/PHTFileServer.h>
68 
69 #include <phool/PHCompositeNode.h>
70 
71 #include <phool/PHCompositeNode.h>
72 #include <phool/getClass.h>
73 
74 #include <g4jets/JetMap.h>
75 #include <g4jets/Jetv1.h>
76 
78 
79 #include <calobase/RawTower.h>
80 #include <calobase/RawTowerContainer.h>
81 #include <calobase/RawTowerGeom.h>
82 #include <calobase/RawTowerGeomContainer.h>
83 #include <calobase/TowerInfoContainer.h>
84 #include <calobase/TowerInfo.h>
85 
87 
88 #include <TTree.h>
89 #include <TH1F.h>
90 #include <TH2F.h>
91 //____________________________________________________________________________..
93 : SubsysReco(name)
94  , m_outputFileName(outputfilename)
95 {
96  std::cout << "UEvsEtaCentrality::UEvsEtaCentrality(const std::string &name) Calling ctor" << std::endl;
97 }
98 
99 //____________________________________________________________________________..
101 {
102  std::cout << "UEvsEtaCentrality::~UEvsEtaCentrality() Calling dtor" << std::endl;
103 }
104 
105 //____________________________________________________________________________..
107 {
108  std::cout << "UEvsEtaCentrality::Init(PHCompositeNode *topNode) Initializing" << std::endl;
109 
111  std::cout << "MyJetAnalysis::Init - Outoput to " << m_outputFileName << std::endl;
112 
114 
115  hv2_cent = new TH2F("hv2_cent","",10,0,100,50,0,0.5);
116  hPsi2_cent = new TH2F("hPsi2_cent","",10,0,100,50,-1.57,1.57);
117  hUEiHcalEta_Cent0_20 = new TH2F("hUEiHcalEta_Cent0_20", "", 24, -1.1,1.1, 48, 0, 0.25);
118  hUEoHcalEta_Cent0_20 = new TH2F("hUEoHcalEta_Cent0_20", "", 24, -1.1,1.1, 48, 0, 0.5);
119  hUEemcalEta_Cent0_20 = new TH2F("hUEemcalEta_Cent0_20", "", 24, -1.1,1.1, 48, 0, 1.5);
120 
121  hUEiHcalEta_Cent20_50 = new TH2F("hUEiHcalEta_Cent20_50", "", 24, -1.1,1.1, 48, 0, 0.25);
122  hUEoHcalEta_Cent20_50 = new TH2F("hUEoHcalEta_Cent20_50", "", 24, -1.1,1.1, 48, 0, 0.5);
123  hUEemcalEta_Cent20_50 = new TH2F("hUEemcalEta_Cent20_50", "", 24, -1.1,1.1, 48, 0, 1.5);
124 
125  hUEiHcalEta_Cent50_100 = new TH2F("hUEiHcalEta_Cent50_100", "", 24, -1.1,1.1, 48, 0, 0.25);
126  hUEoHcalEta_Cent50_100 = new TH2F("hUEoHcalEta_Cent50_100", "", 24, -1.1,1.1, 48, 0, 0.5);
127  hUEemcalEta_Cent50_100 = new TH2F("hUEemcalEta_Cent50_100", "", 24, -1.1,1.1, 48, 0, 1.5);
128 
130 }
131 
132 //____________________________________________________________________________..
134 {
135  std::cout << "UEvsEtaCentrality::InitRun(PHCompositeNode *topNode) Initializing for Run XXX" << std::endl;
137 }
138 
139 //____________________________________________________________________________..
141 {
142 
143  //centrality
144  CentralityInfo* cent_node = findNode::getClass<CentralityInfo>(topNode, "CentralityInfo");
145  if (!cent_node)
146  {
147  std::cout
148  << "MyJetAnalysis::process_event - Error can not find centrality node "
149  << std::endl;
150  exit(-1);
151  }
152 
153 
154 
155  //calorimeter towers
156  TowerInfoContainer *towersEM3 = findNode::getClass<TowerInfoContainer>(topNode, "TOWERINFO_CALIB_CEMC_RETOWER");
157  TowerInfoContainer *towersIH3 = findNode::getClass<TowerInfoContainer>(topNode, "TOWERINFO_CALIB_HCALIN");
158  TowerInfoContainer *towersOH3 = findNode::getClass<TowerInfoContainer>(topNode, "TOWERINFO_CALIB_HCALOUT");
159  RawTowerGeomContainer *tower_geom = findNode::getClass<RawTowerGeomContainer>(topNode, "TOWERGEOM_HCALIN");
160  RawTowerGeomContainer *tower_geomOH = findNode::getClass<RawTowerGeomContainer>(topNode, "TOWERGEOM_HCALOUT");
161  if(!towersEM3 || !towersIH3 || !towersOH3){
162  std::cout
163  <<"MyJetAnalysis::process_event - Error can not find raw tower node "
164  << std::endl;
165  exit(-1);
166  }
167 
168  if(!tower_geom || !tower_geomOH){
169  std::cout
170  <<"MyJetAnalysis::process_event - Error can not find raw tower geometry "
171  << std::endl;
172  exit(-1);
173  }
174 
175  //underlying event
176  TowerBackground *background = findNode::getClass<TowerBackground>(topNode, "TowerInfoBackground_Sub2");
177  if(!background){
178  std::cout<<"Can't get background. Exiting"<<std::endl;
180  }
181 
182  float background_v2 = 0;
183  float background_Psi2 = 0;
184  float m_centrality = 0;
185 
186  m_centrality = cent_node->get_centile(CentralityInfo::PROP::epd_NS);
187  background_v2 = background->get_v2();
188  background_Psi2 = background->get_Psi2();
189 
190  hv2_cent->Fill(m_centrality, background_v2);
191  hPsi2_cent->Fill(m_centrality, background_Psi2);
192 
193  int i=0;
194  for (i=0;i<=23;i++){
195 
196 
197 
198  float UEi = background->get_UE(1).at(i); //24 eta bins for each detector Inner Hcal
199  float UEo = background->get_UE(2).at(i); //24 eta bins for each detector, Outer Hcal
200  float UEe = background->get_UE(0).at(i); //24 eta bins for each detector, EMCal
201 
202  double eta = tower_geom->get_etacenter(i);
203 
204  if (m_centrality > 0 && m_centrality <= 20){
205  hUEiHcalEta_Cent0_20->Fill(eta, UEi);
206  hUEoHcalEta_Cent0_20->Fill(eta, UEo);
207  hUEemcalEta_Cent0_20->Fill(eta, UEe);
208  }
209  if (m_centrality > 20 && m_centrality <= 50){
210  hUEiHcalEta_Cent20_50->Fill(eta, UEi);
211  hUEoHcalEta_Cent20_50->Fill(eta, UEo);
212  hUEemcalEta_Cent20_50->Fill(eta, UEe);
213  }
214 
215  if (m_centrality > 50 && m_centrality <= 100){
216  hUEiHcalEta_Cent50_100->Fill(eta, UEi);
217  hUEoHcalEta_Cent50_100->Fill(eta, UEo);
218  hUEemcalEta_Cent50_100->Fill(eta, UEe);
219  }
220 
221 
222  }
223 
224 
225 
226  // std::cout << "UEvsEtaCentrality::process_event(PHCompositeNode *topNode) Processing Event" << std::endl;
228 }
229 
230 //____________________________________________________________________________..
232 {
233  // std::cout << "UEvsEtaCentrality::ResetEvent(PHCompositeNode *topNode) Resetting internal structures, prepare for next event" << std::endl;
234 
235  // IMPORTANT!! CLEAR YOUR VECTORS AND RESET YOUR TREE VARIABLES HERE!!
236 
238 }
239 
240 //____________________________________________________________________________..
242 {
243  std::cout << "UEvsEtaCentrality::EndRun(const int runnumber) Ending Run for Run " << runnumber << std::endl;
245 }
246 
247 //____________________________________________________________________________..
249 {
250  std::cout << "MyJetAnalysis::End - Output to " << m_outputFileName << std::endl;
252 
253  hv2_cent->Write();
254  hPsi2_cent->Write();
255  hUEiHcalEta_Cent0_20->Write();
256  hUEoHcalEta_Cent0_20->Write();
257  hUEemcalEta_Cent0_20->Write();
258  hUEiHcalEta_Cent20_50->Write();
259  hUEoHcalEta_Cent20_50->Write();
260  hUEemcalEta_Cent20_50->Write();
261  hUEiHcalEta_Cent50_100->Write();
262  hUEoHcalEta_Cent50_100->Write();
263  hUEemcalEta_Cent50_100->Write();
264  std::cout << "UEvsEtaCentrality::End(PHCompositeNode *topNode) This is the End..." << std::endl;
266 }
267 
268 //____________________________________________________________________________..
270 {
271  std::cout << "UEvsEtaCentrality::Reset(PHCompositeNode *topNode) being Reset" << std::endl;
273 }
274 
275 //____________________________________________________________________________..
276 void UEvsEtaCentrality::Print(const std::string &what) const
277 {
278  std::cout << "UEvsEtaCentrality::Print(const std::string &what) const Printing info for " << what << std::endl;
279 }