ATLAS Offline Software
Loading...
Searching...
No Matches
FixHepMC Class Reference

A "fix-up" algorithm to correct weird event records. More...

#include <FixHepMC.h>

Inheritance diagram for FixHepMC:
Collaboration diagram for FixHepMC:

Public Member Functions

 FixHepMC (const std::string &name, ISvcLocator *pSvcLocator)
virtual StatusCode sysInitialize () override
 Override sysInitialize.
virtual const DataObjIDColl & extraOutputDeps () const override
 Return the list of extra output dependencies.
ServiceHandle< StoreGateSvc > & evtStore ()
 The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
const ServiceHandle< StoreGateSvc > & detStore () const
 The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
virtual StatusCode sysStart () override
 Handle START transition.
virtual std::vector< Gaudi::DataHandle * > inputHandles () const override
 Return this algorithm's input handles.
virtual std::vector< Gaudi::DataHandle * > outputHandles () const override
 Return this algorithm's output handles.
Gaudi::Details::PropertyBase & declareProperty (Gaudi::Property< T, V, H > &t)
void updateVHKA (Gaudi::Details::PropertyBase &)
MsgStream & msg () const
bool msgLvl (const MSG::Level lvl) const
Event reduction functions
StatusCode execute ()
StatusCode finalize ()
Event loop algorithm methods
virtual StatusCode initialize () override
Event collection accessors (const and non-const)
HepMC::GenEvent *event ATLAS_NOT_CONST_THREAD_SAFE ()
 Access the current signal event (first in the McEventCollection)
McEventCollection *events ATLAS_NOT_CONST_THREAD_SAFE ()
 Access the current event's McEventCollection.
const HepMC::GenEvent * event_const () const
 Access the current signal event (const)
const McEventCollectionevents_const () const
 Access the current event's McEventCollection (const)
const McEventCollectionevents_const (const EventContext &ctx) const
Particle data accessors
const ServiceHandle< IPartPropSvc > partPropSvc () const
 Access the particle property service.
const HepPDT::ParticleDataTable & particleTable () const
 Get a particle data table.
const HepPDT::ParticleDataTable & pdt () const
 Shorter alias to get a particle data table.
const HepPDT::ParticleData * particleData (int pid) const
 Access an element in the particle data table.

Protected Member Functions

void renounceArray (SG::VarHandleKeyArray &handlesArray)
 remove all handles from I/O resolution
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce (T &h)
void extraDeps_update_handler (Gaudi::Details::PropertyBase &ExtraDeps)
 Add StoreName to extra input/output deps as needed.

Protected Attributes

Properties
std::string m_mcEventKey {}
 StoreGate key for the MC event collection (defaults to GEN_EVENT)
BooleanProperty m_mkMcEvent {this, "MakeMcEvent", false, "Create a new MC event collection if it doesn't exist"}
 Flag to determine if a new MC event collection should be made if it doesn't exist.

Private Types

typedef ServiceHandle< StoreGateSvcStoreGateSvc_t

Private Member Functions

Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
 specialization for handling Gaudi::Property<SG::VarHandleKey>
Classifiers for identifying particles to be removed
bool isPID0 (const HepMC::ConstGenParticlePtr &p) const
bool isNonTransportableInDecayChain (const HepMC::ConstGenParticlePtr &p) const
bool isSimpleLoop (const HepMC::ConstGenParticlePtr &p) const
bool fromDecay (const HepMC::ConstGenParticlePtr &p, std::shared_ptr< std::set< int > > &storage) const

Private Attributes

DataObjIDColl m_extendedExtraObjects
StoreGateSvc_t m_evtStore
 Pointer to StoreGate (event store by default)
StoreGateSvc_t m_detStore
 Pointer to StoreGate (detector store by default)
std::vector< SG::VarHandleKeyArray * > m_vhka
bool m_varHandleArraysDeclared
Config properties
bool m_killLoops
bool m_killPDG0
bool m_cleanDecays
bool m_purgeUnstableWithoutEndVtx
bool m_ignoreSemiDisconnected
std::string m_forced_momentum {""}
std::string m_forced_length {""}
bool m_unitsFix
Cleaned-particle counters
long m_loopKilled
long m_pdg0Killed
long m_decayCleaned
long m_unstablePurged
long m_totalSeen
long m_replacedPIDs
std::map< int, int > m_pidmap
 map of pids to change.
std::map< int, int > m_replacedpid_counts
 map of counters of replacements.
MC::Loops< HepMC::GenEvent, HepMC::ConstGenParticlePtr, HepMC::ConstGenVertexPtrm_looper
 member to detect loops

Utility event-mangling functions

Todo
Replace with HepMC units when available
ServiceHandle< IPartPropSvc > m_ppSvc {this, "PartPropSvc", "PartPropSvc"}
 Handle on the particle property service.
SG::ReadHandleKey< McEventCollectionm_mcevents_const { this, "McEventKey", "GEN_EVENT", "StoreGate key of the MC event collection" }
 Const handle to the MC event collection.
void GeVToMeV (HepMC::GenEvent *evt)
 Scale event energies/momenta by x 1000.
void MeVToGeV (HepMC::GenEvent *evt)
 Scale event energies/momenta by x 1/1000.
void cmTomm (HepMC::GenEvent *evt)
 Scale event lengths by x 10.
void mmTocm (HepMC::GenEvent *evt)
 Scale event lengths by x 1/10.

Detailed Description

A "fix-up" algorithm to correct weird event records.

FixHepMC is run in evgen production, after the chain of input, shower, hadronization, and afterburner generators, but before the TestHepMC check algorithm, any analysis algs, and the POOL event stream output. Its job is to "normalise" strange event features to allow greater consistency of MC event record use in ATLAS.

Examples of its features include removing dummy "padding" particles from event records, stripping parton and EW boson intermediates from hadron/tau decay chains, and ensuring that every event has at least one entry in its event weight vector.

Definition at line 31 of file FixHepMC.h.

Member Typedef Documentation

◆ StoreGateSvc_t

typedef ServiceHandle<StoreGateSvc> AthCommonDataStore< AthCommonMsg< Algorithm > >::StoreGateSvc_t
privateinherited

Definition at line 388 of file AthCommonDataStore.h.

Constructor & Destructor Documentation

◆ FixHepMC()

FixHepMC::FixHepMC ( const std::string & name,
ISvcLocator * pSvcLocator )

Definition at line 14 of file FixHepMC.cxx.

