ATLAS Offline Software
Classes | Public Types | Public Member Functions | List of all members
HepMcParticleLink Class Reference

a link optimized in size for a GenParticle in a McEventCollection More...

#include <HepMcParticleLink.h>

Collaboration diagram for HepMcParticleLink:

Classes

class  ExtendedBarCode
 Persistent representation of a link. More...
 

Public Types

enum  PositionFlag { IS_EVENTNUM = 0, IS_POSITION = 1 }
 
enum  UniqueIDFlag { IS_ID = 0, IS_BARCODE = 1 }
 
typedef uint32_t barcode_type
 
typedef uint32_t index_type
 

Public Member Functions

 HepMcParticleLink (IProxyDict *sg=nullptr)
 Default constructor. More...
 
 HepMcParticleLink (const EventContext &ctx)
 Default constructor. More...
 
 HepMcParticleLink (barcode_type uid, uint32_t eventIndex, PositionFlag positionFlag, UniqueIDFlag uniqueIDFlag, IProxyDict *sg=SG::CurrentEventStore::store())
 Constructor. More...
 
 HepMcParticleLink (barcode_type uid, uint32_t eventIndex, PositionFlag positionFlag, UniqueIDFlag uniqueIDFlag, const EventContext &ctx)
 Constructor. More...
 
 HepMcParticleLink (const HepMC::ConstGenParticlePtr &p, uint32_t eventIndex, PositionFlag positionFlag, IProxyDict *sg=SG::CurrentEventStore::store())
 Constructor. More...
 
 HepMcParticleLink (const HepMC::ConstGenParticlePtr &part, uint32_t eventIndex, PositionFlag positionFlag, const EventContext &ctx)
 Constructor. More...
 
 HepMcParticleLink (const HepMcParticleLink &rhs)=default
 Copy constructor. More...
 
 HepMcParticleLink (HepMcParticleLink &&rhs) noexcept=default
 Move constructor. More...
 
HepMcParticleLinkoperator= (const HepMcParticleLink &rhs)=default
 Assignment. More...
 
HepMcParticleLinkoperator= (HepMcParticleLink &&rhs)=default
 Move Assignment. More...
 
pointer interface
const HepMC::GenParticleoperator* () const
 Dereference. More...
 
HepMC::ConstGenParticlePtr operator-> () const
 Dereference. More...
 
 operator HepMC::ConstGenParticlePtr () const
 Dereference. More...
 
HepMC::ConstGenParticlePtr cptr () const
 Dereference. More...
 
HepMC::ConstGenParticlePtr scptr () const
 Dereference/smart pointer. More...
 
bool linkIsNull () const
 return true if neither barcode nor id are valid More...
 
bool isValid () const
 Validity check. More...
 
bool operator! () const
 Validity check. More...
 
 operator bool () const
 Validity check. More...
 
Comparison operators.
bool operator== (const HepMcParticleLink &rhs) const
 Equality comparison. More...
 
bool operator!= (const HepMcParticleLink &rhs) const
 Inequality comparison. More...
 
bool operator< (const HepMcParticleLink &rhs) const
 Ordering comparison. More...
 

ParticleLink-specific methods.

IProxyDictm_store
 Pointer to the store containing the event. More...
 
ATH_NO_UNIQUE_ADDRESS CxxUtils::CachedValue< HepMC::ConstGenParticlePtrm_ptr
 Transient part. Pointer to the particle. More...
 
ExtendedBarCode m_extBarcode
 Persistent part: barcode and location of target GenEvent. More...
 
int barcode () const
 Return the barcode of the target particle. More...
 
int id () const
 Return the id of the target particle. More...
 
index_type eventIndex () const
 Return the event number of the referenced GenEvent. More...
 
index_type getEventPositionInCollection (const IProxyDict *sg) const
 Return the position in the McEventCollection of the GenEvent pointed to by this HepMcParticleLink. More...
 
EBC_SUPPRESSED_TRUTH getTruthSuppressionType () const
 Return whether the truth particle has been suppressed, as an enum. More...
 
void setTruthSuppressionType (EBC_SUPPRESSED_TRUTH truthSupp)
 Return whether the truth particle has been suppressed. More...
 
char getTruthSuppressionTypeAsChar () const
 Return whether the truth particle has been suppressed, as a char ('a'..'b'). More...
 
