ATLAS Offline Software
InvariantMassDeltaPhiInclusive2AlgTool.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 #include "AlgoDataTypes.h" // bitSetToInt()
7 #include "DataCollector.h"
8 
9 #include "../../../dump.h"
10 #include "../../../dump.icc"
11 
14 
15 #include <sstream>
16 #include <algorithm>
17 
18 namespace GlobalSim {
19 
21  const std::string& name,
22  const IInterface* parent) :
23  base_class(type, name, parent){
24  }
25 
26  bool cutChecker(const std::vector<int>& vals, std::size_t sz) {
27  if (vals.size() != sz) {return false;}
28  return std::all_of(std::cbegin(vals),
29  std::cend(vals),
30  [](const auto& v){return v >= 0;});
31  }
32 
34 
38 
39 
40  if(!cutChecker(m_minEt1Cuts, s_NumResultBits)){
41  ATH_MSG_ERROR("minimum Et1 cuts error");
42  return StatusCode::FAILURE;
43  }
44 
45  if(!cutChecker(m_minEt2Cuts, s_NumResultBits)){
46  ATH_MSG_ERROR("minimum Et2 cuts error");
47  return StatusCode::FAILURE;
48  }
49 
50  if (m_applyEtaCuts) {
51 
52  if(!cutChecker(m_minEta1Cuts, s_NumResultBits)){
53  ATH_MSG_ERROR("minimum Eta1 cuts error");
54  return StatusCode::FAILURE;
55  }
56 
57  if(!cutChecker(m_maxEta1Cuts, s_NumResultBits)){
58  ATH_MSG_ERROR("maximum Eta1 cuts error");
59  return StatusCode::FAILURE;
60  }
61 
62  if(!cutChecker(m_minEta2Cuts, s_NumResultBits)){
63  ATH_MSG_ERROR("minimum Eta2 cuts error");
64  return StatusCode::FAILURE;
65  }
66 
67  if(!cutChecker(m_maxEta2Cuts, s_NumResultBits)){
68  ATH_MSG_ERROR("maximum Eta2 cuts error");
69  return StatusCode::FAILURE;
70  }
71  }
72 
73  if(!cutChecker(m_minInvMassSqrCuts, s_NumResultBits)){
74  ATH_MSG_ERROR("minimum invariant mass cuts error");
75  return StatusCode::FAILURE;
76  }
77 
78  if(!cutChecker(m_maxInvMassSqrCuts, s_NumResultBits)){
79  ATH_MSG_ERROR("maximum invariant mass cuts error");
80  return StatusCode::FAILURE;
81  }
82 
83  if(!cutChecker(m_minDeltaPhiCuts, s_NumResultBits)){
84  ATH_MSG_ERROR("minimum Delta phi cuts error");
85  return StatusCode::FAILURE;
86  }
87 
88  if(!cutChecker(m_maxDeltaPhiCuts, s_NumResultBits)){
89  ATH_MSG_ERROR("maximum Delta phi cuts error");
90  return StatusCode::FAILURE;
91  }
92 
93  return StatusCode::SUCCESS;
94  }
95 
97  InvariantMassDeltaPhiInclusive2AlgTool::run(const EventContext& ctx) const {
98  ATH_MSG_DEBUG("run()");
99 
100  auto tobs1 =
102  ctx);
103 
104  auto tobs2 =
106  ctx);
107 
108  auto ss = std::stringstream();
109  ss << "Tobs 1 in\n";
110  for (const auto& tob: *tobs1) {
111  ss << *tob << '\n';
112  }
113 
114  ss << "Tobs 2 in\n";
115  for (const auto& tob: *tobs1) {
116  ss << *tob << '\n';
117  }
118  ATH_MSG_DEBUG(ss.str());
119 
120  // n selections on Tobs according to the s_NumResult cut categories
121 
122  std::size_t maxCount1 = std::max(tobs1->size(), s_inputWidth1);
123  auto acceptFlagsEtEta1 =
124  AcceptFlags(s_NumResultBits, std::vector<bool>(maxCount1, false));
125 
126  CHECK(selectTobs1(*tobs1, acceptFlagsEtEta1));
127 
128  std::size_t maxCount2 = std::max(tobs2->size(), s_inputWidth2);
129  auto acceptFlagsEtEta2 =
130  AcceptFlags(s_NumResultBits, std::vector<bool>(maxCount2, false));
131  CHECK(selectTobs1(*tobs2, acceptFlagsEtEta2));
132 
133  CHECK(selectTobs2(*tobs2, acceptFlagsEtEta2));
134 
135  auto result = std::make_unique<InvariantMassResult>();
136 
137  for (auto isel{0U}; isel != s_NumResultBits; ++isel) {
138  for (auto i1{0U}; i1 != maxCount1; ++i1) {
139  if (!acceptFlagsEtEta1[isel][i1]) {continue;}
140  for (auto i2{0U}; i2 != maxCount2; ++i2) {
141  if (!acceptFlagsEtEta1[isel][i2]) {continue;}
142  (*result)[isel] = true;
143  }
144  }
145  }
146 
147  auto h_write =
149  CHECK(h_write.record(std::move(result)));
150 
151  return StatusCode::SUCCESS;
152  }
153 
154  std::string
156 
157  std::stringstream ss;
158  ss << "name: " << name() << '\n'
159  << " tobs in 1 read key " << m_tobsInReadKey1
160  << " tobs in 2 read key " << m_tobsInReadKey2
161  << '\n';
162 
163  return ss.str();
164  }
165 
166  StatusCode
168  AcceptFlags& flags) const {
169 
170 
171 
172  for (std::size_t isel{0}; isel != s_NumResultBits; ++isel) {
173  if (m_applyEtaCuts) {
174  CHECK (setAcceptFlags(tobs,
175  flags[isel],
176  m_minEt1Cuts[isel],
177  m_minEta1Cuts[isel],
178  m_maxEta1Cuts[isel]));
179  } else {
180  CHECK (setAcceptFlags(tobs,
181  flags[isel],
182  m_minEt1Cuts[isel]));
183  }
184  }
185 
186  return StatusCode::SUCCESS;
187  }
188 
189  StatusCode
191  AcceptFlags& flags) const {
192 
193 
194  for (std::size_t isel{0}; isel != s_NumResultBits; ++isel) {
195  if (m_applyEtaCuts) {
196  CHECK (setAcceptFlags(tobs,
197  flags[isel],
198  m_minEt2Cuts[isel],
199  m_minEta2Cuts[isel],
200  m_maxEta2Cuts[isel]));
201  } else {
202  CHECK (setAcceptFlags(tobs,
203  flags[isel],
204  m_minEt2Cuts[isel]));
205  }
206  }
207  return StatusCode::SUCCESS;
208  }
209 
210 
211  /* FIXME
212  StatusCode
213  InvariantMassDeltaPhiInclusive2AlgTool::selectTobs(const GenericTobContainer& tobs,
214  GenericTobContainer& selectedTobs,
215  int minEt,
216  int minEta,
217  int maxEta) const {
218 
219  auto tobSelector = [minEt,
220  minEta,
221  maxEta] (const auto& t) {
222  return t->Et() > minEt and t->Eta() >= minEta and t->Eta() <= maxEta;
223  };
224 
225  std::copy_if(std::cbegin(tobs),
226  std::cend(tobs),
227  std::back_inserter(selectedTobs),
228  tobSelector);
229 
230 
231  return StatusCode::SUCCESS;
232  }
233 
234 
235 
236  StatusCode
237  InvariantMassDeltaPhiInclusive2AlgTool::selectTobs(const GenericTobContainer& tobs,
238  GenericTobContainer& selectedTobs,
239  int minEt) const {
240 
241  auto tobSelector = [minEt] (const auto& t) {
242  return t->Et() > minEt;
243  };
244 
245  std::copy_if(std::cbegin(tobs),
246  std::cend(tobs),
247  std::back_inserter(selectedTobs),
248  tobSelector);
249 
250 
251  return StatusCode::SUCCESS;
252  }
253 
254  */
255 
256  StatusCode
258  std::vector<bool>& flags,
259  int minEt,
260  int minEta,
261  int maxEta) const {
262 
263  auto tobSelector = [minEt,
264  minEta,
265  maxEta] (const auto& t) {
266  return t->Et() > minEt and t->Eta() >= minEta and t->Eta() <= maxEta;
267  };
268 
269  std::transform(std::cbegin(tobs),
270  std::cend(tobs),
271  std::back_inserter(flags),
272  tobSelector);
273 
274 
275  return StatusCode::SUCCESS;
276  }
277 
278 
279 
280  StatusCode
282  std::vector<bool>& flags,
283  int minEt) const {
284 
285  auto tobSelector = [minEt] (const auto& t) {
286  return t->Et() > minEt;
287  };
288 
289  std::transform(std::cbegin(tobs),
290  std::cend(tobs),
291  std::back_inserter(flags),
292  tobSelector);
293 
294 
295  return StatusCode::SUCCESS;
296  }
297 }
298 
GlobalSim::InvariantMassDeltaPhiInclusive2AlgTool::s_inputWidth1
constexpr static std::size_t s_inputWidth1
Definition: InvariantMassDeltaPhiInclusive2AlgTool.h:189
fitman.sz
sz
Definition: fitman.py:527
get_generator_info.result
result
Definition: get_generator_info.py:21
PowhegControl_ttHplus_NLO.ss
ss
Definition: PowhegControl_ttHplus_NLO.py:83
GlobalSim::cutChecker
bool cutChecker(const std::vector< int > &vals, std::size_t sz)
Definition: InvariantMassDeltaPhiInclusive2AlgTool.cxx:26
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:67
AthenaPoolTestRead.flags
flags
Definition: AthenaPoolTestRead.py:8
max
constexpr double max()
Definition: ap_fixedTest.cxx:33
AlgoDataTypes.h
GlobalSim::InvariantMassDeltaPhiInclusive2AlgTool::m_applyEtaCuts
Gaudi::Property< bool > m_applyEtaCuts
Definition: InvariantMassDeltaPhiInclusive2AlgTool.h:63
GlobalSim::InvariantMassDeltaPhiInclusive2AlgTool::m_minEta2Cuts
Gaudi::Property< std::vector< int > > m_minEta2Cuts
Definition: InvariantMassDeltaPhiInclusive2AlgTool.h:84
GlobalSim::InvariantMassDeltaPhiInclusive2AlgTool::s_inputWidth2
constexpr static std::size_t s_inputWidth2
Definition: InvariantMassDeltaPhiInclusive2AlgTool.h:190
GlobalSim::InvariantMassDeltaPhiInclusive2AlgTool::m_tobsInReadKey1
SG::ReadHandleKey< GenericTobContainer > m_tobsInReadKey1
Definition: InvariantMassDeltaPhiInclusive2AlgTool.h:143
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
GlobalSim::InvariantMassDeltaPhiInclusive2AlgTool::m_minEt1Cuts
Gaudi::Property< std::vector< int > > m_minEt1Cuts
Definition: InvariantMassDeltaPhiInclusive2AlgTool.h:49
python.CaloAddPedShiftConfig.type
type
Definition: CaloAddPedShiftConfig.py:42
PUfitVar::maxEta
constexpr float maxEta
Definition: GepMETPufitAlg.cxx:13
GlobalSim::InvariantMassDeltaPhiInclusive2AlgTool::m_maxEta1Cuts
Gaudi::Property< std::vector< int > > m_maxEta1Cuts
Definition: InvariantMassDeltaPhiInclusive2AlgTool.h:77
GlobalSim
AlgTool to obtain a selection of eFex RoIs read in from the event store.
Definition: dump.h:8
MonitoredCollection.h
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
GlobalSim::InvariantMassDeltaPhiInclusive2AlgTool::m_maxEta2Cuts
Gaudi::Property< std::vector< int > > m_maxEta2Cuts
Definition: InvariantMassDeltaPhiInclusive2AlgTool.h:91
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
Amg::transform
Amg::Vector3D transform(Amg::Vector3D &v, Amg::Transform3D &tr)
Transform a point from a Trasformation3D.
Definition: GeoPrimitivesHelpers.h:156
test_pyathena.parent
parent
Definition: test_pyathena.py:15
CHECK
#define CHECK(...)
Evaluate an expression and check for errors.
Definition: Control/AthenaKernel/AthenaKernel/errorcheck.h:422
SG::VarHandleKey::initialize
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:103
GlobalSim::InvariantMassDeltaPhiInclusive2AlgTool::initialize
virtual StatusCode initialize() override
Definition: InvariantMassDeltaPhiInclusive2AlgTool.cxx:33
Monitored.h
Header file to be included by clients of the Monitored infrastructure.
GlobalSim::InvariantMassDeltaPhiInclusive2AlgTool::m_maxInvMassSqrCuts
Gaudi::Property< std::vector< int > > m_maxInvMassSqrCuts
Definition: InvariantMassDeltaPhiInclusive2AlgTool.h:106
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:240
GlobalSim::InvariantMassDeltaPhiInclusive2AlgTool::selectTobs1
StatusCode selectTobs1(const GenericTobContainer &, AcceptFlags &) const
Definition: InvariantMassDeltaPhiInclusive2AlgTool.cxx:167
GlobalSim::InvariantMassDeltaPhiInclusive2AlgTool::m_tobsInReadKey2
SG::ReadHandleKey< GenericTobContainer > m_tobsInReadKey2
Definition: InvariantMassDeltaPhiInclusive2AlgTool.h:150
GlobalSim::InvariantMassDeltaPhiInclusive2AlgTool::m_minDeltaPhiCuts
Gaudi::Property< std::vector< int > > m_minDeltaPhiCuts
Definition: InvariantMassDeltaPhiInclusive2AlgTool.h:113
GlobalSim::InvariantMassDeltaPhiInclusive2AlgTool::setAcceptFlags
StatusCode setAcceptFlags(const GenericTobContainer &, std::vector< bool > &, int minEt, int minEta, int maxEta) const
Definition: InvariantMassDeltaPhiInclusive2AlgTool.cxx:257
GlobalSim::InvariantMassDeltaPhiInclusive2AlgTool::AcceptFlags
std::vector< std::vector< bool > > AcceptFlags
Definition: InvariantMassDeltaPhiInclusive2AlgTool.h:165
GlobalSim::GenericTobContainer
std::vector< std::shared_ptr< GenericTob > > GenericTobContainer
Definition: GenericTob.h:72
GlobalSim::InvariantMassDeltaPhiInclusive2AlgTool::m_minInvMassSqrCuts
Gaudi::Property< std::vector< int > > m_minInvMassSqrCuts
Definition: InvariantMassDeltaPhiInclusive2AlgTool.h:98
GlobalSim::InvariantMassDeltaPhiInclusive2AlgTool::InvariantMassDeltaPhiInclusive2AlgTool
InvariantMassDeltaPhiInclusive2AlgTool(const std::string &type, const std::string &name, const IInterface *parent)
Definition: InvariantMassDeltaPhiInclusive2AlgTool.cxx:20
InvariantMassDeltaPhiInclusive2AlgTool.h
python.PyAthena.v
v
Definition: PyAthena.py:154
SG::WriteHandle
Definition: StoreGate/StoreGate/WriteHandle.h:73
GlobalSim::InvariantMassDeltaPhiInclusive2AlgTool::selectTobs2
StatusCode selectTobs2(const GenericTobContainer &, AcceptFlags &) const
Definition: InvariantMassDeltaPhiInclusive2AlgTool.cxx:190
GlobalSim::InvariantMassDeltaPhiInclusive2AlgTool::run
virtual StatusCode run(const EventContext &ctx) const override
Definition: InvariantMassDeltaPhiInclusive2AlgTool.cxx:97
GlobalSim::InvariantMassDeltaPhiInclusive2AlgTool::m_maxDeltaPhiCuts
Gaudi::Property< std::vector< int > > m_maxDeltaPhiCuts
Definition: InvariantMassDeltaPhiInclusive2AlgTool.h:120
GlobalSim::InvariantMassDeltaPhiInclusive2AlgTool::toString
virtual std::string toString() const override
Definition: InvariantMassDeltaPhiInclusive2AlgTool.cxx:155
DataCollector.h
GlobalSim::InvariantMassDeltaPhiInclusive2AlgTool::m_resultsWriteKey
SG::WriteHandleKey< InvariantMassResult > m_resultsWriteKey
Definition: InvariantMassDeltaPhiInclusive2AlgTool.h:158
GlobalSim::InvariantMassDeltaPhiInclusive2AlgTool::m_minEta1Cuts
Gaudi::Property< std::vector< int > > m_minEta1Cuts
Definition: InvariantMassDeltaPhiInclusive2AlgTool.h:70
GlobalSim::InvariantMassDeltaPhiInclusive2AlgTool::m_minEt2Cuts
Gaudi::Property< std::vector< int > > m_minEt2Cuts
Definition: InvariantMassDeltaPhiInclusive2AlgTool.h:56
PlotCalibFromCool.vals
vals
Definition: PlotCalibFromCool.py:474