15 : GenBase(name, pSvcLocator)
16 , m_loopKilled(0)
17 , m_pdg0Killed(0)
20 , m_totalSeen(0)
22{
23 declareProperty("KillLoops", m_killLoops = true, "Remove particles in loops?");
24 declareProperty("KillPDG0", m_killPDG0 = true, "Remove particles with PDG ID 0?");
25 declareProperty("CleanDecays", m_cleanDecays = true, "Clean decay chains from non-propagating particles?");
26 declareProperty("PurgeUnstableWithoutEndVtx", m_purgeUnstableWithoutEndVtx = false, "Remove unstable particles without decay vertex?");
27 declareProperty("IgnoreSemiDisconnected", m_ignoreSemiDisconnected = false, "Ignore semi-disconnected particles (normal in Sherpa)");
28 declareProperty("PIDmap", m_pidmap = std::map<int,int>(), "Map of PDG IDs to replace");
29 declareProperty("forced_momentum", m_forced_momentum = "MEV", "Forced momentum unit");
30 declareProperty("forced_length", m_forced_length = "MM", "Forced length unit");
31 declareProperty("ApplyUnitsFix", m_unitsFix = true, "Attempt to identify momentum units problems and fix them");
32}
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
bool m_purgeUnstableWithoutEndVtx
Definition FixHepMC.h:54
long m_replacedPIDs
Definition FixHepMC.h:68
bool m_killPDG0
Definition FixHepMC.h:52
std::string m_forced_momentum
Definition FixHepMC.h:56
bool m_unitsFix
Definition FixHepMC.h:58
long m_totalSeen
Definition FixHepMC.h:67
long m_pdg0Killed
Definition FixHepMC.h:64
long m_decayCleaned
Definition FixHepMC.h:65
bool m_ignoreSemiDisconnected
Definition FixHepMC.h:55
bool m_cleanDecays
Definition FixHepMC.h:53
bool m_killLoops
Definition FixHepMC.h:51
long m_unstablePurged
Definition FixHepMC.h:66
long m_loopKilled
Definition FixHepMC.h:63
std::map< int, int > m_pidmap
map of pids to change.
Definition FixHepMC.h:71
std::string m_forced_length
Definition FixHepMC.h:57
GenBase(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
Definition GenBase.cxx:11

Member Function Documentation

◆ ATLAS_NOT_CONST_THREAD_SAFE() [1/2]

HepMC::GenEvent *event GenBase::ATLAS_NOT_CONST_THREAD_SAFE ( )
inlineinherited

Access the current signal event (first in the McEventCollection)

Note
This function will make a new McEventCollection if there is not already a valid one and MakeMcEvent=True.

Definition at line 76 of file GenBase.h.

76 {
77 if (events()->empty())
78 ATH_MSG_ERROR("McEventCollection is empty during first event access");
79 return *(events()->begin());
80 }
#define ATH_MSG_ERROR(x)
static const Attributes_t empty

◆ ATLAS_NOT_CONST_THREAD_SAFE() [2/2]

McEventCollection *events GenBase::ATLAS_NOT_CONST_THREAD_SAFE ( )
inherited

Access the current event's McEventCollection.

Note
This function will make a new McEventCollection if there is not already a valid one and MakeMcEvent=True.

◆ cmTomm()

void GenBase::cmTomm ( HepMC::GenEvent * evt)
protectedinherited

Scale event lengths by x 10.

Definition at line 78 of file GenBase.cxx.

78 {
79 for (HepMC::GenEvent::vertex_iterator vtx = evt->vertices_begin(); vtx != evt->vertices_end(); ++vtx) {
80 const HepMC::FourVector fv((*vtx)->position().x() * 10,
81 (*vtx)->position().y() * 10,
82 (*vtx)->position().z() * 10,
83 (*vtx)->position().t() * 10);
84 (*vtx)->set_position(fv);
85 }
86}

◆ declareGaudiProperty()

Gaudi::Details::PropertyBase & AthCommonDataStore< AthCommonMsg< Algorithm > >::declareGaudiProperty ( Gaudi::Property< T, V, H > & hndl,
const SG::VarHandleKeyType &  )
inlineprivateinherited

specialization for handling Gaudi::Property<SG::VarHandleKey>

Definition at line 156 of file AthCommonDataStore.h.

158 {
160 hndl.value(),
161 hndl.documentation());
162
163 }

◆ declareProperty()

Gaudi::Details::PropertyBase & AthCommonDataStore< AthCommonMsg< Algorithm > >::declareProperty ( Gaudi::Property< T, V, H > & t)
inlineinherited

Definition at line 145 of file AthCommonDataStore.h.

145 {
146 typedef typename SG::HandleClassifier<T>::type htype;
148 }
Gaudi::Details::PropertyBase & declareGaudiProperty(Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
specialization for handling Gaudi::Property<SG::VarHandleKey>

◆ detStore()

const ServiceHandle< StoreGateSvc > & AthCommonDataStore< AthCommonMsg< Algorithm > >::detStore ( ) const
inlineinherited

The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 95 of file AthCommonDataStore.h.

◆ event_const()

const HepMC::GenEvent * GenBase::event_const ( ) const
inlineinherited

Access the current signal event (const)

Definition at line 83 of file GenBase.h.

83 {
84 if (events_const()->empty())
85 ATH_MSG_ERROR("Const McEventCollection is empty during first event access");
86 return *(events_const()->begin());
87 }
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
const McEventCollection * events_const() const
Access the current event's McEventCollection (const)
Definition GenBase.h:96

◆ events_const() [1/2]

const McEventCollection * GenBase::events_const ( ) const
inlineinherited

Access the current event's McEventCollection (const)

Definition at line 96 of file GenBase.h.

96 {
97 return events_const( getContext() );
98 }

◆ events_const() [2/2]

const McEventCollection * GenBase::events_const ( const EventContext & ctx) const
inlineinherited

Definition at line 99 of file GenBase.h.

99 {
100 SG::ReadHandle<McEventCollection> ret = SG::makeHandle(m_mcevents_const, ctx);
101 if (!ret.isValid())
102 ATH_MSG_ERROR("No McEventCollection found in StoreGate with key " << m_mcevents_const.key());
103 return ret.cptr();
104 }
SG::ReadHandleKey< McEventCollection > m_mcevents_const
Const handle to the MC event collection.
Definition GenBase.h:163
virtual bool isValid() override final
Can the handle be successfully dereferenced?
const_pointer_type cptr()
Dereference the pointer.
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())

◆ evtStore()

ServiceHandle< StoreGateSvc > & AthCommonDataStore< AthCommonMsg< Algorithm > >::evtStore ( )
inlineinherited

The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 85 of file AthCommonDataStore.h.

◆ execute()

StatusCode FixHepMC::execute ( )
virtual

Case 1: particles without production vertex, except beam particles (status 4)

Case 2: non-final-state particles without end vertex

AV: In case we have 3 particles, we try to add a vertex that correspond to 1->2 and 1->1 splitting. AV: we can try to do that for 4 particles as well.

The condition below will cover 1->1, 1->2 and 2->1 cases

Remove loops inside decay chains AV: Please note that this approach would distort some branching ratios. If some particle would have decay products with bad PDG ids, after the operation below the visible branching ratio of these decays would be zero.

Check the bad particles have prod and end vertices

Check that all particles coming into the decay vertex of bad particle cam from the same production vertex.

Reimplemented from GenBase.

Definition at line 97 of file FixHepMC.cxx.

97 {
98 for (McEventCollection::const_iterator ievt = events()->begin(); ievt != events()->end(); ++ievt) {
99 // FIXME: const_cast
100 HepMC::GenEvent* evt = const_cast<HepMC::GenEvent*>(*ievt);
101 m_looper.findLoops(evt,true);
102 /* AV: To understand why some algorithms fail one would have to request debug explicitly, but that is the reviwers consensus.*/
103 if (!m_looper.loop_particles().empty() || !m_looper.loop_vertices().empty()) {
104 ATH_MSG_DEBUG("Found " << m_looper.loop_vertices().size() << " vertices in loops");
105 ATH_MSG_DEBUG("Found " << m_looper.loop_particles().size() << " particles in loops");
106 ATH_MSG_DEBUG("Please use MC::Loops::findLoops for this event to obtain all particles and vertices in the loops");
107 }
108#ifdef HEPMC3
109 auto old_momentum = evt->momentum_unit();
110 auto old_length = evt->length_unit();
111 evt->set_units(
112 m_forced_momentum != "" ? HepMC3::Units::momentum_unit(m_forced_momentum): old_momentum,
113 m_forced_length != "" ? HepMC3::Units::length_unit(m_forced_length): old_length);
114 if ( m_forced_momentum != "" && m_forced_momentum != HepMC3::Units::name(old_momentum) ) ATH_MSG_WARNING("Updated momentum units " << HepMC3::Units::name(old_momentum) << "->" << m_forced_momentum);
115 if ( m_forced_length != "" && m_forced_length != HepMC3::Units::name(old_length) ) ATH_MSG_WARNING("Updated length units " << HepMC3::Units::name(old_length) << "->" << m_forced_length);
116#else
117 std::string old_momentum = (evt->momentum_unit() == HepMC::Units::MomentumUnit::MEV ? "MEV" : "GEV" );
118 std::string old_length = (evt->length_unit() == HepMC::Units::LengthUnit::MM ? "MM" : "CM" );
119 evt->define_units(
120 m_forced_momentum != "" ? m_forced_momentum: old_momentum,
121 m_forced_length != "" ? m_forced_length: old_length);
122 if ( m_forced_momentum != "" && m_forced_momentum != old_momentum ) ATH_MSG_WARNING("Updated momentum units " << old_momentum << "->" << m_forced_momentum);
123 if ( m_forced_length != "" && m_forced_length != old_length ) ATH_MSG_WARNING("Updated length units " << old_length << "->" << m_forced_length);
124#endif
125
126 if (!m_pidmap.empty()) {
127 for (auto ip: *evt) {
128 // Skip this particle if (somehow) its pointer is null
129 if (!ip) continue;
130 auto newpid = m_pidmap.find(ip->pdg_id());
131 if (newpid == m_pidmap.end()) continue;
132 ip->set_pdg_id(newpid->second);
133 // Increment the counter for replaced PDG IDs
135 m_replacedpid_counts[ip->pdg_id()]++;
136 }
137 }
138#ifdef HEPMC3
139 // Add a unit entry to the event weight vector if it's currently empty
140 if (evt->weights().empty()) {
141 ATH_MSG_DEBUG("Adding a unit weight to empty event weight vector");
142 evt->weights().push_back(1);
143 }
144 // Set a (0,0,0) vertex to be the signal vertex if not already set
146 const HepMC::FourVector nullpos;
147 for (auto iv: evt->vertices()) {
148 if (iv->position() == nullpos) {
149 ATH_MSG_DEBUG("Setting representative event position vertex");
151 break;
152 }
153 }
154 }
155
156 // Catch cases with more than 2 beam particles (16.11.2021)
157 std::vector<HepMC::GenParticlePtr> beams_t;
158 for (const HepMC::GenParticlePtr& p : evt->beams()) {
159 if (p->status() == 4) beams_t.push_back(p);
160 }
161 if (beams_t.size() > 2) {
162 ATH_MSG_INFO("Invalid number of beam particles " << beams_t.size() << ". Will try to fix.");
163 std::vector<HepMC::GenParticlePtr> bparttoremove;
164 for (const auto& bpart : beams_t) {
165 if (bpart->id() == 0 && bpart->production_vertex()) bparttoremove.push_back(bpart);
166 }
167 for (auto bpart: bparttoremove) {
168 bpart->production_vertex()->remove_particle_out(bpart);
169 }
170 }
171
172 // Some generators / samples have a mis-match between the units they report and the units used for momentum, usually because we have applied
173 // a correction to the momentum without also correcting the units. Here we're going to check for states that look particularly suspicious
174 // and apply a correction if required. We will try to identify those issues based on the beam particles.
175 if (m_unitsFix){ // Only if requested - allow folks to disable this if they know what they're doing
176 double units_problem = -1.;
177 // If we have beam particles, let's use them - it's much faster!
178 if (beams_t.size() > 0 ){
179 for (const HepMC::GenParticlePtr& p : beams_t){
180 if (p->momentum().pz() > 1e9) units_problem = p->momentum().pz();
181 }
182 // if we didn't have beam particles, we'll go through some of the main record
183 } else {
184 for (const HepMC::GenParticlePtr& p : evt->particles()) {
185 if (p && p->momentum().pz() > 1e9) units_problem = p->momentum().pz();
186 }
187 }
188 if (units_problem>0){ // No particles should have momenta above 1 PeV; this must be a units issue
189 ATH_MSG_INFO("Apparent units problem; beam particles have z-momentum " << units_problem << " in MeV. Will divide by 1000.");
190 MeVToGeV(evt);
191 }
192 }
193
194 // Some heuristics to catch problematic cases
195 std::vector<HepMC::GenParticlePtr> semi_disconnected, decay_loop_particles;
196 for (auto ip : evt->particles()) {
197 // Skip this particle if (somehow) its pointer is null
198 if (!ip) continue;
199 bool particle_to_fix = false;
200 int abspid = std::abs(ip->pdg_id());
201 auto vProd = ip->production_vertex();
202 auto vEnd = ip->end_vertex();
204 if ( (!vProd || vProd->id() == 0) && vEnd && ip->status() != 4) {
205 particle_to_fix = true;
206 ATH_MSG_DEBUG("Found particle " << ip->pdg_id() << " without production vertex! HepMC status = " << ip->status());
207 }
209 if (vProd && !vEnd && ip->status() != 1) {
210 particle_to_fix = true;
211 ATH_MSG_DEBUG("Found particle " << ip->pdg_id() << " without decay vertex! HepMC status = " << ip->status());
212 }
213 if (particle_to_fix) semi_disconnected.push_back(ip);
214 // Case 3: keep track of loop particles inside decay chains (seen in H7+EvtGen)
215 if (abspid == 43 || abspid == 44 || abspid == 30353 || abspid == 30343) {
216 decay_loop_particles.push_back(std::move(ip));
217 }
218 }
219
223
228 if ( !m_ignoreSemiDisconnected && (semi_disconnected.size() == 4 || semi_disconnected.size() == 3 || semi_disconnected.size() == 2)) {
229 size_t no_endv = 0;
230 size_t no_prov = 0;
231 HepMC::FourVector sum(0,0,0,0);
232 std::set<HepMC::GenVertexPtr> standalone;
233 for (const auto& part : semi_disconnected) {
234 if (!part->production_vertex() || !part->production_vertex()->id()) {
235 no_prov++; sum += part->momentum();
236 }
237 if (!part->end_vertex()) {
238 no_endv++; sum -= part->momentum();
239 }
240 if (part->production_vertex()) standalone.insert(part->production_vertex());
241 if (part->end_vertex()) standalone.insert(part->end_vertex());
242 }
243 ATH_MSG_INFO("Heuristics: found " << semi_disconnected.size() << " semi-disconnected particles. Momentum sum is " << sum << " Standalone vertices " << standalone.size());
244 bool standalonevertex = (standalone.size() == 1 && (*standalone.begin())->particles_in().size() + (*standalone.begin())->particles_out().size() == semi_disconnected.size());
246 if (! standalonevertex && no_endv && no_prov && ( no_endv + no_prov == semi_disconnected.size() )) {
247 if (std::abs(sum.px()) < 1e-2 && std::abs(sum.py()) < 1e-2 && std::abs(sum.pz()) < 1e-2 ) {
248 ATH_MSG_INFO("Try " << no_endv << "->" << no_prov << " splitting/merging.");
249 auto v = HepMC::newGenVertexPtr();
250 for (auto part : semi_disconnected) {
251 if (!part->production_vertex() || part->production_vertex()->id() == 0) v->add_particle_out(std::move(part));
252 }
253 for (auto part : semi_disconnected) {
254 if (!part->end_vertex()) v->add_particle_in(std::move(part));
255 }
256 evt->add_vertex(std::move(v));
257 }
258 }
259 }
260
265 for (auto part: decay_loop_particles) {
267 auto vend = part->end_vertex();
268 auto vprod = part->production_vertex();
269 if (!vprod || !vend) continue;
270 bool loop_in_decay = true;
273 auto sisters = vend->particles_in();
274 for (auto sister: sisters) {
275 if (vprod != sister->production_vertex()) loop_in_decay = false;
276 }
277 if (!loop_in_decay) continue;
278
280 auto daughters = vend->particles_out();
281 for (auto p : daughters) vprod->add_particle_out(std::move(p));
282 for (auto sister : sisters) {
283 vprod->remove_particle_out(sister);
284 vend->remove_particle_in(sister);
285 evt->remove_particle(std::move(sister));
286 }
287 evt->remove_vertex(std::move(vend));
288
289 }
290
291 // Event particle content cleaning -- remove "bad" structures
292 std::vector<HepMC::GenParticlePtr> toremove;
293 for (auto ip: evt->particles()) {
294 // Skip this particle if (somehow) its pointer is null
295 if (!ip) continue;
296 m_totalSeen += 1;
297 // Flag to declare if a particle should be removed
298 bool bad_particle = false;
299 // Check for loops
300 if ( m_killLoops && isSimpleLoop(ip) ) {
301 bad_particle = true;
302 m_loopKilled += 1;
303 ATH_MSG_DEBUG( "Found a looper : " );
304 if ( msgLvl( MSG::DEBUG ) ) HepMC::Print::line(ip);
305 }
306 // Check on PDG ID 0
307 if ( m_killPDG0 && isPID0(ip) ) {
308 bad_particle = true;
309 m_pdg0Killed += 1;
310 ATH_MSG_DEBUG( "Found PDG ID 0 : " );
311 if ( msgLvl( MSG::DEBUG ) )HepMC::Print::line(ip);
312 }
313 // Clean decays
314 int abs_pdg_id = std::abs(ip->pdg_id());
315 bool is_decayed_weak_boson = ( abs_pdg_id == 23 || abs_pdg_id == 24 || abs_pdg_id == 25 ) && ip->end_vertex();
316 if ( m_cleanDecays && isNonTransportableInDecayChain(ip) && !is_decayed_weak_boson ) {
317 bad_particle = true;
318 m_decayCleaned += 1;
319 ATH_MSG_DEBUG( "Found a bad particle in a decay chain : " );
320 if ( msgLvl( MSG::DEBUG ) ) HepMC::Print::line(ip);
321 }
322 // Only add to the toremove vector once, even if multiple tests match
323 if (bad_particle) toremove.push_back(std::move(ip));
324 }
325
326 // Properties before cleaning
327 const int num_particles_orig = evt->particles().size();
328
329 // Do the cleaning
330 if (!toremove.empty()) {
331 ATH_MSG_DEBUG("Cleaning event record of " << toremove.size() << " bad particles");
332 for (auto part: toremove) evt->remove_particle(std::move(part));
333 }
334
336 int purged=0;
337 do {
338 purged=0;
339 const std::vector <HepMC::GenParticlePtr> allParticles=evt->particles();
340 for(auto p : allParticles) {
341 HepMC::ConstGenVertexPtr end_v=p->end_vertex();
342 if(p->status() == 2 && !end_v) {
343 evt->remove_particle(std::move(p));
344 ++purged;
346 }
347 }
348 }
349 while (purged>0);
350 }
351
352 const int num_particles_filt = evt->particles().size();
353
354 if(num_particles_orig!=num_particles_filt) {
355 // Write out the change in the number of particles
356 ATH_MSG_INFO("Particles filtered: " << num_particles_orig << " -> " << num_particles_filt);
357 }
358 #else
359
360 // Add a unit entry to the event weight vector if it's currently empty
361 if (evt->weights().empty()) {
362 ATH_MSG_DEBUG("Adding a unit weight to empty event weight vector");
363 evt->weights().push_back(1);
364 }
365
366 // Set a (0,0,0) vertex to be the signal vertex if not already set
367 if (evt->signal_process_vertex() == NULL) {
368 const HepMC::FourVector nullpos;
369 for (HepMC::GenEvent::vertex_const_iterator iv = evt->vertices_begin(); iv != evt->vertices_end(); ++iv) {
370 if ((*iv)->position() == nullpos) {
371 ATH_MSG_DEBUG("Setting representative event position vertex");
372 evt->set_signal_process_vertex(const_cast<HepMC::GenVertex*>(*iv));
373 break;
374 }
375 }
376 }
377
378
379 // Some heuristics to catch problematic cases
380 std::vector<HepMC::GenParticlePtr> semi_disconnected, decay_loop_particles;
381 for (auto ip : *evt) {
382 // Skip this particle if (somehow) its pointer is null
383 if (!ip) continue;
384 bool particle_to_fix = false;
385 int abspid = std::abs(ip->pdg_id());
386 auto vProd = ip->production_vertex();
387 auto vEnd = ip->end_vertex();
389 if ( (!vProd || vProd->id() == 0) && vEnd && ip->status() != 4) {
390 particle_to_fix = true;
391 ATH_MSG_DEBUG("Found particle " << ip->pdg_id() << " without production vertex! HepMC status = " << ip->status());
392 }
394 if (vProd && !vEnd && ip->status() != 1) {
395 particle_to_fix = true;
396 ATH_MSG_DEBUG("Found particle " << ip->pdg_id() << " without decay vertex! HepMC status = " << ip->status());
397 }
398 if (particle_to_fix) semi_disconnected.push_back(ip);
399 // Case 3: keep track of loop particles inside decay chains (seen in H7+EvtGen)
400 if (abspid == 43 || abspid == 44 || abspid == 30353 || abspid == 30343) {
401 decay_loop_particles.push_back(ip);
402 }
403 }
404
407 if (semi_disconnected.size() == 4 ||semi_disconnected.size() == 3 || semi_disconnected.size() == 2) {
408 size_t no_endv = 0;
409 size_t no_prov = 0;
410 double vsum[4] = {0,0,0,0};
411 for (auto part : semi_disconnected) {
412 if (!part->production_vertex() ) {
413 no_prov++;
414 vsum[0] += part->momentum().px();
415 vsum[1] += part->momentum().py();
416 vsum[2] += part->momentum().pz();
417 vsum[3] += part->momentum().e();
418 }
419 if (!part->end_vertex()) {
420 no_endv++;
421 vsum[0] -= part->momentum().px();
422 vsum[1] -= part->momentum().py();
423 vsum[2] -= part->momentum().pz();
424 vsum[3] -= part->momentum().e();
425 }
426 }
427 HepMC::FourVector sum(vsum[0],vsum[1],vsum[2],vsum[3]);
428 ATH_MSG_INFO("Heuristics: found " << semi_disconnected.size() << " semi-disconnected particles. Momentum sum is " << vsum[0] << " " << vsum[1] << " " << vsum[2] << " " << vsum[3]);
430 if (no_endv && no_prov && ( no_endv + no_prov == semi_disconnected.size() )) {
431 if (std::abs(sum.px()) < 1e-2 && std::abs(sum.py()) < 1e-2 && std::abs(sum.pz()) < 1e-2 ) {
432 ATH_MSG_INFO("Try " << no_endv << "->" << no_prov << " splitting/merging.");
433 auto v = HepMC::newGenVertexPtr();
434 for (auto part : semi_disconnected) {
435 if (!part->production_vertex()) v->add_particle_out(part);
436 }
437 for (auto part : semi_disconnected) {
438 if (!part->end_vertex()) v->add_particle_in(part);
439 }
440 evt->add_vertex(v);
441 }
442 }
443 }
444
449 for (auto part: decay_loop_particles) {
451 auto vend = part->end_vertex();
452 auto vprod = part->production_vertex();
453 if (!vend || !vprod) continue;
454 bool loop_in_decay = true;
456 std::vector<HepMC::GenParticlePtr> sisters;
457 for (auto p = vend->particles_begin(HepMC::parents); p!= vend->particles_end(HepMC::parents); ++p) sisters.push_back(*p);
458 for (auto sister : sisters) {
459 if (vprod != sister->production_vertex()) loop_in_decay = false;
460 }
461 if (!loop_in_decay) continue;
462
463 std::vector<HepMC::GenParticlePtr> daughters;
464 for (auto p = vend->particles_begin(HepMC::children); p!= vend->particles_end(HepMC::children); ++p) daughters.push_back(*p);
465 for (auto p : daughters) vprod->add_particle_out(p);
466 for (auto sister : sisters) {
467 vprod->remove_particle(sister);
468 vend->remove_particle(sister);
469 }
470 evt->remove_vertex(vend);
471
472 }
473
474
475 // Event particle content cleaning -- remove "bad" structures
476 std::vector<HepMC::GenParticlePtr> toremove; toremove.reserve(10);
477 for (HepMC::GenEvent::particle_const_iterator ip = evt->particles_begin(); ip != evt->particles_end(); ++ip) {
478 // Skip this particle if (somehow) its pointer is null
479 if (*ip == NULL) continue;
480 m_totalSeen += 1;
481
482 // Flag to declare if a particle should be removed
483 bool bad_particle = false;
484
485 // Check for loops
486 if ( m_killLoops && isSimpleLoop(*ip) ) {
487 bad_particle = true;
488 m_loopKilled += 1;
489 ATH_MSG_DEBUG( "Found a looper : " );
490 if ( msgLvl( MSG::DEBUG ) ) (*ip)->print();
491 }
492
493 // Check on PDG ID 0
494 if ( m_killPDG0 && isPID0(*ip) ) {
495 bad_particle = true;
496 m_pdg0Killed += 1;
497 ATH_MSG_DEBUG( "Found PDG ID 0 : " );
498 if ( msgLvl( MSG::DEBUG ) ) (*ip)->print();
499 }
500
501 // Clean decays
502 int abs_pdg_id = std::abs((*ip)->pdg_id());
503 bool is_decayed_weak_boson = ( abs_pdg_id == 23 || abs_pdg_id == 24 || abs_pdg_id == 25 ) && (*ip)->end_vertex();
504 if ( m_cleanDecays && isNonTransportableInDecayChain(*ip) && !is_decayed_weak_boson ) {
505 bad_particle = true;
506 m_decayCleaned += 1;
507 ATH_MSG_DEBUG( "Found a bad particle in a decay chain : " );
508 if ( msgLvl( MSG::DEBUG ) ) (*ip)->print();
509 }
510
511 // Only add to the toremove vector once, even if multiple tests match
512 if (bad_particle) toremove.push_back(*ip);
513 }
514
515 // Properties before cleaning
516 const int num_particles_orig = evt->particles_size();
517 int num_orphan_vtxs_orig = 0;
518 int num_noparent_vtxs_orig = 0;
519 int num_nochild_vtxs_orig = 0;
520 for (auto v = evt->vertices_begin(); v != evt->vertices_end(); ++v) {
521 if ((*v)->particles_in_size()==0&&(*v)->particles_out_size()==0) num_orphan_vtxs_orig++;
522 if ((*v)->particles_in_size()==0) num_noparent_vtxs_orig++;
523 if ((*v)->particles_out_size()==0) num_nochild_vtxs_orig++;
524 }
525
526 // Do the cleaning
527 if (!toremove.empty()) {
528 ATH_MSG_DEBUG("Cleaning event record of " << toremove.size() << " bad particles");
529 // Clean!
530 int signal_vertex_bc = evt->signal_process_vertex() ? evt->signal_process_vertex()->barcode() : 0;
531 //This is the only place where reduce is used.
532 reduce(evt , toremove);
533 if (evt->barcode_to_vertex (signal_vertex_bc) == nullptr) {
534 evt->set_signal_process_vertex (nullptr);
535 }
536 }
537
539 int purged=0;
540 do {
541 for (HepMC::GenParticle* p : *evt) {
542 HepMC::ConstGenVertexPtr end_v = p->end_vertex();
543 if (p->status() == 2 && !end_v) {
544 delete p->production_vertex()->remove_particle(p);
545 ++purged;
547 }
548 }
549 }
550 while (purged>0);
551 }
552
553 // Properties after cleaning
554 const int num_particles_filt = evt->particles_size();
555 if(num_particles_orig!=num_particles_filt) {
556 int num_orphan_vtxs_filt = 0;
557 int num_noparent_vtxs_filt = 0;
558 int num_nochild_vtxs_filt = 0;
559 for (auto v = evt->vertices_begin(); v != evt->vertices_end(); ++v) {
560 if ((*v)->particles_in_size()==0&&(*v)->particles_out_size()==0) num_orphan_vtxs_filt++;
561 if ((*v)->particles_in_size()==0) num_noparent_vtxs_filt++;
562 if ((*v)->particles_out_size()==0) num_nochild_vtxs_filt++;
563 }
564
565 // Write out the change in the number of particles
566 ATH_MSG_INFO("Particles filtered: " << num_particles_orig << " -> " << num_particles_filt);
567 // Warn if the numbers of "strange" vertices have changed
568 if (num_orphan_vtxs_filt != num_orphan_vtxs_orig)
569 ATH_MSG_WARNING("Change in orphaned vertices: " << num_orphan_vtxs_orig << " -> " << num_orphan_vtxs_filt);
570 if (num_noparent_vtxs_filt != num_noparent_vtxs_orig)
571 ATH_MSG_WARNING("Change in no-parent vertices: " << num_noparent_vtxs_orig << " -> " << num_noparent_vtxs_filt);
572 if (num_nochild_vtxs_filt != num_nochild_vtxs_orig)
573 ATH_MSG_WARNING("Change in no-parent vertices: " << num_nochild_vtxs_orig << " -> " << num_nochild_vtxs_filt);
574 }
575#endif
576
577 } // End of the loop over events in the MC event collection
578 return StatusCode::SUCCESS;
579}
#define ATH_MSG_INFO(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
static void reduce(HepMC::GenEvent *ge, HepMC::GenParticle *gp)
Remove an unwanted particle from the event, collapsing the graph structure consistently.
Definition FixHepMC.cxx:39
bool msgLvl(const MSG::Level lvl) const
DataModel_detail::const_iterator< DataVector > const_iterator
Definition DataVector.h:838
bool isPID0(const HepMC::ConstGenParticlePtr &p) const
Definition FixHepMC.cxx:599
bool isNonTransportableInDecayChain(const HepMC::ConstGenParticlePtr &p) const
Definition FixHepMC.cxx:631
std::map< int, int > m_replacedpid_counts
map of counters of replacements.
Definition FixHepMC.h:72
MC::Loops< HepMC::GenEvent, HepMC::ConstGenParticlePtr, HepMC::ConstGenVertexPtr > m_looper
member to detect loops
Definition FixHepMC.h:75
bool isSimpleLoop(const HepMC::ConstGenParticlePtr &p) const
Definition FixHepMC.cxx:637
void MeVToGeV(HepMC::GenEvent *evt)
Scale event energies/momenta by x 1/1000.
Definition GenBase.cxx:68
void line(std::ostream &os, const GenEvent &e)
Definition GenEvent.h:677
void set_signal_process_vertex(GenEvent *e, T v)
Definition GenEvent.h:651
GenVertexPtr newGenVertexPtr(const HepMC::FourVector &pos=HepMC::FourVector(0.0, 0.0, 0.0, 0.0), const int i=0)
Definition GenVertex.h:64
GenParticle * GenParticlePtr
Definition GenParticle.h:37
GenVertex * signal_process_vertex(const GenEvent *e)
Definition GenEvent.h:626
const HepMC::GenVertex * ConstGenVertexPtr
Definition GenVertex.h:60

