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

L2 tracks. More...

#include <TrigTrackSelector.h>

Inheritance diagram for TrigTrackSelector:
Collaboration diagram for TrigTrackSelector:

Public Types

typedef std::vector< ElementLink< xAOD::TrackParticleContainer > > TrackParticleLinks_t

Public Member Functions

 TrigTrackSelector (TrackFilter *selector)
 use a radius of 47 mm corresponding to the Run 1 pixel inner radius For the IBL it should be 32 mm, but this was kept as 47 mm for consistency of the definition.
 TrigTrackSelector (TrackFilter *selector, double radius)
 TrigTrackSelector (TrackFilter *selector, int selectPdgId, int selectParentPdgId)
 TrigTrackSelector (TrackFilter *selector, double radius, int selectPdgId, int selectParentPdgId)
template<typename T>
 TrigTrackSelector (T &tm, TrackFilter *selector, double radius=default_radius(), int selectPdgId=0, int selectParentPdgId=0)
template<typename T>
 TrigTrackSelector (T tbegin, T tend, TrackFilter *selector, double radius=default_radius(), int selectPdgId=0, int selectParentPdgId=0)
 ~TrigTrackSelector ()
virtual TrackSelectorclone () override
void setBeamline (double x, double y, double z=0)
double getBeamX () const
double getBeamY () const
double getBeamZ () const
void correctTracks (bool b=true)
virtual void clear () override
bool selectTrack (const TrigInDetTrack *track, const TrigInDetTrackTruthMap *truthMap=0)
 neater code to make use of vector function also for a single ancestor pdgid, instead of the full code duplication, but less efficienct as it then needs to create a single element vector for each particle, to avoid the code duplication.
void selectTracks (const TrigInDetTrackCollection *trigtracks, const TrigInDetTrackTruthMap *truthMap=0)
bool selectTrack (const Rec::TrackParticle *track)
void selectTracks (const Rec::TrackParticleContainer *trigtracks)
void selectTracks (const TruthParticleContainer *truthtracks)
void selectTracks (const xAOD::TruthParticleContainer *truthtracks)
void truthBeamline (const xAOD::TruthParticleContainer *truthtracks, double &x0, double &y0)
 extract all the tracks from a xAOD::TruthParticle collection and histogram the x and y production coordinates to determine the event "beamline" position
bool selectTrack (HepMC::ConstGenParticlePtr track)
bool selectTrack (const TruthParticle &track)
bool selectTrack (const TruthParticle *track)
bool selectTrack (const xAOD::TruthParticle *track, double x0=0, double y0=0)
TIDA::TrackmakeTrack (HepMC::ConstGenParticlePtr track)
TIDA::TrackmakeTrack (const TruthParticle *track, unsigned long tid=0)
bool selectTrack (const Trk::Track *track)
void selectTracks (const TrackCollection *trigtracks)
bool selectTrack (const xAOD::TrackParticle *track, void *=0)
 legacy run 2 selector access
void selectTracks (const xAOD::TrackParticleContainer *tracks, void *=0)
void selectTracks (xAOD::TrackParticleContainer::const_iterator trackitr, xAOD::TrackParticleContainer::const_iterator trackend, void *=0)
 MT selector access.
void selectTracks (const TrackParticleLinks_t &tracks)
void correctToBeamline (double &z0, double &dz0, double &d0, double &dd0, double theta, double phi)
virtual bool addTrack (TIDA::Track *t, bool(*f)(const TIDA::Track *)=0)
virtual void addTracks (std::vector< TIDA::Track * > &t, bool(*f)(const TIDA::Track *)=0)
const std::vector< TIDA::Track * > & tracks () const
std::vector< TIDA::Track * > tracks (TrackFilter *selector) const
unsigned size () const
void delete_track (TIDA::Track *t)

Static Public Member Functions

static double default_radius ()

Protected Member Functions

const xAOD::TruthParticlefromAncestor (const int pdg_id, const xAOD::TruthParticle *p) const
 recursive functions to identify whether a particle comes from some particle of a specific PDG ID, or some numb er of specified PDG IDs.
const xAOD::TruthParticlefromAncestor (const std::vector< int > &ids, const xAOD::TruthParticle *p) const
 recursive function to identify whether a particle comes from some other number of ancestor particles, with the pdgids passed in as a vector.
virtual void cleanup (TIDA::Track *)

Protected Attributes

std::vector< TIDA::Track * > m_tracks
TrackFilterm_selector

Private Attributes

unsigned long m_id
double m_xBeam
double m_yBeam
double m_zBeam
bool m_correctTrkTracks
double m_radius
int m_selectPdgId
int m_selectParentPdgId

Static Private Attributes

static const double s_default_radius = 47
 NB: This was 47 for Run 2, but with the addition of the IBL it should be 32 It was kept at 47 for all Run 2 and migration to MT, but for Run 3 we really want it changed to be 32.

Detailed Description

L2 tracks.

TruthMap offline and EF MC truth FrameWork includes #include "GaudiKernel/ServiceHandle.h" #include "GaudiKernel/IPartPropSvc.h" absolutely pathetic!! write my own class TrigInDetAnalysis classes

Definition at line 58 of file TrigTrackSelector.h.

Member Typedef Documentation

◆ TrackParticleLinks_t

Constructor & Destructor Documentation

◆ TrigTrackSelector() [1/6]

TrigTrackSelector::TrigTrackSelector ( TrackFilter * selector)
inline

use a radius of 47 mm corresponding to the Run 1 pixel inner radius For the IBL it should be 32 mm, but this was kept as 47 mm for consistency of the definition.

this should be changed to 32 mm for Run 3

Definition at line 70 of file TrigTrackSelector.h.

70: TrigTrackSelector( selector, default_radius(), 0, 0 ) { }
TrigTrackSelector(TrackFilter *selector)
use a radius of 47 mm corresponding to the Run 1 pixel inner radius For the IBL it should be 32 mm,...
static double default_radius()

◆ TrigTrackSelector() [2/6]

TrigTrackSelector::TrigTrackSelector ( TrackFilter * selector,
double radius )
inline

Definition at line 72 of file TrigTrackSelector.h.

72: TrigTrackSelector( selector, radius, 0, 0 ) { }

◆ TrigTrackSelector() [3/6]

TrigTrackSelector::TrigTrackSelector ( TrackFilter * selector,
int selectPdgId,
int selectParentPdgId )
inline

Definition at line 74 of file TrigTrackSelector.h.

74: TrigTrackSelector( selector, default_radius(), selectPdgId, selectParentPdgId ) { }

◆ TrigTrackSelector() [4/6]

TrigTrackSelector::TrigTrackSelector ( TrackFilter * selector,
double radius,
int selectPdgId,
int selectParentPdgId )

◆ TrigTrackSelector() [5/6]

template<typename T>
TrigTrackSelector::TrigTrackSelector ( T & tm,
TrackFilter * selector,
double radius = default_radius(),
int selectPdgId = 0,
int selectParentPdgId = 0 )
inline

Definition at line 79 of file TrigTrackSelector.h.

79 :
80 TrigTrackSelector( tm.begin(), tm.end(), selector, radius, selectPdgId, selectParentPdgId ) {
81 }

◆ TrigTrackSelector() [6/6]

template<typename T>
TrigTrackSelector::TrigTrackSelector ( T tbegin,
T tend,
TrackFilter * selector,
double radius = default_radius(),
int selectPdgId = 0,
int selectParentPdgId = 0 )
inline

Definition at line 84 of file TrigTrackSelector.h.

84 :
85 TrigTrackSelector( selector, radius, selectPdgId, selectParentPdgId ) {
86 selectTracks( tbegin, tend );
87 }
void selectTracks(const TrigInDetTrackCollection *trigtracks, const TrigInDetTrackTruthMap *truthMap=0)

◆ ~TrigTrackSelector()

TrigTrackSelector::~TrigTrackSelector ( )
inline

Definition at line 90 of file TrigTrackSelector.h.

90{ clear(); }
virtual void clear() override

Member Function Documentation

◆ addTrack()

virtual bool TrackSelector::addTrack ( TIDA::Track * t,
bool(* )(const TIDA::Track *) = 0 )
inlinevirtualinherited

Definition at line 35 of file Trigger/TrigAnalysis/TrigInDetAnalysis/TrigInDetAnalysis/TrackSelector.h.

35 {
36 //std::cout << "addtrack() before f: t " << *t << " " << size() << "\t f " << f << std::endl;
37 if ( f==0 ) {
38 if ( m_selector && m_selector->select(t) ) { m_tracks.push_back(t); return true; }
39 else { cleanup(t); }
40 }
41 else {
42 if ( f(t) ) { m_tracks.push_back(t); return true; }
43 else { cleanup(t); }
44 }
45 return false;
46 }

◆ addTracks()

