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

offline and EF 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 ()
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 Rec::TrackParticle *track)
 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 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

offline and EF

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

Definition at line 53 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 65 of file TrigTrackSelector.h.

65: 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 67 of file TrigTrackSelector.h.

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

◆ TrigTrackSelector() [3/6]

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

Definition at line 69 of file TrigTrackSelector.h.

69: 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 74 of file TrigTrackSelector.h.

74 :
75 TrigTrackSelector( tm.begin(), tm.end(), selector, radius, selectPdgId, selectParentPdgId ) {
76 }

◆ 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 79 of file TrigTrackSelector.h.

79 :
80 TrigTrackSelector( selector, radius, selectPdgId, selectParentPdgId ) {
81 selectTracks( tbegin, tend );
82 }
void selectTracks(const Rec::TrackParticleContainer *trigtracks)

◆ ~TrigTrackSelector()

TrigTrackSelector::~TrigTrackSelector ( )
inline

Definition at line 85 of file TrigTrackSelector.h.

85{ 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 34 of file Trigger/TrigAnalysis/TrigInDetAnalysis/TrigInDetAnalysis/TrackSelector.h.

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

◆ addTracks()

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

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

47 {
48 for ( size_t i=0 ; i<t.size() ; i++ ) addTrack( t[i], f );
49 }
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 96 of file TrigTrackSelector.h.

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

◆ 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 1173 of file TrigTrackSelector.cxx.

1175 {
1176
1178
1179 // if ( m_first ) {
1180 // if ( m_xBeam==0 && m_yBeam==0 ) {
1181 // std::cerr << "TrigTrackSelector::correctToBeamline() WARNING -- Beamline set to (0,0) -- WARNING" << std::endl;
1182 // }
1183 // else {
1184 // std::cout << "TrigTrackSelector::correctToBeamline() Beamline set to " << m_xBeam << " " << m_yBeam << std::endl;
1185 // }
1186 // m_first = false;
1187 // }
1188
1189
1190 // double theta = 2*std::atan( exp( (-1)*eta ) );
1191 double z0t = z0 + ((std::cos(phi)*m_xBeam + std::sin(phi)*m_yBeam)/std::tan(theta));
1192 double a0t = d0 + std::sin(phi)*m_xBeam - std::cos(phi)*m_yBeam;
1193
1195 double dz0t = dz0 + ((std::cos(phi)*m_xBeam + std::sin(phi)*m_yBeam)/std::tan(theta));
1196 double da0t = dd0 + std::sin(phi)*m_xBeam - std::cos(phi)*m_yBeam;
1197
1198 z0 = z0t;
1199 d0 = a0t;
1200
1201 dz0 = dz0t;
1202 dd0 = da0t;
1203}
Scalar phi() const
phi method
Scalar theta() const
theta method

◆ correctTracks()

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

Definition at line 94 of file TrigTrackSelector.h.

◆ default_radius()

double TrigTrackSelector::default_radius ( )
inlinestatic

Definition at line 176 of file TrigTrackSelector.h.

176{ 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 68 of file Trigger/TrigAnalysis/TrigInDetAnalysis/TrigInDetAnalysis/TrackSelector.h.

68 {
69 m_tracks.erase( std::remove( m_tracks.begin(), m_tracks.end(), t ), m_tracks.end() );
70 }
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 90 of file TrigTrackSelector.h.

90{ return m_xBeam; }

◆ getBeamY()

double TrigTrackSelector::getBeamY ( ) const
inline

Definition at line 91 of file TrigTrackSelector.h.

91{ return m_yBeam; }

◆ getBeamZ()

double TrigTrackSelector::getBeamZ ( ) const
inline

Definition at line 92 of file TrigTrackSelector.h.

92{ 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 611 of file TrigTrackSelector.cxx.

611 {
612
613 if ( track==0 ) return 0;
614 if ( !MC::isStable(track)) return 0;
615
616
617 double phi = track->phi();
618 double eta = track->eta();
619
623 double xp[3] = { 0, 0, 0 };
624
625 if ( track->genParticle()->production_vertex() ) {
626 xp[0] = track->genParticle()->production_vertex()->position().x();
627 xp[1] = track->genParticle()->production_vertex()->position().y();
628 xp[2] = track->genParticle()->production_vertex()->position().z();
629 }
630
631 // CHANGED BY JK - z0 with respect to (0,0)
632 // double z0 = xp[2];
633 double theta = 2*std::atan( exp( (-1)*eta ) );
634 double z0 = xp[2] - (xp[0]*std::cos(phi) + xp[1]*std::sin(phi))/std::tan(theta);
635
636 double xd[3] = { 0, 0, 0 };
637
638 if ( track->genParticle()->end_vertex() ) {
639 xd[0] = track->genParticle()->end_vertex()->position().x();
640 xd[1] = track->genParticle()->end_vertex()->position().y();
641 xd[2] = track->genParticle()->end_vertex()->position().z();
642 }
643
644 double rp = std::sqrt( xp[0]*xp[0] + xp[1]*xp[1] );
645 double rd = std::sqrt( xd[0]*xd[0] + xd[1]*xd[1] );
646
647
648 bool final_state = false;
649
661 const double inner_radius = m_radius;
662 const double outer_radius = m_radius;
663 if ( ( track->genParticle()->production_vertex() && rp<=inner_radius ) &&
664 ( track->genParticle()->end_vertex()==0 || rd>outer_radius ) ) final_state = true;
665
666
667 if ( !final_state ) return 0;
668
679
680 double q = track->charge();
681
682 static const particleType ptype;
683
685 if ( q==-999 ) q = ptype.charge( track->pdgId() );
686
688 if ( q==0 ) return 0;
689
690 double pT = q*track->pt();
691
692
693 double d0 = 0;
694
699
701
702
703 // CHANGED BY JK - d0 with respect to (0,0)
704 // d0 = q*rp*std::sin(phi);
705 d0 = xp[1]*std::cos(phi) - xp[0]*std::sin(phi);
706
707
709
710 double dz0 = 0;
711 double dd0 = 0;
712
713 correctToBeamline( z0, dz0, d0, dd0, theta, phi );
714
715
716
718
720 int author = track->pdgId();
721 int uniqueID = HepMC::uniqueID(track);
722
723
724 unsigned long id = (unsigned long)track;
725 if ( tid!=0 ) id = tid;
726
730
731
733
734 // std::cout << "\t\t\tSUTT Truth track"
735 // << "\teta=" << eta // << " +- " << (*trackitr)->params()->deta()
736 // << "\tphi=" << phi // << " +- " << (*trackitr)->params()->dphi()
737 // << "\tz0=" << z0
738 // << "\tpT=" << pT // << "\t( " << 1/qoverp << ")"
739 // << "\td0=" << d0
740 // << "\tauthor=" << author
741 // << std::endl;
742
743
744
745 TIDA::Track* t = new TIDA::Track(eta, phi, z0, d0, pT, 0, 0,
746 0, 0, 0, 0, 0,
747 0, 0, 0, 0,
748 0, 0, 0, 0,
749 author, false, uniqueID, -1,
750 false,
751 id ) ;
752
753 return t;
754
755}
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 603 of file TrigTrackSelector.cxx.

603 {
604//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.
605 unsigned long id = (unsigned long)(track.get());
606 TruthParticle t = TruthParticle(track);
607 return makeTrack( &t, id );
608}
TIDA::Track * makeTrack(HepMC::ConstGenParticlePtr track)
TruthParticle_v1 TruthParticle
Typedef to implementation.

◆ selectTrack() [1/7]

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

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

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 119 of file TrigTrackSelector.cxx.

119 {
120
121 // do the track extraction stuff here....
122
123 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 };
124
125 if ( track ) {
126
127#ifdef TRKPARAMETERS_MEASUREDPERIGEE_H
128 const Trk::MeasuredPerigee* measPer = track->measuredPerigee();
129#else
130 const Trk::Perigee* measPer = track->measuredPerigee();
131#endif
132 // CLHEP::HepVector perigeeParams = measPer->parameters();
133
134 double pT = measPer->pT();
135 double eta = measPer->eta();
136 double phi = measPer->parameters()[Trk::phi0];
137 double z0 = measPer->parameters()[Trk::z0] + m_zBeam;
138 double d0 = measPer->parameters()[Trk::d0];
139
140 double theta = measPer->parameters()[Trk::theta];
141 double p = 1/measPer->parameters()[Trk::qOverP];
142
143 // AAARCH!!!!! the TrackParticle pT is NOT SIGNED!!!! ( I ask you! )
144 if ( measPer->parameters()[Trk::qOverP]<0 && pT>0 ) pT *= -1;
145
146#ifdef TRKPARAMETERS_MEASUREDPERIGEE_H
147 const Trk::ErrorMatrix err = measPer->localErrorMatrix();
148 double dtheta = err.error(Trk::theta);
149 double dqovp = err.error(Trk::qOverP);
150 double covthetaOvP = err.covValue(Trk::qOverP,Trk::theta);
151#else
152 double dtheta = std::sqrt((*measPer->covariance())(Trk::theta,Trk::theta));
153 double dqovp = std::sqrt((*measPer->covariance())(Trk::qOverP,Trk::qOverP));
154 double covthetaOvP = (*measPer->covariance())(Trk::qOverP,Trk::theta);
155#endif
156
157
158 double deta = 0.5*dtheta/(std::cos(0.5*theta)*std::cos(0.5*theta)*std::tan(0.5*theta));
159
160#ifdef TRKPARAMETERS_MEASUREDPERIGEE_H
161 double dphi = err.error(Trk::phi0);
162 double dz0 = err.error(Trk::z0);
163 double dd0 = err.error(Trk::d0);
164#else
165 double dphi = std::sqrt((*measPer->covariance())(Trk::phi0,Trk::phi0));
166 double dz0 = std::sqrt((*measPer->covariance())(Trk::z0,Trk::z0));
167 double dd0 = std::sqrt((*measPer->covariance())(Trk::d0,Trk::d0));
168#endif
169
170 double dpT = 0;
171
172
173 double sintheta = std::sin(theta);
174 double costheta = std::cos(theta);
175 double dpt2 = (p*p*sintheta)*(p*p*sintheta)*dqovp*dqovp + (p*costheta)*(p*costheta)*dtheta*dtheta - 2*(p*p*sintheta)*(p*costheta)*covthetaOvP;
176
177 if ( dpt2>0 ) dpT = std::sqrt( dpt2 );
178
179 // Check number of hits
180 // NB: a spacepoint is two offline "hits", so a pixel spacepoint is really
181 // 2 "hits" and an offline SCT "hit" is really a 1D cluster, so two intersecting
182 // stereo clusters making a spacepoint are two "hits"
183 const Trk::TrackSummary *summary = track->trackSummary();
184 int nBlayerHits = 2*summary->get(Trk::numberOfBLayerHits);
186 int nSctHits = summary->get(Trk::numberOfSCTHits);
187 int nStrawHits = summary->get(Trk::numberOfTRTHits);
188 int nTrHits = summary->get(Trk::numberOfTRTHighThresholdHits);
189
190 int nSiHits = nPixelHits + nSctHits;
191 bool expectBL = false; // Not stored for Rec::TrackParticle
192
193 const Trk::FitQuality *quality = track->fitQuality();
194 double chi2 = quality->chiSquared();
195 double dof = quality->numberDoF();
196
197 unsigned bitmap = 0;
198
199
200 unsigned long id = (unsigned long)track;
201
202 for ( int ih=0 ; ih<20 ; ih++ ) {
203 if ( summary->isHit(Trk::DetectorType(ih)) ) bitmap |= ( 1<<hpmap[ih] );
204 }
205
208
209 // std::cout << "fetching author info :" << track->info().trackFitter() << ":"
210 // << track->info().dumpInfo() << ": bm 0x" << std::hex << bitmap << std::dec << std::endl;
211
212 int fitter = track->info().trackFitter();
213 std::string dumpinfo = track->info().dumpInfo();
214
215 int trackAuthor = -1;
216 if ( fitter>0 && fitter<Trk::TrackInfo::NumberOfTrackFitters ) {
217 if ( dumpinfo.find("TRTStandalone")!=std::string::npos) trackAuthor = 2;
218 else if ( dumpinfo.find("TRTSeededTrackFinder")!=std::string::npos) trackAuthor = 1;
219 else trackAuthor = 0;
220 }
221
222#if 0
223 std::cout << "\t\t\tSUTT TP track"
224 << "\teta=" << eta // << " +- " << (*trackitr)->params()->deta()
225 << "\tphi=" << phi // << " +- " << (*trackitr)->params()->dphi()
226 << "\tz0=" << z0
227 << "\tpT=" << pT // << "\t( " << 1/qoverp << ")"
228 << "\td0=" << d0
229 << "\tNsi=" << nSiHits
230 << "\tNtrt=" << nTrHits
231 << "\tNstr=" << nStrawHits
232 << "\tauthor=" << trackAuthor
233 << std::endl;
234#endif
235
236 // Create and save Track
237
238 TIDA::Track* t = new TIDA::Track(eta, phi, z0, d0, pT, chi2, dof,
239 deta, dphi, dz0, dd0, dpT,
240 nBlayerHits, nPixelHits, nSctHits, nSiHits,
241 nStrawHits, nTrHits, bitmap, 0,
242 trackAuthor, false, -1, -1,
243 expectBL, id) ;
244
245 // std::cout << "SUTT TP track " << *t << "\t0x" << std::hex << bitmap << std::dec << std::endl;
246
247 if ( !addTrack( t ) ){
248 delete t;
249 return false;
250 }
251 return true;
252
253 }
254 return false;
255}
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/7]

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 760 of file TrigTrackSelector.cxx.

760 {
761
762 // do the track extraction stuff here....
763
764 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 };
765 // std::cout << __FILE__<< " " <<__LINE__<<std::endl;
766
767 if ( track ) {
768
769 // const Trk::Perigee* startPerigee = track->perigeeParameters();
770
771#ifdef TRKPARAMETERS_MEASUREDPERIGEE_H
772 const Trk::MeasuredPerigee* startPerigee = dynamic_cast<const Trk::MeasuredPerigee*>(track->perigeeParameters());
773 // const Trk::MeasuredPerigee* measPer = startPerigee; // just out of laziness
774#else
775 const Trk::Perigee* startPerigee = track->perigeeParameters();
776 const Trk::Perigee* measPer = startPerigee; // just out of laziness
777#endif
778
779
780 // CLHEP::HepVector perigeeParams = measPer->parameters();
781 // double pT = measPer->pT();
782 // double eta = measPer->eta();
783 // double phi = perigeeParams[Trk::phi0];
784 // double z0 = perigeeParams[Trk::z0];
785 // double d0 = perigeeParams[Trk::d0];
786 // // AAARCH!!!!! the TrackParticle pT is NOT SIGNED!!!! ( I ask you! )
787 // if ( perigeeParams[Trk::qOverP]<0 ) pT *= -1;
788 // std::cout <<pT1<<" pt1vspT "<<pT<<std::endl;
789
790 if (startPerigee){
791
792 double theta = startPerigee->parameters()[Trk::theta];
793 double p = 1/startPerigee->parameters()[Trk::qOverP];
794 double qOverPt = startPerigee->parameters()[Trk::qOverP]/std::sin(theta);
795 double charge = startPerigee->charge();
796 double eta = startPerigee->eta();
797 double phi = startPerigee->parameters()[Trk::phi0];
798 double z0 = startPerigee->parameters()[Trk::z0];
799 double d0 = startPerigee->parameters()[Trk::d0];
800 // double pT = (1./qOverPt)*(charge);
801 double pT = (1./qOverPt); // always use signed PT
802
803 if ( charge<0 && pT>0 ) pT *= -1;
804 if ( charge<0 && p>0 ) p *= -1;
805
806
807
808#ifdef TRKPARAMETERS_MEASUREDPERIGEE_H
809 const Trk::ErrorMatrix err = startPerigee->localErrorMatrix();
810 double dtheta = err.error(Trk::theta);
811 double dqovp = err.error(Trk::qOverP);
812 double covthetaOvP = err.covValue(Trk::qOverP,Trk::theta);
813
814 double dphi = err.error(Trk::phi0);
815 double dz0 = err.error(Trk::z0);
816 double dd0 = err.error(Trk::d0);
817#else
818 double dtheta = std::sqrt((*measPer->covariance())(Trk::theta,Trk::theta));
819 double dqovp = std::sqrt((*measPer->covariance())(Trk::qOverP,Trk::qOverP));
820 double covthetaOvP = (*measPer->covariance())(Trk::qOverP,Trk::theta);
821
822 double dphi = std::sqrt((*measPer->covariance())(Trk::phi0,Trk::phi0));
823 double dz0 = std::sqrt((*measPer->covariance())(Trk::z0,Trk::z0));
824 double dd0 = std::sqrt((*measPer->covariance())(Trk::d0,Trk::d0));
825#endif
826
827 double deta = 0.5*dtheta/(std::cos(0.5*theta)*std::cos(0.5*theta)*std::tan(0.5*theta));
828
829
830 if ( m_correctTrkTracks ) correctToBeamline( z0, dz0, d0, dd0, theta, phi );
831
832 double dpT = 0;
833
834
835 double sintheta = std::sin(theta);
836 double costheta = std::cos(theta);
837 double dpT2 = (p*p*sintheta)*(p*p*sintheta)*dqovp*dqovp + (p*costheta)*(p*costheta)*dtheta*dtheta - 2*(p*p*sintheta)*(p*costheta)*covthetaOvP;
838
839 if ( dpT2>0 ) dpT = std::sqrt( dpT2 );
840
841 // Check number of hits
842 // NB: a spacepoint is two offline "hits", so a pixel spacepoint is really
843 // 2 "hits" and an offline SCT "hit" is really a 1D cluster, so two intersetcting
844 // stereo clusters making a spacepoint are two "hits"
845 // const Trk::TrackSummary *summary = dynamic_cast<const Trk::TrackSummary*>(track->trackSummary());
846 //ToolHandle< Trk::ITrackSummaryTool > m_trackSumTool;
847 //m_trackSumTool = ToolHandle<Trk::ITrackSummaryTool>("Trk::TrackSummaryTool/InDetTrackSummaryTool");
848 //const Trk::TrackSummary* summary = NULL;
849 //summary = m_trackSumTool->createSummary(*track);
850
851 const Trk::TrackSummary * summary = track->trackSummary();
852 int nBlayerHits = 0;
853 int nPixelHits = 0;
854 int nSctHits = 0;
855 int nStrawHits = 0;
856 int nTrHits = 0;
857 int nSiHits = 0;
858 bool expectBL = false; // Not stored for Trk::Track
859 unsigned bitmap = 0;
860
861 if(summary==0){
862 std::cerr << "Could not create TrackSummary - Track will likely fail hits requirements" << std::endl;
863 }
864 else{
865 nBlayerHits = 2*summary->get(Trk::numberOfBLayerHits);
867 nSctHits = summary->get(Trk::numberOfSCTHits);
868 nStrawHits = summary->get(Trk::numberOfTRTHits);
870 nSiHits = nPixelHits + nSctHits;
871
872 for ( int ih=0 ; ih<20 ; ih++ ) {
873 if ( summary->isHit(Trk::DetectorType(ih)) ) bitmap |= ( 1<<hpmap[ih] );
874 }
875 }
876
877 unsigned long id = (unsigned long)track;
878 double chi2 = 0;
879 double dof = 0;
880 //const Trk::FitQuality *quality = dynamic_cast<const Trk::FitQuality*>(track->fitQuality());
881 const Trk::FitQuality *quality = (track->fitQuality());
882 if(quality==0) std::cerr << "Could not create FitQuality - Track will likely fail hits requirements" << std::endl;
883 else{
884 chi2 = quality->chiSquared();
885 dof = quality->numberDoF();
886 }
887
888 int trackAuthor = -1;
889
892
893 // std::cout << "fetching author info :" << track->info().trackFitter() << ":"
894 // << track->info().dumpInfo() << ": bm 0x" << std::hex << bitmap << std::dec << std::endl;
895
896 int fitter = track->info().trackFitter();
897 // std::string dumpinfo = track->info().dumpInfo();
898
899 if ( fitter>0 && fitter<Trk::TrackInfo::NumberOfTrackFitters ) {
900 if ((track->info().dumpInfo()).find("TRTStandalone") != std::string::npos) trackAuthor = 2;
901 else if ((track->info().dumpInfo()).find("TRTSeededTrackFinder") != std::string::npos) trackAuthor = 1;
902 else trackAuthor = 0;
903 }
904
905 #if 0
906 std::cout << "\t\t\tSUTT TP track"
907 << "\teta=" << eta // << " +- " << (*trackitr)->params()->deta()
908 << "\tphi=" << phi // << " +- " << (*trackitr)->params()->dphi()
909 << "\tz0=" << z0
910 << "\tpT=" << pT // << "\t( " << 1/qoverp << ")"
911 << "\td0=" << d0
912 << "\tNsi=" << nSiHits
913 << "\tNtrt=" << nTrHits
914 << "\tNstr=" << nStrawHits
915 << "\tauthor=" << trackAuthor
916 << std::endl;
917 #endif
918 // Create and save Track
919 TIDA::Track* t = new TIDA::Track(eta, phi, z0, d0, pT, chi2, dof,
920 deta, dphi, dz0, dd0, dpT,
921 nBlayerHits, nPixelHits, nSctHits, nSiHits,
922 nStrawHits, nTrHits, bitmap, 0,
923 trackAuthor, false, -1, -1,
924 expectBL, id) ;
925
926 if ( !addTrack( t ) ){
927 delete t;
928 return false;
929 }
930 return true;
931
932 //std::cout << "SUTT TP track " << *t << "\t0x" << std::hex << bitmap << std::dec << std::endl;
933 }
934 }
935
936 return false;
937}
double charge(const T &p)
Definition AtlasPID.h:1003
double charge() const
Returns the charge.