◆ extraDeps_update_handler()

void AthCommonDataStore< AthCommonMsg< Algorithm > >::extraDeps_update_handler ( Gaudi::Details::PropertyBase & ExtraDeps)
protectedinherited

Add StoreName to extra input/output deps as needed.

use the logic of the VarHandleKey to parse the DataObjID keys supplied via the ExtraInputs and ExtraOuputs Properties to add the StoreName if it's not explicitly given

◆ extraOutputDeps()

const DataObjIDColl & AthAlgorithm::extraOutputDeps ( ) const
overridevirtualinherited

Return the list of extra output dependencies.

This list is extended to include symlinks implied by inheritance relations.

Definition at line 50 of file AthAlgorithm.cxx.

51{
52 // If we didn't find any symlinks to add, just return the collection
53 // from the base class. Otherwise, return the extended collection.
54 if (!m_extendedExtraObjects.empty()) {
56 }
57 return Algorithm::extraOutputDeps();
58}
DataObjIDColl m_extendedExtraObjects

◆ finalize()

StatusCode FixHepMC::finalize ( )

Definition at line 582 of file FixHepMC.cxx.

582 {
583 if (m_killLoops ) ATH_MSG_INFO( "Removed " << m_loopKilled << " of " << m_totalSeen << " particles because of loops." );
584 if (m_killPDG0 ) ATH_MSG_INFO( "Removed " << m_pdg0Killed << " of " << m_totalSeen << " particles because of PDG ID 0." );
585 if (m_cleanDecays) ATH_MSG_INFO( "Removed " << m_decayCleaned << " of " << m_totalSeen << " particles while cleaning decay chains." );
586 if(m_purgeUnstableWithoutEndVtx) ATH_MSG_INFO( "Removed " << m_unstablePurged << " of " << m_totalSeen << " unstable particles because they had no decay vertex." );
587 if (!m_pidmap.empty()) {
588 ATH_MSG_INFO( "Replaced " << m_replacedPIDs << " PIDs of particles." );
589 for (const auto& p: m_replacedpid_counts) ATH_MSG_INFO( "Replaced " << p.first << " PIDs " << p.second << "times." );
590 }
591 return StatusCode::SUCCESS;
592}