virtual void TrackSelector::addTracks ( std::vector< TIDA::Track * > & t,
bool(* )(const TIDA::Track *) = 0 )
inlinevirtualinherited

Definition at line 48 of file Trigger/TrigAnalysis/TrigInDetAnalysis/TrigInDetAnalysis/TrackSelector.h.

48 {
49 for ( size_t i=0 ; i<t.size() ; i++ ) addTrack( t[i], f );
50 }
virtual bool addTrack(TIDA::Track *t, bool(*f)(const TIDA::Track *)=0)

◆ cleanup()

virtual void TrackSelector::cleanup ( TIDA::Track * )
inlineprotectedvirtualinherited

◆ clear()

virtual void TrigTrackSelector::clear ( )
inlineoverridevirtual

Reimplemented from TrackSelector.

Definition at line 102 of file TrigTrackSelector.h.

102{ for ( size_t i=m_tracks.size() ; i-- ; ) delete m_tracks[i]; m_tracks.clear(); }

◆ clone()

virtual TrackSelector * TrigTrackSelector::clone ( )
inlineoverridevirtual

Implements TrackSelector.

Definition at line 92 of file TrigTrackSelector.h.

92{ return new TrigTrackSelector(*this); }

◆ correctToBeamline()

void TrigTrackSelector::correctToBeamline ( double & z0,
double & dz0,
double & d0,
double & dd0,
double theta,
double phi )

make sure that users have set the beamline parameters

error estimates

Definition at line 1254 of file TrigTrackSelector.cxx.

1256 {
1257
1259
1260 // if ( m_first ) {
1261 // if ( m_xBeam==0 && m_yBeam==0 ) {
1262 // std::cerr << "TrigTrackSelector::correctToBeamline() WARNING -- Beamline set to (0,0) -- WARNING" << std::endl;
1263 // }
1264 // else {
1265 // std::cout << "TrigTrackSelector::correctToBeamline() Beamline set to " << m_xBeam << " " << m_yBeam << std::endl;
1266 // }
1267 // m_first = false;
1268 // }
1269
1270
1271 // double theta = 2*std::atan( exp( (-1)*eta ) );
1272 double z0t = z0 + ((std::cos(phi)*m_xBeam + std::sin(phi)*m_yBeam)/std::tan(theta));
1273 double a0t = d0 + std::sin(phi)*m_xBeam - std::cos(phi)*m_yBeam;
1274
1276 double dz0t = dz0 + ((std::cos(phi)*m_xBeam + std::sin(phi)*m_yBeam)/std::tan(theta));
1277 double da0t = dd0 + std::sin(phi)*m_xBeam - std::cos(phi)*m_yBeam;
1278
1279 z0 = z0t;
1280 d0 = a0t;
1281
1282 dz0 = dz0t;
1283 dd0 = da0t;
1284}
Scalar phi() const
phi method
Scalar theta() const
theta method

◆ correctTracks()

void TrigTrackSelector::correctTracks ( bool b = true)
inline

Definition at line 100 of file TrigTrackSelector.h.

◆ default_radius()

double TrigTrackSelector::default_radius ( )
inlinestatic

Definition at line 188 of file TrigTrackSelector.h.

188{ return s_default_radius; }
static const double s_default_radius
NB: This was 47 for Run 2, but with the addition of the IBL it should be 32 It was kept at 47 for all...

◆ delete_track()

void TrackSelector::delete_track ( TIDA::Track * t)
inlineinherited

Definition at line 69 of file Trigger/TrigAnalysis/TrigInDetAnalysis/TrigInDetAnalysis/TrackSelector.h.

69 {
70 m_tracks.erase( std::remove( m_tracks.begin(), m_tracks.end(), t ), m_tracks.end() );
71 }
DataModel_detail::iterator< DVL > remove(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end, const T &value)
Specialization of remove for DataVector/List.

◆ fromAncestor() [1/2]

const xAOD::TruthParticle * TrigTrackSelector::fromAncestor ( const int pdg_id,
const xAOD::TruthParticle * p ) const
protected

recursive functions to identify whether a particle comes from some particle of a specific PDG ID, or some numb er of specified PDG IDs.

recursive function to identify whether a particle comes from some other ancestor particle at any point in its history - checks its parents and then function calls itself to check their parents etc., until it either finds the pdgid it is looking for, or it has no more ancestors if it finds an appropriate ancestor it returns the pointer to it, otherwise it returns a nullptr

finds an appropriate ancestor and returns the pointer to it, otherwise it just returns a nullptr

Definition at line 39 of file TrigTrackSelector.cxx.

39 {
40 if ( p==nullptr ) return nullptr;
41 if ( MC::isElectron(p) || MC::isMuon(p) ) return nullptr; //don't want light leptons from eg tau decays - they are found directly
42 if ( p->absPdgId()==pdg_id ) {
43 return p; // recursive stopping conditions
44 }
45 auto vertex = p->prodVtx();
46 if ( vertex == nullptr ) {
47 return nullptr; // has no production vertex !!!
48 }
49 if ( vertex->nIncomingParticles() < 1 ) {
50 return nullptr; // recursive stopping conditions
51 }
52 for( unsigned ip = 0; ip < vertex->nIncomingParticles(); ip++ ) {
53 auto* in = vertex->incomingParticle(ip);
54 auto parent = fromAncestor( pdg_id, in);
55 if ( parent!=nullptr ) {
56 if (parent->absPdgId()==pdg_id) return parent;
57 }
58 }
59
60 return nullptr;
61}
const xAOD::TruthParticle * fromAncestor(const int pdg_id, const xAOD::TruthParticle *p) const
recursive functions to identify whether a particle comes from some particle of a specific PDG ID,...
bool isElectron(const T &p)
bool isMuon(const T &p)

◆ fromAncestor() [2/2]

const xAOD::TruthParticle * TrigTrackSelector::fromAncestor ( const std::vector< int > & ids,
const xAOD::TruthParticle * p ) const
protected

recursive function to identify whether a particle comes from some other number of ancestor particles, with the pdgids passed in as a vector.

Any such ancestors at point in it's history will do - checks it's parents and then calls the function calls itself to check the parent's parents etc, until it either finds one of the pdgids it is looking for, or it has no more ancestors if it finds an appropriate ancestor it returns the pointer to it, otherwise it returns a nullptr

Definition at line 73 of file TrigTrackSelector.cxx.

73 {
74 if ( p==nullptr ) return nullptr;
75 if (MC::isElectron(p) || MC::isMuon(p)) return nullptr; //don't want light leptons from eg tau decays - they are found directly
76 for ( size_t i=ids.size() ; i-- ; ) {
77 if ( p->absPdgId()==ids[i] ) return p; // recursive stopping conditions
78 }
79
80 auto vertex = p->prodVtx();
81 if ( vertex == nullptr ) return nullptr; // has no production vertex !!!
82
83 if ( vertex->nIncomingParticles()<1 ) return nullptr; // recursive stopping conditions
84
85 for( unsigned ip = 0; ip < vertex->nIncomingParticles(); ip++ ) {
86 auto* in = vertex->incomingParticle(ip);
87 auto parent = fromAncestor( ids, in);
88 if ( parent!=nullptr ) {
89 for ( size_t i=ids.size() ; i-- ; ) {
90 if ( parent->absPdgId()==ids[i] ) return parent;
91 }
92 }
93 }
94
95 return nullptr;
96}

◆ getBeamX()

double TrigTrackSelector::getBeamX ( ) const
inline

Definition at line 96 of file TrigTrackSelector.h.

96{ return m_xBeam; }

◆ getBeamY()

double TrigTrackSelector::getBeamY ( ) const
inline

Definition at line 97 of file TrigTrackSelector.h.

97{ return m_yBeam; }

◆ getBeamZ()

double TrigTrackSelector::getBeamZ ( ) const
inline

Definition at line 98 of file TrigTrackSelector.h.

98{ return m_zBeam; }

◆ makeTrack() [1/2]

TIDA::Track * TrigTrackSelector::makeTrack ( const TruthParticle * track,
unsigned long tid = 0 )

check for final state

the is our new "final state" requirement the inner and outer radii are in some sense arbitrary - these correspond to an envelope around the pixel detector, so the track must pass through the entire pixel detector NB: In order to ensure you don't miss any tracks they really need to be the same ie if a track brems in your "volume" then you will miss that track, and also the resulting track, even if it is a high et track

keep anything over 10 GeV with the old requirement

avoid default (unset) TruthParticle charge

only use charged tracks

what a faff - refuse to mess about with the classes to swim tracks etc - why can't they just encode this sort of information in the class!! It's not as if it doesn't actually have members for anything else useless!! Classes should be designed for ease of use !!!!

is there a sign issue here ?

correct back to the beamline

how about storing uniqueID/status/pidg info?

this isn't good!! but it will do for testing

probably won't work either