barcode_type compress () const
 Hash the 32 bit barcode and 16 bit eventindex into a 32bit int. More...
 
void setExtendedBarCode (const ExtendedBarCode &extBarcode)
 Alter the persistent part of the link. More...
 
static int getEventNumberAtPosition (index_type position, const IProxyDict *sg)
 Return the event number of the GenEvent at the specified position in the McEventCollection. More...
 
static std::vector< index_typegetEventPositionInCollection (index_type index, const IProxyDict *sg)
 Return a vector of the positions in the McEventCollection of the GenEvent(s) with a given event number. More...
 
static HepMcParticleLink getRedirectedLink (const HepMcParticleLink &particleLink, uint32_t eventIndex, const EventContext &ctx)
 Return a HepMcParticleLink pointing at the same particle, but in a different GenEvent. More...
 
std::ostream & operator<< (std::ostream &, const HepMcParticleLink &)
 Output operator. More...
 
MsgStream & operator<< (MsgStream &, const HepMcParticleLink &)
 Output operator. More...
 
static const McEventCollectionretrieveMcEventCollection (const IProxyDict *sg)
 Look up the event collection we're targeting. More...
 
static SG::DataProxyfind_proxy (const IProxyDict *sg)
 Find the proxy for the target event collection. More...
 
static std::string getLastEventCollectionName ()
 Return the most recent SG key used for a particular collection type. More...
 

Detailed Description

a link optimized in size for a GenParticle in a McEventCollection

A link is defined by three items:

There is a list of StoreGate keys for the McEventCollection (see the initialization of s_keys). When we want to dereference the link, we try to look up each possible key in turn until we find one that works. (The position of that key in the list is then remembered as a hint for where to start searching next time.)

The particular GenEvent within the collection can be represented as either an event number (as returned by GenEvent::event_number()) or by a position within the collection. Which case is desired is indicated by the value of the isIndexEventPosition argument to the constructors (defaulting to the event number case). In order to convert between these, we need to retrieve the McEventCollection from the store, but we don't have the store pointer once the link has been dereferenced. Therefore, when a position-based link is dereferenced, it is automatically changed to be event-number-based. This also happens when a link is constructed with an explicit ConstGenParticlePtr and a position-based GenEvent.

As a special case, a GenEvent number of 0 is interpreted as the first GenEvent in the collection.

The particle within the GenEvent is represented by a unique ID. A unique ID of 0 implies a null link.

In order to dereference a link, we need to reference a particular event store. By default, the current store (as defined by SG::CurrentEventStore::store()) is stored when the link is constructed; however, an explicit IProxyDict* or EventContext may also be specified.

See also
McEventCollection, GenEvent, ElementLink
Author
Paolo Calafiura

Definition at line 71 of file HepMcParticleLink.h.

Member Typedef Documentation

◆ barcode_type

Definition at line 74 of file HepMcParticleLink.h.

◆ index_type

Definition at line 75 of file HepMcParticleLink.h.

Member Enumeration Documentation

◆ PositionFlag

Enumerator
IS_EVENTNUM 
IS_POSITION 

Definition at line 78 of file HepMcParticleLink.h.

78  {
79  IS_EVENTNUM = 0,
80  IS_POSITION = 1,
81  };

◆ UniqueIDFlag

Enumerator
IS_ID 
IS_BARCODE 

Definition at line 83 of file HepMcParticleLink.h.

83  {
84  IS_ID = 0,
85  IS_BARCODE = 1,
86  };

Constructor & Destructor Documentation

◆ HepMcParticleLink() [1/8]

HepMcParticleLink::HepMcParticleLink ( IProxyDict sg = nullptr)

Default constructor.

Makes a null link.

Parameters
sgOptional specification of a specific store to reference.

◆ HepMcParticleLink() [2/8]

HepMcParticleLink::HepMcParticleLink ( const EventContext &  ctx)

Default constructor.

Makes a null link.

Parameters
ctxContext of the store to reference.

◆ HepMcParticleLink() [3/8]

HepMcParticleLink::HepMcParticleLink ( barcode_type  uid,
uint32_t  eventIndex,
PositionFlag  positionFlag,
UniqueIDFlag  uniqueIDFlag,
IProxyDict sg = SG::CurrentEventStore::store() 
)

Constructor.

