ATLAS Offline Software
Loading...
Searching...
No Matches
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
13
14#include "SGTools/DataProxy.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
31
32class IProxyDict;
34
72{
73public:
74 typedef uint32_t barcode_type;
75 typedef uint32_t index_type;
76
77
82
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
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
201
202
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
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
398 uint32_t eventIndex,
399 PositionFlag positionFlag,
400 UniqueIDFlag uniqueIDFlag,
401 const EventContext& ctx);
402
403
416 uint32_t eventIndex /*= 0 */,
417 PositionFlag positionFlag /*= IS_EVENTNUM */,
419
420
433 uint32_t eventIndex,
434 PositionFlag positionFlag,
435 const EventContext& ctx);
436
437
442
443
447 HepMcParticleLink(HepMcParticleLink&& rhs) noexcept = default;
448
453
458
459
461
462
463
467 const HepMC::GenParticle& operator* () const;
468
469
474
475
480
481
486
487
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
697std::ostream& operator<< (std::ostream& os, const HepMcParticleLink& link);
698
699
705MsgStream& operator<< (MsgStream& os, const HepMcParticleLink& link);
706
707
709
710
711#endif
Cached value with atomic update.
std::vector< Identifier > ID
static Double_t a
EBC_SUPPRESSED_TRUTH
@ EBC_UNSUPPRESSED
Hold a pointer to the current event store.
Cached value with atomic update.
Definition CachedValue.h:55
This defines the McEventCollection, which is really just an ObjectVector of McEvent objectsFile: Gene...
static IProxyDict * store()
Fetch the current store.
const GenParticle * ConstGenParticlePtr
Definition GenParticle.h:38
Definition index.py:1
Wrapper for C++20 no_unique_address attribute.
#define ATH_NO_UNIQUE_ADDRESS