ATLAS Offline Software
Loading...
Searching...
No Matches
iFatras::TransportTool Class Reference

Fatras AlgTool to create a ISFParticle at a volume entry/exit. More...

#include <TransportTool.h>

Inheritance diagram for iFatras::TransportTool:
Collaboration diagram for iFatras::TransportTool:

Public Member Functions

 TransportTool (const std::string &, const std::string &, const IInterface *)
 Constructor.
virtual ~TransportTool ()
 Destructor.
virtual StatusCode initialize () override
 AlgTool initialize method.
virtual StatusCode finalize () override
 AlgTool finalize method.
virtual ISF::ISFParticleprocess (const ISF::ISFParticle &isp, CLHEP::HepRandomEngine *) const override
 Creates a new ParticleState from a given ParticleState, universal transport tool.

Private Member Functions

template<class T>
StatusCode retrieveTool (ToolHandle< T > &thandle)
 templated Tool retrieval - gives unique handling & look and feel

Private Attributes

ServiceHandle< IAtRndmGenSvcm_rndGenSvc
 Random Generator service.
CLHEP::HepRandomEngine * m_randomEngine
std::string m_randomEngineName
 Name of the random number stream.
bool m_validationOutput
 Validation output with histogram service.
ToolHandle< IPhysicsValidationToolm_validationTool
 the ntuple
ToolHandle< IParticleDecayHelperm_particleDecayHelper
 Particle Decay.
ToolHandle< ISimHitCreatorm_simHitCreatorID
 The SimHit Creation.
ToolHandle< ISimHitCreatorm_simHitCreatorMS
ToolHandle< Trk::ITimedExtrapolatorm_extrapolator
 The Extrapolator setup.
ToolHandle< ISF::IParticleFilterm_trackFilter
 Filtering setup & other ISF stuff.
ToolHandle< ISF::IParticleFilterm_neutralHadronFilter
ToolHandle< ISF::IParticleFilterm_photonFilter
ToolHandle< ISF::IParticleHelperm_iparticleHelper
ToolHandle< IProcessSamplingToolm_samplingTool
Trk::PdgToParticleHypothesis m_pdgToParticleHypothesis
bool m_errorPropagation
bool m_hitsOff

Detailed Description

Fatras AlgTool to create a ISFParticle at a volume entry/exit.

  • universal transport tool
Author
Sharka Todorova Sarka.Todorova -at- cern.ch
Andreas.Salzburger -at- cern.ch

Definition at line 54 of file ISF_Fatras/ISF_FatrasTools/src/TransportTool.h.

Constructor & Destructor Documentation

◆ TransportTool()

iFatras::TransportTool::TransportTool ( const std::string & t,
const std::string & n,
const IInterface * p )

Constructor.

Definition at line 43 of file ISF_Fatras/ISF_FatrasTools/src/TransportTool.cxx.

46 : base_class(t,n,p),
47 m_rndGenSvc("AtDSFMTGenSvc", n),
48 m_randomEngine(nullptr),
49 m_randomEngineName("FatrasRnd"),
50 m_validationOutput(false),
56 m_trackFilter(""),
61 m_errorPropagation(false),
62 m_hitsOff(false)
63{
64 // validation output section
65 declareProperty( "ValidationOutput", m_validationOutput );
66 declareProperty( "PhysicsValidationTool", m_validationTool );
67 // tool handle for the particle decayer
68 declareProperty( "ParticleDecayHelper", m_particleDecayHelper );
69 // tool handle for the track creator
70 declareProperty( "SimHitCreatorID", m_simHitCreatorID );
71 declareProperty( "SimHitCreatorMS", m_simHitCreatorMS );
72 // tool handles for extrapolator(s)
73 declareProperty( "Extrapolator", m_extrapolator );
74 // tool handles for the filtering setup
75 declareProperty( "TrackFilter", m_trackFilter );
76 declareProperty( "NeutralFilter", m_neutralHadronFilter );
77 declareProperty( "PhotonFilter", m_photonFilter );
78 // tool handles ISF Framework
79 declareProperty( "ParticleHelper", m_iparticleHelper );
80 declareProperty( "TurnOffHitCreation", m_hitsOff );
81 declareProperty( "ProcessSamplingTool", m_samplingTool );
82 declareProperty("DoErrorPropagation", m_errorPropagation );
83 // service handles
84 declareProperty( "RandomNumberService", m_rndGenSvc );
85}
ToolHandle< ISimHitCreator > m_simHitCreatorID
The SimHit Creation.
ToolHandle< ISF::IParticleFilter > m_trackFilter
Filtering setup & other ISF stuff.
ToolHandle< IProcessSamplingTool > m_samplingTool
bool m_validationOutput
Validation output with histogram service.
ToolHandle< ISF::IParticleFilter > m_neutralHadronFilter
ToolHandle< ISF::IParticleFilter > m_photonFilter
ToolHandle< IPhysicsValidationTool > m_validationTool
the ntuple
ToolHandle< IParticleDecayHelper > m_particleDecayHelper
Particle Decay.
std::string m_randomEngineName
Name of the random number stream.
ServiceHandle< IAtRndmGenSvc > m_rndGenSvc
Random Generator service.
ToolHandle< ISF::IParticleHelper > m_iparticleHelper
ToolHandle< Trk::ITimedExtrapolator > m_extrapolator
The Extrapolator setup.

◆ ~TransportTool()

iFatras::TransportTool::~TransportTool ( )
virtual

Destructor.

Definition at line 91 of file ISF_Fatras/ISF_FatrasTools/src/TransportTool.cxx.

92{
93 delete m_randomEngine;
94}

Member Function Documentation

◆ finalize()

StatusCode iFatras::TransportTool::finalize ( )
overridevirtual

AlgTool finalize method.

Definition at line 145 of file ISF_Fatras/ISF_FatrasTools/src/TransportTool.cxx.

146{
147 ATH_MSG_DEBUG( "finalize() successful" );
148 return StatusCode::SUCCESS;
149}
#define ATH_MSG_DEBUG(x)

◆ initialize()

StatusCode iFatras::TransportTool::initialize ( )
overridevirtual

AlgTool initialize method.

Definition at line 101 of file ISF_Fatras/ISF_FatrasTools/src/TransportTool.cxx.

102{
103
104 ATH_MSG_DEBUG( "initialize()" );
105
106 // Retrieve the tools one by one
108 return StatusCode::FAILURE;
110 return StatusCode::FAILURE;
112 return StatusCode::FAILURE;
114 return StatusCode::FAILURE;
116 return StatusCode::FAILURE;
118 return StatusCode::FAILURE;
120 return StatusCode::FAILURE;
122 return StatusCode::FAILURE;
124 return StatusCode::FAILURE;
125 ATH_CHECK( m_validationTool.retrieve( DisableTool{ m_validationTool.empty() || !m_validationOutput } ) );
126
127 if ( m_rndGenSvc.retrieve().isFailure() ){
128 ATH_MSG_FATAL( "Could not retrieve " << m_rndGenSvc );
129 return StatusCode::FAILURE;
130 }
131 //Get own engine with own seeds:
133 if (!m_randomEngine) {
134 ATH_MSG_FATAL( "Could not get random engine '" << m_randomEngineName << "'" );
135 return StatusCode::FAILURE;
136 }
137 ATH_MSG_DEBUG( "finalize() successful" );
138 return StatusCode::SUCCESS;
139}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_FATAL(x)
StatusCode retrieveTool(ToolHandle< T > &thandle)
templated Tool retrieval - gives unique handling & look and feel

◆ process()

ISF::ISFParticle * iFatras::TransportTool::process ( const ISF::ISFParticle & isp,
CLHEP::HepRandomEngine *  ) const
overridevirtual

Creates a new ParticleState from a given ParticleState, universal transport tool.

Definition at line 155 of file ISF_Fatras/ISF_FatrasTools/src/TransportTool.cxx.

