ATLAS Offline Software
Loading...
Searching...
No Matches
TrackHandle_TruthTrack::Imp Class Reference
Collaboration diagram for TrackHandle_TruthTrack::Imp:

Public Member Functions

 Imp (TrackHandle_TruthTrack *tc, const SimBarCode &sbc, const SimHitList &shl, HepMC::ConstGenParticlePtr p)
void ensureInitAscObjs ()
void ensureInitTrkTracks ()
void createTrack (Trk::TrackStates *trackStateOnSurfaces)

Static Public Member Functions

static Trk::PerigeecreateTrkPerigeeFromProdVertex (HepMC::ConstGenParticlePtr p, const double &charge)
static Trk::TrackParameterscreateTrkParamFromDecayVertex (HepMC::ConstGenParticlePtr p, const double &charge)
static Trk::TrackStateOnSurfacecreateTSOS (Trk::TrackParameters *pars)
static void addPars (Trk::TrackStates *dv, Trk::TrackParameters *pars)

Public Attributes

TrackHandle_TruthTracktheclass
SimBarCode simBarCode
SimHitList simHitList
HepMC::ConstGenParticlePtr genParticle
bool ascObjVis
std::vector< AscObj_TruthPoint * > * ascObjs
const Trk::TracktrkTrack

Detailed Description

Definition at line 28 of file TrackHandle_TruthTrack.cxx.

Constructor & Destructor Documentation

◆ Imp()

TrackHandle_TruthTrack::Imp::Imp ( TrackHandle_TruthTrack * tc,
const SimBarCode & sbc,
const SimHitList & shl,
HepMC::ConstGenParticlePtr p )
inline

Definition at line 30 of file TrackHandle_TruthTrack.cxx.

32 : theclass(tc),
33 simBarCode(sbc),
34 simHitList(shl),
35 genParticle(p),
36 ascObjVis(false),
37 ascObjs(nullptr),
38 trkTrack(nullptr) {}
static Double_t tc
std::vector< AscObj_TruthPoint * > * ascObjs
TrackHandle_TruthTrack * theclass
HepMC::ConstGenParticlePtr genParticle

Member Function Documentation

◆ addPars()

void TrackHandle_TruthTrack::Imp::addPars ( Trk::TrackStates * dv,
Trk::TrackParameters * pars )
inlinestatic

Definition at line 92 of file TrackHandle_TruthTrack.cxx.

93 {
94 if (!pars)
95 return;
96 Trk::TrackStateOnSurface * tsos = createTSOS(pars);
97 if (tsos)
98 dv->push_back(tsos);
99 }
static Trk::TrackStateOnSurface * createTSOS(Trk::TrackParameters *pars)

◆ createTrack()

void TrackHandle_TruthTrack::Imp::createTrack ( Trk::TrackStates * trackStateOnSurfaces)
inline

Definition at line 101 of file TrackHandle_TruthTrack.cxx.

102 {
103 if (!trackStateOnSurfaces) {
104 VP1Msg::messageDebug("TrackHandle_TruthTrack WARNING: Could not create track due to null TSOS vector");
105 return;
106 }
107 if (trackStateOnSurfaces->empty()) {
108 VP1Msg::messageDebug("TrackHandle_TruthTrack WARNING: Could not create track due to empty TSOS vector");
109 delete trackStateOnSurfaces;
110 return;
111 }
112 if (trkTrack) {
113 VP1Msg::messageDebug("TrackHandle_TruthTrack ERROR: Already create trkTrack previously!");
114 delete trackStateOnSurfaces;
115 return;
116 }
117
118 Trk::TrackInfo ti(Trk::TrackInfo::Unknown,theclass->extrapolationParticleHypothesis());
119 std::unique_ptr<Trk::TrackStates> sink(trackStateOnSurfaces);
120 trkTrack = new Trk::Track(ti,
121 std::move(sink),
122 nullptr /*fitquality*/);
123
124 }
bool empty() const noexcept
Returns true if the collection is empty.
static void messageDebug(const QString &)
Definition VP1Msg.cxx:39

◆ createTrkParamFromDecayVertex()

Trk::TrackParameters * TrackHandle_TruthTrack::Imp::createTrkParamFromDecayVertex ( HepMC::ConstGenParticlePtr p,
const double & charge )
inlinestatic

Definition at line 65 of file TrackHandle_TruthTrack.cxx.

66 {
67 if (!p)
68 return nullptr;//Fixme: message!
69 HepMC::ConstGenVertexPtr v = p->end_vertex();
70 if (!v)
71 return nullptr;//Fixme: message!
72 Amg::Vector3D mom(p->momentum().px(),p->momentum().py(),p->momentum().pz());
73// double absmom(mom.mag());
74// if (absmom<=0)
75// return 0;//Fixme: message!
76 Amg::Vector3D pos(v->position().x(),v->position().y(),v->position().z());
77
78 Amg::Translation3D amgtranslation(pos.x(),pos.y(),pos.z());
79 Amg::Transform3D amgTransf(amgtranslation * Amg::RotationMatrix3D::Identity());
80
81 return new Trk::AtaPlane(pos,mom,charge, *(new Trk::PlaneSurface(amgTransf)));
82 }
double charge() const
Eigen::Affine3d Transform3D
Eigen::Matrix< double, 3, 1 > Vector3D
Eigen::Translation< double, 3 > Translation3D
const HepMC::GenVertex * ConstGenVertexPtr
Definition GenVertex.h:60
ParametersT< TrackParametersDim, Charged, PlaneSurface > AtaPlane

◆ createTrkPerigeeFromProdVertex()

Trk::Perigee * TrackHandle_TruthTrack::Imp::createTrkPerigeeFromProdVertex ( HepMC::ConstGenParticlePtr p,
const double & charge )
inlinestatic

Definition at line 50 of file TrackHandle_TruthTrack.cxx.

51 {
52 if (!p)
53 return nullptr;//Fixme: message!
54 HepMC::ConstGenVertexPtr v = p->production_vertex();
55 if (!v)
56 return nullptr;//Fixme: message!
57 Amg::Vector3D mom(p->momentum().px(),p->momentum().py(),p->momentum().pz());
58 double absmom(mom.mag());
59 if (absmom<=0)
60 return nullptr;//Fixme: message!
61 Amg::Vector3D pos(v->position().x(),v->position().y(),v->position().z());
62 return new Trk::Perigee(0.,0.,mom.phi(), mom.theta(), charge/absmom, pos);
63 }
ParametersT< TrackParametersDim, Charged, PerigeeSurface > Perigee

◆ createTSOS()

Trk::TrackStateOnSurface * TrackHandle_TruthTrack::Imp::createTSOS ( Trk::TrackParameters * pars)
inlinestatic

Definition at line 84 of file TrackHandle_TruthTrack.cxx.

85 {
86 return pars ? new Trk::TrackStateOnSurface(
87 nullptr,
88 std::unique_ptr<Trk::TrackParameters>(pars),
89 nullptr)
90 : nullptr;
91 }

◆ ensureInitAscObjs()

void TrackHandle_TruthTrack::Imp::ensureInitAscObjs ( )

Definition at line 307 of file TrackHandle_TruthTrack.cxx.

308{
309 if (ascObjs)
310 return;
311 ascObjs = new std::vector<AscObj_TruthPoint*>;
312 HepMC::ConstGenVertexPtr vprod{nullptr};
313 HepMC::ConstGenVertexPtr vend{nullptr};
314 if (genParticle) {
315 vprod=genParticle->production_vertex();
316 vend=genParticle->end_vertex();
317 }
318 ascObjs->reserve((vprod?1:0)+(vend?1:simHitList.size()));
319 if (vprod)
320 ascObjs->push_back(new AscObj_TruthPoint(theclass,vprod,genParticle));
321
322 if (vend) {
323 ascObjs->push_back(new AscObj_TruthPoint(theclass,vend,genParticle));
324 } else {
325 SimHitList::const_iterator it, itE(simHitList.end());
326 for ( it = simHitList.begin(); it != itE; ++it )
327 ascObjs->push_back(new AscObj_TruthPoint(theclass,it->second));
328 }
329 std::vector<AscObj_TruthPoint*>::iterator it, itE(ascObjs->end());
330 for (it=ascObjs->begin();it!=itE;++it)
331 theclass->registerAssocObject(*it);
332 for (it=ascObjs->begin();it!=itE;++it)
333 (*it)->setVisible(ascObjVis);
334}

