ATLAS Offline Software
Loading...
Searching...
No Matches
ISF::FastCaloSimV2Tool Class Reference

#include <FastCaloSimV2Tool.h>

Inheritance diagram for ISF::FastCaloSimV2Tool:
Collaboration diagram for ISF::FastCaloSimV2Tool:

Public Member Functions

 FastCaloSimV2Tool (const std::string &type, const std::string &name, const IInterface *parent)
 Constructor with parameters.
virtual ~FastCaloSimV2Tool ()=default
 Destructor.
virtual StatusCode initialize () override final
 Athena algorithm's interface methods.
virtual StatusCode simulate (const EventContext &ctx, ISFParticle &isp, ISFParticleContainer &, McEventCollection *mcEventCollection) override final
 Simulation Call.
virtual StatusCode setupEvent (const EventContext &) override final
 Setup Event chain - in case of a begin-of event action is needed.
virtual StatusCode setupEventST () override final
 Setup Event chain - in case of a begin-of event action is needed (called by ISimulationSvc)
virtual StatusCode releaseEvent (const EventContext &) override final
 Release Event chain - in case of an end-of event action is needed.
virtual StatusCode releaseEventST () override final
 Release Event chain - in case of an end-of event action is needed (called by ISimulationSvc)
virtual SimulationFlavor simFlavor () const override final
virtual StatusCode sysInitialize () override
 Gaudi sysInitialize() methods.
virtual StatusCode simulateVector (const EventContext &ctx, const ISFParticleVector &particles, ISFParticleContainer &secondaries, McEventCollection *mcEventCollection, McEventCollection *) override
 Simulation call for vectors of particles.
const ChronoEntity * chronoStart (const IChronoSvc::ChronoTag &tag)
 wrapper call to start chrono with given tag
const ChronoEntity * chronoStop (const IChronoSvc::ChronoTag &tag)
 wrapper call to stop chrono with given tag

Protected Attributes

ServiceHandle< IChronoStatSvc > m_chrono {this, "ChronoStatService", "ChronoStatSvc"}
 The timing service for general usage.

Private Member Functions

StatusCode commonSetup (const EventContext &ctx)

Private Attributes

ServiceHandle< IFastCaloSimParamSvcm_paramSvc {this, "ParamSvc", "ISF_FastCaloSimV2ParamSvc"}
bool m_doPunchThrough {true}
ToolHandle< IPunchThroughToolm_punchThroughTool {this, "PunchThroughTool", ""}
PublicToolHandleArray< ICaloCellMakerToolm_caloCellMakerToolsSetup {this, "CaloCellMakerTools_setup", {}, ""}
PublicToolHandleArray< ICaloCellMakerToolm_caloCellMakerToolsRelease {this, "CaloCellMakerTools_release", {}, ""}
PublicToolHandle< IFastCaloSimCaloExtrapolationm_FastCaloSimCaloExtrapolation {this, "FastCaloSimCaloExtrapolation", "", ""}
std::unique_ptr< CaloCellContainerm_theContainer {}
CaloCellContainerm_theContainerPtr {}
SG::WriteHandleKey< CaloCellContainerm_caloCellKey { this, "CaloCells", "DefaultCaloCellContainer", "The name of the output CaloCellContainer" }
ServiceHandle< IAthRNGSvcm_rndmGenSvc {this, "RandomSvc", "AthRNGSvc", ""}
Gaudi::Property< std::string > m_randomEngineName {this, "RandomStream", ""}
Gaudi::Property< std::string > m_caloCellsOutputName {this, "CaloCellsOutputName", "AllCalo"}
ServiceHandle< ISF::ITruthSvcm_truthRecordSvc {this,"ParticleTruthSvc", "ISF_TruthRecordSvc", "ISF Particle Truth Svc"}

Detailed Description

Author
Elmar.Ritsch -at- cern.ch, Geraldine.Conti -at- cern.ch, Flavia.Dias -at- cern.ch

Definition at line 42 of file FastCaloSimV2Tool.h.

Constructor & Destructor Documentation

◆ FastCaloSimV2Tool()

ISF::FastCaloSimV2Tool::FastCaloSimV2Tool ( const std::string & type,
const std::string & name,
const IInterface * parent )

Constructor with parameters.

Constructor.