156{
157 // copy the current particle onto the particle clipboard
159
160 // if process/generation not set, assume primary
161 //if (m_validationOutput && !isp.getUserInformation()) {
162 // ISF::ParticleUserInformation* validInfo = new ISF::ParticleUserInformation();
163 // validInfo->setProcess(0);
164 // validInfo->setGeneration(0);
165 // isp.setUserInformation(validInfo);
166 //}
167
168 ATH_MSG_VERBOSE ("[ fatras transport ] processing particle "<<isp.pdgCode() );
169
170 std::vector<Trk::HitInfo>* hitVector = nullptr; // hit or no hit collection
171
172 int absPdg = abs(isp.pdgCode());
173 bool photon = (absPdg == 22);
174 bool geantino = (absPdg == 999);
175 bool neutrino = (absPdg == 12) || (absPdg == 14) || (absPdg == 16);
176 bool charged = photon || geantino ? false : (isp.charge()*isp.charge() > 0) ;
177
178 // particle Hypothesis for the extrapolation
179
180 Trk::ParticleHypothesis pHypothesis = m_pdgToParticleHypothesis.convert(isp.pdgCode(),isp.charge());
181
182 // geantinos not handled by PdgToParticleHypothesis - fix there
183 if ( absPdg == 999 ) pHypothesis = Trk::geantino;
184
185 // chose the filter & extrapolator
186 const Trk::ITimedExtrapolator* processor = &(*m_extrapolator);
187 const ISF::IParticleFilter* filter = nullptr;
188
189 if ( photon ) {
190 ATH_MSG_VERBOSE( "[ fatras transport ] Photon - use transport tool for photons");
191 filter = m_photonFilter.empty() ? nullptr : &(*m_photonFilter);
192 } else if ( neutrino ) {
193 ATH_MSG_VERBOSE( "[ fatras transport ] Particle is neutrino -> particle ignored.");
194 return nullptr;
195 } else if ( !charged ){
196 ATH_MSG_VERBOSE( "[ fatras transport ] Particle not charged - use transport tool for neutrals");
197 filter = m_neutralHadronFilter.empty() ? nullptr : &(*m_neutralHadronFilter);
198 } else {
199 ATH_MSG_VERBOSE( "[ fatras transport ] Particle is a lepton or charged hadron");
200 filter = m_trackFilter.empty() ? nullptr : &(*m_trackFilter);
201 }
202
203 if (filter)
204 ATH_MSG_DEBUG( "[ fatras transport ] Determined processor and filter.");
205 else
206 ATH_MSG_DEBUG( "[ fatras transport ] Determined processor w/o filter.");
207
208 // now transport the particle - if it passes the filter
209 if ( !processor || ( filter && !filter->passFilter(isp)) ) {
210 ATH_MSG_VERBOSE( "[ fatras transport ] Filter not passed, ignore particle.");
211 return nullptr;
212 }
213
214 ATH_MSG_VERBOSE( "[ fatras transport ] The StackParticle passed filter - starting transport.");
215 // input parameters : curvilinear parameters
216 Trk::CurvilinearParameters inputPar(isp.position(),isp.momentum(),isp.charge());
217
218 // stable vs. unstable check
219 double freepath = ( !m_particleDecayHelper.empty()) ? m_particleDecayHelper->freePath(isp) : - 1.;
220 ATH_MSG_VERBOSE( "[ fatras transport ] Particle free path : " << freepath);
221 // path limit -> time limit ( TODO : extract life-time directly from decay helper )
222 double tDec = freepath > 0. ? freepath : -1.;
223 int decayProc = 0;
224
225 // beta calculated here for further use in validation
226 double mass = Trk::ParticleMasses::mass[pHypothesis];
227 double mom = isp.momentum().mag();
228 double beta = mom/sqrt(mom*mom+mass*mass);
229
230 if ( tDec>0.) {
231 tDec = tDec/beta/CLHEP::c_light + isp.timeStamp();
232 decayProc = 201;
233 }
234
235 Trk::TimeLimit timeLim(tDec,isp.timeStamp(),decayProc);
236
237 // prompt decay
238 if ( freepath>0. && freepath<0.01 ) {
239 if (!m_particleDecayHelper.empty()) {
240 ATH_MSG_VERBOSE( "[ fatras transport ] Decay is triggered for input particle.");
241 m_particleDecayHelper->decay(isp,isp.position(),isp.momentum(),isp.timeStamp()); // Registers TruthIncident internally
242 }
243
244 // validation mode - for all particle registered into stack
245 if ( m_validationOutput && m_validationTool.isEnabled() ) {
246 int endProcess = decayProc;
247 m_validationTool->saveISFParticleInfo(isp,endProcess,&inputPar,timeLim.time,0.);
248 }
249
250 return nullptr;
251 }
252
253 // presample interactions if not done already
254 Trk::PathLimit pathLim(-1.,0);
255 const ISF::MaterialPathInfo* matLimit = isp.getUserInformation() ? isp.getUserInformation()->materialLimit() : nullptr;
256 if (matLimit) {
257 pathLim=Trk::PathLimit( matLimit->dMax,matLimit->process);
258 pathLim.updateMat(matLimit->dCollected,13.,0.); // arbitrary Z choice : update MaterialPathInfo
259 } else if (absPdg!=999 && pHypothesis<99) { // need to resample
260 pathLim = m_samplingTool->sampleProcess(m_randomEngine, isp.momentum().mag(),isp.charge(),pHypothesis);
261 }
262
263 // use extrapolation with path limit - automatic exit at subdetector boundary
264 // additional exercise due to the current mismatch in geoID
265 Trk::GeometrySignature nextGeoID=static_cast<Trk::GeometrySignature>(isp.nextGeoID());
266
267 std::unique_ptr<const Trk::TrackParameters> eParameters = nullptr;
268
269 // hit creation/energy deposit
270 hitVector = (!m_hitsOff) ? new std::vector<Trk::HitInfo> : nullptr;
271 if (hitVector) ATH_MSG_VERBOSE( "[ fatras transport ] hit creation activated");
272
273 if ( !charged ) {
274
275 eParameters = processor->transportNeutralsWithPathLimit(inputPar,
276 pathLim,
277 timeLim,
279 pHypothesis,
280 hitVector,
281 nextGeoID);
282
283 } else {
284
286 // input covariance matrix
287 AmgSymMatrix(5) inputCov;
288 inputCov.setZero();
289 std::unique_ptr<Trk::TrackParameters> measuredInputPar =
290 inputPar.associatedSurface()
291 .createUniqueTrackParameters(inputPar.parameters()[0],
292 inputPar.parameters()[1],
293 inputPar.parameters()[2],
294 inputPar.parameters()[3],
295 inputPar.parameters()[4],
296 std::move(inputCov));
297
298 eParameters = processor->extrapolateWithPathLimit(*measuredInputPar,
299 pathLim,
300 timeLim,
301 Trk::alongMomentum,
302 pHypothesis,
303 hitVector,
304 nextGeoID);
305
306 } else {
307
308 eParameters = processor->extrapolateWithPathLimit(inputPar,
309 pathLim,
310 timeLim,
312 pHypothesis,
313 hitVector,
314 nextGeoID);
315 }
316 }
317
318 // create hits
319 if (hitVector && !hitVector->empty()){
320 ATH_MSG_VERBOSE( "[ fatras transport ] processing .");
321 // create the hits from the parameters vector
322 if ( isp.nextGeoID()==AtlasDetDescr::fAtlasID ) {
323 if (!m_simHitCreatorID.empty()) m_simHitCreatorID->createHits(isp, *hitVector);
324 ATH_MSG_VERBOSE( "[ fatras transport ] ID hits processed.");
326 ATH_MSG_WARNING( "[ fatras transport ] hit vector without Geo info");
327 } else if ( isp.nextGeoID()==AtlasDetDescr::fAtlasMS ) {
328 if (!m_simHitCreatorMS.empty()) m_simHitCreatorMS->createHits(isp, *hitVector);
329 ATH_MSG_VERBOSE( "[ fatras transport ] MS hits processed.");
330 }
331 // memory cleanup
332 delete hitVector; hitVector = nullptr;
333 }
334
335 // additional exercise due to the current mismatch in geoID
337 if (nextGeoID<99) {
338 geoID = static_cast<AtlasDetDescr::AtlasRegion>(nextGeoID);
339 }
340
341 // validation mode - for all particle registered into stack
342 if ( m_validationOutput && m_validationTool.isEnabled() ) {
343
344 int dProc = ( timeLim.tMax>0. && timeLim.tMax<=timeLim.time ) ? timeLim.process : 0;
345 int mProc = ( pathLim.x0Max>0. && ( pathLim.x0Max <= pathLim.x0Collected ||
346 (pathLim.process>100 && pathLim.x0Max <= pathLim.l0Collected))) ? pathLim.process : 0;
347 int endProcess = eParameters ? 0 : ( dProc > mProc ? dProc : mProc );
348
349 m_validationTool->saveISFParticleInfo(isp,endProcess,eParameters.get(),timeLim.time,pathLim.x0Collected);
350
351 }
352
353 // create the updated particle at the end of processing step
354 ISF::ISFParticle* uisp = eParameters ? m_iparticleHelper->updatedParticle(isp,
355 eParameters->position(),
356 eParameters->momentum(),
357 timeLim.time-isp.timeStamp()) : nullptr; // update expects time difference
358 // free memory
359 if ( hitVector ) {
360 delete hitVector;
361 }
362
363 if (uisp && m_validationOutput) {
364 // save validation info
365 ISF::ParticleUserInformation* validInfo = new ISF::ParticleUserInformation();
366 validInfo->setProcess(0);
367 if (isp.getUserInformation()) validInfo->setGeneration(isp.getUserInformation()->generation());
368 else validInfo->setGeneration(0); // assume primary parent
369 uisp->setUserInformation(validInfo);
370 }
371
372 // TODO save material ? if (uisp && m_validationOutput) uisp->setX0(pathLim.x0Collected,m_eloss);
373
374 // trigger decay or return to stack
375
376 if (uisp && timeLim.tMax>0. && timeLim.time >=timeLim.tMax ) {
377 if (!m_particleDecayHelper.empty()) {
378 ATH_MSG_VERBOSE( "[ fatras transport ] Decay is triggered for input particle.");
379 m_particleDecayHelper->decay(*uisp,uisp->position(),uisp->momentum(),uisp->timeStamp()); // Registers TruthIncident internally
380 }
381 delete uisp;
382 return nullptr;
383 } else if (uisp) {
384 ATH_MSG_VERBOSE( "[ fatras transport ] Particle transported to detector boundary, return to stack, timing:" << uisp->timeStamp());
385 uisp->setNextGeoID(geoID);
386 return uisp;
387 }
388
389 // nothing to be returned to the stack (and we should not get here at all)
390 return nullptr;
391}
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
#define AmgSymMatrix(dim)
std::vector< FPGATrackSimHit > hitVector
static HEPVis_BooleanProcessor processor
double charge() const
charge of the particle
void setUserInformation(ParticleUserInformation *userInfo)
const ParticleUserInformation * getUserInformation() const
get/set ParticleUserInformation
const Amg::Vector3D & momentum() const
The current momentum vector of the ISFParticle.
void setNextGeoID(AtlasDetDescr::AtlasRegion geoID)
register the next AtlasDetDescr::AtlasRegion
double timeStamp() const
Timestamp of the ISFParticle.
const Amg::Vector3D & position() const
The current position of the ISFParticle.
int pdgCode() const
PDG value.
AtlasDetDescr::AtlasRegion nextGeoID() const
next geoID the particle will be simulated in
static ParticleClipboard & getInstance()
get the singleton instance
void setParticle(const ISF::ISFParticle &p)
save a particle on the clipboard
const MaterialPathInfo * materialLimit() const
AtlasRegion
A simple enum of ATLAS regions and sub-detectors.
Definition AtlasRegion.h:21
constexpr double mass[PARTICLEHYPOTHESES]
the array of masses
@ alongMomentum
CurvilinearParametersT< TrackParametersDim, Charged, PlaneSurface > CurvilinearParameters
ParticleHypothesis
Enumeration for Particle hypothesis respecting the interaction with material.