get the production vertex for the z0 and d0 but should we store the z0 of the production vertex? or swim the track to the perigee point with respect to 0,0 and use the parameters there?

what to do with these???

Definition at line 692 of file TrigTrackSelector.cxx.

692 {
693
694 if ( track==0 ) return 0;
695 if ( !MC::isStable(track)) return 0;
696
697
698 double phi = track->phi();
699 double eta = track->eta();
700
704 double xp[3] = { 0, 0, 0 };
705
706 if ( track->genParticle()->production_vertex() ) {
707 xp[0] = track->genParticle()->production_vertex()->position().x();
708 xp[1] = track->genParticle()->production_vertex()->position().y();
709 xp[2] = track->genParticle()->production_vertex()->position().z();
710 }
711
712 // CHANGED BY JK - z0 with respect to (0,0)
713 // double z0 = xp[2];
714 double theta = 2*std::atan( exp( (-1)*eta ) );
715 double z0 = xp[2] - (xp[0]*std::cos(phi) + xp[1]*std::sin(phi))/std::tan(theta);
716
717 double xd[3] = { 0, 0, 0 };
718
719 if ( track->genParticle()->end_vertex() ) {
720 xd[0] = track->genParticle()->end_vertex()->position().x();
721 xd[1] = track->genParticle()->end_vertex()->position().y();
722 xd[2] = track->genParticle()->end_vertex()->position().z();
723 }
724
725 double rp = std::sqrt( xp[0]*xp[0] + xp[1]*xp[1] );
726 double rd = std::sqrt( xd[0]*xd[0] + xd[1]*xd[1] );
727
728
729 bool final_state = false;
730
742 const double inner_radius = m_radius;
743 const double outer_radius = m_radius;
744 if ( ( track->genParticle()->production_vertex() && rp<=inner_radius ) &&
745 ( track->genParticle()->end_vertex()==0 || rd>outer_radius ) ) final_state = true;
746
747
748 if ( !final_state ) return 0;
749
760
761 double q = track->charge();
762
763 static const particleType ptype;
764
766 if ( q==-999 ) q = ptype.charge( track->pdgId() );
767
769 if ( q==0 ) return 0;
770
771 double pT = q*track->pt();
772
773
774 double d0 = 0;
775
780
782
783
784 // CHANGED BY JK - d0 with respect to (0,0)
785 // d0 = q*rp*std::sin(phi);
786 d0 = xp[1]*std::cos(phi) - xp[0]*std::sin(phi);
787
788
790
791 double dz0 = 0;
792 double dd0 = 0;
793
794 correctToBeamline( z0, dz0, d0, dd0, theta, phi );
795
796
797
799
801 int author = track->pdgId();
802 int uniqueID = HepMC::uniqueID(track);
803
804
805 unsigned long id = (unsigned long)track;
806 if ( tid!=0 ) id = tid;
807
811
812
814
815 // std::cout << "\t\t\tSUTT Truth track"
816 // << "\teta=" << eta // << " +- " << (*trackitr)->params()->deta()
817 // << "\tphi=" << phi // << " +- " << (*trackitr)->params()->dphi()
818 // << "\tz0=" << z0
819 // << "\tpT=" << pT // << "\t( " << 1/qoverp << ")"
820 // << "\td0=" << d0
821 // << "\tauthor=" << author
822 // << std::endl;
823
824
825
826 TIDA::Track* t = new TIDA::Track(eta, phi, z0, d0, pT, 0, 0,
827 0, 0, 0, 0, 0,
828 0, 0, 0, 0,
829 0, 0, 0, 0,
830 author, false, uniqueID, -1,
831 false,
832 id ) ;
833
834 return t;
835
836}
Scalar eta() const
pseudorapidity method
ReadCards * rp
void correctToBeamline(double &z0, double &dz0, double &d0, double &dd0, double theta, double phi)
double charge(int id) const
int uniqueID(const T &p)
bool isStable(const T &p)
Identify if the particle is stable, i.e. has not decayed.

◆ makeTrack() [2/2]

TIDA::Track * TrigTrackSelector::makeTrack ( HepMC::ConstGenParticlePtr track)

Definition at line 684 of file TrigTrackSelector.cxx.

684 {
685//AV Using memory to get some value is not a good idea. This is not a repruducible/portable way, but I leave it as is.
686 unsigned long id = (unsigned long)(track.get());
687 TruthParticle t = TruthParticle(track);
688 return makeTrack( &t, id );
689}
TIDA::Track * makeTrack(HepMC::ConstGenParticlePtr track)
TruthParticle_v1 TruthParticle
Typedef to implementation.

◆ selectTrack() [1/8]

bool TrigTrackSelector::selectTrack ( const Rec::TrackParticle * track)

temporarily remove interaction mean z position

<< check this <<–

check this !!!

now some ridiculous code to get the author of the TrackParticle (offline) tracks

Definition at line 200 of file TrigTrackSelector.cxx.

200 {
201
202 // do the track extraction stuff here....
203
204 static const int hpmap[20] = { 0, 1, 2, 7, 8, 9, 3, 4, 5, 6, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19 };
205
206 if ( track ) {
207
208#ifdef TRKPARAMETERS_MEASUREDPERIGEE_H
209 const Trk::MeasuredPerigee* measPer = track->measuredPerigee();
210#else
211 const Trk::Perigee* measPer = track->measuredPerigee();
212#endif
213 // CLHEP::HepVector perigeeParams = measPer->parameters();
214
215 double pT = measPer->pT();
216 double eta = measPer->eta();
217 double phi = measPer->parameters()[Trk::phi0];
218 double z0 = measPer->parameters()[Trk::z0] + m_zBeam;
219 double d0 = measPer->parameters()[Trk::d0];
220
221 double theta = measPer->parameters()[Trk::theta];
222 double p = 1/measPer->parameters()[Trk::qOverP];
223
224 // AAARCH!!!!! the TrackParticle pT is NOT SIGNED!!!! ( I ask you! )
225 if ( measPer->parameters()[Trk::qOverP]<0 && pT>0 ) pT *= -1;
226
227#ifdef TRKPARAMETERS_MEASUREDPERIGEE_H
228 const Trk::ErrorMatrix err = measPer->localErrorMatrix();
229 double dtheta = err.error(Trk::theta);
230 double dqovp = err.error(Trk::qOverP);
231 double covthetaOvP = err.covValue(Trk::qOverP,Trk::theta);
232#else
233 double dtheta = std::sqrt((*measPer->covariance())(Trk::theta,Trk::theta));
234 double dqovp = std::sqrt((*measPer->covariance())(Trk::qOverP,Trk::qOverP));
235 double covthetaOvP = (*measPer->covariance())(Trk::qOverP,Trk::theta);
236#endif
237
238
239 double deta = 0.5*dtheta/(std::cos(0.5*theta)*std::cos(0.5*theta)*std::tan(0.5*theta));
240
241#ifdef TRKPARAMETERS_MEASUREDPERIGEE_H
242 double dphi = err.error(Trk::phi0);
243 double dz0 = err.error(Trk::z0);
244 double dd0 = err.error(Trk::d0);
245#else
246 double dphi = std::sqrt((*measPer->covariance())(Trk::phi0,Trk::phi0));
247 double dz0 = std::sqrt((*measPer->covariance())(Trk::z0,Trk::z0));
248 double dd0 = std::sqrt((*measPer->covariance())(Trk::d0,Trk::d0));
249#endif
250
251 double dpT = 0;
252
253
254 double sintheta = std::sin(theta);
255 double costheta = std::cos(theta);
256 double dpt2 = (p*p*sintheta)*(p*p*sintheta)*dqovp*dqovp + (p*costheta)*(p*costheta)*dtheta*dtheta - 2*(p*p*sintheta)*(p*costheta)*covthetaOvP;
257
258 if ( dpt2>0 ) dpT = std::sqrt( dpt2 );
259
260 // Check number of hits
261 // NB: a spacepoint is two offline "hits", so a pixel spacepoint is really
262 // 2 "hits" and an offline SCT "hit" is really a 1D cluster, so two intersecting
263 // stereo clusters making a spacepoint are two "hits"
264 const Trk::TrackSummary *summary = track->trackSummary();
265 int nBlayerHits = 2*summary->get(Trk::numberOfBLayerHits);
267 int nSctHits = summary->get(Trk::numberOfSCTHits);
268 int nStrawHits = summary->get(Trk::numberOfTRTHits);
269 int nTrHits = summary->get(Trk::numberOfTRTHighThresholdHits);
270
271 int nSiHits = nPixelHits + nSctHits;
272 bool expectBL = false; // Not stored for Rec::TrackParticle
273
274 const Trk::FitQuality *quality = track->fitQuality();
275 double chi2 = quality->chiSquared();
276 double dof = quality->numberDoF();
277
278 unsigned bitmap = 0;
279
280
281 unsigned long id = (unsigned long)track;
282
283 for ( int ih=0 ; ih<20 ; ih++ ) {
284 if ( summary->isHit(Trk::DetectorType(ih)) ) bitmap |= ( 1<<hpmap[ih] );
285 }
286
289
290 // std::cout << "fetching author info :" << track->info().trackFitter() << ":"
291 // << track->info().dumpInfo() << ": bm 0x" << std::hex << bitmap << std::dec << std::endl;
292
293 int fitter = track->info().trackFitter();
294 std::string dumpinfo = track->info().dumpInfo();
295
296 int trackAuthor = -1;
297 if ( fitter>0 && fitter<Trk::TrackInfo::NumberOfTrackFitters ) {
298 if ( dumpinfo.find("TRTStandalone")!=std::string::npos) trackAuthor = 2;
299 else if ( dumpinfo.find("TRTSeededTrackFinder")!=std::string::npos) trackAuthor = 1;
300 else trackAuthor = 0;
301 }
302
303#if 0
304 std::cout << "\t\t\tSUTT TP track"
305 << "\teta=" << eta // << " +- " << (*trackitr)->params()->deta()
306 << "\tphi=" << phi // << " +- " << (*trackitr)->params()->dphi()
307 << "\tz0=" << z0
308 << "\tpT=" << pT // << "\t( " << 1/qoverp << ")"
309 << "\td0=" << d0
310 << "\tNsi=" << nSiHits
311 << "\tNtrt=" << nTrHits
312 << "\tNstr=" << nStrawHits
313 << "\tauthor=" << trackAuthor
314 << std::endl;
315#endif
316
317 // Create and save Track
318
319 TIDA::Track* t = new TIDA::Track(eta, phi, z0, d0, pT, chi2, dof,
320 deta, dphi, dz0, dd0, dpT,
321 nBlayerHits, nPixelHits, nSctHits, nSiHits,
322 nStrawHits, nTrHits, bitmap, 0,
323 trackAuthor, false, -1, -1,
324 expectBL, id) ;
325
326 // std::cout << "SUTT TP track " << *t << "\t0x" << std::hex << bitmap << std::dec << std::endl;
327
328 if ( !addTrack( t ) ){
329 delete t;
330 return false;
331 }
332 return true;
333
334 }
335 return false;
336}
int numberDoF() const
returns the number of degrees of freedom of the overall track or vertex fit as integer
Definition FitQuality.h:60
double chiSquared() const
returns the of the overall track fit
Definition FitQuality.h:56
double eta() const
Access method for pseudorapidity - from momentum.
double pT() const
Access method for transverse momentum.
double chi2(TH1 *h0, TH1 *h1)
float nSiHits(const U &p)
float nPixelHits(const U &p)
const ShapeFitter * fitter
ParametersT< TrackParametersDim, Charged, PerigeeSurface > Perigee
Perigee MeasuredPerigee
@ phi0
Definition ParamDefs.h:65
@ theta
Definition ParamDefs.h:66
@ qOverP
perigee
Definition ParamDefs.h:67
@ d0
Definition ParamDefs.h:63
@ z0
Definition ParamDefs.h:64
DetectorType
enumerates the various detector types currently accessible from the isHit() method.
@ numberOfPixelHits
number of pixel layers on track with absence of hits
@ numberOfBLayerHits
these are the hits in the 0th pixel layer?
@ numberOfTRTHighThresholdHits
total number of TRT hits which pass the high threshold

◆ selectTrack() [2/8]

bool TrigTrackSelector::selectTrack ( const TrigInDetTrack * track,
const TrigInDetTrackTruthMap * truthMap = 0 )

neater code to make use of vector function also for a single ancestor pdgid, instead of the full code duplication, but less efficienct as it then needs to create a single element vector for each particle, to avoid the code duplication.

Perhaps something can be done for the compiler optimisation to realise this and somehow
reduce the opverhead of creating the single int vector - need to investiogate this more thoroghly before including this, as it would be a much neater solution

not definied ofr TrigInDetTracks

Definition at line 116 of file TrigTrackSelector.cxx.

116 {
117 // do the track extraction stuff here....
118 if ( track ) {
119
120 double eta = track->param()->eta();
121 double phi = track->param()->phi0();
122 double z0 = track->param()->z0();
123 double pT = track->param()->pT();
124 double d0 = track->param()->a0();
125
126 double deta = track->param()->eeta();
127 double dphi = track->param()->ephi0();
128 double dz0 = track->param()->ez0();
129 double dpT = track->param()->epT();
130 double dd0 = track->param()->ea0();
131
132 double theta = 2*std::atan( exp( (-1)*eta ) );
133 correctToBeamline( z0, dz0, d0, dd0, theta, phi );
134
135 int algoid = track->algorithmId();
136
137 int nBlayerHits = (track->HitPattern() & 0x1);
138 int nPixelHits = 2 * track->NPixelSpacePoints(); // NB: for comparison with offline
139 int nSctHits = 2 * track->NSCT_SpacePoints(); // a spacepoint is 2 "hits"
140 int nStrawHits = track->NStrawHits();
141 int nTrHits = track->NTRHits();
142
143 int nSiHits = nPixelHits + nSctHits;
144
145 bool expectBL = false; //not filled in
146
147 unsigned long id = (unsigned long)track;
148
149 unsigned hitPattern = track->HitPattern();
150 unsigned multiPattern = 0;
151
152 double chi2 = track->chi2();
153 double dof = 0;
154
155 bool truth = false;
156 int match_uniqueID = HepMC::INVALID_PARTICLE_ID;
157
158 if ( truthMap ) {
159 const TrigInDetTrackTruth* trackTruth = truthMap->truth(track);
160 if (trackTruth!=0 && trackTruth->nrMatches() > 0) {
161 match_uniqueID = HepMC::uniqueID(trackTruth->bestSiMatch());
162 truth = true;
163 }
164 }
165
166
167 TIDA::Track* t = new TIDA::Track( eta, phi, z0, d0, pT, chi2, dof,
168 deta, dphi, dz0, dd0, dpT,
169 nBlayerHits, nPixelHits, nSctHits, nSiHits,
170 nStrawHits, nTrHits,
171 hitPattern, multiPattern,
172 algoid, truth, -1, match_uniqueID,
173 expectBL, id) ;
174
175 // std::cout << "SUTT ID track " << *t << "\t0x" << std::hex << track->HitPattern() << std::dec << std::endl;
176
177 if ( !addTrack( t ) ){
178 delete t;
179 return false;
180 }
181 return true;
182 }
183 return false;
184}
const TrigInDetTrackTruth * truth(const TrigInDetTrack *p_trig_trk) const
const HepMcParticleLink * bestSiMatch() const
returns best match according to the number of hits
unsigned int nrMatches() const
returns number of matching particles
constexpr int INVALID_PARTICLE_ID

◆ selectTrack() [3/8]

bool TrigTrackSelector::selectTrack ( const Trk::Track * track)

a covariance!

check this <<–

now some ridiculous code to get the author of the TrackParticle (offline) tracks

Definition at line 841 of file TrigTrackSelector.cxx.

841 {
842
843 // do the track extraction stuff here....
844
845 static const int hpmap[20] = { 0, 1, 2, 7, 8, 9, 3, 4, 5, 6, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19 };
846 // std::cout << __FILE__<< " " <<__LINE__<<std::endl;
847
848 if ( track ) {
849
850 // const Trk::Perigee* startPerigee = track->perigeeParameters();
851
852#ifdef TRKPARAMETERS_MEASUREDPERIGEE_H
853 const Trk::MeasuredPerigee* startPerigee = dynamic_cast<const Trk::MeasuredPerigee*>(track->perigeeParameters());
854 // const Trk::MeasuredPerigee* measPer = startPerigee; // just out of laziness
855#else
856 const Trk::Perigee* startPerigee = track->perigeeParameters();
857 const Trk::Perigee* measPer = startPerigee; // just out of laziness
858#endif
859
860
861 // CLHEP::HepVector perigeeParams = measPer->parameters();
862 // double pT = measPer->pT();
863 // double eta = measPer->eta();
864 // double phi = perigeeParams[Trk::phi0];
865 // double z0 = perigeeParams[Trk::z0];
866 // double d0 = perigeeParams[Trk::d0];
867 // // AAARCH!!!!! the TrackParticle pT is NOT SIGNED!!!! ( I ask you! )
868 // if ( perigeeParams[Trk::qOverP]<0 ) pT *= -1;
869 // std::cout <<pT1<<" pt1vspT "<<pT<<std::endl;
870
871 if (startPerigee){
872
873 double theta = startPerigee->parameters()[Trk::theta];
874 double p = 1/startPerigee->parameters()[Trk::qOverP];
875 double qOverPt = startPerigee->parameters()[Trk::qOverP]/std::sin(theta);
876 double charge = startPerigee->charge();
877 double eta = startPerigee->eta();
878 double phi = startPerigee->parameters()[Trk::phi0];
879 double z0 = startPerigee->parameters()[Trk::z0];
880 double d0 = startPerigee->parameters()[Trk::d0];
881 // double pT = (1./qOverPt)*(charge);
882 double pT = (1./qOverPt); // always use signed PT
883
884 if ( charge<0 && pT>0 ) pT *= -1;
885 if ( charge<0 && p>0 ) p *= -1;
886
887
888
889#ifdef TRKPARAMETERS_MEASUREDPERIGEE_H
890 const Trk::ErrorMatrix err = startPerigee->localErrorMatrix();
891 double dtheta = err.error(Trk::theta);
892 double dqovp = err.error(Trk::qOverP);
893 double covthetaOvP = err.covValue(Trk::qOverP,Trk::theta);
894
895 double dphi = err.error(Trk::phi0);
896 double dz0 = err.error(Trk::z0);
897 double dd0 = err.error(Trk::d0);
898#else
899 double dtheta = std::sqrt((*measPer->covariance())(Trk::theta,Trk::theta));
900 double dqovp = std::sqrt((*measPer->covariance())(Trk::qOverP,Trk::qOverP));
901 double covthetaOvP = (*measPer->covariance())(Trk::qOverP,Trk::theta);
902
903 double dphi = std::sqrt((*measPer->covariance())(Trk::phi0,Trk::phi0));
904 double dz0 = std::sqrt((*measPer->covariance())(Trk::z0,Trk::z0));
905 double dd0 = std::sqrt((*measPer->covariance())(Trk::d0,Trk::d0));
906#endif
907
908 double deta = 0.5*dtheta/(std::cos(0.5*theta)*std::cos(0.5*theta)*std::tan(0.5*theta));
909
910
911 if ( m_correctTrkTracks ) correctToBeamline( z0, dz0, d0, dd0, theta, phi );
912
913 double dpT = 0;
914
915
916 double sintheta = std::sin(theta);
917 double costheta = std::cos(theta);
918 double dpT2 = (p*p*sintheta)*(p*p*sintheta)*dqovp*dqovp + (p*costheta)*(p*costheta)*dtheta*dtheta - 2*(p*p*sintheta)*(p*costheta)*covthetaOvP;
919
920 if ( dpT2>0 ) dpT = std::sqrt( dpT2 );
921
922 // Check number of hits
923 // NB: a spacepoint is two offline "hits", so a pixel spacepoint is really
924 // 2 "hits" and an offline SCT "hit" is really a 1D cluster, so two intersetcting
925 // stereo clusters making a spacepoint are two "hits"
926 // const Trk::TrackSummary *summary = dynamic_cast<const Trk::TrackSummary*>(track->trackSummary());
927 //ToolHandle< Trk::ITrackSummaryTool > m_trackSumTool;
928 //m_trackSumTool = ToolHandle<Trk::ITrackSummaryTool>("Trk::TrackSummaryTool/InDetTrackSummaryTool");
929 //const Trk::TrackSummary* summary = NULL;
930 //summary = m_trackSumTool->createSummary(*track);
931
932 const Trk::TrackSummary * summary = track->trackSummary();
933 int nBlayerHits = 0;
934 int nPixelHits = 0;
935 int nSctHits = 0;
936 int nStrawHits = 0;
937 int nTrHits = 0;
938 int nSiHits = 0;
939 bool expectBL = false; // Not stored for Trk::Track
940 unsigned bitmap = 0;
941
942 if(summary==0){
943 std::cerr << "Could not create TrackSummary - Track will likely fail hits requirements" << std::endl;
944 }
945 else{
946 nBlayerHits = 2*summary->get(Trk::numberOfBLayerHits);
948 nSctHits = summary->get(Trk::numberOfSCTHits);
949 nStrawHits = summary->get(Trk::numberOfTRTHits);
951 nSiHits = nPixelHits + nSctHits;
952
953 for ( int ih=0 ; ih<20 ; ih++ ) {
954 if ( summary->isHit(Trk::DetectorType(ih)) ) bitmap |= ( 1<<hpmap[ih] );
955 }
956 }
957
958 unsigned long id = (unsigned long)track;
959 double chi2 = 0;
960 double dof = 0;
961 //const Trk::FitQuality *quality = dynamic_cast<const Trk::FitQuality*>(track->fitQuality());
962 const Trk::FitQuality *quality = (track->fitQuality());
963 if(quality==0) std::cerr << "Could not create FitQuality - Track will likely fail hits requirements" << std::endl;
964 else{
965 chi2 = quality->chiSquared();
966 dof = quality->numberDoF();
967 }
968
969 int trackAuthor = -1;
970
973
974 // std::cout << "fetching author info :" << track->info().trackFitter() << ":"
975 // << track->info().dumpInfo() << ": bm 0x" << std::hex << bitmap << std::dec << std::endl;
976
977 int fitter = track->info().trackFitter();
978 // std::string dumpinfo = track->info().dumpInfo();
979
980 if ( fitter>0 && fitter<Trk::TrackInfo::NumberOfTrackFitters ) {
981 if ((track->info().dumpInfo()).find("TRTStandalone") != std::string::npos) trackAuthor = 2;
982 else if ((track->info().dumpInfo()).find("TRTSeededTrackFinder") != std::string::npos) trackAuthor = 1;
983 else trackAuthor = 0;
984 }
985
986 #if 0
987 std::cout << "\t\t\tSUTT TP track"
988 << "\teta=" << eta // << " +- " << (*trackitr)->params()->deta()
989 << "\tphi=" << phi // << " +- " << (*trackitr)->params()->dphi()
990 << "\tz0=" << z0
991 << "\tpT=" << pT // << "\t( " << 1/qoverp << ")"
992 << "\td0=" << d0
993 << "\tNsi=" << nSiHits
994 << "\tNtrt=" << nTrHits
995 << "\tNstr=" << nStrawHits
996 << "\tauthor=" << trackAuthor
997 << std::endl;
998 #endif
999 // Create and save Track
1000 TIDA::Track* t = new TIDA::Track(eta, phi, z0, d0, pT, chi2, dof,
1001 deta, dphi, dz0, dd0, dpT,
1002 nBlayerHits, nPixelHits, nSctHits, nSiHits,
1003 nStrawHits, nTrHits, bitmap, 0,
1004 trackAuthor, false, -1, -1,
1005 expectBL, id) ;
1006
1007 if ( !addTrack( t ) ){
1008 delete t;
1009 return false;
1010 }
1011 return true;
1012
1013 //std::cout << "SUTT TP track " << *t << "\t0x" << std::hex << bitmap << std::dec << std::endl;
1014 }
1015 }
1016
1017 return false;
1018}
double charge(const T &p)
Definition AtlasPID.h:997
double charge() const
Returns the charge.

◆ selectTrack() [4/8]

bool TrigTrackSelector::selectTrack ( const TruthParticle & track)

Definition at line 518 of file TrigTrackSelector.cxx.

518 {
519
520 return selectTrack( &track );
521
522}
bool selectTrack(const TrigInDetTrack *track, const TrigInDetTrackTruthMap *truthMap=0)
neater code to make use of vector function also for a single ancestor pdgid, instead of the full code...

◆ selectTrack() [5/8]

bool TrigTrackSelector::selectTrack ( const TruthParticle * track)

Definition at line 526 of file TrigTrackSelector.cxx.

526 {
527 TIDA::Track* t = makeTrack( track, m_id );
528 if ( t == 0 ) return false;
529 if ( !addTrack(t) ) {
530 delete t;
531 return false;
532 }
533 return true;
534}

◆ selectTrack() [6/8]

bool TrigTrackSelector::selectTrack ( const xAOD::TrackParticle * track,
void * = 0 )

legacy run 2 selector access

lazy just to avoid a find-replace of measPer to track

Grrrrr remove interaction mean z position!!!

protect against spurious qOverP = 0 BUT !!! this should NEVER happen !!! so shouldn't really have this failing silently, but not allowed to put in std::cerr output leave the original code in as this is mostly for a test

a covariance not an error

don't correct xaod tracks to the beamline

??? <<– check this

holes

cheat !! pack the holes into the hits so that eg int pixelholes() { return npix/1000; } int pixelhits() { return npix%1000; }

get the total number of holes as well

fit quality

Definition at line 1037 of file TrigTrackSelector.cxx.

