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

#include <FastCaloSimCaloTransportation.h>

Inheritance diagram for FastCaloSimCaloTransportation:
Collaboration diagram for FastCaloSimCaloTransportation:

Public Member Functions

 FastCaloSimCaloTransportation (const std::string &t, const std::string &n, const IInterface *p)
 ~FastCaloSimCaloTransportation ()=default
virtual StatusCode initialize () override final
virtual StatusCode finalize () override final
virtual std::vector< G4FieldTrack > transport (const TFCSTruthState *truth, bool forceNeutral=false) const override final

Protected Member Functions

std::vector< G4FieldTrack > convertToFieldTrack (const std::vector< Trk::HitInfo > &vec) const

Protected Attributes

PublicToolHandle< Trk::ITimedExtrapolatorm_extrapolator {this, "Extrapolator", "TimedExtrapolator"}
CxxUtils::CachedPointer< const Trk::TrackingVolumem_caloEntrance
StringProperty m_caloEntranceName {this, "CaloEntrance", ""}
Trk::PdgToParticleHypothesis m_pdgToParticleHypothesis

Detailed Description

Definition at line 20 of file FastCaloSimCaloTransportation.h.

Constructor & Destructor Documentation

◆ FastCaloSimCaloTransportation()

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

Definition at line 32 of file FastCaloSimCaloTransportation.cxx.

33 : base_class(t,n,p)
34{
35
36}

◆ ~FastCaloSimCaloTransportation()

FastCaloSimCaloTransportation::~FastCaloSimCaloTransportation ( )
default

Member Function Documentation

◆ convertToFieldTrack()

std::vector< G4FieldTrack > FastCaloSimCaloTransportation::convertToFieldTrack ( const std::vector< Trk::HitInfo > & vec) const
protected

Definition at line 210 of file FastCaloSimCaloTransportation.cxx.

210 {
211
212 std::vector<G4FieldTrack> caloSteps;
213 for (auto& step : vec){
214 G4FieldTrack track = G4FieldTrack(' ');
215 track.SetPosition(Amg::EigenToHep3Vector(step.trackParms->position()));
216 track.SetMomentum(Amg::EigenToHep3Vector(step.trackParms->momentum()));
217 track.SetChargeAndMoments(step.trackParms->charge());
218 caloSteps.push_back(track);
219 }
220
221 return caloSteps;
222
223}
std::vector< size_t > vec
CLHEP::Hep3Vector EigenToHep3Vector(const Amg::Vector3D &eigenvector)
Converts an Eigen-based Amg::Vector3D into a CLHEP-based CLHEP::Hep3Vector.

◆ finalize()

StatusCode FastCaloSimCaloTransportation::finalize ( )
finaloverridevirtual

Definition at line 53 of file FastCaloSimCaloTransportation.cxx.

53 {
54 ATH_MSG_INFO( "Finalizing FastCaloSimCaloTransportation" );
55 return StatusCode::SUCCESS;
56}
#define ATH_MSG_INFO(x)

◆ initialize()

StatusCode FastCaloSimCaloTransportation::initialize ( )
finaloverridevirtual

Definition at line 38 of file FastCaloSimCaloTransportation.cxx.

39{
40 ATH_MSG_INFO( "Initializing FastCaloSimCaloTransportation" );
41
42 // Get TimedExtrapolator
43 if(!m_extrapolator.empty()){
44 ATH_CHECK(m_extrapolator.retrieve());
45 ATH_MSG_INFO("Extrapolator retrieved "<< m_extrapolator);
46 }
47
48 return StatusCode::SUCCESS;
49
50}
#define ATH_CHECK
Evaluate an expression and check for errors.
PublicToolHandle< Trk::ITimedExtrapolator > m_extrapolator

◆ transport()

std::vector< G4FieldTrack > FastCaloSimCaloTransportation::transport ( const TFCSTruthState * truth,
bool forceNeutral = false ) const
finaloverridevirtual

Definition at line 59 of file FastCaloSimCaloTransportation.cxx.

