ATLAS Offline Software
HepMcParticleLink.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #ifndef GENERATOROBJECTS_HEPMCPARTICLELINK_H
6 #define GENERATOROBJECTS_HEPMCPARTICLELINK_H
7 
14 #include "SGTools/DataProxy.h"
17 #include "CxxUtils/CachedValue.h"
19 #include "GaudiKernel/MsgStream.h"
20 #include "GaudiKernel/EventContext.h"
21 #include <cassert>
22 #include <cstdint> /*int32_t etc*/
23 #include <iostream>
24 #include <limits> /* numeric_limits */
25 #include <string>
26 #include <vector>
27 
29 #include "AtlasHepMC/GenParticle.h"
31 
32 class IProxyDict;
33 class McEventCollection;
34 
72 {
73 public:
76 
77 
78  enum PositionFlag {
81  };
82 
83  enum UniqueIDFlag {
84  IS_ID = 0,
86  };
87 
88 
94  public:
96  constexpr static index_type UNDEFINED = ~static_cast<index_type>(0); // TODO Move to MagicNumbers.h?
97  constexpr static barcode_type UNDEFINEDBC = ~static_cast<barcode_type>(0); // TODO Move to MagicNumbers.h?
98 
99 
104 
105 
118  PositionFlag isIndexEventPosition = IS_EVENTNUM,
119  UniqueIDFlag isUniqueIDBarcode = IS_ID);
120 
125 
126 
131 
132 
137 
142 
146  barcode_type uid() const;
147 
159 
170  void eventIndex (index_type& index, index_type& position) const;
171 
172 
176  bool linkIsNull() const;
177 
178 
183 
184 
188  inline void setTruthSuppressionType(EBC_SUPPRESSED_TRUTH truthSupp) { m_truthSupp = truthSupp; }
189 
190 
195 
196 
200  static char truthSuppressionTypeAsChar (EBC_SUPPRESSED_TRUTH suppEnum);
201 
202 
206  static EBC_SUPPRESSED_TRUTH truthSuppressionTypeFromChar (char suppChar);
207 
208 
217  bool operator == (const ExtendedBarCode& rhs ) const;
218 
219 
228  bool operator != (const ExtendedBarCode& rhs ) const;
229 
230 
238  bool operator < (const ExtendedBarCode& rhs ) const;
239 
240 
252  static
254  const HepMcParticleLink& rhs);
255 
256 
268  static
270  const HepMcParticleLink& rhs);
271 
272 
276  void print(std::ostream& os) const;
277 
278 
282  void print(MsgStream& os) const;
283 
284 
297  void makeIndex (index_type index, index_type position) const;
298 
299 
313 
314 
315  private:
317  constexpr static index_type POSITION_MASK = UNDEFINED ^ (UNDEFINED>>1);
318 
321 
328  void setIndex (index_type idx, PositionFlag positionFlag);
329 
330 
338 
339 
341  mutable std::atomic<barcode_type> m_BC;
342 
347  mutable std::atomic<index_type> m_evtIndex{0};
348 
351  };
352 
353 
358  HepMcParticleLink (IProxyDict* sg = nullptr);
359 
360 
365  HepMcParticleLink (const EventContext& ctx);
366 
367 
380  uint32_t eventIndex /*= 0*/,
381  PositionFlag positionFlag /*= IS_EVENTNUM*/,
382  UniqueIDFlag uniqueIDFlag /*= IS_ID*/,
384 
385 
399  PositionFlag positionFlag,
400  UniqueIDFlag uniqueIDFlag,
401  const EventContext& ctx);
402 
403 
416  uint32_t eventIndex /*= 0 */,
417  PositionFlag positionFlag /*= IS_EVENTNUM */,
419 
420 
434  PositionFlag positionFlag,
435  const EventContext& ctx);
436 
437 
441  HepMcParticleLink(const HepMcParticleLink& rhs) = default;
442 
443 
447  HepMcParticleLink(HepMcParticleLink&& rhs) noexcept = default;
448 
453 
458 
459 
461 
462 
463 
468 
469 
474 
475 
479  operator HepMC::ConstGenParticlePtr() const;
480 
481 
486 
487 
491  HepMC::ConstGenParticlePtr scptr() const { return cptr(); }
492 
493 
497  bool linkIsNull() const;
498 
499 
503  bool isValid() const;
504 
505 
509  bool operator!() const;
510 
514  operator bool() const;
515 
517 
519 
520 
521 
525  bool operator == (const HepMcParticleLink& rhs) const;
526 
527 
531  bool operator != (const HepMcParticleLink& rhs) const;
532 
533 
537  bool operator < (const HepMcParticleLink& rhs) const;
538 
539 
541 
543 
544 
545 
550  int barcode() const;
551 
552 
556  int id() const;
557 
558 
563  index_type eventIndex() const;
564 
565 
573  static int getEventNumberAtPosition (index_type position, const IProxyDict* sg);
574 
575 
584  static std::vector<index_type> getEventPositionInCollection (index_type index, const IProxyDict* sg);
585 
586 
594 
595 
603  static HepMcParticleLink getRedirectedLink(const HepMcParticleLink& particleLink, uint32_t eventIndex, const EventContext& ctx);
604 
605 
610 
611 
616 
617 
622 
623 
628 
629 
633  void setExtendedBarCode (const ExtendedBarCode& extBarcode);
634 
635 
637 
638 
639  private:
640  friend std::ostream& operator << (std::ostream&, const HepMcParticleLink&);
641  friend MsgStream& operator << (MsgStream&, const HepMcParticleLink&);
642 
643 
649  static const McEventCollection*
651 
652 
658  static SG::DataProxy* find_proxy (const IProxyDict* sg);
659 
660 
664  static std::string getLastEventCollectionName ();
665 
666 
669 
670 
672  // This qualifier allows m_extBarcode to overlap the trailing padding
673  // of @c CachedValue. On x86_64, this reduces the size
674  // of @c HepMcParticleLink from 48 to 40.
677 
678 
681 };
682 
683 
689  const HepMcParticleLink& b);
690 
691 
697 std::ostream& operator<< (std::ostream& os, const HepMcParticleLink& link);
698 
699 
705 MsgStream& operator<< (MsgStream& os, const HepMcParticleLink& link);
706 
707 
709 
710 
711 #endif
ATH_NO_UNIQUE_ADDRESS
#define ATH_NO_UNIQUE_ADDRESS
Definition: no_unique_address.h:36
LArG4FSStartPointFilter.part
part
Definition: LArG4FSStartPointFilter.py:21
EBC_SUPPRESSED_TRUTH
EBC_SUPPRESSED_TRUTH
Definition: MagicNumbers.h:27
CurrentEventStore.h
Hold a pointer to the current event store.
python.PerfMonSerializer.p
def p
Definition: PerfMonSerializer.py:743
ID
std::vector< Identifier > ID
Definition: CalibHitIDCheck.h:24
xAOD::uint32_t
setEventNumber uint32_t
Definition: EventInfo_v1.cxx:127
index
Definition: index.py:1
ExtendedEventContext.h
SG::CurrentEventStore::store
static IProxyDict * store()
Fetch the current store.
IProxyDict
A proxy dictionary.
Definition: AthenaKernel/AthenaKernel/IProxyDict.h:51
GenParticle.h
GenEvent_fwd.h
CxxUtils::CachedValue< HepMC::ConstGenParticlePtr >
no_unique_address.h
Wrapper for C++20 no_unique_address attribute.
McEventCollection
This defines the McEventCollection, which is really just an ObjectVector of McEvent objects.
Definition: McEventCollection.h:33
ReadFromCoolCompare.os
os
Definition: ReadFromCoolCompare.py:231
HepMC::ConstGenParticlePtr
const GenParticle * ConstGenParticlePtr
Definition: GenParticle.h:38
CachedValue.h
Cached value with atomic update.
MagicNumbers.h
plotBeamSpotMon.b
b
Definition: plotBeamSpotMon.py:77
a
TList * a
Definition: liststreamerinfos.cxx:10
LArNewCalib_DelayDump_OFC_Cali.idx
idx
Definition: LArNewCalib_DelayDump_OFC_Cali.py:69
EBC_UNSUPPRESSED
@ EBC_UNSUPPRESSED
Definition: MagicNumbers.h:28
SG::DataProxy
Definition: DataProxy.h:44
xAOD::bool
setBGCode setTAP setLVL2ErrorBits bool
Definition: TrigDecision_v1.cxx:60
GenParticle
@ GenParticle
Definition: TruthClasses.h:30
DataProxy.h