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

ParticleLink-specific methods.

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

Detailed Description

a link optimized in size for a GenParticle in a McEventCollection

A link is defined by three items:

  • A target McEventCollection;
  • A particular GenEvent within this collection; and
  • A particular particle within the GenEvent.

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.

◆ UniqueIDFlag

Enumerator
IS_ID 
IS_BARCODE 

Definition at line 83 of file HepMcParticleLink.h.

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}
#define endmsg
IMessageSvc * getMessageSvc(bool quiet=false)
int uniqueID(const T &p)
HepMC3::GenEvent GenEvent
Definition GenEvent.h:39

◆ 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 310 of file HepMcParticleLink.cxx.

311{
312 // if m_BC is zero (delta rays), then just return that same for barcode and id
313 if (m_extBarcode.uid()) {
314 barcode_type particle_id, particle_barcode;
315 m_extBarcode.uniqueID (particle_id, particle_barcode);
316 if (particle_barcode != ExtendedBarCode::UNDEFINEDBC) {
317 return int(particle_barcode);
318 }
319 // dummy link
320 if (!m_ptr.isValid() && !m_store) {
321 return 0; // TODO Decide if this is a good default - constant from MagicNumbers.h instead?
322 }
323 // we will need to look up the barcode from the GenParticle
324 (void) eventIndex(); // FIXME be careful to avoid an infinite loop of calls here
325 if (cptr()) {
326 return HepMC::barcode(cptr());
327 }
328 }
329 return 0;
330}
int barcode(const T *p)
Definition Barcode.h:15

◆ 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) {
198 sg = SG::CurrentEventStore::store();
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 const auto &particles = pEvt->particles();
251 if (particle_id-1 < particles.size()) {
252 const HepMC::ConstGenParticlePtr p = particles[particle_id-1];
253 if (p) {
254 m_ptr.set (p);
255 return p;
256 }
257 }
258 }
259 }
260 } else {
261 MsgStream log (Athena::getMessageSvc(), "HepMcParticleLink");
262 if (position != ExtendedBarCode::UNDEFINED) {
263 log << MSG::WARNING
264 << "cptr: Mc Truth not stored for event at " << position
265 << endmsg;
266 } else {
267 log << MSG::WARNING
268 << "cptr: Mc Truth not stored for event with event number " << event_number
269 << endmsg;
270 }
271 }
272 } else {
273 MsgStream log (Athena::getMessageSvc(), "HepMcParticleLink");
274 log << MSG::WARNING << "cptr: McEventCollection not found" << endmsg;
275 }
276 return nullptr;
277}
size_t size() const
Number of registered mappings.
ConstGenParticlePtr barcode_to_particle(const GenEvent *e, int id)
Definition GenEvent.h:443
HepMC3::ConstGenParticlePtr ConstGenParticlePtr
Definition GenParticle.h:20
const Amg::Vector3D & position() const
Method to retrieve the position of the Intersection.

◆ 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 337 of file HepMcParticleLink.cxx.

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

◆ 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 508 of file HepMcParticleLink.cxx.

509{
511 unsigned int hint_orig = s_hint.load(std::memory_order_relaxed);
512 if (hint_orig >= NKEYS) hint_orig = 0;
513 unsigned int hint = hint_orig;
514 do {
515 SG::DataProxy* proxy = sg->proxy (clid, s_keys[hint]);
516 if (proxy) {
517 if (hint != s_hint.load(std::memory_order_relaxed)) {
518 s_hint.store(hint, std::memory_order_relaxed);
519 }
520 static std::once_flag log_flag;
521 std::call_once(log_flag, [hint]() {
522 MsgStream log (Athena::getMessageSvc(), "HepMcParticleLink");
523 log << MSG::INFO << "find_proxy: Using " << s_keys[hint]
524 << " as McEventCollection key for this job " << endmsg;
525 });
526 return proxy;
527 }
528 ++hint;
529 if (hint >= NKEYS) hint = 0;
530 } while (hint != hint_orig);
531
532 MsgStream log (Athena::getMessageSvc(), "HepMcParticleLink");
533 static std::atomic<unsigned long> msgCount {0};
534 unsigned int count = ++msgCount;
535 if (count <= CPTRMAXMSGCOUNT) {
536 log << MSG::WARNING << "find_proxy: No Valid MC event Collection found "
537 << endmsg;
538 }
539 if (count == CPTRMAXMSGCOUNT) {
540 log << MSG::WARNING <<"find_proxy: suppressing further messages about valid MC event Collection. Use \n"
541 << " msgSvc.setVerbose += [HepMcParticleLink]\n"
542 << "to see all messages" << endmsg;
543 }
544 if (count > CPTRMAXMSGCOUNT) {
545 log << MSG::VERBOSE << "find_proxy: No Valid MC event Collection found "
546 << endmsg;
547 }
548 return nullptr;
549}
uint32_t CLID
The Class ID type.
virtual SG::DataProxy * proxy(const CLID &id, const std::string &key) const =0
Get proxy with given id and key.
int count(std::string s, const std::string &regx)
count how many occurances of a regx are in a string
Definition hcg.cxx:148