1037 {
1038 // do the track extraction stuff here....
1039
1040 // static int hpmap[20] = { 0, 1, 2, 7, 8, 9, 3, 4, 5, 6, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19 };
1041
1042 if ( track ) {
1043
1045 const xAOD::TrackParticle* measPer = track;
1046
1047 // CLHEP::HepVector perigeeParams = measPer->parameters();
1048
1049 double pT = measPer->pt();
1050 double eta = measPer->eta();
1051 double phi = measPer->phi0();
1052 double z0 = measPer->z0() + measPer->vz();
1053 double d0 = measPer->d0();
1054
1055 double theta = measPer->theta();
1056
1061 // if ( measPer->qOverP()==0 ) return false;
1062 if ( measPer->qOverP()==0 ) throw std::runtime_error( "probable corrupted track - this should never happen" );
1063 double p = 1/measPer->qOverP();
1064
1065 // AAARCH!!!!! the TrackParticle pT is NOT SIGNED!!!! ( I ask you! )
1066 if ( measPer->qOverP()<0 && pT>0 ) pT *= -1;
1067
1068 double dtheta = std::sqrt(measPer->definingParametersCovMatrix()(Trk::theta,Trk::theta));
1069 double dqovp = std::sqrt(measPer->definingParametersCovMatrix()(Trk::qOverP,Trk::qOverP));
1070 double covthetaOvP = measPer->definingParametersCovMatrix()(Trk::qOverP,Trk::theta);
1071
1072 double deta = 0.5*dtheta/(std::cos(0.5*theta)*std::cos(0.5*theta)*std::tan(0.5*theta)); // ???? CHECK THIS <<--
1073
1074 double dphi = std::sqrt(measPer->definingParametersCovMatrix()(Trk::phi0,Trk::phi0));
1075 double dz0 = std::sqrt(measPer->definingParametersCovMatrix()(Trk::z0,Trk::z0));
1076 double dd0 = std::sqrt(measPer->definingParametersCovMatrix()(Trk::d0,Trk::d0));
1077
1078 double dpT = 0;
1079
1080
1082 // if ( m_xBeam!=0 || m_yBeam!=0 ) correctToBeamline( z0, dz0, d0, dd0, theta, phi );
1083
1084
1085 double sintheta = std::sin(theta);
1086 double costheta = std::cos(theta);
1087 double dpt2 = (p*p*sintheta)*(p*p*sintheta)*dqovp*dqovp + (p*costheta)*(p*costheta)*dtheta*dtheta - 2*(p*p*sintheta)*(p*costheta)*covthetaOvP;
1088
1089 if ( dpt2>0 ) dpT = std::sqrt( dpt2 );
1090
1091 // Check number of hits
1092 // NB: a spacepoint is two offline "hits", so a pixel spacepoint is really
1093 // 2 "hits" and an offline SCT "hit" is really a 1D cluster, so two intersetcting
1094 // stereo clusters making a spacepoint are two "hits"
1095
1096 uint8_t sum_nBlayerHits = 0;
1097 track->summaryValue( sum_nBlayerHits, xAOD::numberOfInnermostPixelLayerHits);
1098 int nBlayerHits = 2*sum_nBlayerHits;
1099
1100 uint8_t sum_nPixelHits = 0;
1101 track->summaryValue( sum_nPixelHits, xAOD::numberOfPixelHits);
1102 int nPixelHits = 2*sum_nPixelHits;
1103
1104 uint8_t sum_nSctHits = 0;
1105 track->summaryValue( sum_nSctHits, xAOD::numberOfSCTHits);
1106 int nSctHits = sum_nSctHits;
1107
1108 uint8_t sum_nStrawHits = 0;
1109 track->summaryValue( sum_nStrawHits, xAOD::numberOfTRTHits);
1110 int nStrawHits = sum_nStrawHits;
1111
1112 uint8_t sum_nTrtHits = 0;
1113 track->summaryValue( sum_nTrtHits, xAOD::numberOfTRTHighThresholdHits);
1114 int nTrtHits = sum_nTrtHits;
1115
1116
1117 uint8_t sum_expectBL = 0;
1118 track->summaryValue( sum_expectBL, xAOD::expectInnermostPixelLayerHit);
1119 bool expectBL = ( sum_expectBL ? true : false );
1120
1122
1123 uint8_t sum_sctholes = 0;
1124 track->summaryValue( sum_sctholes, xAOD::numberOfSCTHoles);
1125
1126 uint8_t sum_pixholes = 0;
1127 track->summaryValue( sum_pixholes, xAOD::numberOfPixelHoles);
1128
1132
1133 nSctHits += 1000*sum_sctholes;
1134 nPixelHits += 1000*sum_pixholes;
1135
1137 int nSiHits = nPixelHits + nSctHits;
1138
1140
1141 double chi2 = track->chiSquared();
1142 double dof = track->numberDoF();
1143
1144 unsigned long id = (unsigned long)track;
1145
1146 unsigned bitmap = track->hitPattern();
1147
1148
1149
1150 double xbeam = track->vx();
1151 double ybeam = track->vy();
1152 double zbeam = track->vz();
1153
1154 if ( xbeam!=getBeamX() || ybeam!=getBeamY() || zbeam!=getBeamZ() ) setBeamline( xbeam, ybeam, zbeam );
1155
1156 int trackAuthor = 0;
1157
1158 int fitter = track->trackFitter();
1159 std::bitset<xAOD::NumberOfTrackRecoInfo> patternrec = track->patternRecoInfo();
1160
1161 //int icount = 0;<- never used if section below is commented
1162 for ( unsigned ipr=patternrec.size() ; ipr-- ; ) {
1163 if ( patternrec[ipr] ) {
1164 //icount++; <- never used if section below is commented
1165 trackAuthor |= (ipr >> 16);
1166 // static bool first = true;
1167 // if ( first && icount>1 ) {
1168 // std::cerr << "more than one pattern rec strategy " << ipr << "\t(suppressing further output)" << std::endl;
1169 // first = false;
1170 // }
1171 }
1172 }
1173
1174 trackAuthor |= fitter;
1175
1176 // if ( fitter>0 && fitter<Trk::TrackInfo::NumberOfTrackFitters ) {
1177 // if ( dumpinfo.find("TRTStandalone")!=std::string::npos) trackAuthor = 2;
1178 // else if ( dumpinfo.find("TRTSeededTrackFinder")!=std::string::npos) trackAuthor = 1;
1179 // else trackAuthor = 0;
1180 // }
1181
1182#if 0
1183 std::cout << "\t\t\tSUTT TP track"
1184 << "\teta=" << eta // << " +- " << (*trackitr)->params()->deta()
1185 << "\tphi=" << phi // << " +- " << (*trackitr)->params()->dphi()
1186 << "\tz0=" << z0
1187 << "\tpT=" << pT // << "\t( " << 1/qoverp << ")"
1188 << "\td0=" << d0
1189 << "\tNsi=" << nSiHits
1190 // << "\tNtrt=" << nTrtHits
1191 // << "\tNstr=" << nStrawHits
1192 << "\tfitter=" << fitter
1193 << "\tauthor=" << trackAuthor
1194 << "\tVTX x " << track->vx() << "\ty " << track->vy() << "\tz " << track->vz()
1195 << std::endl;
1196#endif
1197
1198 // Create and save Track
1199
1200 TIDA::Track* t = new TIDA::Track( eta, phi, z0, d0, pT, chi2, dof,
1201 deta, dphi, dz0, dd0, dpT,
1202 nBlayerHits, nPixelHits, nSctHits, nSiHits,
1203 nStrawHits, nTrtHits, bitmap, 0,
1204 trackAuthor, false, -1, -1,
1205 expectBL, id) ;
1206
1207 // std::cout << "SUTT TP track " << *t << "\t0x" << std::hex << bitmap << std::dec << std::endl;
1208
1209 if ( !addTrack( t ) ){
1210 delete t;
1211 return false;
1212 }
1213 return true;
1214
1215 }
1216 return false;
1217
1218
1219}
void setBeamline(double x, double y, double z=0)
double getBeamY() const
double getBeamX() const
double getBeamZ() const
float z0() const
Returns the parameter.
float theta() const
Returns the parameter, which has range 0 to .
const ParametersCovMatrix_t definingParametersCovMatrix() const
Returns the 5x5 symmetric matrix containing the defining parameters covariance matrix.
float vz() const
The z origin for the parameters.
float d0() const
Returns the parameter.
float qOverP() const
Returns the parameter.
virtual double pt() const override final
The transverse momentum ( ) of the particle.
virtual double eta() const override final
The pseudorapidity ( ) of the particle.
float phi0() const
Returns the parameter, which has range to .
TrackParticle_v1 TrackParticle
Reference the current persistent version:
@ expectInnermostPixelLayerHit
Do we expect a 0th-layer barrel hit for this track?
@ numberOfPixelHoles
number of pixel layers on track with absence of hits [unit8_t].
@ numberOfTRTHits
number of TRT hits [unit8_t].
@ numberOfSCTHits
number of hits in SCT [unit8_t].
@ numberOfInnermostPixelLayerHits
these are the hits in the 0th pixel barrel layer
@ numberOfPixelHits
these are the pixel hits, including the b-layer [unit8_t].
@ numberOfTRTHighThresholdHits
number of TRT hits which pass the high threshold (only xenon counted) [unit8_t].
@ numberOfSCTHoles
number of SCT holes [unit8_t].