Parameters
uidUnique ID of the target particle. 0 means a null link.
eventIndexIdentifies the target GenEvent in a McEventCollection, as either the event number if isIndexEventPosition is IS_EVENTNUM, or the position in the container if isIndexEventPosition is IS_POSITION. 0 always means the first event in the collection.
positionFlagSee eventIndex.
sgOptional specification of a specific store to reference.

◆ HepMcParticleLink() [4/8]

HepMcParticleLink::HepMcParticleLink ( barcode_type  uid,
uint32_t  eventIndex,
PositionFlag  positionFlag,
UniqueIDFlag  uniqueIDFlag,
const EventContext &  ctx 
)

Constructor.

Parameters
uidUnique ID of the target particle. 0 means a null link.
eventIndexIdentifies the target GenEvent in a McEventCollection, as either the event number if isIndexEventPosition is IS_EVENTNUM, or the position in the container if isIndexEventPosition is IS_POSITION. 0 always means the first event in the collection.
positionFlagSee eventIndex.
ctxContext of the store to reference.

◆ HepMcParticleLink() [5/8]

HepMcParticleLink::HepMcParticleLink ( const HepMC::ConstGenParticlePtr part,
uint32_t  eventIndex,
PositionFlag  positionFlag,
IProxyDict sg = SG::CurrentEventStore::store() 
)

Constructor.

Parameters
pParticle to reference.
eventIndexIdentifies the target GenEvent in a McEventCollection, as either the event number if isIndexEventPosition is IS_EVENTNUM, or the position in the container if isIndexEventPosition is IS_POSITION. 0 always means the first event in the collection.
positionFlagSee eventIndex.
sgOptional specification of a specific store to reference.

Definition at line 143 of file HepMcParticleLink.cxx.

147  : m_store (sg),
148  m_ptr (part),
149  m_extBarcode((nullptr != part) ? HepMC::uniqueID(part) : 0, eventIndex, positionFlag, IS_ID)
150 {
151  assert(part);
152 
153  if (part != nullptr && positionFlag == IS_POSITION) {
154  if (const McEventCollection* pEvtColl = retrieveMcEventCollection(sg)) {
155  const HepMC::GenEvent *pEvt = pEvtColl->at (eventIndex);
156  m_extBarcode.makeIndex (pEvt->event_number(), eventIndex);
157  }
158  else {
159  MsgStream log (Athena::getMessageSvc(), "HepMcParticleLink");
160  log << MSG::WARNING << "cptr: McEventCollection not found" << endmsg;
161  }
162  }
163 }

◆ HepMcParticleLink() [6/8]

HepMcParticleLink::HepMcParticleLink ( const HepMC::ConstGenParticlePtr part,
uint32_t  eventIndex,
PositionFlag  positionFlag,
const EventContext &  ctx 
)

Constructor.

Parameters
pParticle to reference.
eventIndexIdentifies the target GenEvent in a McEventCollection, as either the event number if isIndexEventPosition is IS_EVENTNUM, or the position in the container if isIndexEventPosition is IS_POSITION. 0 always means the first event in the collection.
positionFlagSee eventIndex.
ctxContext of the store to reference.

◆ HepMcParticleLink() [7/8]

HepMcParticleLink::HepMcParticleLink ( const HepMcParticleLink rhs)
default

Copy constructor.

◆ HepMcParticleLink() [8/8]

HepMcParticleLink::HepMcParticleLink ( HepMcParticleLink &&  rhs)
defaultnoexcept

Move constructor.

Member Function Documentation

◆ barcode()

int HepMcParticleLink::barcode ( ) const

Return the barcode of the target particle.

0 for a null link. FIXME: return type.

Definition at line 318 of file HepMcParticleLink.cxx.

319 {
320  // if m_BC is zero (delta rays), then just return that same for barcode and id
321  if (m_extBarcode.uid()) {
322  barcode_type particle_id, particle_barcode;
323  m_extBarcode.uniqueID (particle_id, particle_barcode);
324  if (particle_barcode != ExtendedBarCode::UNDEFINEDBC) {
325  return int(particle_barcode);
326  }
327  // dummy link
328  if (!m_ptr.isValid() && !m_store) {
329  return 0; // TODO Decide if this is a good default - constant from MagicNumbers.h instead?
330  }
331  // we will need to look up the barcode from the GenParticle
332  (void) eventIndex(); // FIXME be careful to avoid an infinite loop of calls here
333  if (cptr()) {
334  return HepMC::barcode(cptr());
335  }
336  }
337  return 0;
338 }