◆ fromDecay()

bool FixHepMC::fromDecay ( const HepMC::ConstGenParticlePtr & p,
std::shared_ptr< std::set< int > > & storage ) const
private

Definition at line 604 of file FixHepMC.cxx.

604 {
605 if (!p) return false;
606 auto v=p->production_vertex();
607 if (!v) return false;
608#ifdef HEPMC3
609 for ( const auto& anc: v->particles_in()) {
610 if (MC::isDecayed(anc) && (MC::isTau(anc->pdg_id()) || MC::isHadron(anc->pdg_id()))) return true;
611 }
612 if (storage->find(p->id()) != storage->end()) return false;
613 storage->insert(p->id());
614 for ( const auto& anc: v->particles_in()) {
615 if (fromDecay(anc, storage)) return true;
616 }
617#else
618 for (auto anc=v->particles_in_const_begin(); anc != v->particles_in_const_end(); ++anc) {
619 if (MC::isDecayed((*anc)) && (MC::isTau((*anc)->pdg_id()) || MC::isHadron((*anc)->pdg_id()))) return true;
620 }
621 if (storage->find(p->barcode()) != storage->end()) return false;
622 storage->insert(p->barcode());
623 for (auto anc=v->particles_in_const_begin(); anc != v->particles_in_const_end(); ++anc){
624 if (fromDecay(*anc, storage)) return true;
625 }
626#endif
627 return false;
628}
bool fromDecay(const HepMC::ConstGenParticlePtr &p, std::shared_ptr< std::set< int > > &storage) const
Definition FixHepMC.cxx:604
bool isDecayed(const T &p)
Identify if the particle decayed.
bool isHadron(const T &p)
bool isTau(const T &p)

◆ GeVToMeV()

void GenBase::GeVToMeV ( HepMC::GenEvent * evt)
protectedinherited

Scale event energies/momenta by x 1000.

Todo
Add HepMC units awareness and do it differently when HepMC provides this functionality directly (and reference-based FourVector accessors)

Definition at line 58 of file GenBase.cxx.

58 {
59 for (HepMC::GenEvent::particle_iterator p = evt->particles_begin(); p != evt->particles_end(); ++p) {
60 const HepMC::FourVector fv((*p)->momentum().px() * 1000,
61 (*p)->momentum().py() * 1000,
62 (*p)->momentum().pz() * 1000,
63 (*p)->momentum().e() * 1000);
64 (*p)->set_momentum(fv);
65 (*p)->set_generated_mass(1000 * (*p)->generated_mass());
66 }
67}

◆ initialize()

StatusCode GenBase::initialize ( )
overridevirtualinherited

Reimplemented in CopyEventWeight, CountHepMC, DumpMC, EvtInclusiveDecay, FillFilterValues, GenAnalysis, GenFilter, GenModule, HepMCReadFromFile, PrintHijingPars, PrintMC, TestHepMC, and WriteHepMC.

Definition at line 17 of file GenBase.cxx.

17 {
18 ATH_CHECK( m_mcevents_const.initialize() );
20
21 // Get the particle property service
22 ATH_CHECK(m_ppSvc.retrieve());
23 return StatusCode::SUCCESS;
24}
#define ATH_CHECK
Evaluate an expression and check for errors.
std::string m_mcEventKey
StoreGate key for the MC event collection (defaults to GEN_EVENT)
Definition GenBase.h:137
ServiceHandle< IPartPropSvc > m_ppSvc
Handle on the particle property service.
Definition GenBase.h:160

◆ inputHandles()

virtual std::vector< Gaudi::DataHandle * > AthCommonDataStore< AthCommonMsg< Algorithm > >::inputHandles ( ) const
overridevirtualinherited

Return this algorithm's input handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ isNonTransportableInDecayChain()

bool FixHepMC::isNonTransportableInDecayChain ( const HepMC::ConstGenParticlePtr & p) const
private

Definition at line 631 of file FixHepMC.cxx.

631 {
632 auto storage = std::make_shared<std::set<int>>();
633 return !MC::isTransportable(p->pdg_id()) && fromDecay(p, storage);
634}
bool isTransportable(const T &p)

◆ isPID0()

bool FixHepMC::isPID0 ( const HepMC::ConstGenParticlePtr & p) const
private

Definition at line 599 of file FixHepMC.cxx.

599 {
600 return p->pdg_id() == 0;
601}

◆ isSimpleLoop()

bool FixHepMC::isSimpleLoop ( const HepMC::ConstGenParticlePtr & p) const
private

Definition at line 637 of file FixHepMC.cxx.

637 {
638 return (p->production_vertex() == p->end_vertex() && p->end_vertex() != nullptr);
639}

◆ MeVToGeV()

void GenBase::MeVToGeV ( HepMC::GenEvent * evt)
protectedinherited

Scale event energies/momenta by x 1/1000.

Definition at line 68 of file GenBase.cxx.

68 {
69 for (HepMC::GenEvent::particle_iterator p = evt->particles_begin(); p != evt->particles_end(); ++p) {
70 const HepMC::FourVector fv((*p)->momentum().px() / 1000,
71 (*p)->momentum().py() / 1000,
72 (*p)->momentum().pz() / 1000,
73 (*p)->momentum().e() / 1000);
74 (*p)->set_momentum(fv);
75 (*p)->set_generated_mass((*p)->generated_mass() / 1000);
76 }
77}

◆ mmTocm()

void GenBase::mmTocm ( HepMC::GenEvent * evt)
protectedinherited

Scale event lengths by x 1/10.

Definition at line 87 of file GenBase.cxx.

87 {
88 for (HepMC::GenEvent::vertex_iterator vtx = evt->vertices_begin(); vtx != evt->vertices_end(); ++vtx) {
89 const HepMC::FourVector fv((*vtx)->position().x() / 10,
90 (*vtx)->position().y() / 10,
91 (*vtx)->position().z() / 10,
92 (*vtx)->position().t() / 10);
93 (*vtx)->set_position(fv);
94 }
95}

◆ msg()

MsgStream & AthCommonMsg< Algorithm >::msg ( ) const
inlineinherited

Definition at line 24 of file AthCommonMsg.h.

24 {
25 return this->msgStream();
26 }

◆ msgLvl()

bool AthCommonMsg< Algorithm >::msgLvl ( const MSG::Level lvl) const
inlineinherited

Definition at line 30 of file AthCommonMsg.h.

30 {
31 return this->msgLevel(lvl);
32 }

◆ outputHandles()

virtual std::vector< Gaudi::DataHandle * > AthCommonDataStore< AthCommonMsg< Algorithm > >::outputHandles ( ) const
overridevirtualinherited

Return this algorithm's output handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ particleData()

const HepPDT::ParticleData * GenBase::particleData ( int pid) const
inlineinherited

Access an element in the particle data table.

Definition at line 126 of file GenBase.h.

126 {
127 return pdt().particle(HepPDT::ParticleID(std::abs(pid)));
128 }
const HepPDT::ParticleDataTable & pdt() const
Shorter alias to get a particle data table.
Definition GenBase.h:123

◆ particleTable()

const HepPDT::ParticleDataTable & GenBase::particleTable ( ) const
inlineinherited

Get a particle data table.

Definition at line 118 of file GenBase.h.

118 {
119 return *(m_ppSvc->PDT());
120 }

◆ partPropSvc()

const ServiceHandle< IPartPropSvc > GenBase::partPropSvc ( ) const
inlineinherited

Access the particle property service.

Definition at line 113 of file GenBase.h.

113 {
114 return m_ppSvc;
115 }

◆ pdt()

const HepPDT::ParticleDataTable & GenBase::pdt ( ) const
inlineinherited

Shorter alias to get a particle data table.

Definition at line 123 of file GenBase.h.

123{ return particleTable(); }
const HepPDT::ParticleDataTable & particleTable() const
Get a particle data table.
Definition GenBase.h:118

◆ renounce()

std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > AthCommonDataStore< AthCommonMsg< Algorithm > >::renounce ( T & h)
inlineprotectedinherited

Definition at line 380 of file AthCommonDataStore.h.

381 {
382 h.renounce();
384 }
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce(T &h)

◆ renounceArray()

void AthCommonDataStore< AthCommonMsg< Algorithm > >::renounceArray ( SG::VarHandleKeyArray & handlesArray)
inlineprotectedinherited

remove all handles from I/O resolution

Definition at line 364 of file AthCommonDataStore.h.

364 {
366 }

◆ sysInitialize()

StatusCode AthAlgorithm::sysInitialize ( )
overridevirtualinherited

Override sysInitialize.

Override sysInitialize from the base class.

Loop through all output handles, and if they're WriteCondHandles, automatically register them and this Algorithm with the CondSvc

Scan through all outputHandles, and if they're WriteCondHandles, register them with the CondSvc

Reimplemented from AthCommonDataStore< AthCommonMsg< Algorithm > >.

Reimplemented in AthAnalysisAlgorithm, AthFilterAlgorithm, AthHistogramAlgorithm, and PyAthena::Alg.

Definition at line 66 of file AthAlgorithm.cxx.

66 {
68
69 if (sc.isFailure()) {
70 return sc;
71 }
72 ServiceHandle<ICondSvc> cs("CondSvc",name());
73 for (auto h : outputHandles()) {
74 if (h->isCondition() && h->mode() == Gaudi::DataHandle::Writer) {
75 // do this inside the loop so we don't create the CondSvc until needed
76 if ( cs.retrieve().isFailure() ) {
77 ATH_MSG_WARNING("no CondSvc found: won't autoreg WriteCondHandles");
78 return StatusCode::SUCCESS;
79 }
80 if (cs->regHandle(this,*h).isFailure()) {
81 sc = StatusCode::FAILURE;
82 ATH_MSG_ERROR("unable to register WriteCondHandle " << h->fullKey()
83 << " with CondSvc");
84 }
85 }
86 }
87 return sc;
88}
static Double_t sc
virtual StatusCode sysInitialize() override
Override sysInitialize.
AthCommonDataStore(const std::string &name, T... args)
virtual std::vector< Gaudi::DataHandle * > outputHandles() const override
::StatusCode StatusCode
StatusCode definition for legacy code.

◆ sysStart()

virtual StatusCode AthCommonDataStore< AthCommonMsg< Algorithm > >::sysStart ( )
overridevirtualinherited

Handle START transition.

We override this in order to make sure that conditions handle keys can cache a pointer to the conditions container.

◆ updateVHKA()

void AthCommonDataStore< AthCommonMsg< Algorithm > >::updateVHKA ( Gaudi::Details::PropertyBase & )
inlineinherited

Definition at line 308 of file AthCommonDataStore.h.

308 {
309 // debug() << "updateVHKA for property " << p.name() << " " << p.toString()
310 // << " size: " << m_vhka.size() << endmsg;
311 for (auto &a : m_vhka) {
313 for (auto k : keys) {
314 k->setOwner(this);
315 }
316 }
317 }
std::vector< SG::VarHandleKeyArray * > m_vhka

Member Data Documentation

◆ m_cleanDecays

bool FixHepMC::m_cleanDecays
private

Definition at line 53 of file FixHepMC.h.

◆ m_decayCleaned

long FixHepMC::m_decayCleaned
private

Definition at line 65 of file FixHepMC.h.

◆ m_detStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< Algorithm > >::m_detStore
privateinherited

Pointer to StoreGate (detector store by default)

Definition at line 393 of file AthCommonDataStore.h.

◆ m_evtStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< Algorithm > >::m_evtStore
privateinherited

Pointer to StoreGate (event store by default)

Definition at line 390 of file AthCommonDataStore.h.

◆ m_extendedExtraObjects

DataObjIDColl AthAlgorithm::m_extendedExtraObjects
privateinherited

Definition at line 79 of file AthAlgorithm.h.

◆ m_forced_length

std::string FixHepMC::m_forced_length {""}
private

Definition at line 57 of file FixHepMC.h.

57{""}; // Force length unit for the event

◆ m_forced_momentum

std::string FixHepMC::m_forced_momentum {""}
private

Definition at line 56 of file FixHepMC.h.

56{""}; // Force momentum unit for the event

◆ m_ignoreSemiDisconnected

bool FixHepMC::m_ignoreSemiDisconnected
private

Definition at line 55 of file FixHepMC.h.

◆ m_killLoops

bool FixHepMC::m_killLoops
private

Definition at line 51 of file FixHepMC.h.

◆ m_killPDG0

bool FixHepMC::m_killPDG0
private

Definition at line 52 of file FixHepMC.h.

◆ m_looper

MC::Loops<HepMC::GenEvent,HepMC::ConstGenParticlePtr,HepMC::ConstGenVertexPtr> FixHepMC::m_looper
private

member to detect loops

Definition at line 75 of file FixHepMC.h.

◆ m_loopKilled

long FixHepMC::m_loopKilled
private

Definition at line 63 of file FixHepMC.h.

◆ m_mcEventKey

std::string GenBase::m_mcEventKey {}
protectedinherited

StoreGate key for the MC event collection (defaults to GEN_EVENT)

Definition at line 137 of file GenBase.h.

137{};

◆ m_mcevents_const

SG::ReadHandleKey<McEventCollection> GenBase::m_mcevents_const { this, "McEventKey", "GEN_EVENT", "StoreGate key of the MC event collection" }
privateinherited

Const handle to the MC event collection.

Definition at line 163 of file GenBase.h.

163{ this, "McEventKey", "GEN_EVENT", "StoreGate key of the MC event collection" };

◆ m_mkMcEvent

BooleanProperty GenBase::m_mkMcEvent {this, "MakeMcEvent", false, "Create a new MC event collection if it doesn't exist"}
protectedinherited

Flag to determine if a new MC event collection should be made if it doesn't exist.

Definition at line 139 of file GenBase.h.

139{this, "MakeMcEvent", false, "Create a new MC event collection if it doesn't exist"};

◆ m_pdg0Killed

long FixHepMC::m_pdg0Killed
private

Definition at line 64 of file FixHepMC.h.

◆ m_pidmap

std::map<int,int> FixHepMC::m_pidmap
private

map of pids to change.

Definition at line 71 of file FixHepMC.h.

◆ m_ppSvc

ServiceHandle<IPartPropSvc> GenBase::m_ppSvc {this, "PartPropSvc", "PartPropSvc"}
privateinherited

Handle on the particle property service.

Definition at line 160 of file GenBase.h.

160{this, "PartPropSvc", "PartPropSvc"};

◆ m_purgeUnstableWithoutEndVtx

bool FixHepMC::m_purgeUnstableWithoutEndVtx
private

Definition at line 54 of file FixHepMC.h.

◆ m_replacedpid_counts

std::map<int,int> FixHepMC::m_replacedpid_counts
private

map of counters of replacements.

Definition at line 72 of file FixHepMC.h.

◆ m_replacedPIDs

long FixHepMC::m_replacedPIDs
private

Definition at line 68 of file FixHepMC.h.

◆ m_totalSeen

long FixHepMC::m_totalSeen
private

Definition at line 67 of file FixHepMC.h.

◆ m_unitsFix

bool FixHepMC::m_unitsFix
private

Definition at line 58 of file FixHepMC.h.

◆ m_unstablePurged

long FixHepMC::m_unstablePurged
private

Definition at line 66 of file FixHepMC.h.

◆ m_varHandleArraysDeclared

bool AthCommonDataStore< AthCommonMsg< Algorithm > >::m_varHandleArraysDeclared
privateinherited

Definition at line 399 of file AthCommonDataStore.h.

◆ m_vhka

std::vector<SG::VarHandleKeyArray*> AthCommonDataStore< AthCommonMsg< Algorithm > >::m_vhka
privateinherited

Definition at line 398 of file AthCommonDataStore.h.


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