Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SEnergyCorrelator.io.h
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file SEnergyCorrelator.io.h
1 // ----------------------------------------------------------------------------
2 // 'SEnergyCorrelator.io.h'
3 // Derek Anderson
4 // 01.27.2023
5 //
6 // A module to implement Peter Komiske's EEC library
7 // in the sPHENIX software stack for the Cold QCD
8 // Energy-Energy Correlator analysis.
9 // ----------------------------------------------------------------------------
10 
11 #pragma once
12 
13 using namespace std;
14 
15 
16 
17 namespace SColdQcdCorrelatorAnalysis {
18 
19  // i/o methods --------------------------------------------------------------
20 
21  void SEnergyCorrelator::SetInputTree(const string &iTreeName, const bool isTruthTree, const bool isEmbedTree) {
22 
23  // print debug statemet
24  if (m_inDebugMode) PrintDebug(18);
25 
26  m_inTreeName = iTreeName;
27  m_isInputTreeTruth = isTruthTree;
28  m_isInputTreeEmbed = isEmbedTree;
29  return;
30 
31  } // end 'SetInputTree(string&, bool)'
32 
33 
34 
35  void SEnergyCorrelator::SetJetParameters(const vector<pair<double, double>> &pTjetBins, const pair<double, double> etaJetRange) {
36 
37  // print debug statement
38  if (m_inDebugMode) PrintDebug(20);
39 
40  m_etaJetRange = etaJetRange;
41  m_nBinsJetPt = pTjetBins.size();
42  for (uint32_t iPtBin = 0; iPtBin < m_nBinsJetPt; iPtBin++) {
43  const double minPt = pTjetBins.at(iPtBin).first;
44  const double maxPt = pTjetBins.at(iPtBin).second;
45  const pair<double, double> ptBin = {minPt, maxPt};
46  m_ptJetBins.push_back(ptBin);
47  }
48  m_ptJetRange.first = m_ptJetBins[0].first;
49  m_ptJetRange.second = m_ptJetBins[m_nBinsJetPt - 1].second;
50 
51  // announce jet parameters
52  if (m_inStandaloneMode) PrintMessage(6);
53  return;
54 
55  } // end 'SetJetParameters(vector<pair<double, double>>&, pair<double, double>)'
56 
57 
58 
59  void SEnergyCorrelator::SetConstituentParameters(const pair<double, double> momCstRange, const pair<double, double> drCstRange, const bool applyCstCuts) {
60 
61  // print debug statement
62  if (m_inDebugMode) PrintDebug(24);
63 
64  m_momCstRange = momCstRange;
65  m_drCstRange = drCstRange;
66  m_applyCstCuts = applyCstCuts;
67 
68  // announce cst parameters
69  if (m_inStandaloneMode) PrintMessage(12);
70  return;
71 
72  } // end 'SetConstituentParameters(pair<double, double>, pair<double, double>)'
73 
74 
75 
76  void SEnergyCorrelator::SetCorrelatorParameters(const uint32_t nPointCorr, const uint64_t nBinsDr, const pair<double, double> drBinRange) {
77 
78  // print debug statement
79  if (m_inDebugMode) PrintDebug(19);
80 
81  m_nPointCorr = nPointCorr;
82  m_nBinsDr = nBinsDr;
83  m_drBinRange = drBinRange;
84 
85  // announce correlator parameters
86  if (m_inStandaloneMode) PrintMessage(5);
87  return;
88 
89  } // end 'SetCorrelatorParameters(uint32_t, uint64_t, pair<double, double>)'
90 
91 
92 
93  void SEnergyCorrelator::SetSubEventsToUse(const uint16_t subEvtOpt, const vector<int> vecSubEvtsToUse) {
94 
95  // print debug statement
96  if (m_inDebugMode) PrintDebug(32);
97 
98  // parse options
99  m_subEvtOpt = subEvtOpt;
100  if (m_subEvtOpt != 0) {
101  m_selectSubEvts = true;
102  }
103 
104  // if vector isn't empty, load specific emebedding IDs and set flags accordingly
105  if (vecSubEvtsToUse.size() > 0) {
106  m_selectSubEvts = true;
107  m_subEvtOpt = 5;
108  for (const int subEvtToUse : vecSubEvtsToUse) {
109  m_subEvtsToUse.push_back(subEvtToUse);
110  }
111  }
112 
113  // announce sub-events being used
114  if (m_inStandaloneMode) PrintMessage(15);
115  return;
116 
117  } // end 'SetSubEventsToUse(uint16_t, vector<int>)'
118 
119 
120 
121  void SEnergyCorrelator::GrabInputNode() {
122 
123  // print debug statement
124  if (m_inDebugMode) PrintDebug(3);
125 
126  /* TODO method goes here */
127  return;
128 
129  } // end 'GrabInputNode()'
130 
131 
132 
133  void SEnergyCorrelator::OpenInputFiles() {
134 
135  // print debug statement
136  if (m_inDebugMode) PrintDebug(11);
137 
138  // insantiate input chain
139  m_inChain = new TChain(m_inTreeName.data());
140  if (!m_inChain) {
141  PrintError(6);
142  assert(m_inChain);
143  }
144 
145  // loop over provided input files
146  bool isFileGood = true;
147  uint64_t bytes = 0;
148  for (const string& inFileName : m_inFileNames) {
149  bytes = m_inChain -> Add(inFileName.data(), 0);
150  isFileGood = (bytes > 0);
151  if (!isFileGood) {
152  PrintError(7, 0, 0, inFileName);
153  assert(isFileGood);
154  }
155  } // end input file loop
156  return;
157 
158  } // end 'OpenInputFile()'
159 
160 
161 
162  void SEnergyCorrelator::OpenOutputFile() {
163 
164  // print debug statement
165  if (m_inDebugMode) PrintDebug(15);
166 
167  // open file
168  m_outFile = new TFile(m_outFileName.data(), "recreate");
169  if (!m_outFile) {
170  PrintError(11);
171  assert(m_outFile);
172  }
173  return;
174 
175  } // end 'OpenOutputFile()'
176 
177 
178 
179  void SEnergyCorrelator::SaveOutput() {
180 
181  // print debug statement
182  if (m_inDebugMode) PrintDebug(9);
183 
184  m_outFile -> cd();
185  for (size_t iPtBin = 0; iPtBin < m_nBinsJetPt; iPtBin++) {
186  m_outHistVarDrAxis[iPtBin] -> Write();
187  m_outHistErrDrAxis[iPtBin] -> Write();
188  m_outHistVarLnDrAxis[iPtBin] -> Write();
189  m_outHistErrLnDrAxis[iPtBin] -> Write();
190  }
191 
192  // for weird cst check
193  if (m_doSecondCstLoop) {
194  m_outFile -> cd();
195  hCstPtOneVsDr -> Write();
196  hCstPtTwoVsDr -> Write();
197  hCstPtFracVsDr -> Write();
198  hCstPhiOneVsDr -> Write();
199  hCstPhiTwoVsDr -> Write();
200  hCstEtaOneVsDr -> Write();
201  hCstEtaTwoVsDr -> Write();
202  hDeltaPhiOneVsDr -> Write();
203  hDeltaPhiTwoVsDr -> Write();
204  hDeltaEtaOneVsDr -> Write();
205  hDeltaEtaTwoVsDr -> Write();
206  hJetPtFracOneVsDr -> Write();
207  hJetPtFracTwoVsDr -> Write();
208  hCstPairWeightVsDr -> Write();
209  }
210 
211  // announce saving
212  if (m_inStandaloneMode) PrintMessage(10);
213  return;
214 
215  } // end 'SaveOutput()'
216 
217 
218 
219  void SEnergyCorrelator::CloseOutputFile() {
220 
221  // print debug statement
222  if (m_inDebugMode) PrintDebug(30);
223 
224  // close file
225  m_outFile -> cd();
226  m_outFile -> Close();
227  return;
228 
229  } // end 'CloseOutputFile()'
230 
231 } // end SColdQcdCorrelatorAnalysis namespace
232 
233 // end ------------------------------------------------------------------------