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

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