ATLAS Offline Software
WTAObject.h
Go to the documentation of this file.
1 #ifndef WTAObject_h
2 #define WTAObject_h
3 
4 #include <iostream>
5 #include <algorithm>
6 
7 #ifdef BITWISE_SIMULATION
8 // 1: Integer type for bitwise simulation
9 typedef long long int IntOrFloat;
10 const IntOrFloat PI = 32;
11 const IntOrFloat R2PAR = 16;
12 #elif defined(FLOATING_POINT_SIMULATION)
13 // 2: Floating point for athena simulation
14 // typedef double IntOrFloat;
15 typedef float IntOrFloat;
16 const IntOrFloat PI = 3.14159265;
17 const IntOrFloat R2PAR = 0.16;
18 #else
19 #error "Simulation type not defined. Define either BITWISE_SIMULATION or FLOATING_POINT_SIMULATION."
20 #endif
21 
22 template <typename T>
23  static void SortByPt(std::vector<T>& list) // Simple List sorting
24  {
25  std::stable_sort(list.begin(), list.end(), // Use stable_sort to preserve the order of equal elements
26  [](const T &a, const T &b)
27  {
28  return a.pt() > b.pt();
29  }
30  );
31  }
32 
33 class WTATrigObj{
34  public:
35  WTATrigObj(IntOrFloat pt = 0, IntOrFloat eta = 0, IntOrFloat phi = 0, IntOrFloat m = 0)
36  : m_pt(pt), m_eta(eta), m_phi(phi), m_m(m){}; // Constructor
37 
38  IntOrFloat pt() const {return m_pt;};
39  void pt(IntOrFloat pt) {m_pt = pt;};
40  IntOrFloat eta() const {return m_eta;};
41  void eta(IntOrFloat eta) {m_eta = eta;};
42  IntOrFloat phi() const {return m_phi;};
43  void phi(IntOrFloat phi) {m_phi = phi;};
44  IntOrFloat m() const {return m_m;};
45  void m(IntOrFloat m) {m_m = m;};
46 
47  IntOrFloat d_phi_0_2PI(WTATrigObj o2);
48  IntOrFloat d_phi_MPI_PI(WTATrigObj o2);
49  IntOrFloat d_eta(WTATrigObj o2){IntOrFloat tmp = m_eta - o2.eta(); return tmp;}
50  IntOrFloat dR2(WTATrigObj o2);
51  bool IsAssocdR(WTATrigObj& tower, IntOrFloat dr2);
52 
53  // comparison operators for easy sorting
54  friend bool operator< (const WTATrigObj &o1, const WTATrigObj &o2){ return o1.pt() < o2.pt(); }; // Call .pt(), not directly access private m_pt
55  friend bool operator> (const WTATrigObj &o1, const WTATrigObj &o2){ return o1.pt() > o2.pt(); };
56  friend bool operator<= (const WTATrigObj &o1, const WTATrigObj &o2){ return o1.pt() <= o2.pt(); };
57  friend bool operator>= (const WTATrigObj &o1, const WTATrigObj &o2){ return o1.pt() >= o2.pt(); };
58 
59  // operation override, for easy merging
61  WTATrigObj new_obj;
62  new_obj.m_pt = this->pt() + obj.pt(); // Current default is the scalar sum, WTA
63  new_obj.m_eta = this->eta();
64  new_obj.m_phi = this->phi();
65  new_obj.m_m = this->m();
66  return new_obj;
67  };
68 
69  private:
70  IntOrFloat m_pt;
71  IntOrFloat m_eta;
72  IntOrFloat m_phi;
73  IntOrFloat m_m;
74 
75 };
76 
78 {
79  IntOrFloat tmp = m_phi - o2.phi();
80  while(tmp < 0)tmp += 2*PI;
81  while(tmp > 2*PI)tmp -= 2*PI;
82  return tmp;
83 }
85 {
86  IntOrFloat tmp = m_phi - o2.phi();
87  while(tmp < -PI)tmp += 2*PI;
88  while(tmp > PI)tmp -= 2*PI;
89  return tmp;
90 }
91 inline IntOrFloat WTATrigObj::dR2(WTATrigObj o2)
92 {
93  IntOrFloat d_phi = d_phi_MPI_PI(o2);
94  IntOrFloat d_eta_tmp = d_eta(o2);
95  IntOrFloat tmp = (d_phi * d_phi) + (d_eta_tmp * d_eta_tmp);
96  return tmp;
97 }
98 
99 inline bool WTATrigObj::IsAssocdR(WTATrigObj& tower, IntOrFloat dr2){
100  auto dR2 = this->dR2(tower);
101  return dR2 <= dr2;
102 }
103 
104 class WTAJet : public WTATrigObj{ // The class
105  public: // Access specifier
106  WTAJet (IntOrFloat pt = 0, IntOrFloat eta = 0, IntOrFloat phi = 0, IntOrFloat m = 0, IntOrFloat jet_dr2 = R2PAR) :
107  WTATrigObj(pt, eta, phi, m) {m_Seed = WTATrigObj(pt, eta, phi, m); m_Jet_dR2 = jet_dr2; m_ConstituentList.clear(); m_ConstituentList.push_back(m_Seed);};
108 
110  void MergeConstituent(WTATrigObj &tower);
111  void MergeConstituent(WTATrigObj *tower);
112  void MergeWTAJet(WTAJet &targetjet);
113  void PopOutLastConstituent();
114  const std::vector<WTATrigObj>& GetConstituentList() const {return m_ConstituentList;};
115  unsigned int GetConstituentCount() const {return m_ConstituentList.size();}; // Need to quickly access the jet's constituent number
116 
117  private:
119  std::vector<WTATrigObj> m_ConstituentList;
120  IntOrFloat m_Jet_dR2;
121 };
122 
124 {
125  this->pt(this->pt() + tower.pt());// Scalar sum, WTA
126  m_ConstituentList.push_back(tower);
127 }
128 
130 {
131  this->pt(this->pt() + tower->pt());// Scalar sum, WTA
132  m_ConstituentList.push_back(*tower);
133 }
134 
135 inline void WTAJet::MergeWTAJet(WTAJet &targetjet)
136 {
137  WTATrigObj tmptower(targetjet.pt(), targetjet.eta(), targetjet.phi(), targetjet.m());
138  this->pt(this->pt() + tmptower.pt()); // Scalar sum, WTA
139  std::vector<WTATrigObj> tmp_const_list = targetjet.GetConstituentList();
140  m_ConstituentList.insert(m_ConstituentList.end(), tmp_const_list.begin(), tmp_const_list.end());
141 
142 }
143 
145 {
146  WTATrigObj lastconst = m_ConstituentList.back(); //std::vector::back() returns the last element
147  this->pt(this->pt() - lastconst.pt()); // Scalar subtraction, WTA
148  m_ConstituentList.pop_back(); // Popback the last element
149 }
150 
151 #endif
WTAJet::MergeWTAJet
void MergeWTAJet(WTAJet &targetjet)
Definition: WTAObject.h:135
WTATrigObj::phi
IntOrFloat phi() const
Definition: WTAObject.h:42
WTATrigObj::m_phi
IntOrFloat m_phi
Definition: WTAObject.h:72
WTATrigObj::m_m
IntOrFloat m_m
Definition: WTAObject.h:73
PI
const float PI
Definition: test_isolaitonTool.cxx:61
WTAJet::m_Seed
WTATrigObj m_Seed
Definition: WTAObject.h:115
WTAJet::GetConstituentCount
unsigned int GetConstituentCount() const
Definition: WTAObject.h:115
std::stable_sort
void stable_sort(std::reverse_iterator< DataModel_detail::iterator< DVL > > beg, std::reverse_iterator< DataModel_detail::iterator< DVL > > end, Compare comp)
Specialization of stable_sort for DataVector/List.
Definition: DVL_algorithms.h:711
WTATrigObj::pt
IntOrFloat pt() const
Definition: WTAObject.h:38
WTATrigObj::IsAssocdR
bool IsAssocdR(WTATrigObj &tower, IntOrFloat dr2)
Definition: WTAObject.h:99
WTAJet::m_ConstituentList
std::vector< WTATrigObj > m_ConstituentList
Definition: WTAObject.h:119
WTATrigObj::m_pt
IntOrFloat m_pt
Definition: WTAObject.h:67
WTATrigObj::d_phi_0_2PI
IntOrFloat d_phi_0_2PI(WTATrigObj o2)
Definition: WTAObject.h:77
WTATrigObj::operator+
WTATrigObj operator+(const WTATrigObj &obj)
Definition: WTAObject.h:60
WTAJet::MergeConstituent
void MergeConstituent(WTATrigObj &tower)
Definition: WTAObject.h:123
WTATrigObj::m
IntOrFloat m() const
Definition: WTAObject.h:44
WTATrigObj::d_eta
IntOrFloat d_eta(WTATrigObj o2)
Definition: WTAObject.h:49
WTAJet::PopOutLastConstituent
void PopOutLastConstituent()
Definition: WTAObject.h:144
WTATrigObj::phi
void phi(IntOrFloat phi)
Definition: WTAObject.h:43
WTATrigObj::dR2
IntOrFloat dR2(WTATrigObj o2)
Definition: WTAObject.h:91
histSizes.list
def list(name, path='/')
Definition: histSizes.py:38
WTATrigObj::eta
void eta(IntOrFloat eta)
Definition: WTAObject.h:41
DeMoUpdate.tmp
string tmp
Definition: DeMoUpdate.py:1167
WTATrigObj::pt
void pt(IntOrFloat pt)
Definition: WTAObject.h:39
WTATrigObj::operator>
friend bool operator>(const WTATrigObj &o1, const WTATrigObj &o2)
Definition: WTAObject.h:55
WTATrigObj
Definition: WTAObject.h:33
WTATrigObj::operator<
friend bool operator<(const WTATrigObj &o1, const WTATrigObj &o2)
Definition: WTAObject.h:54
WTAJet
Definition: WTAObject.h:104
plotBeamSpotMon.b
b
Definition: plotBeamSpotMon.py:76
WTAJet::GetConstituentList
const std::vector< WTATrigObj > & GetConstituentList() const
Definition: WTAObject.h:114
python.changerun.o2
o2
Definition: changerun.py:43
a
TList * a
Definition: liststreamerinfos.cxx:10
WTATrigObj::eta
IntOrFloat eta() const
Definition: WTAObject.h:40
WTATrigObj::m_eta
IntOrFloat m_eta
Definition: WTAObject.h:71
WTATrigObj::d_phi_MPI_PI
IntOrFloat d_phi_MPI_PI(WTATrigObj o2)
Definition: WTAObject.h:84
WTAJet::GetSeed
WTATrigObj GetSeed()
Definition: WTAObject.h:109
WTAJet::m_Jet_dR2
IntOrFloat m_Jet_dR2
Definition: WTAObject.h:120
WTATrigObj::operator<=
friend bool operator<=(const WTATrigObj &o1, const WTATrigObj &o2)
Definition: WTAObject.h:56
WTATrigObj::WTATrigObj
WTATrigObj(IntOrFloat pt=0, IntOrFloat eta=0, IntOrFloat phi=0, IntOrFloat m=0)
Definition: WTAObject.h:35
python.changerun.o1
o1
Definition: changerun.py:42
WTAJet::WTAJet
WTAJet(IntOrFloat pt=0, IntOrFloat eta=0, IntOrFloat phi=0, IntOrFloat m=0, IntOrFloat jet_dr2=R2PAR)
Definition: WTAObject.h:106
python.PyAthena.obj
obj
Definition: PyAthena.py:132
WTATrigObj::m
void m(IntOrFloat m)
Definition: WTAObject.h:45
TSU::T
unsigned long long T
Definition: L1TopoDataTypes.h:35
WTATrigObj::operator>=
friend bool operator>=(const WTATrigObj &o1, const WTATrigObj &o2)
Definition: WTAObject.h:57