◆ compress()

barcode_type HepMcParticleLink::compress ( ) const

Hash the 32 bit barcode and 16 bit eventindex into a 32bit int.

◆ cptr()

HepMC::ConstGenParticlePtr HepMcParticleLink::cptr ( ) const

Dereference.

Definition at line 177 of file HepMcParticleLink.cxx.

178 {
179  // dummy link
180  const bool is_valid = m_ptr.isValid();
181  if (!is_valid && !m_store) {
182  return nullptr;
183  }
184  if (is_valid) {
185  return *m_ptr.ptr();
186  }
187  if (m_extBarcode.linkIsNull()) {
188  #if 0
189  MsgStream log (Athena::getMessageSvc(), "HepMcParticleLink");
190  log << MSG::DEBUG
191  << "cptr: no truth particle associated with this hit (barcode==0)."
192  << " Probably this is a noise hit" << endmsg;
193  #endif
194  return nullptr;
195  }
196  IProxyDict* sg = m_store;
197  if (!sg) {
199  }
200  if (const McEventCollection* pEvtColl = retrieveMcEventCollection(sg)) {
201  const HepMC::GenEvent *pEvt = nullptr;
202  index_type event_number, position;
203  m_extBarcode.eventIndex (event_number, position);
204  if (event_number == 0) {
205  pEvt = pEvtColl->at(0);
206  }
207  else if (position != ExtendedBarCode::UNDEFINED) {
208  if (position < pEvtColl->size()) {
209  pEvt = pEvtColl->at (position);
210  }
211  else {
212  #if 0
213  MsgStream log (Athena::getMessageSvc(), "HepMcParticleLink");
214  log << MSG::WARNING << "cptr: position = " << position << ", McEventCollection size = "<< pEvtColl->size() << endmsg;
215  #endif
216  return nullptr;
217  }
218  }
219  else {
220  pEvt = pEvtColl->find (event_number);
221  }
222 
223  if (nullptr != pEvt) {
224  // Be sure to update m_extBarcode before m_ptrs;
225  // otherwise, the logic in eventIndex() won't work correctly.
226  if (position != ExtendedBarCode::UNDEFINED) {
227  m_extBarcode.makeIndex (pEvt->event_number(), position);
228  }
229  if (event_number == 0) {
230  m_extBarcode.makeIndex (pEvt->event_number(), position);
231  }
232  if ( !m_extBarcode.linkIsNull() ) { // Check that either the ID or Barcode is non-zero or undefined
233  barcode_type particle_id, particle_barcode;
234  m_extBarcode.uniqueID (particle_id, particle_barcode);
235  if (particle_id == ExtendedBarCode::UNDEFINEDBC) {
236  // barcode to GenParticle
237  const HepMC::ConstGenParticlePtr p = HepMC::barcode_to_particle(pEvt,int(particle_barcode));
238  if (p) {
239  int genParticleID = HepMC::uniqueID(p);
240  if (genParticleID > -1) {
241  particle_id = static_cast<barcode_type>(genParticleID);
242  m_extBarcode.makeID (particle_id, particle_barcode);
243  }
244  m_ptr.set (p);
245  return p;
246  }
247  }
248  else {
249  // id to GenParticle
250 #ifdef HEPMC3
251  const auto &particles = pEvt->particles();
252  if (particle_id-1 < particles.size()) {
253  const HepMC::ConstGenParticlePtr p = particles[particle_id-1];
254  if (p) {
255  m_ptr.set (p);
256  return p;
257  }
258  }
259 #else
260  const HepMC::ConstGenParticlePtr p = HepMC::barcode_to_particle(pEvt,int(particle_id)); // For HepMC2 "id" == barcode
261  if (p) {
262  m_ptr.set (p);
263  return p;
264  }
265 #endif
266  }
267  }
268  } else {
269  MsgStream log (Athena::getMessageSvc(), "HepMcParticleLink");
270  if (position != ExtendedBarCode::UNDEFINED) {
271  log << MSG::WARNING
272  << "cptr: Mc Truth not stored for event at " << position
273  << endmsg;
274  } else {
275  log << MSG::WARNING
276  << "cptr: Mc Truth not stored for event with event number " << event_number
277  << endmsg;
278  }
279  }
280  } else {
281  MsgStream log (Athena::getMessageSvc(), "HepMcParticleLink");
282  log << MSG::WARNING << "cptr: McEventCollection not found" << endmsg;
283  }
284  return nullptr;
285 }