◆ selectTrack() [3/7]

bool TrigTrackSelector::selectTrack ( const TruthParticle & track)

Definition at line 437 of file TrigTrackSelector.cxx.

437 {
438
439 return selectTrack( &track );
440
441}
bool selectTrack(const Rec::TrackParticle *track)
neater code to make use of vector function also for a single ancestor pdgid, instead of the full code...

◆ selectTrack() [4/7]

bool TrigTrackSelector::selectTrack ( const TruthParticle * track)

Definition at line 445 of file TrigTrackSelector.cxx.

445 {
446 TIDA::Track* t = makeTrack( track, m_id );
447 if ( t == 0 ) return false;
448 if ( !addTrack(t) ) {
449 delete t;
450 return false;
451 }
452 return true;
453}

◆ selectTrack() [5/7]

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 956 of file TrigTrackSelector.cxx.

956 {
957 // do the track extraction stuff here....
958
959 // static int hpmap[20] = { 0, 1, 2, 7, 8, 9, 3, 4, 5, 6, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19 };
960
961 if ( track ) {
962
964 const xAOD::TrackParticle* measPer = track;
965
966 // CLHEP::HepVector perigeeParams = measPer->parameters();
967
968 double pT = measPer->pt();
969 double eta = measPer->eta();
970 double phi = measPer->phi0();
971 double z0 = measPer->z0() + measPer->vz();
972 double d0 = measPer->d0();
973
974 double theta = measPer->theta();
975
980 // if ( measPer->qOverP()==0 ) return false;
981 if ( measPer->qOverP()==0 ) throw std::runtime_error( "probable corrupted track - this should never happen" );
982 double p = 1/measPer->qOverP();
983
984 // AAARCH!!!!! the TrackParticle pT is NOT SIGNED!!!! ( I ask you! )
985 if ( measPer->qOverP()<0 && pT>0 ) pT *= -1;
986
987 double dtheta = std::sqrt(measPer->definingParametersCovMatrix()(Trk::theta,Trk::theta));
988 double dqovp = std::sqrt(measPer->definingParametersCovMatrix()(Trk::qOverP,Trk::qOverP));
989 double covthetaOvP = measPer->definingParametersCovMatrix()(Trk::qOverP,Trk::theta);
990
991 double deta = 0.5*dtheta/(std::cos(0.5*theta)*std::cos(0.5*theta)*std::tan(0.5*theta)); // ???? CHECK THIS <<--
992
993 double dphi = std::sqrt(measPer->definingParametersCovMatrix()(Trk::phi0,Trk::phi0));
994 double dz0 = std::sqrt(measPer->definingParametersCovMatrix()(Trk::z0,Trk::z0));
995 double dd0 = std::sqrt(measPer->definingParametersCovMatrix()(Trk::d0,Trk::d0));
996
997 double dpT = 0;
998
999
1001 // if ( m_xBeam!=0 || m_yBeam!=0 ) correctToBeamline( z0, dz0, d0, dd0, theta, phi );
1002
1003
1004 double sintheta = std::sin(theta);
1005 double costheta = std::cos(theta);
1006 double dpt2 = (p*p*sintheta)*(p*p*sintheta)*dqovp*dqovp + (p*costheta)*(p*costheta)*dtheta*dtheta - 2*(p*p*sintheta)*(p*costheta)*covthetaOvP;
1007
1008 if ( dpt2>0 ) dpT = std::sqrt( dpt2 );
1009
1010 // Check number of hits
1011 // NB: a spacepoint is two offline "hits", so a pixel spacepoint is really
1012 // 2 "hits" and an offline SCT "hit" is really a 1D cluster, so two intersetcting
1013 // stereo clusters making a spacepoint are two "hits"
1014
1015 uint8_t sum_nBlayerHits = 0;
1016 track->summaryValue( sum_nBlayerHits, xAOD::numberOfInnermostPixelLayerHits);
1017 int nBlayerHits = 2*sum_nBlayerHits;
1018
1019 uint8_t sum_nPixelHits = 0;
1020 track->summaryValue( sum_nPixelHits, xAOD::numberOfPixelHits);
1021 int nPixelHits = 2*sum_nPixelHits;
1022
1023 uint8_t sum_nSctHits = 0;
1024 track->summaryValue( sum_nSctHits, xAOD::numberOfSCTHits);
1025 int nSctHits = sum_nSctHits;
1026
1027 uint8_t sum_nStrawHits = 0;
1028 track->summaryValue( sum_nStrawHits, xAOD::numberOfTRTHits);
1029 int nStrawHits = sum_nStrawHits;
1030
1031 uint8_t sum_nTrtHits = 0;
1032 track->summaryValue( sum_nTrtHits, xAOD::numberOfTRTHighThresholdHits);
1033 int nTrtHits = sum_nTrtHits;
1034
1035
1036 uint8_t sum_expectBL = 0;
1037 track->summaryValue( sum_expectBL, xAOD::expectInnermostPixelLayerHit);
1038 bool expectBL = ( sum_expectBL ? true : false );
1039
1041
1042 uint8_t sum_sctholes = 0;
1043 track->summaryValue( sum_sctholes, xAOD::numberOfSCTHoles);
1044
1045 uint8_t sum_pixholes = 0;
1046 track->summaryValue( sum_pixholes, xAOD::numberOfPixelHoles);
1047
1051
1052 nSctHits += 1000*sum_sctholes;
1053 nPixelHits += 1000*sum_pixholes;
1054
1056 int nSiHits = nPixelHits + nSctHits;
1057
1059
1060 double chi2 = track->chiSquared();
1061 double dof = track->numberDoF();
1062
1063 unsigned long id = (unsigned long)track;
1064
1065 unsigned bitmap = track->hitPattern();
1066
1067
1068
1069 double xbeam = track->vx();
1070 double ybeam = track->vy();
1071 double zbeam = track->vz();
1072
1073 if ( xbeam!=getBeamX() || ybeam!=getBeamY() || zbeam!=getBeamZ() ) setBeamline( xbeam, ybeam, zbeam );
1074
1075 int trackAuthor = 0;
1076
1077 int fitter = track->trackFitter();
1078 std::bitset<xAOD::NumberOfTrackRecoInfo> patternrec = track->patternRecoInfo();
1079
1080 //int icount = 0;<- never used if section below is commented
1081 for ( unsigned ipr=patternrec.size() ; ipr-- ; ) {
1082 if ( patternrec[ipr] ) {
1083 //icount++; <- never used if section below is commented
1084 trackAuthor |= (ipr >> 16);
1085 // static bool first = true;
1086 // if ( first && icount>1 ) {
1087 // std::cerr << "more than one pattern rec strategy " << ipr << "\t(suppressing further output)" << std::endl;
1088 // first = false;
1089 // }
1090 }
1091 }
1092
1093 trackAuthor |= fitter;
1094
1095 // if ( fitter>0 && fitter<Trk::TrackInfo::NumberOfTrackFitters ) {
1096 // if ( dumpinfo.find("TRTStandalone")!=std::string::npos) trackAuthor = 2;
1097 // else if ( dumpinfo.find("TRTSeededTrackFinder")!=std::string::npos) trackAuthor = 1;
1098 // else trackAuthor = 0;
1099 // }
1100
1101#if 0
1102 std::cout << "\t\t\tSUTT TP track"
1103 << "\teta=" << eta // << " +- " << (*trackitr)->params()->deta()
1104 << "\tphi=" << phi // << " +- " << (*trackitr)->params()->dphi()
1105 << "\tz0=" << z0
1106 << "\tpT=" << pT // << "\t( " << 1/qoverp << ")"
1107 << "\td0=" << d0
1108 << "\tNsi=" << nSiHits
1109 // << "\tNtrt=" << nTrtHits
1110 // << "\tNstr=" << nStrawHits
1111 << "\tfitter=" << fitter
1112 << "\tauthor=" << trackAuthor
1113 << "\tVTX x " << track->vx() << "\ty " << track->vy() << "\tz " << track->vz()
1114 << std::endl;
1115#endif
1116
1117 // Create and save Track
1118
1119 TIDA::Track* t = new TIDA::Track( eta, phi, z0, d0, pT, chi2, dof,
1120 deta, dphi, dz0, dd0, dpT,
1121 nBlayerHits, nPixelHits, nSctHits, nSiHits,
1122 nStrawHits, nTrtHits, bitmap, 0,
1123 trackAuthor, false, -1, -1,
1124 expectBL, id) ;
1125
1126 // std::cout << "SUTT TP track " << *t << "\t0x" << std::hex << bitmap << std::dec << std::endl;
1127
1128 if ( !addTrack( t ) ){
1129 delete t;
1130 return false;
1131 }
1132 return true;
1133
1134 }
1135 return false;
1136
1137
1138}
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() [6/7]

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 459 of file TrigTrackSelector.cxx.