Definition at line 46 of file FastCaloSimV2Tool.cxx.

47 : BaseSimulatorTool(type, name, parent)
48{
49}
BaseSimulatorTool()
Default constructor.

◆ ~FastCaloSimV2Tool()

virtual ISF::FastCaloSimV2Tool::~FastCaloSimV2Tool ( )
virtualdefault

Destructor.

Member Function Documentation

◆ chronoStart()

const ChronoEntity * ISF::BaseSimulatorTool::chronoStart ( const IChronoSvc::ChronoTag & tag)
inlineinherited

wrapper call to start chrono with given tag

Definition at line 98 of file BaseSimulatorTool.h.

98 {
99 if (m_chrono) return m_chrono->chronoStart( tag);
100 return nullptr;
101 }
ServiceHandle< IChronoStatSvc > m_chrono
The timing service for general usage.

◆ chronoStop()

const ChronoEntity * ISF::BaseSimulatorTool::chronoStop ( const IChronoSvc::ChronoTag & tag)
inlineinherited

wrapper call to stop chrono with given tag

Definition at line 104 of file BaseSimulatorTool.h.

104 {
105 if (m_chrono) return m_chrono->chronoStop( tag);
106 return nullptr;
107 }

◆ commonSetup()

StatusCode ISF::FastCaloSimV2Tool::commonSetup ( const EventContext & ctx)
private

Definition at line 103 of file FastCaloSimV2Tool.cxx.