◆ retrieveTool()

template<class T>
StatusCode iFatras::TransportTool::retrieveTool ( ToolHandle< T > & thandle)
inlineprivate

templated Tool retrieval - gives unique handling & look and feel

Definition at line 76 of file ISF_Fatras/ISF_FatrasTools/src/TransportTool.h.

76 {
77 if (!thandle.empty() && thandle.retrieve().isFailure()){
78 ATH_MSG_FATAL( "[ fatras setup ] Cannot retrieve " << thandle << ". Abort.");
79 return StatusCode::FAILURE;
80 }
81 else {
82 ATH_MSG_DEBUG("[ fatras setup ] Successfully retrieved " << thandle);
83 }
84 return StatusCode::SUCCESS;
85 }

Member Data Documentation

◆ m_errorPropagation

bool iFatras::TransportTool::m_errorPropagation
private

◆ m_extrapolator

ToolHandle<Trk::ITimedExtrapolator> iFatras::TransportTool::m_extrapolator
private

The Extrapolator setup.

Definition at line 109 of file ISF_Fatras/ISF_FatrasTools/src/TransportTool.h.

◆ m_hitsOff

bool iFatras::TransportTool::m_hitsOff
private

◆ m_iparticleHelper

ToolHandle<ISF::IParticleHelper> iFatras::TransportTool::m_iparticleHelper
private