◆ 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 435 of file HepMcParticleLink.cxx.

436{
437 if (const McEventCollection* coll = retrieveMcEventCollection (sg)) {
438 if (position < coll->size()) {
439 return coll->at (position)->event_number();
440 }
441 }
442#if 0
443 MsgStream log (Athena::getMessageSvc(), "HepMcParticleLink");
444 log << MSG::WARNING << "getEventNumberAtPosition: position = " << position << ", McEventCollection size = "<< coll->size() << endmsg;
445#endif
446 return -999;
447}

◆ 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 391 of file HepMcParticleLink.cxx.

392{
393 index_type event_number, position;
394 m_extBarcode.eventIndex (event_number, position);
395 if (position != ExtendedBarCode::UNDEFINED) {
396 return position;
397 }
398 if (event_number == 0) {
399 return 0;
400 }
401
402 std::vector<index_type> positions = getEventPositionInCollection(event_number, sg);
403 return positions[0];
404}

◆ 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 412 of file HepMcParticleLink.cxx.

413{
414 std::vector<index_type> positions; positions.reserve(1);
415 const int int_event_number = static_cast<int>(event_number);
416 if (const McEventCollection* coll = retrieveMcEventCollection (sg)) {
417 size_t sz = coll->size();
418 for (size_t i = 0; i < sz; i++) {
419 if ((*coll)[i]->event_number() == int_event_number) {
420 positions.push_back(i);
421 }
422 }
423 }
424 if (positions.empty() ) {
425 positions.push_back(ExtendedBarCode::UNDEFINED);
426 }
427 return positions;
428}
static Double_t sz

◆ getLastEventCollectionName()

std::string HepMcParticleLink::getLastEventCollectionName ( )
staticprivate

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

Definition at line 555 of file HepMcParticleLink.cxx.

556{
557 static const std::string unset = "CollectionNotSet";
558 unsigned idx = s_hint;
559 if (idx < NKEYS) {
560 return s_keys[idx];
561 }
562 return unset;
563}

◆ 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 457 of file HepMcParticleLink.cxx.

458{
459 const HepMcParticleLink::PositionFlag idxFlag =
461 // Support reading in legacy barcode-based persistent EDM for now
462 const int uniqueID =
463 (particleLink.barcode() != 0) ? particleLink.barcode() : particleLink.id();
464 const HepMcParticleLink::UniqueIDFlag uidFlag =
466 HepMcParticleLink redirectedLink(uniqueID, eventIndex, idxFlag, uidFlag, ctx);
467 redirectedLink.setTruthSuppressionType(particleLink.getTruthSuppressionType());
468 return redirectedLink;
469}

◆ 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 283 of file HepMcParticleLink.cxx.

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

◆ 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 489 of file HepMcParticleLink.cxx.

490{
491 const McEventCollection* pEvtColl = nullptr;
492 SG::DataProxy* proxy = find_proxy (sg);
493 if (proxy) {
494 pEvtColl = SG::DataProxy_cast<McEventCollection> (proxy);
495 if (!pEvtColl) {
496 MsgStream log (Athena::getMessageSvc(), "HepMcParticleLink");
497 log << MSG::WARNING << "cptr: McEventCollection not found" << endmsg;
498 }
499 }
500 return pEvtColl;
501}
DATA * DataProxy_cast(DataProxy *proxy)
cast the proxy into the concrete data object it proxies

◆ 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 475 of file HepMcParticleLink.cxx.

476{
477 m_extBarcode = extBarcode;
478 m_store = SG::CurrentEventStore::store();
479 m_ptr.reset();
480}

◆ setTruthSuppressionType()

void HepMcParticleLink::setTruthSuppressionType ( EBC_SUPPRESSED_TRUTH truthSupp)

Return whether the truth particle has been suppressed.

◆ 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 584 of file HepMcParticleLink.cxx.

586{
587 link.m_extBarcode.print(os);
588 return os;
589}
pointer & link(pointer p) const
Return a reference to the link for an element.

◆ 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 571 of file HepMcParticleLink.cxx.

573{
574 link.m_extBarcode.print(os);
575 return os;
576}

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: