ATLAS Offline Software
TruthParentDecoratorAlg.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3 */
5 
8 
10 
11 #include <format>
12 
13 // structure to hold info on a matched parent particle
15 {
18  float deltaR;
19  unsigned int parent_index;
20  std::set<int> cascade_pids;
21 };
22 
23 namespace {
24 
25  using Barcodex = TruthParentDecoratorAlg::Barcodex;
26  using IPMap = TruthParentDecoratorAlg::IPMap;
27  using JC = TruthParentDecoratorAlg::JC;
28  using TPC = TruthParentDecoratorAlg::TPC;
29  using parent_mask_t = unsigned long long;
30 
31  parent_mask_t matchMask(const std::vector<MatchedParent>& matches) {
32  parent_mask_t mask = 0x0;
33  for (const auto& match: matches) {
34  constexpr size_t max_idx = std::numeric_limits<decltype(mask)>::digits;
35  if (match.parent_index > max_idx) {
36  throw std::runtime_error(
37  "parent index overflowed the match mask "
38  "[index: " + std::to_string(match.parent_index) +
39  " , max_mask: " + std::to_string(max_idx) + "]");
40  }
41  mask |= (0x1u << match.parent_index);
42  }
43  return mask;
44  }
45 
46  // debugging functions
47  std::string join(const std::vector<std::string>& v, const std::string& sep = ", ") {
48  std::string out;
49  for (unsigned int pos = 0; pos < v.size(); pos++) {
50  out.append(v.at(pos));
51  if (pos + 1 < v.size()) out.append(sep);
52  }
53  return out;
54  }
55  template <typename T>
56  std::vector<std::string> stringify(const T& container) {
57  std::vector<std::string> out;
58  for (const auto& v: container) out.push_back(std::to_string(v));
59  return out;
60  }
61  // debugging function, not used now
62  [[maybe_unused]]
63  std::string listAllChildren(const xAOD::TruthParticle* p) {
64  std::vector<std::string> output;
65  for (unsigned int child_n = 0; child_n < p->nChildren(); child_n++) {
66  output.push_back(std::to_string(p->child(child_n)->pdgId()));
67  }
68  if (output.empty()) return "none";
69  return "[" + join(output) + "]";
70  }
71 
72 
73  // debugging functions using MsgStream
74  void logInputs(MsgStream& msg,SG::ReadHandle<JC>& targets,SG::ReadHandle<TPC>& truth,std::vector<SG::ReadHandle<TPC>>& cascades_raw,const MSG::Level level = MSG::DEBUG)
75  {
76  if (msg.level() > level) return;
77  unsigned int n_cascade_candidates = 0;
78  for (auto& cascade: cascades_raw) {
79  n_cascade_candidates += cascade->size();
80  }
81  msg << level <<
82  "n_targets: " << targets->size() << ", "
83  "n_parents: " << truth->size() << ", "
84  "n_cascade_candidates: " << n_cascade_candidates <<
85  endmsg;
86  }
87  void logIPMap(MsgStream& msg,const IPMap& ipmap,const MSG::Level level = MSG::VERBOSE)
88  {
89  if (msg.level() > level) return;
90  for (const auto& [barcode, children]: ipmap) {
91  std::set<int> ids;
92  for (const xAOD::TruthParticle* dup: children) ids.insert(dup->pdgId());
93  msg << level << "barcode: " << barcode << ", n_dup: " << children.size()
94  << " idg_ids: [" << join(stringify(ids)) << "]" << endmsg;
95  }
96  }
97 
98 
99  // functions to traverse barcodex and disambiguate the selected
100  // child
101  std::map<int, std::set<int>> findAllDescendants(int parent, const Barcodex& barcodex, std::set<int> history = {})
102  {
103  using return_t = std::map<int,std::set<int>>;
104  auto itr = barcodex.find(parent);
105  if (itr == barcodex.end()) {
106  auto hist = stringify(history);
107  throw std::runtime_error(
108  "can't find barcode " + std::to_string(parent) + " history:"
109  " {" + join(hist) + "}");
110  }
111  const std::set<int>& children = itr->second;
112  if (children.empty()) return return_t{{parent, history}};
113  if (!history.insert(parent).second) {
114  auto hist = stringify(history);
115  throw std::runtime_error("found cycle, tried to add " + std::to_string(parent) + " to {" + join(hist) + "}");
116  }
117  return_t all_children;
118  for (int child: children) {
119  // We don't just merge the children here in case there are
120  // multiple histories that lead to the same discendent. Instead
121  // we merge the histories of all descendents.
122  for (auto& [dec, dh]: findAllDescendants(child, barcodex, history)) {
123  all_children[dec].merge(dh);
124  }
125  }
126  return all_children;
127  }
128 
129 
130  const xAOD::TruthParticle* selectChild(const IPMap::mapped_type& barkids)
131  {
132  const xAOD::TruthParticle* child = *barkids.begin();
133  if (barkids.size() > 1) {
134  std::set<int> pdg_ids;
135  TLorentzVector sum_p4;
136  // look at duplicates, take the one with the most children
137  for (const xAOD::TruthParticle* dupkid: barkids) {
138  sum_p4 += dupkid->p4();
139  pdg_ids.insert(dupkid->pdgId());
140  if (dupkid->nChildren() > child->nChildren()) child = dupkid;
141  }
142  if (pdg_ids.size() != 1) {
143  throw std::runtime_error("same barcode, different pdgid: [" + join(stringify(pdg_ids)) + "]");
144  }
145  if (float dr = child->p4().DeltaR(sum_p4); dr > 0.001) {
146  throw std::runtime_error( "Same barcode, different vector: { deltaR: " + std::to_string(dr) + ", pdgid: " + std::to_string(child->pdgId()) + "}"
147  );
148  }
149  }
150  return child;
151  }
152 
153 
154  bool isOriginal(const xAOD::TruthParticle* p) {
155  for (unsigned int parent_n = 0; parent_n < p->nParents(); parent_n++) {
156  const xAOD::TruthParticle* parent = p->parent(parent_n);
157  if (!parent) throw std::runtime_error("broken truth record");
158  if (parent->pdgId() == p->pdgId()) return false;
159  }
160  return true;
161  }
162 
163 
164  // these functions are for dealing with specific vertices
165 
166  const xAOD::TruthParticle* getParent(const xAOD::TruthParticle* p) {
167  if (int n_parents = p->nParents(); n_parents != 1) {
168  throw std::logic_error("can't get parent [n_parents: " + std::to_string(n_parents) + "]");
169  }
170  return p->parent(0);
171  }
172  bool isSoftLepton(const xAOD::TruthParticle* p) {
173  const xAOD::TruthParticle* parent = getParent(p);
174  return (parent->hasCharm() || parent->hasBottom()) && p->isChLepton();
175  }
176  bool isSoftCharm(const xAOD::TruthParticle* p) {
177  const xAOD::TruthParticle* parent = getParent(p);
178  return parent->hasBottom() && p->hasCharm();
179  }
180 
181 }
182 
183 
184 // cascade count decorator
185 CascadeCountDecorator::CascadeCountDecorator( const std::string& name, const std::vector<int>& pids):
186  m_pids(pids.begin(), pids.end()),
187  m_dec(name),
188  // also hang on to the auxid so we can lock it later
189  m_auxid(SG::AuxTypeRegistry::instance().findAuxID(name))
190 {
191 }
192 void CascadeCountDecorator::decorate(const SG::AuxElement& target,const std::vector<MatchedParent>& parents) const
193 {
194  unsigned char n_match = 0;
195  for (const auto& parent: parents) {
196  for (const auto& pid: m_pids) {
197  if (parent.cascade_pids.contains(pid)) n_match++;
198  }
199  }
200  m_dec(target) = n_match;
201 }
203 {
204  m_dec(target) = 0;
205 }
207 {
208  // We're locking a decoration on a const container, which would be a
209  // problem if they were made by anyone else since someone else might
210  // be messing with them. But here it shouldn't be a problem since we
211  // made them.
212  auto* cont ATLAS_THREAD_SAFE = const_cast<xAOD::IParticleContainer*>(target);
213  cont->lockDecoration(m_auxid);
214 }
215 
216 
217 // main algorithm
218 TruthParentDecoratorAlg::TruthParentDecoratorAlg(const std::string& name, ISvcLocator* loc):
220 {
221  // these aren't user configurable
222  declare(m_target_pdgid_key);
223  declare(m_target_dr_truth_key);
224  declare(m_target_link_key);
225  declare(m_target_index_key);
226  declare(m_target_n_matched_key);
227  declare(m_target_match_mask_key);
228  declare(m_match_pdgid_key);
229  declare(m_match_children_key);
230  declare(m_match_link_key);
231 }
232 
234  // initialize inputs
235  ATH_CHECK(m_parents_key.initialize());
236  ATH_CHECK(m_target_container_key.initialize());
237  ATH_CHECK(m_cascades_key.initialize());
238  // weird hack because Gaudi can't handle an infinite default
239  if (m_match_delta_r.value() <= 0) m_match_delta_r.value() = INFINITY;
240  // initialize outputs
241  std::string jc = m_target_container_key.key();
242  std::string pfx = jc + "." + m_prefix.value();
243  m_target_pdgid_key = pfx + "PdgId";
244  m_target_dr_truth_key = pfx + "DRTruthParticle";
245  m_target_link_key = pfx + "Link";
246  m_target_index_key = pfx + "Index";
247  m_target_n_matched_key = pfx + "NMatchedChildren";
248  m_target_match_mask_key = pfx + "ParentsMask";
249  m_match_pdgid_key = pfx + "MatchingParticlePdgId";
250  m_match_children_key = pfx + "MatchingParticleNChildren";
251  m_match_link_key = pfx + "MatchingParticleLink";
252  ATH_CHECK(m_target_pdgid_key.initialize());
253  ATH_CHECK(m_target_dr_truth_key.initialize());
254  ATH_CHECK(m_target_link_key.initialize());
255  ATH_CHECK(m_target_index_key.initialize());
256  ATH_CHECK(m_target_n_matched_key.initialize());
257  ATH_CHECK(m_target_match_mask_key.initialize());
258  ATH_CHECK(m_match_pdgid_key.initialize());
259  ATH_CHECK(m_match_children_key.initialize());
260  ATH_CHECK(m_match_link_key.initialize());
261 
262  for (auto& [key, pids]: m_counts_matching_cascade) {
263  m_cascade_count_writer_keys.emplace_back(jc + "." + key);
264  m_cascade_count_decorators.emplace_back(key, pids);
265  }
266  for (auto& key: m_cascade_count_writer_keys) declare(key);
268 
269  return StatusCode::SUCCESS;
270 }
271 
272 StatusCode TruthParentDecoratorAlg::execute(const EventContext& cxt) const
273 {
274  ATH_MSG_DEBUG("Executing");
275 
277  // part 1: read in the particles
280 
281  using uc_t = unsigned char;
291 
292  if (targets->empty()) return StatusCode::SUCCESS;
293 
294  // read in and sort the parent collection
295  SG::ReadHandle<TPC> phandle(m_parents_key, cxt);
296  std::set<int> parentids(m_parent_pdgids.begin(), m_parent_pdgids.end());
297  std::vector<const xAOD::TruthParticle*> psort;
298  for (const xAOD::TruthParticle* p: *phandle) {
299  if (!parentids.contains(p->pdgId())) continue;
300  if (!isOriginal(p)) continue;
301  psort.push_back(p);
302  }
303  // for lack of a better idea, store truth parents sorted by mass
304  std::sort(psort.begin(), psort.end(),[](const auto* p1, const auto* p2) {return p1->m() > p2->m();});
305  // check to make sure we don't overflow the match mask
306  constexpr size_t max_idx = std::numeric_limits<parent_mask_t>::digits;
307  if (psort.size() > max_idx) {
309  "Found too many parent particles to store in parent match mask "
310  "truncating the parent collection [max: " << max_idx << ", "
311  "n: " << psort.size() << "]");
312  psort.resize(max_idx);
313  }
314 
315 
316  std::vector<SG::ReadHandle<TPC>> cascades_raw;
317  for (const auto& key: m_cascades_key) {
318  cascades_raw.emplace_back(key, cxt);
319  }
320  logInputs(msgStream(), targets, phandle, cascades_raw);
321 
323  // part 2: build the barcodex
325  Barcodex barcodex;
326  IPMap ipmap;
327  addTruthContainer(barcodex, ipmap, *phandle);
328  for (auto& cascade: cascades_raw) {
329  addTruthContainer(barcodex, ipmap, *cascade);
330  }
331  logIPMap(msg(), ipmap);
332 
333  ATH_MSG_DEBUG("merged cascade contains " << barcodex.size() << " particles");
334 
336  // Part 3: build map from targets to parents
338  std::unordered_map<const J*, std::vector<MatchedParent>> labeled_targets;
339  unsigned int n_parents = 0;
340  for (const auto* p: psort) {
341  unsigned int parent_index = n_parents++;
342  ATH_MSG_VERBOSE("pdgid: " << p->pdgId() << ", barcode: " << HepMC::uniqueID(p));
343  for (auto& [cbar, histbars]: findAllDescendants(HepMC::uniqueID(p), barcodex)) {
344  IPMap::mapped_type& barkids = ipmap.at(cbar);
345  const xAOD::TruthParticle* child = selectChild(barkids);
346  std::vector<std::pair<float, const J*>> drs;
347  float drsMinDR=9999;
348  const J* drsMinMatch = 0;
349  for (const auto* j: *targets) {
350  if(j->p4().DeltaR(child->p4()) < drsMinDR) {
351  drsMinDR=j->p4().DeltaR(child->p4());
352  drsMinMatch=j;
353  }
354  }
355  if(drsMinMatch){
357  match.parent = p;
358  match.child = child;
359  match.deltaR = drsMinDR;
360  match.parent_index = parent_index;
361  match.cascade_pids.insert(child->pdgId());
362  for (auto& histbar: histbars) {
363  match.cascade_pids.insert(selectChild(ipmap.at(histbar))->pdgId());
364  }
365  if (match.deltaR < m_match_delta_r) {
366  labeled_targets[drsMinMatch].push_back(match);
367  }
368  }
369  }
370  }
371 
373  // Part 4: decorate!
375 
376  for (const J* j: *targets) {
377  if (labeled_targets.contains(j)) {
378  const std::vector<MatchedParent>& matches = labeled_targets.at(j);
379  auto min_dr = [](auto& p1, auto& p2) {
380  return p1.deltaR < p2.deltaR;
381  };
382  const MatchedParent& nearest = *std::min_element(
383  matches.begin(), matches.end(), min_dr);
384  const xAOD::TruthParticle* p = nearest.parent;
385  pdgid(*j) = p->pdgId();
386  deltaR(*j) = nearest.deltaR;
387  auto* container = dynamic_cast<const TPC*>(p->container());
388  link(*j) = JL(*container, p->index());
389  index(*j) = nearest.parent_index;
390  nMatched(*j) = matches.size();
391  mask(*j) = matchMask(matches);
392  const xAOD::TruthParticle* child = nearest.child;
393  matchPdgId(*j) = child->pdgId();
394  matchChildCount(*j) = child->nChildren();
395  auto* matchedContainer = dynamic_cast<const TPC*>(child->container());
396  matchLink(*j) = JL(*matchedContainer, child->index());
397  for (const auto& cascadeCount: m_cascade_count_decorators) {
398  cascadeCount.decorate(*j, matches);
399  }
400  } else {
401  pdgid(*j) = 0;
402  deltaR(*j) = NAN;
403  link(*j) = JL();
404  index(*j) = -1;
405  nMatched(*j) = -1;
406  mask(*j) = 0x0;
407  matchPdgId(*j) = 0;
408  matchChildCount(*j) = 0;
409  matchLink(*j) = JL();
410  for (const auto& cascadeCount: m_cascade_count_decorators) {
411  cascadeCount.decorateDefault(*j);
412  }
413  }
414  }
415 
417  // Part 5: lock decorations
419 
420  for (const auto& dec: m_cascade_count_decorators) {
421  dec.lock(targets.get());
422  }
423 
424  return StatusCode::SUCCESS;
425 }
426 
428  if (!m_allow_missing_children_pdgids.empty()) {
429  float missing_fraction = double(m_missing_n_ignored) / m_total_children;
430  auto msg = std::format("ignored {} missing children out of {} ({:.2}%)",m_missing_n_ignored.load(),m_total_children.load(),missing_fraction * 100);
431  if (missing_fraction > m_missing_children_fraction_warning_threshold) {
433  } else {
434  ATH_MSG_INFO(msg);
435  }
436  }
437  if (!m_warn_missing_children_pdgids.empty()) {
438  auto msg = std::format("warned of {} missing children out of {}", m_missing_n_warned.load(), m_total_children.load());
439  if (m_missing_n_warned > 0) {
441  } else {
442  ATH_MSG_INFO(msg);
443  }
444  }
445  return StatusCode::SUCCESS;
446 }
447 
449 
450  std::set<int> targid(m_cascade_pdgids.begin(), m_cascade_pdgids.end());
451  // we allow decays through any of the parent pdgids
452  targid.insert(m_parent_pdgids.begin(), m_parent_pdgids.end());
453 
454  // this determines if a cascade vertex should be saved or not
455  auto cascadeWants = [
456  &targid,
457  b=m_add_b,
458  c=m_add_c,
459  vsl=m_veto_soft_lepton,
461  ] (const xAOD::TruthParticle* p) {
462  if (int n_parents = p->nParents(); n_parents == 1) {
463  if (vsl && isSoftLepton(p)) return false;
464  if (vsc && isSoftCharm(p)) return false;
465  }
466  if (targid.contains(p->pdgId())) return true;
467  if (b && p->hasBottom()) return true;
468  if (c && p->hasCharm()) return true;
469  return false;
470  };
471 
472  // insert a particle into the record, return the child set
473  auto insert = [&barcodex, &ipmap](const xAOD::TruthParticle* p) -> auto& {
474  ipmap[HepMC::uniqueID(p)].insert(p);
475  return barcodex[HepMC::uniqueID(p)];
476  };
477 
478  for (const xAOD::TruthParticle* p: container) {
479  if (cascadeWants(p)) {
480  auto& child_set = insert(p);
481  for (unsigned int child_n = 0; child_n < p->nChildren(); child_n++) {
482  const xAOD::TruthParticle* c = p->child(child_n);
483 
484  // Unfortunately the truth record is often broken in various
485  // ways. There are a few configurable ways to deal with
486  // this. We keep track of the total number and how often we
487  // use these workarounds to make sure things don't go too
488  // crazy.
490  const auto& ok_missing = m_allow_missing_children_pdgids.value();
491  if (!c) {
492  if(ok_missing.contains(p->pdgId())) {
494  } else {
495  auto problem = std::format(
496  "null truth child [barcode={},pdg_id={},child={}of{}]",
497  HepMC::uniqueID(p), p->pdgId(), child_n, p->nChildren());
498  const auto& warn_missing = m_warn_missing_children_pdgids.value();
499  if (warn_missing.contains(p->pdgId())) {
501  ATH_MSG_WARNING(problem);
502  } else {
503  throw std::runtime_error(problem);
504  }
505  }
506  } else if (cascadeWants(c)) {
507  insert(c);
508  child_set.insert(HepMC::uniqueID(c));
509  }
510  };
511  }
512  }
513 }
TruthParentDecoratorAlg::m_parent_pdgids
Gaudi::Property< std::vector< int > > m_parent_pdgids
Definition: TruthParentDecoratorAlg.h:53
TruthParentDecoratorAlg::m_cascades_key
SG::ReadHandleKeyArray< TPC > m_cascades_key
Definition: TruthParentDecoratorAlg.h:80
TruthParentDecoratorAlg::initialize
virtual StatusCode initialize() override
Definition: TruthParentDecoratorAlg.cxx:233
MatchedParent::child
const xAOD::TruthParticle * child
Definition: TruthParentDecoratorAlg.cxx:17
TruthParentDecoratorAlg::m_veto_soft_lepton
Gaudi::Property< bool > m_veto_soft_lepton
Definition: TruthParentDecoratorAlg.h:65
TruthParentDecoratorAlg::addTruthContainer
void addTruthContainer(Barcodex &, IPMap &, const TPC &) const
Definition: TruthParentDecoratorAlg.cxx:448
SG
Forward declaration.
Definition: CaloCellPacker_400_500.h:32
MatchedParent::deltaR
float deltaR
Definition: TruthParentDecoratorAlg.cxx:18
vtune_athena.format
format
Definition: vtune_athena.py:14
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
CascadeCountDecorator::m_auxid
SG::auxid_t m_auxid
Definition: TruthParentDecoratorAlg.h:28
TruthParentDecoratorAlg::JL
ElementLink< JC > JL
Definition: TruthParentDecoratorAlg.h:39
CascadeCountDecorator::CascadeCountDecorator
CascadeCountDecorator(const std::string &name, const std::vector< int > &pids)
Definition: TruthParentDecoratorAlg.cxx:185
TruthParentDecoratorAlg::m_match_link_key
SG::WriteDecorHandleKey< JC > m_match_link_key
Definition: TruthParentDecoratorAlg.h:91
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:67
SG::AuxElement
Base class for elements of a container that can have aux data.
Definition: AuxElement.h:483
python.DecayParser.parents
parents
print ("==> buf:",buf)
Definition: DecayParser.py:31
TruthParentDecoratorAlg::finalize
virtual StatusCode finalize() override
Definition: TruthParentDecoratorAlg.cxx:427
plotmaker.hist
hist
Definition: plotmaker.py:148
xAOD::char
char
Definition: TrigDecision_v1.cxx:38
TRTCalib_cfilter.p1
p1
Definition: TRTCalib_cfilter.py:130
PlotCalibFromCool.begin
begin
Definition: PlotCalibFromCool.py:94
python.AthDsoLogger.out
out
Definition: AthDsoLogger.py:70
TruthParentDecoratorAlg::m_target_container_key
SG::ReadHandleKey< JC > m_target_container_key
Definition: TruthParentDecoratorAlg.h:47
python.TurnDataReader.dr
dr
Definition: TurnDataReader.py:111
TruthParentDecoratorAlg::m_add_b
Gaudi::Property< bool > m_add_b
Definition: TruthParentDecoratorAlg.h:59
PyPoolBrowser.dh
dh
Definition: PyPoolBrowser.py:102
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
xAOD::IParticle
Class providing the definition of the 4-vector interface.
Definition: Event/xAOD/xAODBase/xAODBase/IParticle.h:41
TruthParentDecoratorAlg::TPC
xAOD::TruthParticleContainer TPC
Definition: TruthParentDecoratorAlg.h:38
TruthParentDecoratorAlg::m_cascade_count_decorators
std::vector< CascadeCountDecorator > m_cascade_count_decorators
Definition: TruthParentDecoratorAlg.h:99
Trk::u
@ u
Enums for curvilinear frames.
Definition: ParamDefs.h:77
TruthParentDecoratorAlg::TruthParentDecoratorAlg
TruthParentDecoratorAlg(const std::string &name, ISvcLocator *loc)
Definition: TruthParentDecoratorAlg.cxx:218
python.utils.AtlRunQueryLookup.mask
string mask
Definition: AtlRunQueryLookup.py:459
TruthParentDecoratorAlg::m_parents_key
SG::ReadHandleKey< TPC > m_parents_key
Definition: TruthParentDecoratorAlg.h:77
TruthParentDecoratorAlg::m_target_pdgid_key
SG::WriteDecorHandleKey< JC > m_target_pdgid_key
Definition: TruthParentDecoratorAlg.h:83
CascadeCountDecorator::m_pids
std::vector< int > m_pids
Definition: TruthParentDecoratorAlg.h:26
mergePhysValFiles.end
end
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:92
python.iconfTool.models.loaders.level
level
Definition: loaders.py:20
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition: AthReentrantAlgorithm.h:74
instance
std::map< std::string, double > instance
Definition: Run_To_Get_Tags.h:8
TruthParentDecoratorAlg::m_match_delta_r
Gaudi::Property< float > m_match_delta_r
Definition: TruthParentDecoratorAlg.h:73
TRTCalib_cfilter.p2
p2
Definition: TRTCalib_cfilter.py:131
CascadeCountDecorator::m_dec
SG::AuxElement::Decorator< unsigned char > m_dec
Definition: TruthParentDecoratorAlg.h:27
TruthParentDecoratorAlg::IPMap
std::map< int, std::set< const xAOD::TruthParticle * > > IPMap
Definition: TruthParentDecoratorAlg.h:35
TruthParentDecoratorAlg::m_add_c
Gaudi::Property< bool > m_add_c
Definition: TruthParentDecoratorAlg.h:62
TruthParentDecoratorAlg::m_cascade_pdgids
Gaudi::Property< std::vector< int > > m_cascade_pdgids
Definition: TruthParentDecoratorAlg.h:56
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:209
TrigConf::MSGTC::Level
Level
Definition: Trigger/TrigConfiguration/TrigConfBase/TrigConfBase/MsgStream.h:21
stringify
std::string stringify(T obj)
Definition: VolumeTreeNavigator.h:73
TruthParentDecoratorAlg::m_total_children
std::atomic< unsigned long long > m_total_children
Definition: TruthParentDecoratorAlg.h:115
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
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
TruthParentDecoratorAlg::Barcodex
std::map< int, std::set< int > > Barcodex
Definition: TruthParentDecoratorAlg.h:34
HepMC::barcode
int barcode(const T *p)
Definition: Barcode.h:16
rerun_display.pfx
pfx
Definition: rerun_display.py:60
xAOD::TruthParticle_v1
Class describing a truth particle in the MC record.
Definition: TruthParticle_v1.h:37
SG::WriteDecorHandle
Handle class for adding a decoration to an object.
Definition: StoreGate/StoreGate/WriteDecorHandle.h:100
TruthParentDecoratorAlg::m_counts_matching_cascade
Gaudi::Property< cascade_counter_property_t > m_counts_matching_cascade
Definition: TruthParentDecoratorAlg.h:93
PyAlgorithmExample.min_dr
def min_dr(p, l)
Definition: PyAlgorithmExample.py:57
TruthParentDecoratorAlg::m_match_children_key
SG::WriteDecorHandleKey< JC > m_match_children_key
Definition: TruthParentDecoratorAlg.h:90
WriteDecorHandle.h
Handle class for adding a decoration to an object.
HepMC::uniqueID
int uniqueID(const T &p)
Definition: MagicNumbers.h:116
ParticleGun_EoverP_Config.pid
pid
Definition: ParticleGun_EoverP_Config.py:62
TruthParentDecoratorAlg::m_target_n_matched_key
SG::WriteDecorHandleKey< JC > m_target_n_matched_key
Definition: TruthParentDecoratorAlg.h:87
test_pyathena.parent
parent
Definition: test_pyathena.py:15
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
TruthParentDecoratorAlg::m_warn_missing_children_pdgids
Gaudi::Property< std::unordered_set< int > > m_warn_missing_children_pdgids
Definition: TruthParentDecoratorAlg.h:109
TruthParentDecoratorAlg::m_missing_n_ignored
std::atomic< unsigned long long > m_missing_n_ignored
Definition: TruthParentDecoratorAlg.h:113
TruthParentDecoratorAlg::m_cascade_count_writer_keys
SG::WriteDecorHandleKeyArray< JC > m_cascade_count_writer_keys
Definition: TruthParentDecoratorAlg.h:98
MatchedParent::parent_index
unsigned int parent_index
Definition: TruthParentDecoratorAlg.cxx:19
xAOD::double
double
Definition: CompositeParticle_v1.cxx:159
SG::AuxElement::index
size_t index() const
Return the index of this element within its container.
DataVector
Derived DataVector<T>.
Definition: DataVector.h:794
TruthParentDecoratorAlg::m_prefix
Gaudi::Property< std::string > m_prefix
Definition: TruthParentDecoratorAlg.h:50
CascadeCountDecorator::decorate
void decorate(const SG::AuxElement &target, const std::vector< MatchedParent > &parents) const
Definition: TruthParentDecoratorAlg.cxx:192
merge.output
output
Definition: merge.py:16
grepfile.sep
sep
Definition: grepfile.py:38
TruthParentDecoratorAlg::m_missing_children_fraction_warning_threshold
Gaudi::Property< float > m_missing_children_fraction_warning_threshold
Definition: TruthParentDecoratorAlg.h:105
TCS::join
std::string join(const std::vector< std::string > &v, const char c=',')
Definition: Trigger/TrigT1/L1Topo/L1TopoCommon/Root/StringUtils.cxx:10
TruthParentDecoratorAlg::m_target_index_key
SG::WriteDecorHandleKey< JC > m_target_index_key
Definition: TruthParentDecoratorAlg.h:86
xAOD::TruthParticle_v1::nChildren
size_t nChildren() const
Number of children of this particle.
Definition: TruthParticle_v1.cxx:135
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:240
python.subdetectors.mmg.ids
ids
Definition: mmg.py:8
ActsTrk::to_string
std::string to_string(const DetectorType &type)
Definition: GeometryDefs.h:34
plotBeamSpotMon.b
b
Definition: plotBeamSpotMon.py:76
TruthParentDecoratorAlg::execute
virtual StatusCode execute(const EventContext &) const override
Definition: TruthParentDecoratorAlg.cxx:272
xAOD::IParticle::p4
virtual FourMom_t p4() const =0
The full 4-momentum of the particle.
python.LumiBlobConversion.pos
pos
Definition: LumiBlobConversion.py:16
MatchedParent::cascade_pids
std::set< int > cascade_pids
Definition: TruthParentDecoratorAlg.cxx:20
MatchedParent
Definition: TruthParentDecoratorAlg.cxx:15
python.PyAthena.v
v
Definition: PyAthena.py:154
TruthParentDecoratorAlg::m_target_dr_truth_key
SG::WriteDecorHandleKey< JC > m_target_dr_truth_key
Definition: TruthParentDecoratorAlg.h:84
DeMoScan.index
string index
Definition: DeMoScan.py:362
TruthParentDecoratorAlg.h
TruthParentDecoratorAlg::m_veto_soft_charm
Gaudi::Property< bool > m_veto_soft_charm
Definition: TruthParentDecoratorAlg.h:69
CascadeCountDecorator::decorateDefault
void decorateDefault(const SG::AuxElement &target) const
Definition: TruthParentDecoratorAlg.cxx:202
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
copySelective.target
string target
Definition: copySelective.py:36
DEBUG
#define DEBUG
Definition: page_access.h:11
TruthParentDecoratorAlg::m_target_match_mask_key
SG::WriteDecorHandleKey< JC > m_target_match_mask_key
Definition: TruthParentDecoratorAlg.h:88
AthCommonMsg< Gaudi::Algorithm >::msg
MsgStream & msg() const
Definition: AthCommonMsg.h:24
TruthParentDecoratorAlg::m_allow_missing_children_pdgids
Gaudi::Property< std::unordered_set< int > > m_allow_missing_children_pdgids
Definition: TruthParentDecoratorAlg.h:101
CascadeCountDecorator::lock
void lock(const xAOD::IParticleContainer *target) const
Definition: TruthParentDecoratorAlg.cxx:206
TruthParentDecoratorAlg::m_target_link_key
SG::WriteDecorHandleKey< JC > m_target_link_key
Definition: TruthParentDecoratorAlg.h:85
python.DecayParser.children
children
Definition: DecayParser.py:32
TruthParentDecoratorAlg::JC
xAOD::IParticleContainer JC
Definition: TruthParentDecoratorAlg.h:36
TruthParentDecoratorAlg::m_match_pdgid_key
SG::WriteDecorHandleKey< JC > m_match_pdgid_key
Definition: TruthParentDecoratorAlg.h:89
ATLAS_THREAD_SAFE
#define ATLAS_THREAD_SAFE
Definition: checker_macros.h:211
python.Constants.VERBOSE
int VERBOSE
Definition: Control/AthenaCommon/python/Constants.py:13
xAOD::TruthParticle_v1::p4
virtual FourMom_t p4() const override final
The full 4-momentum of the particle.
Definition: TruthParticle_v1.cxx:191
SG::AuxElement::container
const SG::AuxVectorData * container() const
Return the container holding this element.
xAOD::TruthParticle_v1::pdgId
int pdgId() const
PDG ID code.
MatchedParent::parent
const xAOD::TruthParticle * parent
Definition: TruthParentDecoratorAlg.cxx:16
makeComparison.deltaR
float deltaR
Definition: makeComparison.py:36
python.compressB64.c
def c
Definition: compressB64.py:93
TruthParentDecoratorAlg::m_missing_n_warned
std::atomic< unsigned long long > m_missing_n_warned
Definition: TruthParentDecoratorAlg.h:114
python.AutoConfigFlags.msg
msg
Definition: AutoConfigFlags.py:7
HepMCHelpers.h
TSU::T
unsigned long long T
Definition: L1TopoDataTypes.h:35
match
bool match(std::string s1, std::string s2)
match the individual directories of two strings
Definition: hcg.cxx:356
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37