◆ m_neutralHadronFilter

ToolHandle<ISF::IParticleFilter> iFatras::TransportTool::m_neutralHadronFilter
private

◆ m_particleDecayHelper

ToolHandle<IParticleDecayHelper> iFatras::TransportTool::m_particleDecayHelper
private

Particle Decay.

Definition at line 102 of file ISF_Fatras/ISF_FatrasTools/src/TransportTool.h.

◆ m_pdgToParticleHypothesis

Trk::PdgToParticleHypothesis iFatras::TransportTool::m_pdgToParticleHypothesis
private

◆ m_photonFilter

ToolHandle<ISF::IParticleFilter> iFatras::TransportTool::m_photonFilter
private

◆ m_randomEngine

CLHEP::HepRandomEngine* iFatras::TransportTool::m_randomEngine
private

◆ m_randomEngineName

std::string iFatras::TransportTool::m_randomEngineName
private

Name of the random number stream.

Definition at line 94 of file ISF_Fatras/ISF_FatrasTools/src/TransportTool.h.

◆ m_rndGenSvc

ServiceHandle<IAtRndmGenSvc> iFatras::TransportTool::m_rndGenSvc
private

Random Generator service.

Definition at line 92 of file ISF_Fatras/ISF_FatrasTools/src/TransportTool.h.

◆ m_samplingTool

ToolHandle<IProcessSamplingTool> iFatras::TransportTool::m_samplingTool
private

◆ m_simHitCreatorID

ToolHandle<ISimHitCreator> iFatras::TransportTool::m_simHitCreatorID
private

The SimHit Creation.

Definition at line 105 of file ISF_Fatras/ISF_FatrasTools/src/TransportTool.h.

◆ m_simHitCreatorMS

ToolHandle<ISimHitCreator> iFatras::TransportTool::m_simHitCreatorMS
private

◆ m_trackFilter

ToolHandle<ISF::IParticleFilter> iFatras::TransportTool::m_trackFilter
private

Filtering setup & other ISF stuff.

Definition at line 112 of file ISF_Fatras/ISF_FatrasTools/src/TransportTool.h.

◆ m_validationOutput

bool iFatras::TransportTool::m_validationOutput
private

Validation output with histogram service.

turn validation mode on/off

Definition at line 98 of file ISF_Fatras/ISF_FatrasTools/src/TransportTool.h.

◆ m_validationTool

ToolHandle<IPhysicsValidationTool> iFatras::TransportTool::m_validationTool
private

the ntuple

Definition at line 99 of file ISF_Fatras/ISF_FatrasTools/src/TransportTool.h.


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