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.
HepMcParticleLink & operator= (const HepMcParticleLink &rhs)=default
 Assignment.
HepMcParticleLink & operator= (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.

IProxyDict * m_store
 Pointer to the store containing the event.
ATH_NO_UNIQUE_ADDRESS CxxUtils::CachedValue< HepMC::ConstGenParticlePtr > m_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.
index_type getEventPositionInCollection (const EventContext &ctx) 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 int getEventNumberAtPosition (index_type position, const EventContext &ctx)
 Return the event number of the GenEvent at the specified position in the McEventCollection.
static std::vector< index_type > getEventPositionInCollection (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 McEventCollection * retrieveMcEventCollection (const IProxyDict *sg)
 Look up the event collection we're targeting.
static SG::DataProxy * find_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 144 of file HepMcParticleLink.cxx.

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

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

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

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

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

532{
534 unsigned int hint_orig = s_hint.load(std::memory_order_relaxed);
535 if (hint_orig >= NKEYS) hint_orig = 0;
536 unsigned int hint = hint_orig;
537 do {
538 SG::DataProxy* proxy = sg->proxy (clid, s_keys[hint]);
539 if (proxy) {
540 if (hint != s_hint.load(std::memory_order_relaxed)) {
541 s_hint.store(hint, std::memory_order_relaxed);
542 }
543 static std::once_flag log_flag;
544 std::call_once(log_flag, [hint]() {
545 MsgStream log (Athena::getMessageSvc(), "HepMcParticleLink");
546 log << MSG::INFO << "find_proxy: Using " << s_keys[hint]
547 << " as McEventCollection key for this job " << endmsg;
548 });
549 return proxy;
550 }
551 ++hint;
552 if (hint >= NKEYS) hint = 0;
553 } while (hint != hint_orig);
554
555 MsgStream log (Athena::getMessageSvc(), "HepMcParticleLink");
556 static std::atomic<unsigned long> msgCount {0};
557 unsigned int count = ++msgCount;
558 if (count <= CPTRMAXMSGCOUNT) {
559 log << MSG::WARNING << "find_proxy: No Valid MC event Collection found "
560 << endmsg;
561 }
562 if (count == CPTRMAXMSGCOUNT) {
563 log << MSG::WARNING <<"find_proxy: suppressing further messages about valid MC event Collection. Use \n"
564 << " msgSvc.setVerbose += [HepMcParticleLink]\n"
565 << "to see all messages" << endmsg;
566 }
567 if (count > CPTRMAXMSGCOUNT) {
568 log << MSG::VERBOSE << "find_proxy: No Valid MC event Collection found "
569 << endmsg;
570 }
571 return nullptr;
572}
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() [1/2]

int HepMcParticleLink::getEventNumberAtPosition ( index_type position,
const EventContext & ctx )
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 467 of file HepMcParticleLink.cxx.

468{
470}
IProxyDict * proxyDictFromEventContext()
Return the IProxyDict for this thread's current context.

◆ getEventNumberAtPosition() [2/2]

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

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

◆ getEventPositionInCollection() [1/3]

HepMcParticleLink::index_type HepMcParticleLink::getEventPositionInCollection ( const EventContext & ctx) 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 context. FIXME - need to be able to flag when no event with the appropriate event_number was found.

Definition at line 413 of file HepMcParticleLink.cxx.

414{
415 IProxyDict* sg = Atlas::proxyDictFromEventContext (ctx);
417}

◆ getEventPositionInCollection() [2/3]

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

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

◆ getEventPositionInCollection() [3/3]

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

426{
427 std::vector<index_type> positions; positions.reserve(1);
428 const int int_event_number = static_cast<int>(event_number);
429 if (const McEventCollection* coll = retrieveMcEventCollection (sg)) {
430 size_t sz = coll->size();
431 for (size_t i = 0; i < sz; i++) {
432 if ((*coll)[i]->event_number() == int_event_number) {
433 positions.push_back(i);
434 }
435 }
436 }
437 if (positions.empty() ) {
438 positions.push_back(ExtendedBarCode::UNDEFINED);
439 }
440 return positions;
441}
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 578 of file HepMcParticleLink.cxx.

579{
580 static const std::string unset = "CollectionNotSet";
581 unsigned idx = s_hint;
582 if (idx < NKEYS) {
583 return s_keys[idx];
584 }
585 return unset;
586}

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

481{
482 const HepMcParticleLink::PositionFlag idxFlag =
484 // Support reading in legacy barcode-based persistent EDM for now
485 const int uniqueID =
486 (particleLink.barcode() != 0) ? particleLink.barcode() : particleLink.id();
487 const HepMcParticleLink::UniqueIDFlag uidFlag =
489 HepMcParticleLink redirectedLink(uniqueID, eventIndex, idxFlag, uidFlag, ctx);
490 redirectedLink.setTruthSuppressionType(particleLink.getTruthSuppressionType());
491 return redirectedLink;
492}

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

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

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

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

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

513{
514 const McEventCollection* pEvtColl = nullptr;
515 SG::DataProxy* proxy = find_proxy (sg);
516 if (proxy) {
517 pEvtColl = SG::DataProxy_cast<McEventCollection> (proxy);
518 if (!pEvtColl) {
519 MsgStream log (Athena::getMessageSvc(), "HepMcParticleLink");
520 log << MSG::WARNING << "cptr: McEventCollection not found" << endmsg;
521 }
522 }
523 return pEvtColl;
524}
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 498 of file HepMcParticleLink.cxx.

499{
500 m_extBarcode = extBarcode;
501 m_store = SG::CurrentEventStore::store();
502 m_ptr.reset();
503}

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

609{
610 link.m_extBarcode.print(os);
611 return os;
612}
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 594 of file HepMcParticleLink.cxx.

596{
597 link.m_extBarcode.print(os);
598 return os;
599}

Member Data Documentation

◆ m_extBarcode

ExtendedBarCode HepMcParticleLink::m_extBarcode
private

Persistent part: barcode and location of target GenEvent.

Definition at line 699 of file HepMcParticleLink.h.

◆ m_ptr

Transient part. Pointer to the particle.

Definition at line 695 of file HepMcParticleLink.h.

◆ m_store

IProxyDict* HepMcParticleLink::m_store
private

Pointer to the store containing the event.

Definition at line 687 of file HepMcParticleLink.h.


The documentation for this class was generated from the following files: