Skip to content
Snippets Groups Projects
Commit 1a1fb870 authored by Frank Winklmeier's avatar Frank Winklmeier
Browse files

Merge branch 'SimDocPart4_main' into 'main'

Introduce a common naming scheme for methods and variables related to primary GenParticles

See merge request !71701
parents e9f780f5 c6d5e015
No related branches found
No related tags found
28 merge requests!78241Draft: FPGATrackSim: GenScan code refactor,!78236Draft: Switching Streams https://its.cern.ch/jira/browse/ATR-27417,!78056AFP monitoring: new synchronization and cleaning,!78041AFP monitoring: new synchronization and cleaning,!77990Updating TRT chip masks for L1TRT trigger simulation - ATR-28372,!77733Draft: add new HLT NN JVT, augmented with additional tracking information,!77731Draft: Updates to ZDC reconstruction,!77728Draft: updates to ZDC reconstruction,!77522Draft: sTGC Pad Trigger Emulator,!76725ZdcNtuple: Fix cppcheck warning.,!76611L1CaloFEXByteStream: Fix out-of-bounds array accesses.,!76475Punchthrough AF3 implementation in FastG4,!76474Punchthrough AF3 implementation in FastG4,!75729New implementation of ZDC nonlinear FADC correction.,!75703Draft: Update to HI han config for HLT jets,!75184Draft: Update file heavyions_run.config,!74430Draft: Fixing upper bound for Delayed Jet Triggers,!73963Changing the path of the histograms to "Expert" area,!73875updating ID ART reference plots,!73874AtlasCLHEP_RandomGenerators: Fix cppcheck warnings.,!73449Add muon detectors to DarkJetPEBTLA partial event building,!73343Draft: [TrigEgamma] Add photon ringer chains on bootstrap mechanism,!72336Fixed TRT calibration crash,!72176Draft: Improving L1TopoOnline chain that now gets no-empty plots. Activating it by default,!72012Draft: Separate JiveXMLConfig.py into Config files,!71876Fix MET trigger name in MissingETMonitoring,!71820Draft: Adding new TLA End-Of-Fill (EOF) chains and removing obsolete DIPZ chains,!71701Introduce a common naming scheme for methods and variables related to primary GenParticles
Showing
with 50 additions and 56 deletions
......@@ -63,7 +63,7 @@ G4bool ZDC_G4CalibSD::SimpleHit(const Identifier& id, const std::vector<double>&
unsigned int particleID = 0;
if( m_doPID ) {
AtlasG4EventUserInfo * atlasG4EvtUserInfo = dynamic_cast<AtlasG4EventUserInfo*>(G4RunManager::GetRunManager()->GetCurrentEvent()->GetUserInformation());
if (atlasG4EvtUserInfo) particleID = HepMC::barcode(atlasG4EvtUserInfo->GetCurrentPrimary()); // FIXME Barcode-based
if (atlasG4EvtUserInfo) particleID = HepMC::barcode(atlasG4EvtUserInfo->GetCurrentPrimaryGenParticle()); // FIXME Barcode-based
}
......
......@@ -75,7 +75,7 @@ G4bool LArG4CalibSD::SimpleHit( const LArG4Identifier& a_ident , const std::vect
unsigned int particleID = 0;
if( m_doPID ) {
AtlasG4EventUserInfo * atlasG4EvtUserInfo = dynamic_cast<AtlasG4EventUserInfo*>(G4RunManager::GetRunManager()->GetCurrentEvent()->GetUserInformation());
if (atlasG4EvtUserInfo) particleID = HepMC::barcode(atlasG4EvtUserInfo->GetCurrentPrimary()); // FIXME Barcode-based
if (atlasG4EvtUserInfo) particleID = HepMC::barcode(atlasG4EvtUserInfo->GetCurrentPrimaryGenParticle()); // FIXME Barcode-based
}
// Build the hit from the calculator results.
......
......@@ -43,16 +43,16 @@ public:
* implementations and Sensitive Detectors which record
* CaloCalibrationHits.) TODO Rename
*/
HepMC::ConstGenParticlePtr GetCurrentPrimary() const {return m_currentPrimary;}
HepMC::ConstGenParticlePtr GetCurrentPrimaryGenParticle() const {return m_currentPrimaryGenParticle;}
/**
* @brief set m_currentPrimary, the pointer to the
* @brief set m_currentPrimaryGenParticle, the pointer to the
* HepMC::GenParticle used to create the current
* G4PrimaryParticle. This pointer is updated each time there is a
* new G4PrimaryParticle. Called from
* (AthenaTrackingAction/TrackProcessorUserActionBase)::
* PreUserTrackingAction(...). TODO Rename
*/
void SetCurrentPrimary(HepMC::ConstGenParticlePtr p) {m_currentPrimary=p;}
void SetCurrentPrimaryGenParticle(HepMC::ConstGenParticlePtr p) {m_currentPrimaryGenParticle = p;}
/**
* @brief return a pointer to the GenParticle corresponding to the
......@@ -105,7 +105,7 @@ public:
private:
HepMC::GenEvent *m_theEvent{};
HepMC::ConstGenParticlePtr m_currentPrimary{};
HepMC::ConstGenParticlePtr m_currentPrimaryGenParticle{};
HepMC::GenParticlePtr m_currentlyTraced{};
// These next two variables are used by the CaloCalibrationHit
// recording code as event-level flags They correspond to the Track
......
......@@ -50,17 +50,17 @@ public:
* @brief return a pointer to the GenParticle used to create the
* initial G4PrimaryParticle from which the current G4Track decends.
* Should match the return value of
* ISF::TruthBinding::getPrimaryTruthParticle().
* ISF::TruthBinding::getPrimaryGenParticle().
* TODO Check that this is required.
*/
HepMC::ConstGenParticlePtr GetPrimaryHepMCParticle() const {return m_thePrimaryParticle;}
HepMC::GenParticlePtr GetPrimaryHepMCParticle() {return m_thePrimaryParticle;}
HepMC::ConstGenParticlePtr GetPrimaryGenParticle() const {return m_primaryGenParticle;}
HepMC::GenParticlePtr GetPrimaryGenParticle() {return m_primaryGenParticle;}
/**
* @brief set the pointer to the GenParticle used to create the
* initial G4PrimaryParticle from which the current G4Track decends.
* TODO Check that this is required - if so, ensure it is set consistently.
*/
void SetPrimaryHepMCParticle(HepMC::GenParticlePtr);
void SetPrimaryGenParticle(HepMC::GenParticlePtr);
/**
* @brief return a pointer to the GenParticle corresponding to the
......@@ -107,7 +107,7 @@ public:
virtual void Print() const {}
private:
TrackClassification m_classify;
HepMC::GenParticlePtr m_thePrimaryParticle{};
HepMC::GenParticlePtr m_primaryGenParticle{};
};
#endif // MCTRUTH_VTRACKINFORMATION_H
......@@ -8,9 +8,9 @@ VTrackInformation::VTrackInformation(TrackClassification tc):m_classify(tc)
{
}
void VTrackInformation::SetPrimaryHepMCParticle(HepMC::GenParticlePtr p)
void VTrackInformation::SetPrimaryGenParticle(HepMC::GenParticlePtr p)
{
m_thePrimaryParticle=p;
m_primaryGenParticle = p;
}
bool VTrackInformation::GetReturnedToISF() const
......
/*
Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
*/
#include "AthenaTrackingAction.h"
......@@ -48,7 +48,7 @@ namespace G4UA
// Assign the GenParticle to the AtlasG4EventUserInfo.
AtlasG4EventUserInfo* atlasG4EvtUserInfo = static_cast<AtlasG4EventUserInfo*>
(G4EventManager::GetEventManager()->GetConstCurrentEvent()->GetUserInformation());
if (trackHelper.IsPrimary()) atlasG4EvtUserInfo->SetCurrentPrimary(part);
if (trackHelper.IsPrimary()) atlasG4EvtUserInfo->SetCurrentPrimaryGenParticle(part);
atlasG4EvtUserInfo->SetCurrentlyTraced(part);
}
......
/*
Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
*/
#include "TrackWriteFastSim/NeutronFastSim.h"
......@@ -53,8 +53,8 @@ G4bool NeutronFastSim::ModelTrigger(const G4FastTrack& fastTrack)
// Not a neutron... Pick it up if the primary had eta>6.0
AtlasG4EventUserInfo *atlasG4EvtUserInfo=static_cast<AtlasG4EventUserInfo*>(G4EventManager::GetEventManager()->GetConstCurrentEvent()->GetUserInformation());
HepMC::ConstGenParticlePtr gp = atlasG4EvtUserInfo->GetCurrentPrimary();
if (std::abs(gp->momentum().eta())>m_etaCut && !HepMC::is_simulation_particle(gp)){
HepMC::ConstGenParticlePtr primaryGenParticle = atlasG4EvtUserInfo->GetCurrentPrimaryGenParticle();
if (std::abs(primaryGenParticle->momentum().eta())>m_etaCut && !HepMC::is_simulation_particle(primaryGenParticle)){
return true;
} else {
return false;
......
......@@ -2,10 +2,6 @@
Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
*/
///////////////////////////////////////////////////////////////////
// TruthBinding.h, (c) ATLAS Detector software
///////////////////////////////////////////////////////////////////
#ifndef ISF_EVENT_TRUTHBINDING_H
#define ISF_EVENT_TRUTHBINDING_H
......@@ -51,8 +47,8 @@ namespace ISF {
inline void setTruthParticle(HepMC::GenParticlePtr p);
/** pointer to the primary particle in the simulation truth */
inline HepMC::GenParticlePtr getPrimaryTruthParticle();
inline HepMC::ConstGenParticlePtr getPrimaryTruthParticle() const;
inline HepMC::GenParticlePtr getPrimaryGenParticle();
inline HepMC::ConstGenParticlePtr getPrimaryGenParticle() const;
/** pointer to the simulation truth particle before any regeneration happened (eg. brem) */
inline HepMC::GenParticlePtr getGenerationZeroTruthParticle();
......@@ -64,7 +60,7 @@ namespace ISF {
private:
HepMC::GenParticlePtr m_truthParticle{}; //!< pointer to particle in MC truth
HepMC::GenParticlePtr m_primaryTruthParticle{}; //!< pointer to corresponding primary (generator) particle
HepMC::GenParticlePtr m_primaryGenParticle{}; //!< pointer to corresponding primary (generator) particle
HepMC::GenParticlePtr m_generationZeroTruthParticle{}; //!< pointer to corresponding truth particle before any regenration
};
......
......@@ -8,13 +8,13 @@ namespace ISF {
/** constructor setting all truth particle pointers to the given particle */
TruthBinding::TruthBinding(HepMC::GenParticlePtr allTruthP) :
m_truthParticle(allTruthP),
m_primaryTruthParticle(allTruthP),
m_primaryGenParticle(allTruthP),
m_generationZeroTruthParticle(allTruthP) { }
/** constructor setting all truth particle pointers individually */
TruthBinding::TruthBinding(HepMC::GenParticlePtr truthP, HepMC::GenParticlePtr primaryTruthP, HepMC::GenParticlePtr genZeroTruthP) :
m_truthParticle(truthP),
m_primaryTruthParticle(primaryTruthP),
m_primaryGenParticle(primaryTruthP),
m_generationZeroTruthParticle(genZeroTruthP) { }
/** destructor */
......@@ -40,12 +40,12 @@ namespace ISF {
return false;
}
const auto rhsPrimary = rhs.getPrimaryTruthParticle();
if (m_primaryTruthParticle && rhsPrimary) {
const auto rhsPrimary = rhs.getPrimaryGenParticle();
if (m_primaryGenParticle && rhsPrimary) {
#ifdef HEPMC3
pass &= (m_primaryTruthParticle == rhsPrimary);
pass &= (m_primaryGenParticle == rhsPrimary);
#else
pass &= *m_primaryTruthParticle == *rhsPrimary;
pass &= *m_primaryGenParticle == *rhsPrimary;
#endif
} else {
return false;
......@@ -69,7 +69,7 @@ namespace ISF {
bool TruthBinding::isIdent(const TruthBinding& rhs) const {
bool pass = true;
pass &= m_truthParticle == rhs.getTruthParticle();
pass &= m_primaryTruthParticle == rhs.getPrimaryTruthParticle();
pass &= m_primaryGenParticle == rhs.getPrimaryGenParticle();
pass &= m_generationZeroTruthParticle == rhs.getGenerationZeroTruthParticle();
return pass;
}
......@@ -80,8 +80,8 @@ namespace ISF {
void TruthBinding::setTruthParticle(HepMC::GenParticlePtr p) { m_truthParticle = p; }
/** pointer to the primary particle in the simulation truth */
HepMC::GenParticlePtr TruthBinding::getPrimaryTruthParticle() { return m_primaryTruthParticle; }
HepMC::ConstGenParticlePtr TruthBinding::getPrimaryTruthParticle() const { return m_primaryTruthParticle; }
HepMC::GenParticlePtr TruthBinding::getPrimaryGenParticle() { return m_primaryGenParticle; }
HepMC::ConstGenParticlePtr TruthBinding::getPrimaryGenParticle() const { return m_primaryGenParticle; }
/** pointer to the simulation truth particle before any regeneration (eg. brem) */
HepMC::GenParticlePtr TruthBinding::getGenerationZeroTruthParticle() { return m_generationZeroTruthParticle; }
......@@ -92,7 +92,7 @@ namespace ISF {
// Not const: otherwise it can trigger a thread-safety checker warning
// because the non-const m_primaryTruthParticle escapes.
TruthBinding* TruthBinding::childTruthBinding(HepMC::GenParticlePtr childP) {
return new TruthBinding(childP, m_primaryTruthParticle, childP);
return new TruthBinding(childP, m_primaryGenParticle, childP);
}
} // end ISF namespace
......@@ -192,9 +192,9 @@ HepMC::GenParticlePtr ISF::ISFTruthIncident::updateHepMCTruthParticle( ISF::ISFP
truthBinding->setTruthParticle(hepTruthParticle);
} else {
auto parentTruthBinding = parent ? parent->getTruthBinding() : nullptr;
auto hepPrimaryParticle = parentTruthBinding ? parentTruthBinding->getPrimaryTruthParticle() : nullptr;
auto primaryGenParticle = parentTruthBinding ? parentTruthBinding->getPrimaryGenParticle() : nullptr;
auto hepGenZeroParticle = hepTruthParticle;
truthBinding = new TruthBinding( hepTruthParticle, hepPrimaryParticle, hepGenZeroParticle );
truthBinding = new TruthBinding( hepTruthParticle, primaryGenParticle, hepGenZeroParticle );
particle.setTruthBinding(truthBinding);
}
// At this point the values returned by particle.getParticleLink()
......
......@@ -999,7 +999,7 @@ G4PrimaryParticle* ISF::InputConverter::getG4PrimaryParticle(ISF::ISFParticle& i
return nullptr; //The G4Exception call above should abort the job, but Coverity does not seem to pick this up.
}
HepMC::GenParticlePtr genpart = truthBinding->getTruthParticle();
HepMC::GenParticlePtr primaryGenpart = truthBinding->getPrimaryTruthParticle();
HepMC::GenParticlePtr primaryGenpart = truthBinding->getPrimaryGenParticle();
const G4ParticleDefinition *particleDefinition = this->getG4ParticleDefinition(isp.pdgCode());
......
......@@ -101,9 +101,7 @@ iGeant4::ISFG4Helper::attachTrackInfoToNewG4Track( G4Track& aTrack,
}
TrackInformation *trackInfo = new TrackInformation( nonRegeneratedTruthParticle, &baseIsp );
auto primaryTruthParticle = truthBinding->getPrimaryTruthParticle();
trackInfo->SetPrimaryHepMCParticle( primaryTruthParticle );
trackInfo->SetPrimaryGenParticle( truthBinding->getPrimaryGenParticle() );
trackInfo->SetClassification( classification );
aTrack.SetUserInformation( trackInfo );
......
......@@ -168,11 +168,11 @@ void TrackProcessorUserActionBase::setupPrimary(G4Track& aTrack)
int regenerationNr = ppInfo->GetRegenerationNr();
HepMC::GenParticlePtr primaryTruthParticle = truthBinding->getGenerationZeroTruthParticle();
HepMC::GenParticlePtr primaryGenParticle = truthBinding->getGenerationZeroTruthParticle();
HepMC::GenParticlePtr generationZeroTruthParticle = truthBinding->getGenerationZeroTruthParticle();
HepMC::GenParticlePtr currentlyTracedHepPart = truthBinding->getTruthParticle();
auto classification = classify(primaryTruthParticle,
auto classification = classify(primaryGenParticle,
generationZeroTruthParticle,
currentlyTracedHepPart,
regenerationNr);
......@@ -184,7 +184,7 @@ void TrackProcessorUserActionBase::setupPrimary(G4Track& aTrack)
newTrackInfo->SetRegenerationNr(regenerationNr);
setCurrentParticle(baseISP,
primaryTruthParticle,
primaryGenParticle,
currentlyTracedHepPart);
return;
......@@ -195,36 +195,36 @@ void TrackProcessorUserActionBase::setupSecondary(const G4Track& aTrack)
auto* trackInfo = ::iGeant4::ISFG4Helper::getISFTrackInfo(aTrack);
HepMC::GenParticlePtr currentlyTracedTruthParticle = trackInfo->GetHepMCParticle();
HepMC::GenParticlePtr primaryTruthParticle = trackInfo->GetPrimaryHepMCParticle();
HepMC::GenParticlePtr primaryGenParticle = trackInfo->GetPrimaryGenParticle();
ISF::ISFParticle* baseISFParticle = trackInfo->GetBaseISFParticle();
setCurrentParticle(baseISFParticle, primaryTruthParticle, currentlyTracedTruthParticle);
setCurrentParticle(baseISFParticle, primaryGenParticle, currentlyTracedTruthParticle);
return;
}
void TrackProcessorUserActionBase::setCurrentParticle(ISF::ISFParticle* baseISFParticle,
HepMC::ConstGenParticlePtr truthPrimary,
HepMC::ConstGenParticlePtr primaryGenParticle,
HepMC::GenParticlePtr truthCurrentlyTraced)
{
m_curBaseISP = baseISFParticle;
m_atlasG4EvtUserInfo->SetCurrentPrimary( truthPrimary );
m_atlasG4EvtUserInfo->SetCurrentPrimaryGenParticle( primaryGenParticle );
m_atlasG4EvtUserInfo->SetCurrentlyTraced( truthCurrentlyTraced );
return;
}
/// Classify the particle represented by the given set of truth links
TrackClassification TrackProcessorUserActionBase::classify(HepMC::ConstGenParticlePtr primaryTruthParticle,
TrackClassification TrackProcessorUserActionBase::classify(HepMC::ConstGenParticlePtr primaryGenParticle,
HepMC::ConstGenParticlePtr generationZeroTruthParticle,
HepMC::ConstGenParticlePtr currentlyTracedHepPart,
int regenerationNumber) const
{
// if particle points to a non-zero truth particle it can not just be a 'simple' Secondary
if (currentlyTracedHepPart) {
if (currentlyTracedHepPart==primaryTruthParticle) {
if (currentlyTracedHepPart==primaryGenParticle) {
return Primary;
}
else if (generationZeroTruthParticle==primaryTruthParticle && regenerationNumber>0) {
else if (generationZeroTruthParticle==primaryGenParticle && regenerationNumber>0) {
return RegeneratedPrimary;
}
else {
......
......@@ -64,11 +64,11 @@ private:
/// Set the following information as the currently traced particle
void setCurrentParticle(ISF::ISFParticle* baseISFParticle,
HepMC::ConstGenParticlePtr truthPrimary,
HepMC::ConstGenParticlePtr primaryGenParticle,
HepMC::GenParticlePtr truthCurrentlyTraced);
/// Classify the particle represented by the given set of truth links
TrackClassification classify(HepMC::ConstGenParticlePtr primaryTruthParticle,
TrackClassification classify(HepMC::ConstGenParticlePtr primaryGenParticle,
HepMC::ConstGenParticlePtr generationZeroTruthParticle,
HepMC::ConstGenParticlePtr currentlyTracedHepPart,
int regenerationNumber) const;
......
......@@ -231,10 +231,10 @@ namespace G4UA {
return nullptr; //The G4Exception call above should abort the job, but Coverity does not seem to pick this up.
}
HepMC::GenParticlePtr primaryHepParticle = trackInfo->GetPrimaryHepMCParticle();
HepMC::GenParticlePtr primaryGenParticle = trackInfo->GetPrimaryGenParticle();
HepMC::GenParticlePtr generationZeroHepParticle = trackInfo->GetHepMCParticle();
ISF::TruthBinding* tBinding = new ISF::TruthBinding(truthParticle, primaryHepParticle, generationZeroHepParticle);
ISF::TruthBinding* tBinding = new ISF::TruthBinding(truthParticle, primaryGenParticle, generationZeroHepParticle);
return tBinding;
}
......
......@@ -356,7 +356,7 @@ G4bool TileGeoG4CalibSD::ProcessHits(G4Step* step, G4TouchableHistory* /*ROhist*
int primary_id = 0;
if (m_doCalibHitParticleID) {
if (m_atlasG4EvtUserInfo && m_atlasG4EvtUserInfo->GetCurrentPrimary()) primary_id = HepMC::barcode(m_atlasG4EvtUserInfo->GetCurrentPrimary()); // FIXME Barcode-based
if (m_atlasG4EvtUserInfo && m_atlasG4EvtUserInfo->GetCurrentPrimaryGenParticle()) primary_id = HepMC::barcode(m_atlasG4EvtUserInfo->GetCurrentPrimaryGenParticle()); // FIXME Barcode-based
else throw std::runtime_error("CalibrationSensitiveDetector: Unable to retrieve barcode!");
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment