ATLAS Offline Software
Loading...
Searching...
No Matches
Trk::TruthTrackRecordToTrack Class Referencefinal

TruthTrackRecordToTrack is an AlgTool to create Trk::TrackParameters from a HepMC::GenParticle expressed at a "TrackRecordCollection" anywhere in ATLAS. More...

#include <TruthTrackRecordToTrack.h>

Inheritance diagram for Trk::TruthTrackRecordToTrack:
Collaboration diagram for Trk::TruthTrackRecordToTrack:

Public Member Functions

 TruthTrackRecordToTrack (const std::string &type, const std::string &name, const IInterface *parent)
virtual StatusCode initialize ()
virtual const Trk::TrackParametersmakeProdVertexParameters (HepMC::ConstGenParticlePtr part) const
 This function produces a Trk::TrackParameters object corresponding to the HepMC::GenParticle at the production vertex.
virtual const Trk::TrackParametersmakeProdVertexParameters (const xAOD::TruthParticle *part) const
virtual const Trk::TrackParametersmakePerigeeParameters (HepMC::ConstGenParticlePtr part) const
 This function extrapolates track to the perigee, and returns perigee parameters.
virtual const Trk::TrackParametersmakePerigeeParameters (const xAOD::TruthParticle *part) const
ServiceHandle< StoreGateSvc > & evtStore ()
 The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
const ServiceHandle< StoreGateSvc > & detStore () const
 The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
virtual StatusCode sysInitialize () override
 Perform system initialization for an algorithm.
virtual StatusCode sysStart () override
 Handle START transition.
virtual std::vector< Gaudi::DataHandle * > inputHandles () const override
 Return this algorithm's input handles.
virtual std::vector< Gaudi::DataHandle * > outputHandles () const override
 Return this algorithm's output handles.
Gaudi::Details::PropertyBase & declareProperty (Gaudi::Property< T, V, H > &t)
void updateVHKA (Gaudi::Details::PropertyBase &)
MsgStream & msg () const
bool msgLvl (const MSG::Level lvl) const

Static Public Member Functions

static const InterfaceID & interfaceID ()

Protected Member Functions

void renounceArray (SG::VarHandleKeyArray &handlesArray)
 remove all handles from I/O resolution
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce (T &h)
void extraDeps_update_handler (Gaudi::Details::PropertyBase &ExtraDeps)
 Add StoreName to extra input/output deps as needed.

Private Types

typedef ServiceHandle< StoreGateSvcStoreGateSvc_t

Private Member Functions

 TruthTrackRecordToTrack (const TruthTrackRecordToTrack &)=delete
 Forbid copying of Truth...ToTrack to not mess with the internal pointers.
TruthTrackRecordToTrackoperator= (const TruthTrackRecordToTrack &)=delete
Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
 specialization for handling Gaudi::Property<SG::VarHandleKey>

Private Attributes

ToolHandle< Trk::IExtrapolatorm_extrapolator
SG::ReadHandleKey< TrackRecordCollectionm_reccollkey
StoreGateSvc_t m_evtStore
 Pointer to StoreGate (event store by default)
StoreGateSvc_t m_detStore
 Pointer to StoreGate (detector store by default)
std::vector< SG::VarHandleKeyArray * > m_vhka
bool m_varHandleArraysDeclared

Detailed Description

TruthTrackRecordToTrack is an AlgTool to create Trk::TrackParameters from a HepMC::GenParticle expressed at a "TrackRecordCollection" anywhere in ATLAS.

The purpose is to analyse non-collision particles (therefore uses TrackRecord, not GenParticle's prod vertex) in the reconstructed Track's reference frame. The code stems from old cosmics-testbeam analysis refurbished under the ITruthToTrack interface.

Author
Wolfgang.Liebig -at- cern.ch

Definition at line 37 of file TruthTrackRecordToTrack.h.

Member Typedef Documentation

◆ StoreGateSvc_t

typedef ServiceHandle<StoreGateSvc> AthCommonDataStore< AthCommonMsg< AlgTool > >::StoreGateSvc_t
privateinherited

Definition at line 388 of file AthCommonDataStore.h.

Constructor & Destructor Documentation

◆ TruthTrackRecordToTrack() [1/2]

Trk::TruthTrackRecordToTrack::TruthTrackRecordToTrack ( const std::string & type,
const std::string & name,
const IInterface * parent )

Definition at line 23 of file TruthTrackRecordToTrack.cxx.

25 : AthAlgTool(type,name,parent),
26 m_extrapolator("Trk::Extrapolator/AtlasExtrapolator")
27{
28 declareInterface<ITruthToTrack>(this);
29
30 declareProperty("Extrapolator", m_extrapolator);
31 declareProperty("TrackRecordKey",m_reccollkey="CosmicPerigee");
32}
AthAlgTool()
Default constructor:
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
ToolHandle< Trk::IExtrapolator > m_extrapolator
SG::ReadHandleKey< TrackRecordCollection > m_reccollkey

◆ TruthTrackRecordToTrack() [2/2]

Trk::TruthTrackRecordToTrack::TruthTrackRecordToTrack ( const TruthTrackRecordToTrack & )
privatedelete

Forbid copying of Truth...ToTrack to not mess with the internal pointers.

Member Function Documentation

◆ declareGaudiProperty()

Gaudi::Details::PropertyBase & AthCommonDataStore< AthCommonMsg< AlgTool > >::declareGaudiProperty ( Gaudi::Property< T, V, H > & hndl,
const SG::VarHandleKeyType &  )
inlineprivateinherited

specialization for handling Gaudi::Property<SG::VarHandleKey>

Definition at line 156 of file AthCommonDataStore.h.

158 {
160 hndl.value(),
161 hndl.documentation());
162
163 }

◆ declareProperty()

Gaudi::Details::PropertyBase & AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty ( Gaudi::Property< T, V, H > & t)
inlineinherited

Definition at line 145 of file AthCommonDataStore.h.