459 {
460 if ( track ) {
461
462 if (!MC::isStable(track) ) return false;
463
465 const xAOD::TruthParticle* measPer = track;
466
467 double pT = measPer->pt();
468 double eta = measPer->eta();
469 double phi = measPer->phi();
470
471 // AAARCH!!!!! the TrackParticle pT is NOT SIGNED!!!! ( I ask you! )
472 if ( measPer->charge()<0 && pT>0 ) pT *= -1;
473 double q = track->charge();
474
475 static const particleType ptype;
476
478 if ( q==-999 ) q = ptype.charge( track->pdgId() );
479
481 if ( q==0 ) return 0;
482
486 // double xbeam = getBeamX(); // track->vx();
487 // double ybeam = getBeamY(); // track->vy();
488 // double zbeam = getBeamZ(); // track->vz();
489
490 if ( !track->hasProdVtx() ) return false;
491
493
494 double xp[3] = { measPer->prodVtx()->x(), measPer->prodVtx()->y(), measPer->prodVtx()->z() };
495 double xb[3] = { xp[0]-x0, xp[1]-y0, measPer->prodVtx()->z() };
496 double xd[3] = { 0, 0, 0 };
497
498 if ( track->hasDecayVtx() ) {
499 xd[0] = track->decayVtx()->x();
500 xd[1] = track->decayVtx()->y();
501 xd[2] = track->decayVtx()->z();
502 }
503
504 double rp = std::sqrt( xp[0]*xp[0] + xp[1]*xp[1] );
505 double rd = std::sqrt( xd[0]*xd[0] + xd[1]*xd[1] );
506
509 double theta = 2*std::atan( std::exp( -eta ) );
510 double z0 = xb[2] - (xb[0]*std::cos(phi) + xb[1]*std::sin(phi))/std::tan(theta);
511 double d0 = xb[1]*std::cos(phi) - xb[0]*std::sin(phi);
512
513 bool final_state = false;
514
526 const double inner_radius = m_radius;
527 const double outer_radius = m_radius;
528
529 if ( ( track->hasProdVtx() && rp<=inner_radius ) &&
530 ( !track->hasDecayVtx() || rd>outer_radius ) ) final_state = true;
531
532 if ( !final_state ) return false;
533
534 double deta = 0;
535 double dphi = 0;
536 double dz0 = 0;
537 double dd0 = 0;
538
539 double dpT = 0;
540
541 int nBlayerHits = 0;
542 int nPixelHits = 0;
543 int nSctHits = 0;
544 int nStrawHits = 0;
545 int nTrtHits = 0;
546
547 double chi2 = 0;
548 double dof = 0;
549
550 bool expectBL = false;
551
552 nSctHits += 0;
553 nPixelHits += 0;
554
556 int nSiHits = 0;
557
558 unsigned long id = (unsigned long)track;
559
560 unsigned bitmap = 0;
561
562 int trackAuthor = track->pdgId();
563 int uniqueID = HepMC::uniqueID(track);
564
565#if 0
566 std::cout << "\t\t\tSUTT TP track"
567 << "\teta=" << eta
568 << "\tphi=" << phi
569 << "\tz0=" << z0
570 << "\tpT=" << pT
571 << "\td0=" << d0
572 << "\tauthor=" << trackAuthor
573 << "\tVTX x " << xp[0]<< "\ty " << xp[1] << "\tz " << xp[2]
574 << std::endl;
575#endif
576
577 // Create and save Track
578
579 TIDA::Track* t = new TIDA::Track( eta, phi, z0, d0, pT, chi2, dof,
580 deta, dphi, dz0, dd0, dpT,
581 nBlayerHits, nPixelHits, nSctHits, nSiHits,
582 nStrawHits, nTrtHits, bitmap, 0,
583 trackAuthor, false, uniqueID, -1,
584 expectBL, id) ;
585
587 // std::cout << "SUTT TP track " << *t << "\t0x" << std::hex << bitmap << std::dec << std::endl;
588
589 // addTrack applies additional cuts using the Filter
590 if ( !addTrack( t ) ){
591 delete t;
592 return false;
593 }
594 }
595 return false;
596
597}
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() [7/7]

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 419 of file TrigTrackSelector.cxx.

