Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
FlowTools.h
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file FlowTools.h
1 // ----------------------------------------------------------------------------
2 // 'FlowTools.h'
3 // Derek Anderson
4 // 11.16.2023
5 //
6 // Collection of frequent particle flow-related methods utilized
7 // in the sPHENIX Cold QCD Energy-Energy Correlator analysis.
8 // ----------------------------------------------------------------------------
9 
10 #pragma once
11 
12 // c++ utilities
13 #include <cassert>
14 // f4a libraries
15 #include <fun4all/SubsysReco.h>
16 // phool libraries
17 #include <phool/phool.h>
18 #include <phool/getClass.h>
19 #include <phool/PHIODataNode.h>
20 #include <phool/PHNodeIterator.h>
21 #include <phool/PHCompositeNode.h>
22 // particle flow libraries
23 #include <particleflowreco/ParticleFlowElement.h>
24 #include <particleflowreco/ParticleFlowElementContainer.h>
25 
26 // make common namespaces implicit
27 using namespace std;
28 using namespace findNode;
29 
30 
31 
32 namespace SColdQcdCorrelatorAnalysis {
33  namespace SCorrelatorUtilities {
34 
35  // FlowInfo definition ----------------------------------------------------
36 
37  struct FlowInfo {
38 
39  // data members
40  int id = numeric_limits<int>::max();
41  int type = numeric_limits<int>::max();
42  double mass = numeric_limits<double>::max();
43  double eta = numeric_limits<double>::max();
44  double phi = numeric_limits<double>::max();
45  double ene = numeric_limits<double>::max();
46  double px = numeric_limits<double>::max();
47  double py = numeric_limits<double>::max();
48  double pz = numeric_limits<double>::max();
49  double pt = numeric_limits<double>::max();
50 
51  void SetInfo(const ParticleFlowElement* flow) {
52  id = flow -> get_id();
53  type = flow -> get_type();
54  mass = flow -> get_mass();
55  eta = flow -> get_eta();
56  phi = flow -> get_phi();
57  ene = flow -> get_e();
58  px = flow -> get_px();
59  py = flow -> get_py();
60  pz = flow -> get_pz();
61  pt = flow -> get_pt();
62  return;
63  } // end 'SetInfo(ParticleFlowElement*)'
64 
65  void Reset() {
66  id = numeric_limits<int>::max();
67  type = numeric_limits<int>::max();
68  mass = numeric_limits<double>::max();
69  eta = numeric_limits<double>::max();
70  phi = numeric_limits<double>::max();
71  ene = numeric_limits<double>::max();
72  px = numeric_limits<double>::max();
73  py = numeric_limits<double>::max();
74  pz = numeric_limits<double>::max();
75  pt = numeric_limits<double>::max();
76  return;
77  } // end 'Reset()'
78 
79  static vector<string> GetListOfMembers() {
80  vector<string> members = {
81  "id",
82  "type",
83  "mass",
84  "eta",
85  "phi",
86  "ene",
87  "px",
88  "py",
89  "pz",
90  "pt"
91  };
92  return members;
93  } // end 'GetListOfMembers()'
94 
95  // overloaded < operator
96  friend bool operator<(const FlowInfo& lhs, const FlowInfo& rhs) {
97 
98  // note that some quantities aren't relevant for this comparison
99  const bool isLessThan = (
100  (lhs.mass < rhs.mass) &&
101  (lhs.ene < rhs.ene) &&
102  (lhs.eta < rhs.eta) &&
103  (lhs.phi < rhs.phi) &&
104  (lhs.px < rhs.px) &&
105  (lhs.py < rhs.py) &&
106  (lhs.pz < rhs.pz) &&
107  (lhs.pt < rhs.pt)
108  );
109  return isLessThan;
110 
111  } // end 'operator<(FlowInfo&, FlowInfo&)'
112 
113  // overloaded > operator
114  friend bool operator>(const FlowInfo& lhs, const FlowInfo& rhs) {
115 
116  // note that some quantities aren't relevant for this comparison
117  const bool isGreaterThan = (
118  (lhs.mass > rhs.mass) &&
119  (lhs.ene > rhs.ene) &&
120  (lhs.eta > rhs.eta) &&
121  (lhs.phi > rhs.phi) &&
122  (lhs.px > rhs.px) &&
123  (lhs.py > rhs.py) &&
124  (lhs.pz > rhs.pz) &&
125  (lhs.pt > rhs.pt)
126  );
127  return isGreaterThan;
128 
129  } // end 'operator>(FlowInfo&, FlowInfo&)'
130 
131  // overloaded, <=, >= operators
132  inline friend bool operator<=(const FlowInfo& lhs, const FlowInfo& rhs) {return !(lhs > rhs);}
133  inline friend bool operator>=(const FlowInfo& lhs, const FlowInfo& rhs) {return !(lhs < rhs);}
134 
135  // default ctor/dtor
136  FlowInfo() {};
137  ~FlowInfo() {};
138 
139  // ctor accepting ParticleFlowElements
141  SetInfo(flow);
142  }
143 
144  }; // end FlowInfo definition
145 
146 
147 
148  // particle flow methods --------------------------------------------------
149 
151 
152  ParticleFlowElementContainer* store = findNode::getClass<ParticleFlowElementContainer>(topNode, "ParticleFlowElements");
153  if (!store) {
154  cerr << PHWHERE
155  << "PANIC: Couldn't grab particle flow container!"
156  << endl;
157  assert(store);
158  }
159  return store;
160 
161  } // end 'GetFlowStore(PHCompositeNode*)'
162 
163 
164 
166 
167  // get container
169 
170  // get objects
171  ParticleFlowElementContainer::ConstRange objects = store -> getParticleFlowElements();
172  if (!objects) {
173  cerr << PHWHERE
174  << "PANIC: Couldn't grab particle flow objects!"
175  << endl;
176  assert(objects);
177  }
178  return objects;
179 
180  } // end 'GetParticleFlowObjects(PHCompositeNode*)'
181 
182 
183 
184  bool IsInAcceptance(const FlowInfo& flow, const FlowInfo& minimum, const FlowInfo& maximum) {
185 
186  return ((flow >= minimum) && (flow <= maximum));
187 
188  } // end 'IsInAcceptance(FlowInfo&, FlowInfo&, FlowInfo&)'
189 
190  } // end SCorrelatorUtilities namespace
191 } // end SColdQcdCorrealtorAnalysis namespace
192 
193 // end ------------------------------------------------------------------------