◆ ensureInitTrkTracks()

void TrackHandle_TruthTrack::Imp::ensureInitTrkTracks ( )

Definition at line 157 of file TrackHandle_TruthTrack.cxx.

158{
159 if (trkTrack)
160 return;
161
162 //The GenParticle part is used if it is available with a production
163 //vertex. The sim. hits are used if present and the genparticle does
164 //not have an end vertex:
165 bool useGenParticle = genParticle && genParticle->production_vertex();
166 bool decayedGenParticle = useGenParticle && genParticle->end_vertex();
167 bool useSimHits = !decayedGenParticle && !simHitList.empty();
168
169 if (!useGenParticle&&!useSimHits) {
170 VP1Msg::message("TrackHandle_TruthTrack ERROR: Track has neither a genparticle or sim. hits!!");
171 return;
172 }
173
174 if (!theclass->hasCharge()) {
175 VP1Msg::message("TrackHandle_TruthTrack ERROR: Could not determine particle charge (pdg="
176 +QString::number(theclass->pdgCode())+").");//Fixme: I guess we could show non-extrapolated version?
177 return;
178 }
179 const double charge = theclass->charge();
180
181 Trk::TrackStates* trackStateOnSurfaces = new Trk::TrackStates;
182
183 if (useGenParticle) {
185
186 if (decayedGenParticle) {
188 createTrack(trackStateOnSurfaces);
189 return;
190 }
191 }
192
193 if (useSimHits) {
194 //Add parameters from simhits (yes, if !useGenParticle, we get no perigee).
195 SimHitList::const_iterator it, itE(simHitList.end());
196 for ( it = simHitList.begin(); it != itE; ++it ) {
197 //Fixme: momentum() < 0 (i.e. not present);
198 //Fixme: Possibly add points for both posStart() and posEnd() (and use energy loss information to get different momenta?)
199 addPars(trackStateOnSurfaces,it->second->createTrackParameters());
200 }
201
202 }
203
204 createTrack(trackStateOnSurfaces);
205}
static Trk::Perigee * createTrkPerigeeFromProdVertex(HepMC::ConstGenParticlePtr p, const double &charge)
void createTrack(Trk::TrackStates *trackStateOnSurfaces)
static void addPars(Trk::TrackStates *dv, Trk::TrackParameters *pars)
static Trk::TrackParameters * createTrkParamFromDecayVertex(HepMC::ConstGenParticlePtr p, const double &charge)
static void message(const QString &, IVP1System *sys=0)
Definition VP1Msg.cxx:30
DataVector< const Trk::TrackStateOnSurface > TrackStates

Member Data Documentation

◆ ascObjs

std::vector<AscObj_TruthPoint*>* TrackHandle_TruthTrack::Imp::ascObjs

Definition at line 45 of file TrackHandle_TruthTrack.cxx.

◆ ascObjVis

bool TrackHandle_TruthTrack::Imp::ascObjVis

Definition at line 44 of file TrackHandle_TruthTrack.cxx.

◆ genParticle

HepMC::ConstGenParticlePtr TrackHandle_TruthTrack::Imp::genParticle

Definition at line 42 of file TrackHandle_TruthTrack.cxx.

◆ simBarCode

SimBarCode TrackHandle_TruthTrack::Imp::simBarCode

Definition at line 40 of file TrackHandle_TruthTrack.cxx.

◆ simHitList

SimHitList TrackHandle_TruthTrack::Imp::simHitList

Definition at line 41 of file TrackHandle_TruthTrack.cxx.

◆ theclass

TrackHandle_TruthTrack* TrackHandle_TruthTrack::Imp::theclass

Definition at line 39 of file TrackHandle_TruthTrack.cxx.

◆ trkTrack

const Trk::Track* TrackHandle_TruthTrack::Imp::trkTrack

Definition at line 47 of file TrackHandle_TruthTrack.cxx.


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