◆ selectTrack() [7/8]

bool TrigTrackSelector::selectTrack ( const xAOD::TruthParticle * track,
double x0 = 0,
double y0 = 0 )

lazy just to avoid a find-replace of measPer to track

avoid default (unset) TruthParticle charge

only use charged tracks

need to calculate the origin, and the beamline, and the d0 and z0 with respect to the beamline leave this in until we have checked whether everything is implemented correctly

need to calculate d0 and z0 correctly.

these are the d0 and z at the point of closest approach to x0, y0, the event "beamline", which is the best that we can do for the moment

the is our new "final state" requirement the inner and outer radii are in some sense arbitrary - these correspond to an envelope around the pixel detector, so the track must pass through the entire pixel detector NB: In order to ensure you don't miss any tracks they really need to be the same ie if a track brems in your "volume" then you will miss that track, and also the resulting track, even if it is a high et track

was hardcoded as 47 - now is set from the constructor

get the total number of holes as well

useful debug info - leave in

Definition at line 540 of file TrigTrackSelector.cxx.

540 {
541 if ( track ) {
542
543 if (!MC::isStable(track) ) return false;
544
546 const xAOD::TruthParticle* measPer = track;
547
548 double pT = measPer->pt();
549 double eta = measPer->eta();
550 double phi = measPer->phi();
551
552 // AAARCH!!!!! the TrackParticle pT is NOT SIGNED!!!! ( I ask you! )
553 if ( measPer->charge()<0 && pT>0 ) pT *= -1;
554 double q = track->charge();
555
556 static const particleType ptype;
557
559 if ( q==-999 ) q = ptype.charge( track->pdgId() );
560
562 if ( q==0 ) return 0;
563
567 // double xbeam = getBeamX(); // track->vx();
568 // double ybeam = getBeamY(); // track->vy();
569 // double zbeam = getBeamZ(); // track->vz();
570
571 if ( !track->hasProdVtx() ) return false;
572
574
575 double xp[3] = { measPer->prodVtx()->x(), measPer->prodVtx()->y(), measPer->prodVtx()->z() };
576 double xb[3] = { xp[0]-x0, xp[1]-y0, measPer->prodVtx()->z() };
577 double xd[3] = { 0, 0, 0 };
578
579 if ( track->hasDecayVtx() ) {
580 xd[0] = track->decayVtx()->x();
581 xd[1] = track->decayVtx()->y();
582 xd[2] = track->decayVtx()->z();
583 }
584
585 double rp = std::sqrt( xp[0]*xp[0] + xp[1]*xp[1] );
586 double rd = std::sqrt( xd[0]*xd[0] + xd[1]*xd[1] );
587
590 double theta = 2*std::atan( std::exp( -eta ) );
591 double z0 = xb[2] - (xb[0]*std::cos(phi) + xb[1]*std::sin(phi))/std::tan(theta);
592 double d0 = xb[1]*std::cos(phi) - xb[0]*std::sin(phi);
593
594 bool final_state = false;
595
607 const double inner_radius = m_radius;
608 const double outer_radius = m_radius;
609
610 if ( ( track->hasProdVtx() && rp<=inner_radius ) &&
611 ( !track->hasDecayVtx() || rd>outer_radius ) ) final_state = true;
612
613 if ( !final_state ) return false;
614
615 double deta = 0;
616 double dphi = 0;
617 double dz0 = 0;
618 double dd0 = 0;
619
620 double dpT = 0;
621
622 int nBlayerHits = 0;
623 int nPixelHits = 0;
624 int nSctHits = 0;
625 int nStrawHits = 0;
626 int nTrtHits = 0;
627
628 double chi2 = 0;
629 double dof = 0;
630
631 bool expectBL = false;
632
633 nSctHits += 0;
634 nPixelHits += 0;
635
637 int nSiHits = 0;
638
639 unsigned long id = (unsigned long)track;
640
641 unsigned bitmap = 0;
642
643 int trackAuthor = track->pdgId();
644 int uniqueID = HepMC::uniqueID(track);
645
646#if 0
647 std::cout << "\t\t\tSUTT TP track"
648 << "\teta=" << eta
649 << "\tphi=" << phi
650 << "\tz0=" << z0
651 << "\tpT=" << pT
652 << "\td0=" << d0
653 << "\tauthor=" << trackAuthor
654 << "\tVTX x " << xp[0]<< "\ty " << xp[1] << "\tz " << xp[2]
655 << std::endl;
656#endif
657
658 // Create and save Track
659
660 TIDA::Track* t = new TIDA::Track( eta, phi, z0, d0, pT, chi2, dof,
661 deta, dphi, dz0, dd0, dpT,
662 nBlayerHits, nPixelHits, nSctHits, nSiHits,
663 nStrawHits, nTrtHits, bitmap, 0,
664 trackAuthor, false, uniqueID, -1,
665 expectBL, id) ;
666
668 // std::cout << "SUTT TP track " << *t << "\t0x" << std::hex << bitmap << std::dec << std::endl;
669
670 // addTrack applies additional cuts using the Filter
671 if ( !addTrack( t ) ){
672 delete t;
673 return false;
674 }
675 }
676 return false;
677
678}
virtual double pt() const override final
The transverse momentum ( ) of the particle.
const TruthVertex_v1 * prodVtx() const
The production vertex of this particle.
double charge() const
Physical charge.
virtual double eta() const override final
The pseudorapidity ( ) of the particle.
virtual double phi() const override final
The azimuthal angle ( ) of the particle.
float z() const
Vertex longitudinal distance along the beam line form the origin.
float y() const
Vertex y displacement.
float x() const
Vertex x displacement.

◆ selectTrack() [8/8]

bool TrigTrackSelector::selectTrack ( HepMC::ConstGenParticlePtr track)

not a "final state" particle

set this so can use it as the identifier - don't forget to reset!!

Definition at line 500 of file TrigTrackSelector.cxx.

500 {
501
503 if ( !MC::isStable(track) ) return false;
504
506//AV Using memory to get some value is not a good idea. This is not a repruducible/portable way, but I leave it as is.
507 m_id = (unsigned long)(track.get());
508 bool sel;
509 sel = selectTrack( TruthParticle(track) );
510 m_id = 0;
511
512 return sel;
513
514}

◆ selectTracks() [1/8]

void TrigTrackSelector::selectTracks ( const Rec::TrackParticleContainer * trigtracks)

Definition at line 340 of file TrigTrackSelector.cxx.

340 {
341
342 // std::cout << "\t\t\tSUTT \tTrackParticleContainer->size() = " << trigtracks->size() << std::endl;
343
344 Rec::TrackParticleContainer::const_iterator trackitr = trigtracks->begin();
345 Rec::TrackParticleContainer::const_iterator trackend = trigtracks->end();
346
347 while ( trackitr!=trackend ) {
348
349 selectTrack( *trackitr );
350
351 ++trackitr;
352
353 } // loop over tracks
354
355}
DataModel_detail::const_iterator< DataVector > const_iterator
Definition DataVector.h:838
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.

◆ selectTracks() [2/8]

void TrigTrackSelector::selectTracks ( const TrackCollection * trigtracks)

Definition at line 1021 of file TrigTrackSelector.cxx.

1021 {
1022
1023 // std::cout << "\t\t\tSUTT \tTrackContainer->size() = " << trigtracks->size() << std::endl;
1024
1025 TrackCollection::const_iterator trackitr = trigtracks->begin();
1026 TrackCollection::const_iterator trackend = trigtracks->end();
1027
1028 while ( trackitr!=trackend ) {
1029 selectTrack( *trackitr );
1030 ++trackitr;
1031 } // loop over tracks
1032
1033}

◆ selectTracks() [3/8]

void TrigTrackSelector::selectTracks ( const TrackParticleLinks_t & tracks)

Definition at line 1246 of file TrigTrackSelector.cxx.

1246 {
1247 for( const auto& track : tracks ) selectTrack( *track );
1248}

◆ selectTracks() [4/8]

void TrigTrackSelector::selectTracks ( const TrigInDetTrackCollection * trigtracks,
const TrigInDetTrackTruthMap * truthMap = 0 )

Definition at line 188 of file TrigTrackSelector.cxx.

188 {
189 // do the track extraction stuff here....
190 TrigInDetTrackCollection::const_iterator trackitr = trigtracks->begin();
191 TrigInDetTrackCollection::const_iterator trackend = trigtracks->end();
192 while ( trackitr!=trackend ) {
193 selectTrack( *trackitr, truthMap );
194 ++trackitr;
195 }
196}

◆ selectTracks() [5/8]

void TrigTrackSelector::selectTracks ( const TruthParticleContainer * truthtracks)

Definition at line 360 of file TrigTrackSelector.cxx.

