ATLAS Offline Software
utilityFunctions.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #include "utilityFunctions.h"
6 #include "PdgConditional.h"
7 #include <cmath>
8 #include <algorithm>
9 
10 namespace{
11  enum CountIndices{
17  };
18 }
19 
20 namespace DerivationFramework{
21  int
22  gluinoSquarkClassification(const std::array<int, 35> & c){
23  int result{};
24  // gluino/squark + X
25  if (c[gluino]==1 && (c[squark]==1 || c[antisquark] ==1)) return 1;
26  else if (c[gluino]==2) return 2;
27  else if (c[squark]==2 || c[antisquark]==2) return 3;
28  else if (c[squark]==1 && c[antisquark]==1) return 4;
29 
30  else if (c[sbottom]==1 && c[antisbottom]==1) return 51;
31  else if (c[sbottom2]==1 && c[antisbottom2]==1) return 52;
32  else if (c[stop]==1 && c[antistop]==1) return 61;
33  else if (c[stop2]==1 && c[antistop2]==1) return 62;
34 
35  else if (c[gluino]==1 && c[chi01]==1) return 71;
36  else if (c[gluino]==1 && c[chi02]==1) return 72;
37  else if (c[gluino]==1 && c[chi03]==1) return 73;
38  else if (c[gluino]==1 && c[chi04]==1) return 74;
39 
40  else if (c[gluino]==1 && c[ch1plus]==1) return 75;
41  else if (c[gluino]==1 && c[ch2plus]==1) return 76;
42  else if (c[gluino]==1 && c[ch1minus]==1) return 77;
43  else if (c[gluino]==1 && c[ch2minus]==1) return 78;
44 
45  else if ((c[squark]==1 || c[antisquark ]==1) && c[chi01]==1) return 81;
46  else if ((c[squark]==1 || c[antisquark ]==1) && c[chi02]==1) return 82;
47  else if ((c[squark]==1 || c[antisquark ]==1) && c[chi03]==1) return 83;
48  else if ((c[squark]==1 || c[antisquark ]==1) && c[chi04]==1) return 84;
49 
50  else if ((c[squark]==1 || c[antisquark ]==1) && c[ch1plus]==1) return 85;
51  else if ((c[squark]==1 || c[antisquark ]==1) && c[ch2plus]==1) return 86;
52  else if ((c[squark]==1 || c[antisquark ]==1) && c[ch1minus]==1) return 87;
53  else if ((c[squark]==1 || c[antisquark ]==1) && c[ch2minus]==1) return 88;
54  return result;
55  }
56 
57  int
58  gauginoPairProduction(const std::array<int, 35> & c){
59  // Gaugino pair-production
60  // chi^{0}_1 + X
61  int result{};
62  if (c[chi01]==2) return 111;
63  else if (c[chi01]==1 && c[chi02]==1) return 112;
64  else if (c[chi01]==1 && c[chi03]==1) return 113;
65  else if (c[chi01]==1 && c[chi04]==1) return 114;
66  else if (c[chi01]==1 && c[ch1plus]==1) return 115;
67  else if (c[chi01]==1 && c[ch2plus]==1) return 116;
68  else if (c[chi01]==1 && c[ch1minus]==1) return 117;
69  else if (c[chi01]==1 && c[ch2minus]==1) return 118;
70 
71  // chi^{0}_2 + X
72  else if (c[chi02]==2) return 122;
73  else if (c[chi02]==1 && c[chi03]==1) return 123;
74  else if (c[chi02]==1 && c[chi04]==1) return 124;
75  else if (c[chi02]==1 && c[ch1plus]==1) return 125;
76  else if (c[chi02]==1 && c[ch2plus]==1) return 126;
77  else if (c[chi02]==1 && c[ch1minus]==1) return 127;
78  else if (c[chi02]==1 && c[ch2minus]==1) return 128;
79 
80  // chi^{0}_3 + X
81  else if (c[chi03]==2) return 133;
82  else if (c[chi03]==1 && c[chi04]==1) return 134;
83  else if (c[chi03]==1 && c[ch1plus]==1) return 135;
84  else if (c[chi03]==1 && c[ch2plus]==1) return 136;
85  else if (c[chi03]==1 && c[ch1minus]==1) return 137;
86  else if (c[chi03]==1 && c[ch2minus]==1) return 138;
87 
88  // chi^{0}_4 + X
89  else if (c[chi04]==2) return 144;
90  else if (c[chi04]==1 && c[ch1plus]==1) return 145;
91  else if (c[chi04]==1 && c[ch2plus]==1) return 146;
92  else if (c[chi04]==1 && c[ch1minus]==1) return 147;
93  else if (c[chi04]==1 && c[ch2minus]==1) return 148;
94 
95  // chi^{+}_1/2 + chi^{-}_1/2
96  else if (c[ch1plus]==1 && c[ch1minus]==1) return 157;
97  else if (c[ch1plus]==1 && c[ch2minus]==1) return 158;
98 
99  else if (c[ch2plus]==1 && c[ch1minus]==1) return 167;
100  else if (c[ch2plus]==1 && c[ch2minus]==1) return 168;
101  return result;
102  }
103  int
104  slepton(const std::array<int, 35> & c){
105  int result{};
106  // slepton
107  if (c[selecLplus]==1 && c[selecLminus]==1) return 201; // sElectronLPair
108  else if (c[selecRplus]==1 && c[selecRminus]==1) return 202; // sElectronRPair
109  else if (c[selnuL]==2) return 203; // sElectron neutrino pair
110  else if (c[selecLplus]==1 && c[selnuL]==1) return 204; // sElectron+ sNutrino
111  else if (c[selecLminus]==1 && c[selnuL]==1) return 205; // sElectron- sNutrino
112  else if (c[stau1plus]==1 && c[stau1minus]==1) return 206;
113  else if (c[stau2plus]==1 && c[stau2minus]==1) return 207;
114  else if ((c[stau1plus]==1 || c[stau1minus]==1) && (c[stau2plus]==1 || c[stau2minus]==1)) return 208;
115  else if (c[staunuL]==2) return 209; // sTau neutrino pair
116  else if (c[stau1plus]==1 && c[staunuL]==1) return 210;
117  else if (c[stau1minus]==1 && c[staunuL]==1) return 211;
118  else if (c[stau2plus]==1 && c[staunuL]==1) return 212;
119  else if (c[stau2minus]==1 && c[staunuL]==1) return 213;
120  return result;
121  }
122  int
123  smuon(const std::array<int, 35> & c){
124  int result{};
125  if (c[smuonLplus]==1 && c[smuonLminus]==1) return 216; // sMuonPair
126  else if (c[smuonRplus]==1 && c[smuonRminus]==1) return 217; // sMuonPair
127  else if (c[smunuL]==2) return 218; // sMuon neutrino pair
128  else if (c[smuonLplus]==1 && c[smunuL]==1) return 219; // sMuon+ sNutrino
129  else if (c[smuonLminus]==1 && c[smunuL]==1) return 220; // sMuon- sNutrino
130  return result;
131  }
132 
133 
134  unsigned int
135  finalStateID(const int SUSY_Spart1_pdgId, const int SUSY_Spart2_pdgId){
136  std::array<int, nParticleIndices> particleCountByType{};
137  std::array<PdgConditional,34> conditions{
138  unsigned(1000022), //unsigned number does an std::abs before comparison
139  unsigned(1000023),
140  unsigned(1000025),
141  unsigned(1000035),
142  1000024, //signed int does a straight equality comparison
143  -1000024,
144  1000037,
145  -1000037,
146  1000021,
147  //insert a lambda to do the comparison
148  PdgConditional([](int pdgId)->bool{return ((std::abs(pdgId)>1000000 && std::abs(pdgId)<= 1000004) || (std::abs(pdgId)>2000000 && std::abs(pdgId)<=2000004)) && (pdgId>0);}),
149  PdgConditional([](int pdgId)->bool{return (std::abs(pdgId)>1000000 && std::abs(pdgId)<= 1000004) || (std::abs(pdgId)>2000000 && std::abs(pdgId)<=2000004);}),
150  1000005,
151  1000006,
152  2000005,
153  2000006,
154  -1000005,
155  -1000006,
156  -2000005,
157  -2000006,
158  2000011,
159  -2000011,
160  1000011,
161  -1000011,
162  unsigned(1000012),
163  2000013,
164  -2000013,
165  1000013,
166  -1000013,
167  unsigned(1000014),
168  1000015,
169  -1000015,
170  2000015,
171  -2000015,
172  unsigned(1000016)
173  };
174  auto it = std::find(conditions.begin(),conditions.end(), SUSY_Spart1_pdgId);
175  int idx = std::distance(conditions.begin(), it);
176  ++particleCountByType[idx];
177  //
178  it = std::find(conditions.begin(),conditions.end(), SUSY_Spart2_pdgId);
179  idx = std::distance(conditions.begin(), it);
180  ++particleCountByType[idx];
181  if (const auto & v=gluinoSquarkClassification(particleCountByType);v) return v;
182  // Gaugino pair-production
183  // chi^{0}_1 + X
184  if (const auto & v=gauginoPairProduction(particleCountByType);v) return v;
185  // slepton
186  if (const auto & v=slepton(particleCountByType);v) return v;
187  // smuon
188  if (const auto & v=smuon(particleCountByType);v) return v;
189  return 0;
190  }
191 
192 
193 
194 
195 
196 
197 }
DerivationFramework::stau1minus
@ stau1minus
Definition: utilityFunctions.h:14
DerivationFramework::antisbottom2
@ antisbottom2
Definition: utilityFunctions.h:12
DerivationFramework::smunuL
@ smunuL
Definition: utilityFunctions.h:14
get_generator_info.result
result
Definition: get_generator_info.py:21
DerivationFramework::selecRplus
@ selecRplus
Definition: utilityFunctions.h:13
DerivationFramework::selecRminus
@ selecRminus
Definition: utilityFunctions.h:13
utilityFunctions.h
find
std::string find(const std::string &s)
return a remapped string
Definition: hcg.cxx:135
DerivationFramework::unattributed
@ unattributed
Definition: utilityFunctions.h:15
DerivationFramework::finalStateID
unsigned int finalStateID(const int SUSY_Spart1_pdgId, const int SUSY_Spart2_pdgId)
Definition: utilityFunctions.cxx:135
skel.it
it
Definition: skel.GENtoEVGEN.py:396
DerivationFramework::smuonLplus
@ smuonLplus
Definition: utilityFunctions.h:14
DerivationFramework::gauginoPairProduction
int gauginoPairProduction(const std::array< int, 35 > &c)
Definition: utilityFunctions.cxx:58
DerivationFramework::chi04
@ chi04
Definition: utilityFunctions.h:11
DerivationFramework::stop
@ stop
Definition: utilityFunctions.h:12
PixelModuleFeMask_create_db.stop
int stop
Definition: PixelModuleFeMask_create_db.py:76
DerivationFramework::slepton
int slepton(const std::array< int, 35 > &c)
Definition: utilityFunctions.cxx:104
DerivationFramework::gluino
@ gluino
Definition: utilityFunctions.h:11
xAOD::unsigned
unsigned
Definition: RingSetConf_v1.cxx:662
DerivationFramework::selecLplus
@ selecLplus
Definition: utilityFunctions.h:13
DerivationFramework::stau2minus
@ stau2minus
Definition: utilityFunctions.h:15
DerivationFramework::sbottom
@ sbottom
Definition: utilityFunctions.h:12
DerivationFramework::ch2minus
@ ch2minus
Definition: utilityFunctions.h:11
PdgConditional.h
DerivationFramework::smuonLminus
@ smuonLminus
Definition: utilityFunctions.h:14
DerivationFramework::selecLminus
@ selecLminus
Definition: utilityFunctions.h:13
DerivationFramework::PdgConditional
Definition: PdgConditional.h:16
DerivationFramework::staunuL
@ staunuL
Definition: utilityFunctions.h:15
DerivationFramework::stop2
@ stop2
Definition: utilityFunctions.h:12
DerivationFramework
THE reconstruction tool.
Definition: ParticleSortingAlg.h:24
DerivationFramework::antistop2
@ antistop2
Definition: utilityFunctions.h:13
DerivationFramework::ch2plus
@ ch2plus
Definition: utilityFunctions.h:11
DerivationFramework::selnuL
@ selnuL
Definition: utilityFunctions.h:13
DerivationFramework::antistop
@ antistop
Definition: utilityFunctions.h:12
DerivationFramework::ch1minus
@ ch1minus
Definition: utilityFunctions.h:11
DerivationFramework::chi01
@ chi01
Definition: utilityFunctions.h:11
DerivationFramework::smuon
int smuon(const std::array< int, 35 > &c)
Definition: utilityFunctions.cxx:123
DerivationFramework::antisquark
@ antisquark
Definition: utilityFunctions.h:12
DerivationFramework::antisbottom
@ antisbottom
Definition: utilityFunctions.h:12
DerivationFramework::chi03
@ chi03
Definition: utilityFunctions.h:11
python.PyAthena.v
v
Definition: PyAthena.py:154
DerivationFramework::chi02
@ chi02
Definition: utilityFunctions.h:11
DerivationFramework::sbottom2
@ sbottom2
Definition: utilityFunctions.h:12
LArNewCalib_DelayDump_OFC_Cali.idx
idx
Definition: LArNewCalib_DelayDump_OFC_Cali.py:69
DerivationFramework::nParticleIndices
@ nParticleIndices
Definition: utilityFunctions.h:15
DerivationFramework::squark
@ squark
Definition: utilityFunctions.h:11
DerivationFramework::ch1plus
@ ch1plus
Definition: utilityFunctions.h:11
DerivationFramework::stau2plus
@ stau2plus
Definition: utilityFunctions.h:15
DerivationFramework::smuonRplus
@ smuonRplus
Definition: utilityFunctions.h:14
DerivationFramework::gluinoSquarkClassification
int gluinoSquarkClassification(const std::array< int, 35 > &c)
Definition: utilityFunctions.cxx:22
Amg::distance
float distance(const Amg::Vector3D &p1, const Amg::Vector3D &p2)
calculates the distance between two point in 3D space
Definition: GeoPrimitivesHelpers.h:54
python.compressB64.c
def c
Definition: compressB64.py:93
DerivationFramework::stau1plus
@ stau1plus
Definition: utilityFunctions.h:14
DerivationFramework::smuonRminus
@ smuonRminus
Definition: utilityFunctions.h:14