59 {
60 // Start calo extrapolation
61 ATH_MSG_DEBUG ("[ fastCaloSim transport ] processing particle "<<truth->pdgid() );
62
63 auto hitVector = std::make_unique<std::vector<Trk::HitInfo>>();
64
65 int pdgId = truth->pdgid();
66 double charge = HepPDT::ParticleID(pdgId).charge();
67 if (forceNeutral) charge = 0.;
68
69 // particle Hypothesis for the extrapolation
70 Trk::ParticleHypothesis pHypothesis = m_pdgToParticleHypothesis.convert(pdgId, charge);
71
72 ATH_MSG_DEBUG ("particle hypothesis "<< pHypothesis);
73
74 // geantinos not handled by PdgToParticleHypothesis - fix there
75 if (pdgId == 999) pHypothesis = Trk::geantino;
76
77 Amg::Vector3D pos = Amg::Vector3D(truth->vertex().X(), truth->vertex().Y(), truth->vertex().Z());
78
79 Amg::Vector3D mom(truth->X(), truth->Y(), truth->Z());
80
81 ATH_MSG_DEBUG( "[ fastCaloSim transport ] x from position eta="<<pos.eta()<<" phi="<<pos.phi()<<" d="<<pos.mag()<<" pT="<<mom.perp() );
82
83 // input parameters : curvilinear parameters
84 Trk::CurvilinearParameters inputPar(pos,mom,charge);
85
86 double freepath = -1.;
87 double tDec = freepath > 0. ? freepath : -1.;
88 int decayProc = 0;
89
90 Trk::TimeLimit timeLim(tDec, 0., decayProc);
91 Trk::PathLimit pathLim(-1., 0);
93
94 // first extrapolation to reach the ID boundary
95 ATH_MSG_DEBUG( "[ fastCaloSim transport ] before calo entrance ");
96
97 // get CaloEntrance if not done already
98 if(!m_caloEntrance.get()){
99 m_caloEntrance.set(m_extrapolator->trackingGeometry()->trackingVolume(m_caloEntranceName));
100 if(!m_caloEntrance.get())
101 ATH_MSG_WARNING("CaloEntrance not found");
102 else
103 ATH_MSG_DEBUG("CaloEntrance found");
104 }
105
106 ATH_MSG_DEBUG( "[ fastCaloSim transport ] after calo entrance ");
107
108 std::unique_ptr<const Trk::TrackParameters> caloEntry = nullptr;
109
110 if(m_caloEntrance.get() && m_caloEntrance.get()->inside(pos, 0.001) && !m_extrapolator->trackingGeometry()->atVolumeBoundary(pos,m_caloEntrance.get(), 0.001)){
111 std::vector<Trk::HitInfo>* dummyHitVector = nullptr;
112 if (charge == 0){
113 caloEntry =
114 m_extrapolator->transportNeutralsWithPathLimit(inputPar,
115 pathLim,
116 timeLim,
118 pHypothesis,
119 dummyHitVector,
120 nextGeoID,
121 m_caloEntrance.get());
122 }else{
123 caloEntry = m_extrapolator->extrapolateWithPathLimit(inputPar,
124 pathLim,
125 timeLim,
127 pHypothesis,
128 dummyHitVector,
129 nextGeoID,
130 m_caloEntrance.get());
131 }
132 } else
133 caloEntry = inputPar.uniqueClone();
134
135 ATH_MSG_DEBUG( "[ fastCaloSim transport ] after calo caloEntry ");
136
137 if(caloEntry){
138 std::unique_ptr<const Trk::TrackParameters> eParameters = nullptr;
139
140 // save Calo entry hit (fallback info)
141 hitVector->push_back(Trk::HitInfo(caloEntry->uniqueClone(), timeLim.time, nextGeoID, 0.));
142
144 "[ fastCaloSim transport ] starting Calo transport from position eta="
145 << caloEntry->position().eta() << " phi=" << caloEntry->position().phi()
146 << " d=" << caloEntry->position().mag());
147
148 std::vector<Trk::HitInfo>* rawHitVector = hitVector.get();
149 if (charge == 0){
150 eParameters =
151 m_extrapolator->transportNeutralsWithPathLimit(*caloEntry,
152 pathLim,
153 timeLim,
155 pHypothesis,
156 rawHitVector,
157 nextGeoID);
158 }else{
159 eParameters =
160 m_extrapolator->extrapolateWithPathLimit(*caloEntry,
161 pathLim,
162 timeLim,
164 pHypothesis,
165 rawHitVector,
166 nextGeoID);
167 }
168 // save Calo exit hit (fallback info)
169 if(eParameters) hitVector->push_back(Trk::HitInfo(std::move(eParameters), timeLim.time, nextGeoID, 0.));
170 } //if caloEntry
171
172 //used to identify ID-Calo boundary in tracking tools
173 int IDCaloBoundary = 3000;
174
175 if(msgLvl(MSG::DEBUG)){
176 std::vector<Trk::HitInfo>::iterator it = hitVector->begin();
177 while (it < hitVector->end()){
178 int sample=(*it).detID;
179 Amg::Vector3D hitPos = (*it).trackParms->position();
180 ATH_MSG_DEBUG(" HIT: layer="<<sample<<" sample="<<sample-IDCaloBoundary<<" eta="<<hitPos.eta()<<" phi="<<hitPos.phi()<<" d="<<hitPos.mag());
181 ++it;
182 }
183 }
184
185 std::vector<Trk::HitInfo>::iterator it2 = hitVector->begin();
186 while(it2 < hitVector->end()){
187 int sample=(*it2).detID;
188 Amg::Vector3D hitPos = (*it2).trackParms->position();
189 ATH_MSG_DEBUG(" HIT: layer="<<sample<<" sample="<<sample-IDCaloBoundary<<" eta="<<hitPos.eta()<<" phi="<<hitPos.phi()<<" r="<<hitPos.perp()<<" z="<<hitPos[Amg::z]);
190 ++it2;
191 }
192
193 // Extrapolation may fail for very low pT charged particles. Enforce charge 0 to prevent this
194 if (!forceNeutral && hitVector->empty()){
195 ATH_MSG_DEBUG("forcing neutral charge in FastCaloSimCaloTransportation::caloHits");
196 transport(truth, true);
197 }
198 // Don't expect this ever to happen. Nevertheless, error handling should be improved.
199 // This may require changes in periphery (adjustments after setting function type to StatusCode)
200 else if(hitVector->empty()) ATH_MSG_ERROR("Empty hitVector even after forcing neutral charge. This may cause a segfault soon.");
201
202
203 std::vector<G4FieldTrack> caloSteps = convertToFieldTrack(*hitVector);
204
205 return caloSteps;
206
207}
#define ATH_MSG_ERROR(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
double charge(const T &p)
Definition AtlasPID.h:997
std::vector< FPGATrackSimHit > hitVector
virtual std::vector< G4FieldTrack > transport(const TFCSTruthState *truth, bool forceNeutral=false) const override final
Trk::PdgToParticleHypothesis m_pdgToParticleHypothesis
CxxUtils::CachedPointer< const Trk::TrackingVolume > m_caloEntrance
std::vector< G4FieldTrack > convertToFieldTrack(const std::vector< Trk::HitInfo > &vec) const
int pdgid() const
const TLorentzVector & vertex() const
Eigen::Matrix< double, 3, 1 > Vector3D
@ alongMomentum
CurvilinearParametersT< TrackParametersDim, Charged, PlaneSurface > CurvilinearParameters
ParticleHypothesis
Enumeration for Particle hypothesis respecting the interaction with material.

Member Data Documentation

◆ m_caloEntrance

CxxUtils::CachedPointer<const Trk::TrackingVolume> FastCaloSimCaloTransportation::m_caloEntrance
protected

Definition at line 40 of file FastCaloSimCaloTransportation.h.

◆ m_caloEntranceName

StringProperty FastCaloSimCaloTransportation::m_caloEntranceName {this, "CaloEntrance", ""}
protected

Definition at line 41 of file FastCaloSimCaloTransportation.h.

41{this, "CaloEntrance", ""};

◆ m_extrapolator

PublicToolHandle<Trk::ITimedExtrapolator> FastCaloSimCaloTransportation::m_extrapolator {this, "Extrapolator", "TimedExtrapolator"}
protected

Definition at line 38 of file FastCaloSimCaloTransportation.h.

38{this, "Extrapolator", "TimedExtrapolator"};

◆ m_pdgToParticleHypothesis

Trk::PdgToParticleHypothesis FastCaloSimCaloTransportation::m_pdgToParticleHypothesis
protected

Definition at line 42 of file FastCaloSimCaloTransportation.h.


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