419 {
420
422 if ( !MC::isStable(track) ) return false;
423
425//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.
426 m_id = (unsigned long)(track.get());
427 bool sel;
428 sel = selectTrack( TruthParticle(track) );
429 m_id = 0;
430
431 return sel;
432
433}

◆ selectTracks() [1/7]

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

Definition at line 259 of file TrigTrackSelector.cxx.

259 {
260
261 // std::cout << "\t\t\tSUTT \tTrackParticleContainer->size() = " << trigtracks->size() << std::endl;
262
263 Rec::TrackParticleContainer::const_iterator trackitr = trigtracks->begin();
264 Rec::TrackParticleContainer::const_iterator trackend = trigtracks->end();
265
266 while ( trackitr!=trackend ) {
267
268 selectTrack( *trackitr );
269
270 ++trackitr;
271
272 } // loop over tracks
273
274}
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/7]

void TrigTrackSelector::selectTracks ( const TrackCollection * trigtracks)

Definition at line 940 of file TrigTrackSelector.cxx.

940 {
941
942 // std::cout << "\t\t\tSUTT \tTrackContainer->size() = " << trigtracks->size() << std::endl;
943
944 TrackCollection::const_iterator trackitr = trigtracks->begin();
945 TrackCollection::const_iterator trackend = trigtracks->end();
946
947 while ( trackitr!=trackend ) {
948 selectTrack( *trackitr );
949 ++trackitr;
950 } // loop over tracks
951
952}