145 {
146 typedef typename SG::HandleClassifier<T>::type htype;
148 }
Gaudi::Details::PropertyBase & declareGaudiProperty(Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
specialization for handling Gaudi::Property<SG::VarHandleKey>

◆ detStore()

const ServiceHandle< StoreGateSvc > & AthCommonDataStore< AthCommonMsg< AlgTool > >::detStore ( ) const
inlineinherited

The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 95 of file AthCommonDataStore.h.

◆ evtStore()

ServiceHandle< StoreGateSvc > & AthCommonDataStore< AthCommonMsg< AlgTool > >::evtStore ( )
inlineinherited

The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 85 of file AthCommonDataStore.h.

◆ extraDeps_update_handler()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::extraDeps_update_handler ( Gaudi::Details::PropertyBase & ExtraDeps)
protectedinherited

Add StoreName to extra input/output deps as needed.

use the logic of the VarHandleKey to parse the DataObjID keys supplied via the ExtraInputs and ExtraOuputs Properties to add the StoreName if it's not explicitly given

◆ initialize()

StatusCode Trk::TruthTrackRecordToTrack::initialize ( )
virtual

Definition at line 35 of file TruthTrackRecordToTrack.cxx.

35 {
36
37 ATH_CHECK ( m_extrapolator.retrieve() );
38
39 ATH_CHECK( m_reccollkey.initialize() );
40
41 return StatusCode::SUCCESS;
42}
#define ATH_CHECK
Evaluate an expression and check for errors.

◆ inputHandles()

virtual std::vector< Gaudi::DataHandle * > AthCommonDataStore< AthCommonMsg< AlgTool > >::inputHandles ( ) const
overridevirtualinherited

Return this algorithm's input handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ interfaceID()

const InterfaceID & Trk::ITruthToTrack::interfaceID ( )
inlinestaticinherited

Definition at line 40 of file ITruthToTrack.h.

40 {
41 static const InterfaceID IID_ITruthToTrack("Trk::ITruthToTrack",1,0);
42 return IID_ITruthToTrack;
43 }

◆ makePerigeeParameters() [1/2]

const Trk::TrackParameters * Trk::TruthTrackRecordToTrack::makePerigeeParameters ( const xAOD::TruthParticle * part) const
virtual

Implements Trk::ITruthToTrack.

Definition at line 187 of file TruthTrackRecordToTrack.cxx.

187 {
188 const Trk::TrackParameters* generatedTrackPerigee = nullptr;
189
190 if(part && part->hasProdVtx() && m_extrapolator) {
191
192 MsgStream log(msgSvc(), name());
193
194 std::unique_ptr<const Trk::TrackParameters> productionVertexTrackParams( makeProdVertexParameters(part) );
195 if(productionVertexTrackParams) {
196
197 // Extrapolate the TrackParameters object to the perigee. Direct extrapolation,
198 // no material effects.
199 generatedTrackPerigee =
200 m_extrapolator->extrapolateDirectly(Gaudi::Hive::currentContext(),
201 *productionVertexTrackParams,
202 Trk::PerigeeSurface(),
204 false,
205 Trk::nonInteracting).release();
206 }
207 }
208
209 return generatedTrackPerigee;
210}
virtual const Trk::TrackParameters * makeProdVertexParameters(HepMC::ConstGenParticlePtr part) const
This function produces a Trk::TrackParameters object corresponding to the HepMC::GenParticle at the p...
msgSvc
Provide convenience handles for various services.
Definition StdJOSetup.py:36
@ anyDirection
ParametersBase< TrackParametersDim, Charged > TrackParameters

◆ makePerigeeParameters() [2/2]

const Trk::TrackParameters * Trk::TruthTrackRecordToTrack::makePerigeeParameters ( HepMC::ConstGenParticlePtr part) const
virtual

This function extrapolates track to the perigee, and returns perigee parameters.

The return value points to an object allocated with the operator new. The caller is responsible for deletion of the object.

Implements Trk::ITruthToTrack.

Definition at line 161 of file TruthTrackRecordToTrack.cxx.

161 {
162 const Trk::TrackParameters* generatedTrackPerigee = nullptr;
163
164 if(part && part->production_vertex() && m_extrapolator) {
165
166 MsgStream log(msgSvc(), name());
167
168 std::unique_ptr<const Trk::TrackParameters> productionVertexTrackParams( makeProdVertexParameters(part) );
169 if(productionVertexTrackParams) {
170
171 // Extrapolate the TrackParameters object to the perigee. Direct extrapolation,
172 // no material effects.
173 generatedTrackPerigee =
174 m_extrapolator->extrapolateDirectly(Gaudi::Hive::currentContext(),
175 *productionVertexTrackParams,
176 Trk::PerigeeSurface(),
178 false,
179 Trk::nonInteracting).release();
180 }
181 }
182
183 return generatedTrackPerigee;
184}

◆ makeProdVertexParameters() [1/2]

const Trk::TrackParameters * Trk::TruthTrackRecordToTrack::makeProdVertexParameters ( const xAOD::TruthParticle * part) const
virtual

Implements Trk::ITruthToTrack.

Definition at line 105 of file TruthTrackRecordToTrack.cxx.

105 {
106
107 if (part == nullptr) return nullptr;
108
110 Amg::Vector3D prodVertexVector(0., 0., 0.);
111 Amg::Vector3D globalPos(0., 0., 0.);
112 Amg::Vector3D globalMom(0., 0., 0.);
113 int id=0;
114 double charge = 0.0;
115
116 SG::ReadHandle<TrackRecordCollection> trackRecordCollection(m_reccollkey);
117
118 if (trackRecordCollection.isValid()) {
119 ATH_MSG_ERROR ("Could not get track record!");
120 return nullptr;
121 }
122
123 ATH_MSG_DEBUG("reading from track record, size=" << trackRecordCollection->size());
124
125 if (trackRecordCollection->empty()) ATH_MSG_WARNING ("action required but TrackRecordCollection size is 0");
126
127 for (const auto & trackRecord : *trackRecordCollection) {
128 if ( HepMC::is_same_particle(trackRecord,part) ) {
129 id = trackRecord.GetPDGCode();
130 if (!id) continue;
131 CLHEP::Hep3Vector tv = trackRecord.GetPosition();
132 prodVertexVector = Amg::Vector3D(tv.x(),tv.y(),tv.z());
133 globalPos = prodVertexVector;
134 Amg::Vector3D hv2(trackRecord.GetMomentum().x(), trackRecord.GetMomentum().y(), trackRecord.GetMomentum().z());
135 globalMom = hv2;
136 ATH_MSG_DEBUG("found particle " << part << ", momentum " << hv2 << " production " << globalPos);
137 }
138 } // loop over G4 records
139
140 if (id) {
141 charge = MC::charge(id);
142
143 Amg::Translation3D prodSurfaceCentre( prodVertexVector.x(),
144 prodVertexVector.y(),
145 prodVertexVector.z() );
146
147 Amg::Transform3D tmpTransf = prodSurfaceCentre * Amg::RotationMatrix3D::Identity();
148
149 Trk::PlaneSurface planeSurface(tmpTransf, 5., 5. );
150 result = new Trk::AtaPlane(globalPos, globalMom, charge, planeSurface);
151
152 } else {
153 ATH_MSG_WARNING ("Could not get particle data for particle ID="<<id);
154 }
155 return result;
156}
#define ATH_MSG_ERROR(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
double charge(const T &p)
Definition AtlasPID.h:997
Eigen::Affine3d Transform3D
Eigen::Matrix< double, 3, 1 > Vector3D
Eigen::Translation< double, 3 > Translation3D
bool is_same_particle(const T1 &p1, const T2 &p2)
Method to establish if two particles in the GenEvent actually represent the same particle.
double charge(const T &p)
ParametersT< TrackParametersDim, Charged, PlaneSurface > AtaPlane

◆ makeProdVertexParameters() [2/2]

const Trk::TrackParameters * Trk::TruthTrackRecordToTrack::makeProdVertexParameters ( HepMC::ConstGenParticlePtr part) const
virtual

This function produces a Trk::TrackParameters object corresponding to the HepMC::GenParticle at the production vertex.

The object is allocated using operator new and returned by pointer. The caller is responsible for deletion of the object. (Wrapping it into a smart pointer may be the most convenient way to make sure the memory is freed.)

Implements Trk::ITruthToTrack.

Definition at line 45 of file TruthTrackRecordToTrack.cxx.

45 {
46
47 if (part == nullptr) return nullptr;
48
50 Amg::Vector3D prodVertexVector;
51 prodVertexVector.setZero();
52 Amg::Vector3D globalPos;
53 Amg::Vector3D globalMom;
54 int id=0;
55
56 SG::ReadHandle<TrackRecordCollection> trackRecordCollection(m_reccollkey);
57
58 if (trackRecordCollection.isValid()) {
59 ATH_MSG_ERROR ("Could not get track record!");
60 return nullptr;
61 }
62 ATH_MSG_DEBUG("reading from track record, size=" << trackRecordCollection->size());
63
64 if (trackRecordCollection->empty()) ATH_MSG_WARNING ("action required but TrackRecordCollection size is 0");
65
66 for (const auto & trackRecord : *trackRecordCollection) {
67
68 if ( !HepMC::is_same_particle(trackRecord,part) ) continue;
69
70 id = trackRecord.GetPDGCode();
71
72 CLHEP::Hep3Vector tv = trackRecord.GetPosition();
73 prodVertexVector = Amg::Vector3D(tv.x(),tv.y(),tv.z());
74 globalPos = prodVertexVector;
75
76 Amg::Vector3D hv2(trackRecord.GetMomentum().x(), trackRecord.GetMomentum().y(),
77 trackRecord.GetMomentum().z());
78 globalMom = hv2;
79
80 ATH_MSG_DEBUG("Found particle " << part << ", momentum " << hv2 << " production " << globalPos);
81
82
83 } // loop over G4 records
84
85 if (id) {
86 const double charge = MC::charge(id);
87
88 Amg::Translation3D prodSurfaceCentre( prodVertexVector.x(),
89 prodVertexVector.y(),
90 prodVertexVector.z() );
91
92 Amg::Transform3D tmpTransf = prodSurfaceCentre * Amg::RotationMatrix3D::Identity();
93
94 Trk::PlaneSurface planeSurface(tmpTransf, 5., 5. );
95 result = new Trk::AtaPlane(globalPos, globalMom, charge, planeSurface);
96 } else {
97 ATH_MSG_WARNING ("Could not get particle data for particle ID="<<id);
98 }
99 return result;
100}

◆ msg()

MsgStream & AthCommonMsg< AlgTool >::msg ( ) const
inlineinherited

Definition at line 24 of file AthCommonMsg.h.

24 {
25 return this->msgStream();
26 }

◆ msgLvl()

bool AthCommonMsg< AlgTool >::msgLvl ( const MSG::Level lvl) const
inlineinherited

Definition at line 30 of file AthCommonMsg.h.

30 {
31 return this->msgLevel(lvl);
32 }

◆ operator=()

TruthTrackRecordToTrack & Trk::TruthTrackRecordToTrack::operator= ( const TruthTrackRecordToTrack & )
privatedelete

◆ outputHandles()

virtual std::vector< Gaudi::DataHandle * > AthCommonDataStore< AthCommonMsg< AlgTool > >::outputHandles ( ) const
overridevirtualinherited

Return this algorithm's output handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ renounce()

std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > AthCommonDataStore< AthCommonMsg< AlgTool > >::renounce ( T & h)
inlineprotectedinherited

Definition at line 380 of file AthCommonDataStore.h.

381 {
382 h.renounce();
384 }
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce(T &h)

◆ renounceArray()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::renounceArray ( SG::VarHandleKeyArray & handlesArray)
inlineprotectedinherited

remove all handles from I/O resolution

Definition at line 364 of file AthCommonDataStore.h.

364 {
366 }

◆ sysInitialize()

virtual StatusCode AthCommonDataStore< AthCommonMsg< AlgTool > >::sysInitialize ( )
overridevirtualinherited

Perform system initialization for an algorithm.

We override this to declare all the elements of handle key arrays at the end of initialization. See comments on updateVHKA.

Reimplemented in asg::AsgMetadataTool, AthCheckedComponent< AthAlgTool >, AthCheckedComponent<::AthAlgTool >, and DerivationFramework::CfAthAlgTool.

◆ sysStart()

virtual StatusCode AthCommonDataStore< AthCommonMsg< AlgTool > >::sysStart ( )
overridevirtualinherited

Handle START transition.

We override this in order to make sure that conditions handle keys can cache a pointer to the conditions container.

◆ updateVHKA()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::updateVHKA ( Gaudi::Details::PropertyBase & )
inlineinherited

Definition at line 308 of file AthCommonDataStore.h.

308 {
309 // debug() << "updateVHKA for property " << p.name() << " " << p.toString()
310 // << " size: " << m_vhka.size() << endmsg;
311 for (auto &a : m_vhka) {
313 for (auto k : keys) {
314 k->setOwner(this);
315 }
316 }
317 }
std::vector< SG::VarHandleKeyArray * > m_vhka

Member Data Documentation

◆ m_detStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< AlgTool > >::m_detStore
privateinherited

Pointer to StoreGate (detector store by default)

Definition at line 393 of file AthCommonDataStore.h.

◆ m_evtStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< AlgTool > >::m_evtStore
privateinherited

Pointer to StoreGate (event store by default)

Definition at line 390 of file AthCommonDataStore.h.

◆ m_extrapolator

ToolHandle<Trk::IExtrapolator> Trk::TruthTrackRecordToTrack::m_extrapolator
private

Definition at line 65 of file TruthTrackRecordToTrack.h.

◆ m_reccollkey

SG::ReadHandleKey<TrackRecordCollection> Trk::TruthTrackRecordToTrack::m_reccollkey
private

Definition at line 66 of file TruthTrackRecordToTrack.h.

◆ m_varHandleArraysDeclared

bool AthCommonDataStore< AthCommonMsg< AlgTool > >::m_varHandleArraysDeclared
privateinherited

Definition at line 399 of file AthCommonDataStore.h.

◆ m_vhka

std::vector<SG::VarHandleKeyArray*> AthCommonDataStore< AthCommonMsg< AlgTool > >::m_vhka
privateinherited

Definition at line 398 of file AthCommonDataStore.h.


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