104{
105 // Set the RNGs to use for this event. We need to reset it for MT jobs
106 // because of the mismatch between Gaudi slot-local and G4 thread-local RNG.
107 ATHRNG::RNGWrapper* rngWrapper = m_rndmGenSvc->getEngine(this, m_randomEngineName);
108 rngWrapper->setSeed( m_randomEngineName, ctx );
109
110 for (const ToolHandle<ICaloCellMakerTool>& tool : m_caloCellMakerToolsSetup)
111 {
112 std::string chronoName=this->name()+"_"+ tool.name();
113 if (m_chrono) m_chrono->chronoStart(chronoName);
114 StatusCode sc = tool->process(m_theContainerPtr, ctx);
115 if (m_chrono) {
116 m_chrono->chronoStop(chronoName);
117 ATH_MSG_DEBUG( "Chrono stop : delta " << m_chrono->chronoDelta (chronoName,IChronoStatSvc::USER) * CLHEP::microsecond / CLHEP::second << " second " );
118 }
119
120 if (sc.isFailure())
121 {
122 ATH_MSG_ERROR( "Error executing tool " << tool.name() );
123 return StatusCode::FAILURE;
124 }
125 }
126
127 return StatusCode::SUCCESS;
128}
#define ATH_MSG_ERROR(x)
#define ATH_MSG_DEBUG(x)
static Double_t sc
void setSeed(const std::string &algName, const EventContext &ctx)
Set the random seed using a string (e.g.
Definition RNGWrapper.h:169
CaloCellContainer * m_theContainerPtr
Gaudi::Property< std::string > m_randomEngineName
PublicToolHandleArray< ICaloCellMakerTool > m_caloCellMakerToolsSetup
ServiceHandle< IAthRNGSvc > m_rndmGenSvc
::StatusCode StatusCode
StatusCode definition for legacy code.

◆ initialize()

StatusCode ISF::FastCaloSimV2Tool::initialize ( )
finaloverridevirtual

Athena algorithm's interface methods.

framework methods

Reimplemented from ISF::BaseSimulatorTool.

Definition at line 52 of file FastCaloSimV2Tool.cxx.

53{
55
57 ATH_MSG_DEBUG( "Successfully retrieve CaloCellMakerTools: " << m_caloCellMakerToolsSetup );
59
60 ATH_CHECK(m_rndmGenSvc.retrieve());
61
62 ATH_CHECK(m_paramSvc.retrieve());
63
64 // m_paramSvc->setLevel(MSG::VERBOSE);
65
67 if (m_doPunchThrough) {
68 ATH_CHECK(m_punchThroughTool.retrieve());
69 }
70
71 ATH_CHECK(m_truthRecordSvc.retrieve());
72
73 // Get FastCaloSimCaloExtrapolation
75
76 // Output data handle
77 ATH_CHECK( m_caloCellKey.initialize() );
78
79 return StatusCode::SUCCESS;
80}
#define ATH_CHECK
Evaluate an expression and check for errors.
virtual StatusCode initialize() override
SG::WriteHandleKey< CaloCellContainer > m_caloCellKey
PublicToolHandle< IFastCaloSimCaloExtrapolation > m_FastCaloSimCaloExtrapolation
ToolHandle< IPunchThroughTool > m_punchThroughTool
ServiceHandle< IFastCaloSimParamSvc > m_paramSvc
ServiceHandle< ISF::ITruthSvc > m_truthRecordSvc
PublicToolHandleArray< ICaloCellMakerTool > m_caloCellMakerToolsRelease

◆ releaseEvent()

StatusCode ISF::FastCaloSimV2Tool::releaseEvent ( const EventContext & ctx)
finaloverridevirtual

Release Event chain - in case of an end-of event action is needed.

Reimplemented from ISF::BaseSimulatorTool.

Definition at line 130 of file FastCaloSimV2Tool.cxx.

131{
132 ATH_MSG_VERBOSE( "FastCaloSimV2Tool " << name() << " releaseEvent() " );
133 // Run the version of releaseEvent that returns the output collection
134 // Run the normal method
135 ATH_CHECK(this->releaseEventST());
136 if ( m_theContainer ) {
137
138 // Record with WriteHandle
139 SG::WriteHandle< CaloCellContainer > caloCellHandle( m_caloCellKey, ctx );
140 ATH_CHECK( caloCellHandle.record( std::move( m_theContainer ) ) );
141 return StatusCode::SUCCESS;
142 }
143 return StatusCode::FAILURE;
144}
#define ATH_MSG_VERBOSE(x)
virtual StatusCode releaseEventST() override final
Release Event chain - in case of an end-of event action is needed (called by ISimulationSvc)
std::unique_ptr< CaloCellContainer > m_theContainer

◆ releaseEventST()

StatusCode ISF::FastCaloSimV2Tool::releaseEventST ( )
finaloverridevirtual

Release Event chain - in case of an end-of event action is needed (called by ISimulationSvc)

Reimplemented from ISF::BaseSimulatorTool.

Definition at line 146 of file FastCaloSimV2Tool.cxx.

147{
148 ATH_MSG_VERBOSE("release Event");
149 const EventContext& ctx = Gaudi::Hive::currentContext();
150
151 //run release tools in a loop
152 for (const ToolHandle<ICaloCellMakerTool>& tool : m_caloCellMakerToolsRelease)
153 {
154 ATH_MSG_VERBOSE( "Calling tool " << tool.name() );
155
156 ATH_CHECK(tool->process(m_theContainerPtr, ctx));
157 }
158
159 return StatusCode::SUCCESS;
160
161}

◆ setupEvent()

StatusCode ISF::FastCaloSimV2Tool::setupEvent ( const EventContext & ctx)
finaloverridevirtual

Setup Event chain - in case of a begin-of event action is needed.

Reimplemented from ISF::BaseSimulatorTool.

Definition at line 94 of file FastCaloSimV2Tool.cxx.

95{
96 ATH_MSG_DEBUG ("setupEvent");
97
98 m_theContainer = std::make_unique<CaloCellContainer>(SG::VIEW_ELEMENTS);
100 return this->commonSetup(ctx);
101}
StatusCode commonSetup(const EventContext &ctx)
@ VIEW_ELEMENTS
this data object is a view, it does not own its elmts

◆ setupEventST()

StatusCode ISF::FastCaloSimV2Tool::setupEventST ( )
finaloverridevirtual

Setup Event chain - in case of a begin-of event action is needed (called by ISimulationSvc)

Reimplemented from ISF::BaseSimulatorTool.

Definition at line 82 of file FastCaloSimV2Tool.cxx.

83{
84 ATH_MSG_DEBUG ("setupEventST");
85
86 m_theContainer = std::make_unique<CaloCellContainer>(SG::VIEW_ELEMENTS);
88 ATH_CHECK(evtStore()->record(std::move(m_theContainer), m_caloCellsOutputName));
89 // NB: m_theContainer is now nullptr
90 const EventContext& ctx = Gaudi::Hive::currentContext();
91 return this->commonSetup(ctx);
92}
Gaudi::Property< std::string > m_caloCellsOutputName

◆ simFlavor()

virtual SimulationFlavor ISF::FastCaloSimV2Tool::simFlavor ( ) const
inlinefinaloverridevirtual

Definition at line 68 of file FastCaloSimV2Tool.h.

68{ return ISF::FastCaloSimV2; };
@ FastCaloSimV2

◆ simulate()

StatusCode ISF::FastCaloSimV2Tool::simulate ( const EventContext & ctx,
ISF::ISFParticle & isfp,
ISFParticleContainer & secondaries,
McEventCollection * mcEventCollection )
finaloverridevirtual

Simulation Call.

for anti protons and anti neutrons the kinetic energy should be calculated as Ekin = E() + M() instead of E() - M() this is achieved by setting an Ekin offset of 2*M() to the truth state

Reimplemented from ISF::BaseSimulatorTool.

Definition at line 164 of file FastCaloSimV2Tool.cxx.

165{
166
167 ATH_MSG_VERBOSE("NEW PARTICLE! FastCaloSimV2Tool called with ISFParticle: " << isfp);
168
169 Amg::Vector3D particle_position = isfp.position();
170 Amg::Vector3D particle_direction(isfp.momentum().x(),isfp.momentum().y(),isfp.momentum().z());
171
172 ATHRNG::RNGWrapper* rngWrapper = m_rndmGenSvc->getEngine(this, m_randomEngineName);
173
174 //Don't simulate particles with total energy below 10 MeV
175 if(isfp.ekin() < 10) {
176 ATH_MSG_VERBOSE("Skipping particle with Ekin: " << isfp.ekin() <<" MeV. Below the 10 MeV threshold.");
177 return StatusCode::SUCCESS;
178 }
179
180 TFCSTruthState truth;
181 truth.SetPtEtaPhiM(particle_direction.perp(), particle_direction.eta(), particle_direction.phi(), isfp.mass());
182 truth.set_pdgid(isfp.pdgCode());
183 truth.set_vertex(particle_position[Amg::x], particle_position[Amg::y], particle_position[Amg::z]);
184
188 if(isfp.pdgCode() == -2212 || isfp.pdgCode() == -2112) {
189 truth.set_Ekin_off(2*isfp.mass());
190 ATH_MSG_VERBOSE("Found anti-proton/neutron, setting Ekin offset in TFCSTruthState.");
191 }
192
193 TFCSExtrapolationState extrapol;
194 m_FastCaloSimCaloExtrapolation->extrapolate(extrapol, &truth);
195
196 ATH_MSG_DEBUG(" particle: " << isfp.pdgCode() << " Ekin: " << isfp.ekin() << " position eta: " << particle_position.eta() << " direction eta: " << particle_direction.eta() << " position phi: " << particle_position.phi() << " direction phi: " << particle_direction.phi());
197
198 //only simulate if extrapolation to calo surface succeeded
199 if(extrapol.IDCaloBoundary_eta() != -999){
200 CLHEP::HepRandomEngine *rndmEngine = rngWrapper->getEngine(ctx);
201 TFCSSimulationState simulstate(rndmEngine);
202
203 // ATH_MSG_WARNING("Event number for this event: " << ctx.evt());
204 simulstate.setAuxInfo<int>("EventNr"_FCShash, ctx.evt() );
205
206 ATH_CHECK(m_paramSvc->simulate(simulstate, &truth, &extrapol));
207
208 ATH_MSG_DEBUG("Energy returned: " << simulstate.E());
209 ATH_MSG_VERBOSE("Energy fraction for layer: ");
210 for (int s = 0; s < CaloCell_ID_FCS::MaxSample; s++)
211 ATH_MSG_VERBOSE(" Sampling " << s << " energy " << simulstate.E(s));
212
213 //Now deposit all cell energies into the CaloCellContainer
214 for(const auto& iter : simulstate.cells()) {
215 CaloCell* theCell = (CaloCell*)m_theContainerPtr->findCell(iter.first->calo_hash());
216 theCell->addEnergy(iter.second);
217 }
218
219 //now perform punch through
220 if (m_doPunchThrough) {
221 int process = 201;
222 // call punch-through simulation
223 const ISF::ISFParticleVector *someSecondaries = m_punchThroughTool->computePunchThroughParticles(isfp, simulstate, rndmEngine);
224
225 if (someSecondaries && !someSecondaries->empty()) {
226 //Record truth incident for created punch through particles
227 ISF::ISFTruthIncident truth( const_cast<ISF::ISFParticle&>(isfp),
228 *someSecondaries,
229 process,
230 isfp.nextGeoID(), // inherits from the parent
232
233 m_truthRecordSvc->registerTruthIncident( truth, true );
234 // At this point we need to update the properties of the
235 // ISFParticles produced in the interaction
236 truth.updateChildParticleProperties();
237
238 for (auto *secondary : *someSecondaries) {
239 if (secondary->getTruthBinding()) {
240 secondaries.push_back(secondary);
241 }
242 else {
243 ATH_MSG_WARNING("Secondary particle created by PunchThroughTool not written out to truth.\n Parent (" << isfp << ")\n Secondary (" << *secondary <<")");
244 delete secondary;
245 }
246 }
247 delete someSecondaries;
248 }
249 }
250 simulstate.DoAuxInfoCleanup();
251 }
252 else ATH_MSG_DEBUG("Skipping simulation as extrapolation to ID-Calo boundary failed.");
253
254
255 return StatusCode::SUCCESS;
256
257}
#define ATH_MSG_WARNING(x)
CLHEP::HepRandomEngine * getEngine(const EventContext &ctx) const
Retrieve the random engine corresponding to the provided EventContext.
Definition RNGWrapper.h:134
void addEnergy(float energy)
add energy
Definition CaloCell.h:449
double ekin() const
Kinetic energy.
const Amg::Vector3D & momentum() const
The current momentum vector of the ISFParticle.
const Amg::Vector3D & position() const
The current position of the ISFParticle.
int pdgCode() const
PDG value.
double mass() const
mass of the particle
AtlasDetDescr::AtlasRegion nextGeoID() const
next geoID the particle will be simulated in
void set_pdgid(int val)
void set_vertex(const TLorentzVector &val)
void set_Ekin_off(double val)
const std::string process
Eigen::Matrix< double, 3, 1 > Vector3D
@ fKillsPrimary
std::vector< ISF::ISFParticle * > ISFParticleVector
ISFParticle vector.

◆ simulateVector()

virtual StatusCode ISF::BaseSimulatorTool::simulateVector ( const EventContext & ctx,
const ISFParticleVector & particles,
ISFParticleContainer & secondaries,
McEventCollection * mcEventCollection,
McEventCollection *  )
inlineoverridevirtualinherited

Simulation call for vectors of particles.

Reimplemented in ISF::ActsFatrasSimTool, ISF::BaseSimulatorG4Tool, and ISF::ParticleKillerSimTool.

Definition at line 75 of file BaseSimulatorTool.h.

76 {
77 // this implementation is a wrapper in case the simulator does
78 // implement particle-vector input
79
80 // simulate each particle individually
81 for (auto* cisp : particles) {
82 ATH_MSG_VERBOSE( "Starting simulation of particle: " << (*cisp) );
83 ATH_CHECK(this->simulate(ctx, *cisp, secondaries, mcEventCollection));
84 }
85 return StatusCode::SUCCESS;
86
87 }
virtual StatusCode simulate(const EventContext &, ISFParticle &, ISFParticleContainer &, McEventCollection *) override

◆ sysInitialize()

virtual StatusCode ISF::BaseSimulatorTool::sysInitialize ( )
inlineoverridevirtualinherited

Gaudi sysInitialize() methods.

Definition at line 49 of file BaseSimulatorTool.h.

50 {
52 ATH_CHECK( m_chrono.retrieve() );
53 return StatusCode::SUCCESS;
54 }
virtual StatusCode sysInitialize() override

Member Data Documentation

◆ m_caloCellKey

SG::WriteHandleKey< CaloCellContainer > ISF::FastCaloSimV2Tool::m_caloCellKey { this, "CaloCells", "DefaultCaloCellContainer", "The name of the output CaloCellContainer" }
private

Definition at line 82 of file FastCaloSimV2Tool.h.

82{ this, "CaloCells", "DefaultCaloCellContainer", "The name of the output CaloCellContainer" };

◆ m_caloCellMakerToolsRelease

PublicToolHandleArray<ICaloCellMakerTool> ISF::FastCaloSimV2Tool::m_caloCellMakerToolsRelease {this, "CaloCellMakerTools_release", {}, ""}
private

Definition at line 76 of file FastCaloSimV2Tool.h.

76{this, "CaloCellMakerTools_release", {}, ""};

◆ m_caloCellMakerToolsSetup

PublicToolHandleArray<ICaloCellMakerTool> ISF::FastCaloSimV2Tool::m_caloCellMakerToolsSetup {this, "CaloCellMakerTools_setup", {}, ""}
private

Definition at line 75 of file FastCaloSimV2Tool.h.

75{this, "CaloCellMakerTools_setup", {}, ""};

◆ m_caloCellsOutputName

Gaudi::Property<std::string> ISF::FastCaloSimV2Tool::m_caloCellsOutputName {this, "CaloCellsOutputName", "AllCalo"}
private

Definition at line 86 of file FastCaloSimV2Tool.h.

86{this, "CaloCellsOutputName", "AllCalo"};

◆ m_chrono

ServiceHandle<IChronoStatSvc> ISF::BaseSimulatorTool::m_chrono {this, "ChronoStatService", "ChronoStatSvc"}
protectedinherited

The timing service for general usage.

Definition at line 115 of file BaseSimulatorTool.h.

115{this, "ChronoStatService", "ChronoStatSvc"};

◆ m_doPunchThrough

bool ISF::FastCaloSimV2Tool::m_doPunchThrough {true}
private

Definition at line 73 of file FastCaloSimV2Tool.h.

73{true};

◆ m_FastCaloSimCaloExtrapolation

PublicToolHandle<IFastCaloSimCaloExtrapolation> ISF::FastCaloSimV2Tool::m_FastCaloSimCaloExtrapolation {this, "FastCaloSimCaloExtrapolation", "", ""}
private

Definition at line 78 of file FastCaloSimV2Tool.h.

78{this, "FastCaloSimCaloExtrapolation", "", ""};

◆ m_paramSvc

ServiceHandle<IFastCaloSimParamSvc> ISF::FastCaloSimV2Tool::m_paramSvc {this, "ParamSvc", "ISF_FastCaloSimV2ParamSvc"}
private

Definition at line 72 of file FastCaloSimV2Tool.h.

72{this, "ParamSvc", "ISF_FastCaloSimV2ParamSvc"};

◆ m_punchThroughTool

ToolHandle< IPunchThroughTool > ISF::FastCaloSimV2Tool::m_punchThroughTool {this, "PunchThroughTool", ""}
private

Definition at line 74 of file FastCaloSimV2Tool.h.

74{this, "PunchThroughTool", ""};

◆ m_randomEngineName

Gaudi::Property<std::string> ISF::FastCaloSimV2Tool::m_randomEngineName {this, "RandomStream", ""}
private

Definition at line 85 of file FastCaloSimV2Tool.h.

85{this, "RandomStream", ""};

◆ m_rndmGenSvc

ServiceHandle<IAthRNGSvc> ISF::FastCaloSimV2Tool::m_rndmGenSvc {this, "RandomSvc", "AthRNGSvc", ""}
private

Definition at line 84 of file FastCaloSimV2Tool.h.

84{this, "RandomSvc", "AthRNGSvc", ""};

◆ m_theContainer

std::unique_ptr<CaloCellContainer> ISF::FastCaloSimV2Tool::m_theContainer {}
private

Definition at line 80 of file FastCaloSimV2Tool.h.

80{};

◆ m_theContainerPtr

CaloCellContainer* ISF::FastCaloSimV2Tool::m_theContainerPtr {}
private

Definition at line 81 of file FastCaloSimV2Tool.h.

81{};

◆ m_truthRecordSvc

ServiceHandle<ISF::ITruthSvc> ISF::FastCaloSimV2Tool::m_truthRecordSvc {this,"ParticleTruthSvc", "ISF_TruthRecordSvc", "ISF Particle Truth Svc"}
private

Definition at line 87 of file FastCaloSimV2Tool.h.

87{this,"ParticleTruthSvc", "ISF_TruthRecordSvc", "ISF Particle Truth Svc"};

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