◆ selectTracks() [3/7]

void TrigTrackSelector::selectTracks ( const TrackParticleLinks_t & tracks)

Definition at line 1165 of file TrigTrackSelector.cxx.

1165 {
1166 for( const auto& track : tracks ) selectTrack( *track );
1167}

◆ selectTracks() [4/7]

void TrigTrackSelector::selectTracks ( const TruthParticleContainer * truthtracks)

Definition at line 279 of file TrigTrackSelector.cxx.

279 {
280 // std::cout << "\t\t\tSUTT \tTrackParticleContainer->size() = " << trigtracks->size() << std::endl;
281
282 TruthParticleContainer::const_iterator trackitr = truthtracks->begin();
283 TruthParticleContainer::const_iterator trackend = truthtracks->end();
284
285 while ( trackitr!=trackend ) {
286
287 selectTrack( *trackitr );
288
289 ++trackitr;
290
291 } // loop over tracks
292
293}

◆ selectTracks() [5/7]

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

Definition at line 1141 of file TrigTrackSelector.cxx.

1141 {
1142 // std::cout << "\t\t\tSUTT \tTrackContainer->size() = " << trigtracks->size() << std::endl;
1145 while ( trackitr!=trackend ) {
1146 selectTrack( *trackitr );
1147 ++trackitr;
1148 } // loop over tracks
1149}

