40 if ( p==
nullptr )
return nullptr;
42 if ( p->absPdgId()==pdg_id ) {
45 auto vertex = p->prodVtx();
46 if ( vertex ==
nullptr ) {
49 if ( vertex->nIncomingParticles() < 1 ) {
52 for(
unsigned ip = 0; ip < vertex->nIncomingParticles(); ip++ ) {
53 auto* in = vertex->incomingParticle(ip);
55 if ( parent!=
nullptr ) {
56 if (parent->absPdgId()==pdg_id)
return parent;
74 if ( p==
nullptr )
return nullptr;
76 for (
size_t i=ids.size() ; i-- ; ) {
77 if ( p->absPdgId()==ids[i] )
return p;
80 auto vertex = p->prodVtx();
81 if ( vertex ==
nullptr )
return nullptr;
83 if ( vertex->nIncomingParticles()<1 )
return nullptr;
85 for(
unsigned ip = 0; ip < vertex->nIncomingParticles(); ip++ ) {
86 auto* in = vertex->incomingParticle(ip);
88 if ( parent!=
nullptr ) {
89 for (
size_t i=ids.size() ; i-- ; ) {
90 if ( parent->absPdgId()==ids[i] )
return parent;
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();
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();
132 double theta = 2*std::atan( exp( (-1)*
eta ) );
135 int algoid = track->algorithmId();
137 int nBlayerHits = (track->HitPattern() & 0x1);
138 int nPixelHits = 2 * track->NPixelSpacePoints();
139 int nSctHits = 2 * track->NSCT_SpacePoints();
140 int nStrawHits = track->NStrawHits();
141 int nTrHits = track->NTRHits();
143 int nSiHits = nPixelHits + nSctHits;
145 bool expectBL =
false;
147 unsigned long id = (
unsigned long)track;
149 unsigned hitPattern = track->HitPattern();
150 unsigned multiPattern = 0;
152 double chi2 = track->chi2();
160 if (trackTruth!=0 && trackTruth->
nrMatches() > 0) {
168 deta, dphi, dz0, dd0, dpT,
169 nBlayerHits, nPixelHits, nSctHits, nSiHits,
171 hitPattern, multiPattern,
172 algoid, truth, -1, match_uniqueID,
192 while ( trackitr!=trackend ) {
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 };
208#ifdef TRKPARAMETERS_MEASUREDPERIGEE_H
215 double pT = measPer->
pT();
216 double eta = measPer->
eta();
219 double d0 = measPer->parameters()[
Trk::d0];
225 if ( measPer->parameters()[
Trk::qOverP]<0 && pT>0 ) pT *= -1;
227#ifdef TRKPARAMETERS_MEASUREDPERIGEE_H
239 double deta = 0.5*dtheta/(std::cos(0.5*
theta)*std::cos(0.5*
theta)*std::tan(0.5*
theta));
241#ifdef TRKPARAMETERS_MEASUREDPERIGEE_H
243 double dz0 = err.error(
Trk::z0);
244 double dd0 = err.error(
Trk::d0);
247 double dz0 = std::sqrt((*measPer->covariance())(
Trk::z0,
Trk::z0));
248 double dd0 = std::sqrt((*measPer->covariance())(
Trk::d0,
Trk::d0));
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;
258 if ( dpt2>0 ) dpT = std::sqrt( dpt2 );
271 int nSiHits = nPixelHits + nSctHits;
272 bool expectBL =
false;
281 unsigned long id = (
unsigned long)track;
283 for (
int ih=0 ; ih<20 ; ih++ ) {
293 int fitter = track->info().trackFitter();
294 std::string dumpinfo = track->info().dumpInfo();
296 int trackAuthor = -1;
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;
304 std::cout <<
"\t\t\tSUTT TP track"
310 <<
"\tNsi=" << nSiHits
311 <<
"\tNtrt=" << nTrHits
312 <<
"\tNstr=" << nStrawHits
313 <<
"\tauthor=" << trackAuthor
320 deta, dphi, dz0, dd0, dpT,
321 nBlayerHits, nPixelHits, nSctHits, nSiHits,
322 nStrawHits, nTrHits, bitmap, 0,
323 trackAuthor,
false, -1, -1,
347 while ( trackitr!=trackend ) {
366 while ( trackitr!=trackend ) {
392 std::vector<double> xpos(Nx,0);
393 std::vector<double> ypos(Ny,0);
396 std::vector<int> xn(Nx,0);
397 std::vector<int> yn(Ny,0);
402 double deltax = 3.0/Nx;
403 double deltay = 3.0/Ny;
410 for ( ; trackitr!=trackend ; ++trackitr ) {
414 if ( !
MC::isStable(track) || !track->hasProdVtx() )
continue;
418 double xp[3] = { track->prodVtx()->x(), track->prodVtx()->y(), track->prodVtx()->z() };
422 int ix = xp[0]/deltax + xoffset;
423 int iy = xp[1]/deltay + yoffset;
425 if ( ix<0 || ix>=Nx || iy<0 || iy>=Nx )
continue;
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;
448 if ( xn[imx]>1 ) x0 = xpos[imx]/xn[imx];
449 if ( yn[imy]>1 ) y0 = ypos[imy]/yn[imy];
467 for ( ; trackitr!=trackend; ++trackitr) {
471 double q = (*trackitr)->charge();
475 if ( q==-999 ) q = ptype.
charge( (*trackitr)->pdgId() );
482 bool gotPdgId =
true;
486 bool gotParentPdgId =
true;
491 if ( gotParentPdgId && gotPdgId )
selectTrack( *trackitr, x0, y0);
508 m_id = (
unsigned long)(track.get());
510 m_id = (
unsigned long)track;
532 if ( t == 0 )
return false;
552 double pT = measPer->
pt();
553 double eta = measPer->
eta();
554 double phi = measPer->
phi();
557 if ( measPer->
charge()<0 && pT>0 ) pT *= -1;
558 double q = track->charge();
563 if ( q==-999 ) q = ptype.
charge( track->pdgId() );
566 if ( q==0 )
return 0;
575 if ( !track->hasProdVtx() )
return false;
580 double xb[3] = { xp[0]-x0, xp[1]-y0, measPer->
prodVtx()->
z() };
581 double xd[3] = { 0, 0, 0 };
583 if ( track->hasDecayVtx() ) {
584 xd[0] = track->decayVtx()->x();
585 xd[1] = track->decayVtx()->y();
586 xd[2] = track->decayVtx()->z();
589 double rp = std::sqrt( xp[0]*xp[0] + xp[1]*xp[1] );
590 double rd = std::sqrt( xd[0]*xd[0] + xd[1]*xd[1] );
594 double theta = 2*std::atan( std::exp( -
eta ) );
595 double z0 = xb[2] - (xb[0]*std::cos(
phi) + xb[1]*std::sin(
phi))/std::tan(
theta);
596 double d0 = xb[1]*std::cos(
phi) - xb[0]*std::sin(
phi);
598 bool final_state =
false;
611 const double inner_radius =
m_radius;
612 const double outer_radius =
m_radius;
614 if ( ( track->hasProdVtx() &&
rp<=inner_radius ) &&
615 ( !track->hasDecayVtx() || rd>outer_radius ) ) final_state =
true;
617 if ( !final_state )
return false;
635 bool expectBL =
false;
643 unsigned long id = (
unsigned long)track;
647 int trackAuthor = track->pdgId();
651 std::cout <<
"\t\t\tSUTT TP track"
657 <<
"\tauthor=" << trackAuthor
658 <<
"\tVTX x " << xp[0]<<
"\ty " << xp[1] <<
"\tz " << xp[2]
665 deta, dphi, dz0, dd0, dpT,
666 nBlayerHits, nPixelHits, nSctHits, nSiHits,
667 nStrawHits, nTrtHits, bitmap, 0,
668 trackAuthor,
false, uniqueID, -1,
691 unsigned long id = (
unsigned long)(track.get());
693 unsigned long id = (
unsigned long)track;
702 if ( track==0 )
return 0;
706 double phi = track->phi();
707 double eta = track->eta();
712 double xp[3] = { 0, 0, 0 };
714 if ( track->genParticle()->production_vertex() ) {
715 xp[0] = track->genParticle()->production_vertex()->position().x();
716 xp[1] = track->genParticle()->production_vertex()->position().y();
717 xp[2] = track->genParticle()->production_vertex()->position().z();
722 double theta = 2*std::atan( exp( (-1)*
eta ) );
723 double z0 = xp[2] - (xp[0]*std::cos(
phi) + xp[1]*std::sin(
phi))/std::tan(
theta);
725 double xd[3] = { 0, 0, 0 };
727 if ( track->genParticle()->end_vertex() ) {
728 xd[0] = track->genParticle()->end_vertex()->position().x();
729 xd[1] = track->genParticle()->end_vertex()->position().y();
730 xd[2] = track->genParticle()->end_vertex()->position().z();
733 double rp = std::sqrt( xp[0]*xp[0] + xp[1]*xp[1] );
734 double rd = std::sqrt( xd[0]*xd[0] + xd[1]*xd[1] );
737 bool final_state =
false;
750 const double inner_radius =
m_radius;
751 const double outer_radius =
m_radius;
752 if ( ( track->genParticle()->production_vertex() &&
rp<=inner_radius ) &&
753 ( track->genParticle()->end_vertex()==0 || rd>outer_radius ) ) final_state =
true;
756 if ( !final_state )
return 0;
769 double q = track->charge();
774 if ( q==-999 ) q = ptype.
charge( track->pdgId() );
777 if ( q==0 )
return 0;
779 double pT = q*track->pt();
794 d0 = xp[1]*std::cos(
phi) - xp[0]*std::sin(
phi);
823 int author = track->pdgId();
827 unsigned long id = (
unsigned long)track;
828 if ( tid!=0 )
id = tid;
852 author,
false, uniqueID, -1,
867 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 };
874#ifdef TRKPARAMETERS_MEASUREDPERIGEE_H
878 const Trk::Perigee* startPerigee = track->perigeeParameters();
896 double p = 1/startPerigee->parameters()[
Trk::qOverP];
899 double eta = startPerigee->
eta();
901 double z0 = startPerigee->parameters()[
Trk::z0];
902 double d0 = startPerigee->parameters()[
Trk::d0];
904 double pT = (1./qOverPt);
911#ifdef TRKPARAMETERS_MEASUREDPERIGEE_H
918 double dz0 = err.error(
Trk::z0);
919 double dd0 = err.error(
Trk::d0);
926 double dz0 = std::sqrt((*measPer->covariance())(
Trk::z0,
Trk::z0));
927 double dd0 = std::sqrt((*measPer->covariance())(
Trk::d0,
Trk::d0));
930 double deta = 0.5*dtheta/(std::cos(0.5*
theta)*std::cos(0.5*
theta)*std::tan(0.5*
theta));
938 double sintheta = std::sin(
theta);
939 double costheta = std::cos(
theta);
940 double dpT2 = (p*p*sintheta)*(p*p*sintheta)*dqovp*dqovp + (p*costheta)*(p*costheta)*dtheta*dtheta - 2*(p*p*sintheta)*(p*costheta)*covthetaOvP;
942 if ( dpT2>0 ) dpT = std::sqrt( dpT2 );
961 bool expectBL =
false;
965 std::cerr <<
"Could not create TrackSummary - Track will likely fail hits requirements" << std::endl;
973 nSiHits = nPixelHits + nSctHits;
975 for (
int ih=0 ; ih<20 ; ih++ ) {
980 unsigned long id = (
unsigned long)track;
985 if(quality==0) std::cerr <<
"Could not create FitQuality - Track will likely fail hits requirements" << std::endl;
991 int trackAuthor = -1;
999 int fitter = track->info().trackFitter();
1003 if ((track->info().dumpInfo()).find(
"TRTStandalone") != std::string::npos) trackAuthor = 2;
1004 else if ((track->info().dumpInfo()).find(
"TRTSeededTrackFinder") != std::string::npos) trackAuthor = 1;
1005 else trackAuthor = 0;
1009 std::cout <<
"\t\t\tSUTT TP track"
1015 <<
"\tNsi=" << nSiHits
1016 <<
"\tNtrt=" << nTrHits
1017 <<
"\tNstr=" << nStrawHits
1018 <<
"\tauthor=" << trackAuthor
1023 deta, dphi, dz0, dd0, dpT,
1024 nBlayerHits, nPixelHits, nSctHits, nSiHits,
1025 nStrawHits, nTrHits, bitmap, 0,
1026 trackAuthor,
false, -1, -1,
1050 while ( trackitr!=trackend ) {
1071 double pT = measPer->
pt();
1072 double eta = measPer->
eta();
1074 double z0 = measPer->
z0() + measPer->
vz();
1075 double d0 = measPer->
d0();
1084 if ( measPer->
qOverP()==0 )
throw std::runtime_error(
"probable corrupted track - this should never happen" );
1085 double p = 1/measPer->
qOverP();
1088 if ( measPer->
qOverP()<0 && pT>0 ) pT *= -1;
1094 double deta = 0.5*dtheta/(std::cos(0.5*
theta)*std::cos(0.5*
theta)*std::tan(0.5*
theta));
1107 double sintheta = std::sin(
theta);
1108 double costheta = std::cos(
theta);
1109 double dpt2 = (p*p*sintheta)*(p*p*sintheta)*dqovp*dqovp + (p*costheta)*(p*costheta)*dtheta*dtheta - 2*(p*p*sintheta)*(p*costheta)*covthetaOvP;
1111 if ( dpt2>0 ) dpT = std::sqrt( dpt2 );
1118 uint8_t sum_nBlayerHits = 0;
1120 int nBlayerHits = 2*sum_nBlayerHits;
1122 uint8_t sum_nPixelHits = 0;
1124 int nPixelHits = 2*sum_nPixelHits;
1126 uint8_t sum_nSctHits = 0;
1128 int nSctHits = sum_nSctHits;
1130 uint8_t sum_nStrawHits = 0;
1132 int nStrawHits = sum_nStrawHits;
1134 uint8_t sum_nTrtHits = 0;
1136 int nTrtHits = sum_nTrtHits;
1139 uint8_t sum_expectBL = 0;
1141 bool expectBL = ( sum_expectBL ? true : false );
1145 uint8_t sum_sctholes = 0;
1148 uint8_t sum_pixholes = 0;
1155 nSctHits += 1000*sum_sctholes;
1156 nPixelHits += 1000*sum_pixholes;
1159 int nSiHits = nPixelHits + nSctHits;
1163 double chi2 = track->chiSquared();
1164 double dof = track->numberDoF();
1166 unsigned long id = (
unsigned long)track;
1168 unsigned bitmap = track->hitPattern();
1172 double xbeam = track->vx();
1173 double ybeam = track->vy();
1174 double zbeam = track->vz();
1178 int trackAuthor = 0;
1180 int fitter = track->trackFitter();
1181 std::bitset<xAOD::NumberOfTrackRecoInfo> patternrec = track->patternRecoInfo();
1184 for (
unsigned ipr=patternrec.size() ; ipr-- ; ) {
1185 if ( patternrec[ipr] ) {
1187 trackAuthor |= (ipr >> 16);
1196 trackAuthor |= fitter;
1205 std::cout <<
"\t\t\tSUTT TP track"
1211 <<
"\tNsi=" << nSiHits
1214 <<
"\tfitter=" << fitter
1215 <<
"\tauthor=" << trackAuthor
1216 <<
"\tVTX x " << track->vx() <<
"\ty " << track->vy() <<
"\tz " << track->vz()
1223 deta, dphi, dz0, dd0, dpT,
1224 nBlayerHits, nPixelHits, nSctHits, nSiHits,
1225 nStrawHits, nTrtHits, bitmap, 0,
1226 trackAuthor,
false, -1, -1,
1248 while ( trackitr!=trackend ) {
1261 while ( trackitr!=trackend ) {
1277 double& d0,
double& dd0,
Scalar eta() const
pseudorapidity method
Scalar phi() const
phi method
Scalar theta() const
theta method
double charge(const T &p)
ATLAS-specific HepMC functions.
DataVector< Trk::Track > TrackCollection
This typedef represents a collection of Trk::Track objects.
DataModel_detail::const_iterator< DataVector > const_iterator
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.
virtual bool addTrack(TIDA::Track *t, bool(*f)(const TIDA::Track *)=0)
TrackSelector(TrackFilter *selector=0)
const std::vector< TIDA::Track * > & tracks() const
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
represents a LVL2 ID track
void setBeamline(double x, double y, double z=0)
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 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...
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...
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,...
void selectTracks(const TrigInDetTrackCollection *trigtracks, const TrigInDetTrackTruthMap *truthMap=0)
TIDA::Track * makeTrack(HepMC::ConstGenParticlePtr track)
void correctToBeamline(double &z0, double &dz0, double &d0, double &dd0, double theta, double phi)
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...
std::vector< ElementLink< xAOD::TrackParticleContainer > > TrackParticleLinks_t
Class to represent and store fit qualities from track reconstruction in terms of and number of degre...
int numberDoF() const
returns the number of degrees of freedom of the overall track or vertex fit as integer
double chiSquared() const
returns the of the overall track fit
double eta() const
Access method for pseudorapidity - from momentum.
double charge() const
Returns the charge.
double pT() const
Access method for transverse momentum.
@ NumberOfTrackFitters
maximum number of enums
A summary of the information contained by a track.
(HepMC) Monte Carlo particle.
double charge(int id) 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 .
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.
double chi2(TH1 *h0, TH1 *h1)
constexpr int INVALID_PARTICLE_ID
const GenParticle * ConstGenParticlePtr
bool isElectron(const T &p)
bool isStable(const T &p)
Identify if the particle is stable, i.e. has not decayed.
ParametersT< TrackParametersDim, Charged, PerigeeSurface > Perigee
DetectorType
enumerates the various detector types currently accessible from the isHit() method.
@ numberOfSCTHits
number of SCT holes
@ numberOfPixelHits
number of pixel layers on track with absence of hits
@ numberOfBLayerHits
these are the hits in the 0th pixel layer?
@ numberOfTRTHits
number of TRT outliers
@ numberOfTRTHighThresholdHits
total number of TRT hits which pass the high threshold
TrackParticle_v1 TrackParticle
Reference the current persistent version:
TruthParticle_v1 TruthParticle
Typedef to implementation.
TrackParticleContainer_v1 TrackParticleContainer
Definition of the current "TrackParticle container 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].
TruthParticleContainer_v1 TruthParticleContainer
Declare the latest version of the truth particle container.