◆ eventIndex()

HepMcParticleLink::index_type HepMcParticleLink::eventIndex ( ) const

Return the event number of the referenced GenEvent.

0 means the first GenEvent in the collection.

Definition at line 345 of file HepMcParticleLink.cxx.

346 {
347  // dummy link
348  if (!m_ptr.isValid() && !m_store) {
350  }
351 
352  index_type event_number, event_position;
353  m_extBarcode.eventIndex (event_number, event_position);
354  if (event_number == ExtendedBarCode::UNDEFINED) {
355  const HepMC::GenEvent* pEvt{};
357  if (event_position < coll->size()) {
358  pEvt = coll->at (event_position);
359  }
360  if (pEvt) {
361  const int genEventNumber = pEvt->event_number();
362  // Be sure to update m_extBarcode before m_ptr.
363  // Otherwise, if two threads run this method simultaneously,
364  // one thread could see event_number == UNDEFINED, but where m_ptr
365  // is already updated so we get nullptr back for sg.
366  if (genEventNumber > -1) {
367  event_number = static_cast<index_type>(genEventNumber);
368  m_extBarcode.makeIndex (event_number, event_position);
369  return event_number;
370  }
371  if (barcode() != 0) {
373  if (pp) {
374  m_ptr.set (pp);
375  }
376  }
377  }
378  }
379  }
380  // Don't trip the assertion for a null link.
381  if ( m_extBarcode.linkIsNull() )
382  {
383  return (event_number != ExtendedBarCode::UNDEFINED) ? event_number : 0;
384  }
385  // Attempt to find the GenParticle
386  cptr();
387  // Check if event_number is valid once more
388  m_extBarcode.eventIndex (event_number, event_position);
389  assert (event_number != ExtendedBarCode::UNDEFINED);
390  return event_number;
391 }

◆ find_proxy()

SG::DataProxy * HepMcParticleLink::find_proxy ( const IProxyDict sg)
staticprivate

Find the proxy for the target event collection.

Parameters
sgTarget event store. May return nullptr if the collection is not found.

Definition at line 516 of file HepMcParticleLink.cxx.

517 {
519  unsigned int hint_orig = s_hint;
520  if (hint_orig >= NKEYS) hint_orig = 0;
521  unsigned int hint = hint_orig;
522  do {
523  SG::DataProxy* proxy = sg->proxy (clid, s_keys[hint]);
524  if (proxy) {
525  if (hint != s_hint) {
526  s_hint = hint;
527  }
528  static std::atomic<unsigned> findCount {0};
529  if(++findCount == 1) {
530  MsgStream log (Athena::getMessageSvc(), "HepMcParticleLink");
531  log << MSG::INFO << "find_proxy: Using " << s_keys[hint]
532  <<" as McEventCollection key for this job " << endmsg;
533  }
534  return proxy;
535  }
536  ++hint;
537  if (hint >= NKEYS) hint = 0;
538  } while (hint != hint_orig);
539 
540  MsgStream log (Athena::getMessageSvc(), "HepMcParticleLink");
541  static std::atomic<unsigned long> msgCount {0};
542  unsigned int count = ++msgCount;
543  if (count <= CPTRMAXMSGCOUNT) {
544  log << MSG::WARNING << "find_proxy: No Valid MC event Collection found "
545  << endmsg;
546  }
547  if (count == CPTRMAXMSGCOUNT) {
548  log << MSG::WARNING <<"find_proxy: suppressing further messages about valid MC event Collection. Use \n"
549  << " msgSvc.setVerbose += [HepMcParticleLink]\n"
550  << "to see all messages" << endmsg;
551  }
552  if (count > CPTRMAXMSGCOUNT) {
553  log << MSG::VERBOSE << "find_proxy: No Valid MC event Collection found "
554  << endmsg;
555  }
556  return nullptr;
557 }

◆ getEventNumberAtPosition()

int HepMcParticleLink::getEventNumberAtPosition ( index_type  position,
const IProxyDict sg 
)
static

Return the event number of the GenEvent at the specified position in the McEventCollection.

Parameters
positionin the McEventCollection
sgTarget event store. Returns -999 when position is larger than the McEventCollection size

Definition at line 443 of file HepMcParticleLink.cxx.

444 {
445  if (const McEventCollection* coll = retrieveMcEventCollection (sg)) {
446  if (position < coll->size()) {
447  return coll->at (position)->event_number();
448  }
449  }
450 #if 0
451  MsgStream log (Athena::getMessageSvc(), "HepMcParticleLink");
452  log << MSG::WARNING << "getEventNumberAtPosition: position = " << position << ", McEventCollection size = "<< coll->size() << endmsg;
453 #endif
454  return -999;
455 }

◆ getEventPositionInCollection() [1/2]

HepMcParticleLink::index_type HepMcParticleLink::getEventPositionInCollection ( const IProxyDict sg) const

Return the position in the McEventCollection of the GenEvent pointed to by this HepMcParticleLink.

Return the position in the McEventCollection of the (first) GenEvent with a given event number.

Parameters
sgTarget event store. FIXME - need to be able to flag when no event with the appropriate event_number was found.

Definition at line 399 of file HepMcParticleLink.cxx.

400 {
401  index_type event_number, position;
402  m_extBarcode.eventIndex (event_number, position);
403  if (position != ExtendedBarCode::UNDEFINED) {
404  return position;
405  }
406  if (event_number == 0) {
407  return 0;
408  }
409 
410  std::vector<index_type> positions = getEventPositionInCollection(event_number, sg);
411  return positions[0];
412 }

◆ getEventPositionInCollection() [2/2]

std::vector< HepMcParticleLink::index_type > HepMcParticleLink::getEventPositionInCollection ( index_type  index,
const IProxyDict sg 
)
static

Return a vector of the positions in the McEventCollection of the GenEvent(s) with a given event number.

Return the position in the McEventCollection of the (first) GenEvent with a given event number.