◆ selectTracks() [6/7]

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 374 of file TrigTrackSelector.cxx.

374 {
375
376 xAOD::TruthParticleContainer::const_iterator trackitr = truthtracks->begin();
377 xAOD::TruthParticleContainer::const_iterator trackend = truthtracks->end();
378
380 double x0 = 0;
381 double y0 = 0;
382
383 truthBeamline( truthtracks, x0, y0 );
384
385
386 for ( ; trackitr!=trackend; ++trackitr) {
387
388
389 // Only select charged final state particles
390 double q = (*trackitr)->charge();
391
393 static const particleType ptype;
394 if ( q==-999 ) q = ptype.charge( (*trackitr)->pdgId() );
395
396 if (q == 0 || !MC::isStable(*trackitr) ) continue;
397
398 // If looking for tau parents, don't select mu or e children
399
400 // select based on the pdg of final state particle
401 bool gotPdgId = true;
402 if (m_selectPdgId!=0) gotPdgId = (*trackitr)->absPdgId()==m_selectPdgId;
403
404 // select based on the pdg of the parent or ancestor
405 bool gotParentPdgId = true;
406 if ( gotPdgId && m_selectParentPdgId!=0 ) gotParentPdgId = fromAncestor(m_selectParentPdgId, (*trackitr))!=nullptr;
409
410 if ( gotParentPdgId && gotPdgId ) selectTrack( *trackitr, x0, y0);
411
412 } // loop over tracks
413
414}
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() [7/7]

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 1153 of file TrigTrackSelector.cxx.