360 {
361 // std::cout << "\t\t\tSUTT \tTrackParticleContainer->size() = " << trigtracks->size() << std::endl;
362
363 TruthParticleContainer::const_iterator trackitr = truthtracks->begin();
364 TruthParticleContainer::const_iterator trackend = truthtracks->end();
365
366 while ( trackitr!=trackend ) {
367
368 selectTrack( *trackitr );
369
370 ++trackitr;
371
372 } // loop over tracks
373
374}

◆ selectTracks() [6/8]

void TrigTrackSelector::selectTracks ( const xAOD::TrackParticleContainer * tracks,
void * = 0 )

Definition at line 1222 of file TrigTrackSelector.cxx.

1222 {
1223 // std::cout << "\t\t\tSUTT \tTrackContainer->size() = " << trigtracks->size() << std::endl;
1226 while ( trackitr!=trackend ) {
1227 selectTrack( *trackitr );
1228 ++trackitr;
1229 } // loop over tracks
1230}

◆ selectTracks() [7/8]

void TrigTrackSelector::selectTracks ( const xAOD::TruthParticleContainer * truthtracks)

get truth beamline

fix default (unset) TruthParticle charge

not just yet - save for later ... else ( gotPdgId && m_selectParentPdgIds.size()!=0 ) gotParentPdgId = fromAncestor(m_selectParentPdgIds, (*trackitr))!=nullptr;

Definition at line 455 of file TrigTrackSelector.cxx.

455 {
456
457 xAOD::TruthParticleContainer::const_iterator trackitr = truthtracks->begin();
458 xAOD::TruthParticleContainer::const_iterator trackend = truthtracks->end();
459
461 double x0 = 0;
462 double y0 = 0;
463
464 truthBeamline( truthtracks, x0, y0 );
465
466
467 for ( ; trackitr!=trackend; ++trackitr) {
468
469
470 // Only select charged final state particles
471 double q = (*trackitr)->charge();
472
474 static const particleType ptype;
475 if ( q==-999 ) q = ptype.charge( (*trackitr)->pdgId() );
476
477 if (q == 0 || !MC::isStable(*trackitr) ) continue;
478
479 // If looking for tau parents, don't select mu or e children
480
481 // select based on the pdg of final state particle
482 bool gotPdgId = true;
483 if (m_selectPdgId!=0) gotPdgId = (*trackitr)->absPdgId()==m_selectPdgId;
484
485 // select based on the pdg of the parent or ancestor
486 bool gotParentPdgId = true;
487 if ( gotPdgId && m_selectParentPdgId!=0 ) gotParentPdgId = fromAncestor(m_selectParentPdgId, (*trackitr))!=nullptr;
490
491 if ( gotParentPdgId && gotPdgId ) selectTrack( *trackitr, x0, y0);
492
493 } // loop over tracks
494
495}
void truthBeamline(const xAOD::TruthParticleContainer *truthtracks, double &x0, double &y0)
extract all the tracks from a xAOD::TruthParticle collection and histogram the x and y production coo...

◆ selectTracks() [8/8]

void TrigTrackSelector::selectTracks ( xAOD::TrackParticleContainer::const_iterator trackitr,
xAOD::TrackParticleContainer::const_iterator trackend,
void * = 0 )

MT selector access.

will need this printout during debugging, so leave commented until all the feature access has been properly debugged

Definition at line 1234 of file TrigTrackSelector.cxx.

1235 {
1238 // std::cout << "\t\t\tSUTT \tTrackContainer->size() = " << trigtracks->size() << std::endl;
1239 while ( trackitr!=trackend ) {
1240 selectTrack( *trackitr );
1241 ++trackitr;
1242 } // loop over tracks
1243}

◆ setBeamline()

void TrigTrackSelector::setBeamline ( double x,
double y,
double z = 0 )
inline

Definition at line 94 of file TrigTrackSelector.h.

94{ m_xBeam = x; m_yBeam = y; m_zBeam=z; }
#define y
#define x
#define z

◆ size()

unsigned TrackSelector::size ( ) const
inlineinherited

◆ tracks() [1/2]

const std::vector< TIDA::Track * > & TrackSelector::tracks ( ) const
inlineinherited

◆ tracks() [2/2]

std::vector< TIDA::Track * > TrackSelector::tracks ( TrackFilter * selector) const
inlineinherited

Definition at line 55 of file Trigger/TrigAnalysis/TrigInDetAnalysis/TrigInDetAnalysis/TrackSelector.h.

55 {
56 if ( selector==0 ) return m_tracks;
57 std::vector<TIDA::Track*> t;
58 for ( int i=m_tracks.size() ; i-- ; ) if ( selector->select(m_tracks[i]) ) t.push_back(m_tracks[i]);
59 return t;
60 }

◆ truthBeamline()

void TrigTrackSelector::truthBeamline ( const xAOD::TruthParticleContainer * truthtracks,
double & x0,
double & y0 )

extract all the tracks from a xAOD::TruthParticle collection and histogram the x and y production coordinates to determine the event "beamline" position

histograms and book keeoing

positions

numbers of tracks

fill histograms ...

get track production vertex

add to the correct bins

calculate the most populous bin in x and y

require more than 1 particle for it to be classed a "vertex" therefore, for single particle Monte Carlo, this will not be updated and (0,0) will still be correctly used

Definition at line 381 of file TrigTrackSelector.cxx.

381 {
382
383 x0 = 0;
384 y0 = 0;
385
387
388 int Nx = 300;
389 int Ny = 300;
390
392 std::vector<double> xpos(Nx,0);
393 std::vector<double> ypos(Ny,0);
394
396 std::vector<int> xn(Nx,0);
397 std::vector<int> yn(Ny,0);
398
399 int xoffset = Nx/2;;
400 int yoffset = Ny/2;
401
402 double deltax = 3.0/Nx;
403 double deltay = 3.0/Ny;
404
406
407 xAOD::TruthParticleContainer::const_iterator trackitr = truthtracks->begin();
408 xAOD::TruthParticleContainer::const_iterator trackend = truthtracks->end();
409
410 for ( ; trackitr!=trackend ; ++trackitr ) {
411
412 const xAOD::TruthParticle* track = (*trackitr);
413
414 if ( !MC::isStable(track) || !track->hasProdVtx() ) continue;
415
417
418 double xp[3] = { track->prodVtx()->x(), track->prodVtx()->y(), track->prodVtx()->z() };
419
421
422 int ix = xp[0]/deltax + xoffset;
423 int iy = xp[1]/deltay + yoffset;
424
425 if ( ix<0 || ix>=Nx || iy<0 || iy>=Nx ) continue;
426
427 xpos[ix] += xp[0];
428 ypos[iy] += xp[1];
429
430 xn[ix]++;
431 yn[iy]++;
432
433 } // loop over tracks
434
436
437 int imx = 0;
438 int imy = 0;
439
440 for ( size_t i=0 ; i<xpos.size() ; i++ ) {
441 if ( xn[i]>xn[imx] ) imx = i;
442 if ( yn[i]>yn[imy] ) imy = i;
443 }
444
448 if ( xn[imx]>1 ) x0 = xpos[imx]/xn[imx];
449 if ( yn[imy]>1 ) y0 = ypos[imy]/yn[imy];
450
451}

Member Data Documentation

◆ m_correctTrkTracks

bool TrigTrackSelector::m_correctTrkTracks
private

Definition at line 198 of file TrigTrackSelector.h.

◆ m_id

unsigned long TrigTrackSelector::m_id
private

Definition at line 192 of file TrigTrackSelector.h.

◆ m_radius

double TrigTrackSelector::m_radius
private

Definition at line 200 of file TrigTrackSelector.h.

◆ m_selector

TrackFilter* TrackSelector::m_selector
protectedinherited

◆ m_selectParentPdgId

int TrigTrackSelector::m_selectParentPdgId
private

Definition at line 203 of file TrigTrackSelector.h.

◆ m_selectPdgId

int TrigTrackSelector::m_selectPdgId
private

Definition at line 202 of file TrigTrackSelector.h.

◆ m_tracks

std::vector<TIDA::Track*> TrackSelector::m_tracks
protectedinherited

◆ m_xBeam

double TrigTrackSelector::m_xBeam
private

Definition at line 194 of file TrigTrackSelector.h.

◆ m_yBeam

double TrigTrackSelector::m_yBeam
private

Definition at line 195 of file TrigTrackSelector.h.

◆ m_zBeam

double TrigTrackSelector::m_zBeam
private

Definition at line 196 of file TrigTrackSelector.h.

◆ s_default_radius

const double TrigTrackSelector::s_default_radius = 47
staticprivate

NB: This was 47 for Run 2, but with the addition of the IBL it should be 32 It was kept at 47 for all Run 2 and migration to MT, but for Run 3 we really want it changed to be 32.

Definition at line 205 of file TrigTrackSelector.h.


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