Parameters
indexthe event number of the required GenEvent
sgTarget event store. Returns a vector containing only ExtendedBarCode::UNDEFINED FIXME when no event with the appropriate event_number was found. (Multiple entries in the vector is technically a bug, but can't be fixed until the HepMC3 migration.)

Definition at line 420 of file HepMcParticleLink.cxx.

421 {
422  std::vector<index_type> positions; positions.reserve(1);
423  const int int_event_number = static_cast<int>(event_number);
424  if (const McEventCollection* coll = retrieveMcEventCollection (sg)) {
425  size_t sz = coll->size();
426  for (size_t i = 0; i < sz; i++) {
427  if ((*coll)[i]->event_number() == int_event_number) {
428  positions.push_back(i);
429  }
430  }
431  }
432  if (positions.empty() ) {
433  positions.push_back(ExtendedBarCode::UNDEFINED);
434  }
435  return positions;
436 }

◆ getLastEventCollectionName()

std::string HepMcParticleLink::getLastEventCollectionName ( )
staticprivate

Return the most recent SG key used for a particular collection type.

Definition at line 563 of file HepMcParticleLink.cxx.

564 {
565  static const std::string unset = "CollectionNotSet";
566  unsigned idx = s_hint;
567  if (idx < NKEYS) {
568  return s_keys[idx];
569  }
570  return unset;
571 }

◆ getRedirectedLink()

HepMcParticleLink HepMcParticleLink::getRedirectedLink ( const HepMcParticleLink particleLink,
uint32_t  eventIndex,
const EventContext &  ctx 
)
static

Return a HepMcParticleLink pointing at the same particle, but in a different GenEvent.

Parameters
particleLinkthe current HepMcParticleLink
eventIndexthe event number (unless zero) of the GenEvent which the redirected HepMcParticleLink should point at

Definition at line 465 of file HepMcParticleLink.cxx.

466 {
467  const HepMcParticleLink::PositionFlag idxFlag =
469  // Support reading in legacy barcode-based persistent EDM for now
470  const int uniqueID =
471  (particleLink.barcode() != 0) ? particleLink.barcode() : particleLink.id();
472  const HepMcParticleLink::UniqueIDFlag uidFlag =
474  HepMcParticleLink redirectedLink(uniqueID, eventIndex, idxFlag, uidFlag, ctx);
475  redirectedLink.setTruthSuppressionType(particleLink.getTruthSuppressionType());
476  return redirectedLink;
477 }

◆ getTruthSuppressionType()

EBC_SUPPRESSED_TRUTH HepMcParticleLink::getTruthSuppressionType ( ) const

Return whether the truth particle has been suppressed, as an enum.

◆ getTruthSuppressionTypeAsChar()

char HepMcParticleLink::getTruthSuppressionTypeAsChar ( ) const

Return whether the truth particle has been suppressed, as a char ('a'..'b').

◆ id()

int HepMcParticleLink::id ( ) const

Return the id of the target particle.

Return the id of the referenced GenParticle.

0 for a null link.

Definition at line 291 of file HepMcParticleLink.cxx.

292 {
293  // if m_BC is zero (delta rays), then just return that same for barcode and id
294  if (m_extBarcode.uid()) {
295  // dummy link
296  if (!m_ptr.isValid() && !m_store) {
297  return 0; // TODO Decide if this is a good default - constant from MagicNumbers.h instead?
298  }
299 
300  barcode_type particle_id, particle_barcode;
301  m_extBarcode.uniqueID (particle_id, particle_barcode);
302  if (particle_id == ExtendedBarCode::UNDEFINEDBC) {
303  (void) cptr(); // FIXME be careful to avoid an infinite loop of calls here
304  m_extBarcode.uniqueID (particle_id, particle_barcode);
305  }
306  if (particle_id != ExtendedBarCode::UNDEFINEDBC) {
307  return particle_id;
308  }
309  }
310  return 0;
311 }

◆ isValid()

bool HepMcParticleLink::isValid ( ) const

Validity check.

Dereference and check for null.

◆ linkIsNull()

bool HepMcParticleLink::linkIsNull ( ) const

return true if neither barcode nor id are valid

Definition at line 169 of file HepMcParticleLink.cxx.

169  {
170  return m_extBarcode.linkIsNull();
171 }

◆ operator bool()

HepMcParticleLink::operator bool ( ) const

Validity check.

Dereference and check for null.

◆ operator HepMC::ConstGenParticlePtr()

HepMcParticleLink::operator HepMC::ConstGenParticlePtr ( ) const

Dereference.

◆ operator!()

bool HepMcParticleLink::operator! ( ) const

Validity check.

Dereference and check for null.

◆ operator!=()

Inequality comparison.

◆ operator*()

const HepMC::GenParticle& HepMcParticleLink::operator* ( ) const

Dereference.

◆ operator->()

HepMC::ConstGenParticlePtr HepMcParticleLink::operator-> ( ) const

Dereference.

◆ operator<()

bool HepMcParticleLink::operator< ( const HepMcParticleLink rhs) const

Ordering comparison.

◆ operator=() [1/2]

HepMcParticleLink& HepMcParticleLink::operator= ( const HepMcParticleLink rhs)
default

Assignment.

◆ operator=() [2/2]

HepMcParticleLink& HepMcParticleLink::operator= ( HepMcParticleLink &&  rhs)
default

Move Assignment.

◆ operator==()

bool HepMcParticleLink::operator== ( const HepMcParticleLink rhs) const

Equality comparison.

◆ retrieveMcEventCollection()

const McEventCollection * HepMcParticleLink::retrieveMcEventCollection ( const IProxyDict sg)
staticprivate

Look up the event collection we're targeting.

Parameters
sgTarget event store. May return nullptr if the collection is not found.

Definition at line 497 of file HepMcParticleLink.cxx.

498 {
499  const McEventCollection* pEvtColl = nullptr;
501  if (proxy) {
502  pEvtColl = SG::DataProxy_cast<McEventCollection> (proxy);
503  if (!pEvtColl) {
504  MsgStream log (Athena::getMessageSvc(), "HepMcParticleLink");
505  log << MSG::WARNING << "cptr: McEventCollection not found" << endmsg;
506  }
507  }
508  return pEvtColl;
509 }

◆ scptr()

HepMC::ConstGenParticlePtr HepMcParticleLink::scptr ( ) const
inline

Dereference/smart pointer.

Definition at line 491 of file HepMcParticleLink.h.

491 { return cptr(); }

◆ setExtendedBarCode()

void HepMcParticleLink::setExtendedBarCode ( const ExtendedBarCode extBarcode)

Alter the persistent part of the link.

Definition at line 483 of file HepMcParticleLink.cxx.

484 {
485  m_extBarcode = extBarcode;
487  m_ptr.reset();
488 }

◆ setTruthSuppressionType()

void HepMcParticleLink::setTruthSuppressionType ( EBC_SUPPRESSED_TRUTH  truthSupp)

Return whether the truth particle has been suppressed.

Friends And Related Function Documentation

◆ operator<< [1/2]

MsgStream& operator<< ( MsgStream &  os,
const HepMcParticleLink link 
)
friend

Output operator.

Parameters
osMsgStream to which to output.
linkLink to dump.

Definition at line 592 of file HepMcParticleLink.cxx.

594 {
595  link.m_extBarcode.print(os);
596  return os;
597 }

◆ operator<< [2/2]

std::ostream& operator<< ( std::ostream &  os,
const HepMcParticleLink link 
)
friend

Output operator.

Parameters
osStream to which to output.
linkLink to dump.

Definition at line 579 of file HepMcParticleLink.cxx.

581 {
582  link.m_extBarcode.print(os);
583  return os;
584 }

Member Data Documentation

◆ m_extBarcode

ExtendedBarCode HepMcParticleLink::m_extBarcode
private

Persistent part: barcode and location of target GenEvent.

Definition at line 680 of file HepMcParticleLink.h.

◆ m_ptr

Transient part. Pointer to the particle.

Definition at line 676 of file HepMcParticleLink.h.

◆ m_store

IProxyDict* HepMcParticleLink::m_store
private

Pointer to the store containing the event.

Definition at line 668 of file HepMcParticleLink.h.


The documentation for this class was generated from the following files:
LArG4FSStartPointFilter.part
part
Definition: LArG4FSStartPointFilter.py:21
CxxUtils::CachedValue::reset
void reset()
Reset the value to invalid.
CxxUtils::CachedValue::ptr
const T * ptr() const
Return a pointer to the cached value.
fitman.sz
sz
Definition: fitman.py:527
IProxyDict::proxy
virtual SG::DataProxy * proxy(const CLID &id, const std::string &key) const =0
Get proxy with given id and key.
StateLessPT_NewConfig.proxy
proxy
Definition: StateLessPT_NewConfig.py:392
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
CxxUtils::CachedValue::isValid
bool isValid() const
Test to see if the value is valid.
SG::CurrentEventStore::store
static IProxyDict * store()
Fetch the current store.
IProxyDict
A proxy dictionary.
Definition: AthenaKernel/AthenaKernel/IProxyDict.h:47
Athena::getMessageSvc
IMessageSvc * getMessageSvc(bool quiet=false)
Definition: getMessageSvc.cxx:20
XMLtoHeader.count
count
Definition: XMLtoHeader.py:85
python.setupRTTAlg.size
int size
Definition: setupRTTAlg.py:39
ClassID_traits::ID
static const CLID & ID()
the CLID of T
Definition: Control/AthenaKernel/AthenaKernel/ClassID_traits.h:50
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
HepMC::barcode_to_particle
GenParticle * barcode_to_particle(const GenEvent *e, int id)
Definition: GenEvent.h:628
lumiFormat.i
int i
Definition: lumiFormat.py:85
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
HepMC::barcode
int barcode(const T *p)
Definition: Barcode.h:16
HepMC::uniqueID
int uniqueID(const T &p)
Definition: MagicNumbers.h:116
McEventCollection
This defines the McEventCollection, which is really just an ObjectVector of McEvent objects.
Definition: McEventCollection.h:33
CLID
uint32_t CLID
The Class ID type.
Definition: Event/xAOD/xAODCore/xAODCore/ClassID_traits.h:47
ReadFromCoolCompare.os
os
Definition: ReadFromCoolCompare.py:231
HepMC::ConstGenParticlePtr
const GenParticle * ConstGenParticlePtr
Definition: GenParticle.h:38
CxxUtils::CachedValue::set
void set(const T &val) const
Set the value, assuming it is currently invalid.
DEBUG
#define DEBUG
Definition: page_access.h:11
python.CaloCondTools.log
log
Definition: CaloCondTools.py:20
LArG4FSStartPointFilter.particles
list particles
Definition: LArG4FSStartPointFilter.py:84
LArNewCalib_DelayDump_OFC_Cali.idx
idx
Definition: LArNewCalib_DelayDump_OFC_Cali.py:69
python.Constants.VERBOSE
int VERBOSE
Definition: Control/AthenaCommon/python/Constants.py:14
SG::DataProxy
Definition: DataProxy.h:45
index_type
unsigned int index_type
Definition: FPGATrackSimSGToRawHitsTool.h:37