1154 {
1157 // std::cout << "\t\t\tSUTT \tTrackContainer->size() = " << trigtracks->size() << std::endl;
1158 while ( trackitr!=trackend ) {
1159 selectTrack( *trackitr );
1160 ++trackitr;
1161 } // loop over tracks
1162}

◆ setBeamline()

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

Definition at line 88 of file TrigTrackSelector.h.

88{ 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 54 of file Trigger/TrigAnalysis/TrigInDetAnalysis/TrigInDetAnalysis/TrackSelector.h.

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

◆ 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 300 of file TrigTrackSelector.cxx.

300 {
301
302 x0 = 0;
303 y0 = 0;
304
306
307 int Nx = 300;
308 int Ny = 300;
309
311 std::vector<double> xpos(Nx,0);
312 std::vector<double> ypos(Ny,0);
313
315 std::vector<int> xn(Nx,0);
316 std::vector<int> yn(Ny,0);
317
318 int xoffset = Nx/2;;
319 int yoffset = Ny/2;
320
321 double deltax = 3.0/Nx;
322 double deltay = 3.0/Ny;
323
325
326 xAOD::TruthParticleContainer::const_iterator trackitr = truthtracks->begin();
327 xAOD::TruthParticleContainer::const_iterator trackend = truthtracks->end();
328
329 for ( ; trackitr!=trackend ; ++trackitr ) {
330
331 const xAOD::TruthParticle* track = (*trackitr);
332
333 if ( !MC::isStable(track) || !track->hasProdVtx() ) continue;
334
336
337 double xp[3] = { track->prodVtx()->x(), track->prodVtx()->y(), track->prodVtx()->z() };
338
340
341 int ix = xp[0]/deltax + xoffset;
342 int iy = xp[1]/deltay + yoffset;
343
344 if ( ix<0 || ix>=Nx || iy<0 || iy>=Nx ) continue;
345
346 xpos[ix] += xp[0];
347 ypos[iy] += xp[1];
348
349 xn[ix]++;
350 yn[iy]++;
351
352 } // loop over tracks
353
355
356 int imx = 0;
357 int imy = 0;
358
359 for ( size_t i=0 ; i<xpos.size() ; i++ ) {
360 if ( xn[i]>xn[imx] ) imx = i;
361 if ( yn[i]>yn[imy] ) imy = i;
362 }
363
367 if ( xn[imx]>1 ) x0 = xpos[imx]/xn[imx];
368 if ( yn[imy]>1 ) y0 = ypos[imy]/yn[imy];
369
370}

Member Data Documentation

◆ m_correctTrkTracks

bool TrigTrackSelector::m_correctTrkTracks
private

Definition at line 186 of file TrigTrackSelector.h.

◆ m_id

unsigned long TrigTrackSelector::m_id
private

Definition at line 180 of file TrigTrackSelector.h.

◆ m_radius

double TrigTrackSelector::m_radius
private

Definition at line 188 of file TrigTrackSelector.h.

◆ m_selector

TrackFilter* TrackSelector::m_selector
protectedinherited

◆ m_selectParentPdgId

int TrigTrackSelector::m_selectParentPdgId
private

Definition at line 191 of file TrigTrackSelector.h.

◆ m_selectPdgId

int TrigTrackSelector::m_selectPdgId
private

Definition at line 190 of file TrigTrackSelector.h.

◆ m_tracks

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

◆ m_xBeam

double TrigTrackSelector::m_xBeam
private

Definition at line 182 of file TrigTrackSelector.h.

◆ m_yBeam

double TrigTrackSelector::m_yBeam
private

Definition at line 183 of file TrigTrackSelector.h.

◆ m_zBeam

double TrigTrackSelector::m_zBeam
private

Definition at line 184 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 193 of file TrigTrackSelector.h.


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