Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CstTools.h
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file CstTools.h
1 // ----------------------------------------------------------------------------
2 // 'CstTools.h'
3 // Derek Anderson
4 // 10.22.2023
5 //
6 // Collection of frequent constituent-related methods and
7 // types utilized in the sPHENIX cold QCD Energy-Energy
8 // Correlator analysis.
9 // ----------------------------------------------------------------------------
10 
11 #pragma once
12 
13 // c++ utilities
14 #include <limits>
15 #include <string>
16 #include <vector>
17 #include <optional>
18 // analysis utilities
19 #include "Constants.h"
20 
21 // make common namespaces implicit
22 using namespace std;
23 
24 
25 
26 namespace SColdQcdCorrelatorAnalysis {
27  namespace SCorrelatorUtilities {
28 
29  struct CstInfo {
30 
31  // data members
32  int type = numeric_limits<int>::max();
33  int cstID = numeric_limits<int>::max();
34  int embedID = numeric_limits<int>::max();
35  int pid = numeric_limits<int>::max();
36  double z = numeric_limits<double>::max();
37  double dr = numeric_limits<double>::max();
38  double ene = numeric_limits<double>::max();
39  double pt = numeric_limits<double>::max();
40  double eta = numeric_limits<double>::max();
41  double phi = numeric_limits<double>::max();
42 
43  void SetInfo(int t, int id, double z, double d, double e, double p, double h, double f, optional<int> eid = nullopt, optional<int> pdg = nullopt) {
44  type = t;
45  cstID = id;
46  z = z;
47  dr = d;
48  ene = e;
49  pt = p;
50  eta = h;
51  phi = f;
52  if (eid.has_value()) {
53  embedID = eid.value();
54  }
55  if (pdg.has_value()) {
56  pid = pdg.value();
57  }
58  return;
59  } // end 'SetInfo(int x 2, double x 6, optional<int> x 2)'
60 
61  void Rest() {
62  type = numeric_limits<int>::max();
63  cstID = numeric_limits<int>::max();
64  embedID = numeric_limits<int>::max();
65  pid = numeric_limits<int>::max();
66  z = numeric_limits<double>::max();
67  dr = numeric_limits<double>::max();
68  ene = numeric_limits<double>::max();
69  pt = numeric_limits<double>::max();
70  eta = numeric_limits<double>::max();
71  phi = numeric_limits<double>::max();
72  return;
73  } // end 'Reset()'
74 
75  static vector<string> GetListOfMembers() {
76  vector<string> members = {
77  "type",
78  "cstID",
79  "embedID",
80  "pid",
81  "z",
82  "dr",
83  "ene",
84  "pt",
85  "eta",
86  "phi"
87  };
88  return members;
89  } // end 'GetListOfMembers()'
90 
91  // overloaded < operator
92  friend bool operator<(const CstInfo& lhs, const CstInfo& rhs) {
93 
94  // note that some quantities aren't relevant for this comparison
95  const bool isLessThan = (
96  (lhs.z < rhs.z) &&
97  (lhs.dr < rhs.dr) &&
98  (lhs.ene < rhs.ene) &&
99  (lhs.pt < rhs.pt) &&
100  (lhs.eta < rhs.eta) &&
101  (lhs.phi < rhs.phi)
102  );
103  return isLessThan;
104 
105  } // end 'operator<(CstInfo&, CstInfo&)'
106 
107  // overloaded > operator
108  friend bool operator>(const CstInfo& lhs, const CstInfo& rhs) {
109 
110  // note that some quantities aren't relevant for this comparison
111  const bool isGreaterThan = (
112  (lhs.z > rhs.z) &&
113  (lhs.dr > rhs.dr) &&
114  (lhs.ene > rhs.ene) &&
115  (lhs.pt > rhs.pt) &&
116  (lhs.eta > rhs.eta) &&
117  (lhs.phi > rhs.phi)
118  );
119  return isGreaterThan;
120 
121  } // end 'operator<(CstInfo&, CstInfo&)'
122 
123  // overloaded <=, >= operators
124  inline friend bool operator<=(const CstInfo& lhs, const CstInfo& rhs) {return !(lhs > rhs);}
125  inline friend bool operator>=(const CstInfo& lhs, const CstInfo& rhs) {return !(lhs < rhs);}
126 
127  // default ctor/dtor
128  CstInfo() {};
129  ~CstInfo() {};
130 
131  // ctor accepting arguments
132  CstInfo(int t, int id, double z, double d, double e, double p, double h, double f, optional<int> eid = nullopt, optional<int> pdg = nullopt) {
133  SetInfo(t, id, z, d, e, p, h, f, eid, pdg);
134  }
135 
136  }; // end CstInfo def
137 
138 
139 
140  // constituent methods ----------------------------------------------------
141 
142  bool IsInAcceptance(const CstInfo& cst, const CstInfo& minimum, const CstInfo& maximum) {
143 
144  return ((cst >= minimum) && (cst <= maximum));
145 
146  } // end 'IsInAcceptance(CstInfo&, CstInfo&, CstInfo&)'
147 
148  } // end SCorrelatorUtilities namespace
149 } // end SColdQcdCorrealtorAnalysis namespace
150 
151 // end ------------------------------------------------------------------------