Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SCorrelatorJetTree.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file SCorrelatorJetTree.cc
1 // ----------------------------------------------------------------------------
2 // 'SCorrelatorJetTree.cc'
3 // Derek Anderson
4 // 12.04.2022
5 //
6 // A module to produce a tree of jets for the sPHENIX
7 // Cold QCD Energy-Energy Correlator analysis.
8 //
9 // Derived from code by Antonio Silva (thanks!!)
10 // ----------------------------------------------------------------------------
11 
12 #define SCORRELATORJETTREE_CC
13 
14 // user includes
15 #include "SCorrelatorJetTree.h"
16 #include "SCorrelatorJetTree.io.h"
17 #include "SCorrelatorJetTree.evt.h"
18 #include "SCorrelatorJetTree.jet.h"
19 #include "SCorrelatorJetTree.cst.h"
20 #include "SCorrelatorJetTree.sys.h"
21 
22 using namespace std;
23 using namespace fastjet;
24 using namespace findNode;
25 
26 
27 
28 namespace SColdQcdCorrelatorAnalysis {
29 
30  // ctor/dtor ----------------------------------------------------------------
31 
32  SCorrelatorJetTree::SCorrelatorJetTree(const string& name, const string& outFile, const bool isMC, const bool isEmbed, const bool debug) : SubsysReco(name) {
33 
34  // print debug statement
35  m_isMC = isMC;
36  m_isEmbed = isEmbed;
37  m_doDebug = debug;
38  if (m_doDebug) {
39  cout << "SCorrelatorJetTree::SCorrelatorJetTree(string, string, bool, bool, bool) Calling ctor" << endl;
40  }
41  m_outFileName = outFile;
42  InitVariables();
43 
44  } // end ctor(string&, string&, bool, bool, bool)
45 
46 
47 
49 
50  // print debug statement
51  if (m_doDebug) {
52  cout << "SCorrelatorJetTree::~SCorrelatorJetTree() Calling dtor" << endl;
53  }
54 
55  // clean up dangling pointers
56  if (m_histMan) {
57  delete m_histMan;
58  m_histMan = NULL;
59  }
60  if (m_evalStack) {
61  delete m_evalStack;
62  m_evalStack = NULL;
63  m_trackEval = NULL;
64  }
65  if (m_trueJetDef) {
66  delete m_trueJetDef;
67  m_trueJetDef = NULL;
68  }
69  if (m_recoJetDef) {
70  delete m_recoJetDef;
71  m_recoJetDef = NULL;
72  }
73  if (m_trueClust) {
74  delete m_trueClust;
75  m_trueClust = NULL;
76  }
77  if (m_recoClust) {
78  delete m_recoClust;
79  m_recoClust = NULL;
80  }
81 
82  } // end dtor
83 
84 
85 
86  // F4A methods --------------------------------------------------------------
87 
89 
90  // print debug statement
91  if (m_doDebug || (Verbosity() > 1)) {
92  cout << "SCorrelatorJetTree::Init(PHCompositeNode*) Initializing..." << endl;
93  }
94 
95  // intitialize output file
96  m_outFile = new TFile(m_outFileName.c_str(), "RECREATE");
97  if (!m_outFile) {
98  cerr << "PANIC: couldn't open SCorrelatorJetTree output file!" << endl;
99  }
100 
101  // create node for jet-tree
102  if (m_saveDST) {
103  CreateJetNode(topNode);
104  }
105 
106  // initialize QA histograms/tuples, output trees, and functions
107  InitHists();
108  InitTuples();
109  InitTrees();
110  InitFuncs();
112 
113  } // end 'Init(PHcompositeNode*)'
114 
115 
116 
118 
119  // print debug statement
120  if (m_doDebug || (Verbosity() > 1)) {
121  cout << "SCorrelatorJetTree::process_event(PHCompositeNode*) Processing Event..." << endl;
122  }
123 
124  // reset event-wise variables & members
125  ResetVariables();
126 
127  // initialize evaluator & determine subevts to grab for event
128  if (m_isMC) {
129  InitEvals(topNode);
130  DetermineEvtsToGrab(topNode);
131  }
132 
133  // get event-wise variables
134  GetEventVariables(topNode);
135  if (m_isMC) {
136  GetPartonInfo(topNode);
137  }
138 
139  // check if reconstructed vertex is in in acceptance
140  bool isGoodEvt = true;
141  if (m_doVtxCut) {
142  isGoodEvt = IsGoodVertex(m_recoVtx);
143  }
144 
145  // set event status
146  int eventStatus = Fun4AllReturnCodes::EVENT_OK;
147  if (m_doVtxCut && !isGoodEvt) {
148  eventStatus = Fun4AllReturnCodes::DISCARDEVENT;
149  } else {
150  eventStatus = Fun4AllReturnCodes::EVENT_OK;
151  }
152 
153  // if event is good, continue processing
154  if (isGoodEvt) {
155 
156  // find jets
157  FindRecoJets(topNode);
158  if (m_isMC) {
159  FindTrueJets(topNode);
160  }
161 
162  // fill output trees
163  FillRecoTree();
164  if (m_isMC) {
165  FillTrueTree();
166  }
167  }
168  return eventStatus;
169 
170  } // end 'process_event(PHCompositeNode*)'
171 
172 
173 
175 
176  // print debug statements
177  if (m_doDebug || (Verbosity() > 1)) {
178  cout << "SCorrelatorJetTree::End(PHCompositeNode*) This is the End..." << endl;
179  }
180 
181  // save output and close
182  SaveOutput();
183  m_outFile -> cd();
184  m_outFile -> Close();
186 
187  } // end 'End(PHcompositeNode*)'
188 
189 } // end SColdQcdCorrelatorAnalysis namespace
190 
191 // end ------------------------------------------------------------------------