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 31 of file FastCaloSimCaloTransportation.cxx.

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

◆ ~FastCaloSimCaloTransportation()

FastCaloSimCaloTransportation::~FastCaloSimCaloTransportation ( )
default

Member Function Documentation

◆ convertToFieldTrack()

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

Definition at line 213 of file FastCaloSimCaloTransportation.cxx.

213 {
214
215 std::vector<G4FieldTrack> caloSteps;
216 for (auto& step : vec){
217 G4FieldTrack track = G4FieldTrack(' ');
218 track.SetPosition(Amg::EigenToHep3Vector(step.trackParms->position()));
219 track.SetMomentum(Amg::EigenToHep3Vector(step.trackParms->momentum()));
220 track.SetChargeAndMoments(step.trackParms->charge());
221 caloSteps.push_back(track);
222 }
223
224 return caloSteps;
225
226}
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 52 of file FastCaloSimCaloTransportation.cxx.

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

◆ initialize()

StatusCode FastCaloSimCaloTransportation::initialize ( )
finaloverridevirtual

Definition at line 37 of file FastCaloSimCaloTransportation.cxx.

38{
39 ATH_MSG_INFO( "Initializing FastCaloSimCaloTransportation" );
40
41 // Get TimedExtrapolator
42 if(!m_extrapolator.empty()){
43 ATH_CHECK(m_extrapolator.retrieve());
44 ATH_MSG_INFO("Extrapolator retrieved "<< m_extrapolator);
45 }
46
47 return StatusCode::SUCCESS;
48
49}
#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 58 of file FastCaloSimCaloTransportation.cxx.

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