ATLAS Offline Software
Loading...
Searching...
No Matches
ValidationBarcodeSvc.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3*/
4
6// framework include
7#include "GaudiKernel/IIncidentSvc.h"
9
10
12Barcode::ValidationBarcodeSvc::ValidationBarcodeSvc(const std::string& name,ISvcLocator* svc) :
13 base_class(name,svc),
14 m_incidentSvc("IncidentSvc", name),
15 m_firstVertex(-HepMC::SIM_BARCODE_THRESHOLD-1),
18 m_firstSecondary(HepMC::SIM_BARCODE_THRESHOLD+1),
21 m_particleGenerationIncrement(HepMC::SIM_REGENERATION_INCREMENT),
23{
24 // python properties
25 declareProperty("VertexIncrement" , m_vertexIncrement);
26 declareProperty("SecondaryIncrement" , m_secondaryIncrement);
27 declareProperty("BarcodeGenerationOffset" , m_barcodeGenerationOffset);
28}
29
30
33
34
37{
38 ATH_MSG_VERBOSE ("initialize() ...");
39
40 CHECK( m_incidentSvc.retrieve() );
41
42 // register to the incident service: BeginEvent needed for refresh of counter
43 m_incidentSvc->addListener( this, IncidentType::BeginEvent);
44
45 ATH_MSG_VERBOSE ("initialize() successful");
46 return StatusCode::SUCCESS;
47}
48
49
52{
54 // a naive underflog checking based on the fact that vertex
55 // barcodes should never be positive
56 if ( m_currentVertex > 0)
57 {
58 ATH_MSG_ERROR("ValidationBarcodeSvc::newVertex(...)"
59 << " will return a vertex barcode greater than 0: "
60 << m_currentVertex << ". Possibly Integer Underflow?");
61 }
62 return m_currentVertex;
63}
64
65
69{
71 // a naive overflow checking based on the fact that particle
72 // barcodes should never be negative
73 if ( m_currentSecondary < 0)
74 {
75 ATH_MSG_ERROR("ValidationBarcodeSvc::newSecondaryParticle(...)"
76 << " will return a particle barcode of less than 0: "
77 << m_currentSecondary << ". Possibly Integer Overflow?");
78 }
79 int primGen = int( (parentBC-m_particleGenerationIncrement) / m_barcodeGenerationOffset);
80 int returnBC = m_currentSecondary + (primGen+1)*m_barcodeGenerationOffset;
81
82 return returnBC;
83}
84
85
88{
90 // a naive overflow checking based on the fact that particle
91 // barcodes should never be negative
92 if ( m_currentSecondary < 0)
93 {
94 ATH_MSG_ERROR("ValidationBarcodeSvc::newGeneratedParticle(...)"
95 << " will return a particle barcode of less than 0: "
96 << m_currentSecondary << ". Possibly Integer Overflow?");
97 }
98 int primGen = int( (parentBC-m_particleGenerationIncrement) / m_barcodeGenerationOffset);
99 int returnBC = m_currentSecondary + (primGen+1)*m_barcodeGenerationOffset;
100
101 return returnBC;
102}
103
104
107{
109 // a naive underflog checking based on the fact that vertex
110 // barcodes should never be positive
111 if ( m_currentVertex > 0)
112 {
113 ATH_MSG_ERROR("ValidationBarcodeSvc::newGeneratedVertex(...)"
114 << " will return a vertex barcode greater than 0: "
115 << m_currentVertex << ". Possibly Integer Underflow?");
116 }
117 return m_currentVertex;
118}
119
120
126
127
133
134
137{
138 if ( inc.type() == IncidentType::BeginEvent )
139 {
140 ATH_MSG_VERBOSE("'BeginEvent' incident caught. Resetting Vertex and Particle barcode counters.");
143 }
144}
145
146
149{
150 ATH_MSG_VERBOSE ("finalize() ...");
151 ATH_MSG_VERBOSE ("finalize() successful");
152 return StatusCode::SUCCESS;
153}
#define ATH_MSG_ERROR(x)
#define ATH_MSG_VERBOSE(x)
#define CHECK(...)
Evaluate an expression and check for errors.
int m_particleGenerationIncrement
barcode offset for each generation of updated particles
ValidationBarcodeSvc(const std::string &name, ISvcLocator *pSvcLocator)
Constructor with parameters.
virtual int newSecondaryParticle(int parentBC=HepMC::UNDEFINED_ID) override
Generate a new unique barcode for a secondary particle, based on the parent particle barcode.
virtual int secondaryVertexBcOffset() const override
Return the secondary vertex offset.
virtual StatusCode finalize() override
framework methods
virtual int newGeneratedVertex() override
Generate a new unique vertex barcode below the simulation offset.
int m_firstSecondary
barcode information used for secondary GenParticles
virtual int newGeneratedParticle(int parentBC=HepMC::UNDEFINED_ID) override
Generate a new unique particle barcode below the simulation offset (for particles from pre-defined de...
virtual int newSimulationVertex() override
Generate a new unique vertex barcode, based on the parent particle barcode and the physics process co...
virtual StatusCode initialize() override
Athena algorithm's interface methods.
virtual void handle(const Incident &inc) override
Incident to reset the barcodes at the beginning of the event.
ServiceHandle< IIncidentSvc > m_incidentSvc
IncidentSvc to catch begin of event and end of envent.
virtual ~ValidationBarcodeSvc()
Destructor.
int m_barcodeGenerationOffset
not sure why this is needed...
virtual int secondaryParticleBcOffset() const override
Return the secondary particle and vertex offsets.
int m_firstVertex
barcode information used for GenVertices