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);
507 m_id = (
unsigned long)(track.get());
528 if ( t == 0 )
return false;
548 double pT = measPer->
pt();
549 double eta = measPer->
eta();
550 double phi = measPer->
phi();
553 if ( measPer->
charge()<0 && pT>0 ) pT *= -1;
554 double q = track->charge();
559 if ( q==-999 ) q = ptype.
charge( track->pdgId() );
562 if ( q==0 )
return 0;
571 if ( !track->hasProdVtx() )
return false;
576 double xb[3] = { xp[0]-x0, xp[1]-y0, measPer->
prodVtx()->
z() };
577 double xd[3] = { 0, 0, 0 };
579 if ( track->hasDecayVtx() ) {
580 xd[0] = track->decayVtx()->x();
581 xd[1] = track->decayVtx()->y();
582 xd[2] = track->decayVtx()->z();
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] );
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);
594 bool final_state =
false;
607 const double inner_radius =
m_radius;
608 const double outer_radius =
m_radius;
610 if ( ( track->hasProdVtx() &&
rp<=inner_radius ) &&
611 ( !track->hasDecayVtx() || rd>outer_radius ) ) final_state =
true;
613 if ( !final_state )
return false;
631 bool expectBL =
false;
639 unsigned long id = (
unsigned long)track;
643 int trackAuthor = track->pdgId();
647 std::cout <<
"\t\t\tSUTT TP track"
653 <<
"\tauthor=" << trackAuthor
654 <<
"\tVTX x " << xp[0]<<
"\ty " << xp[1] <<
"\tz " << xp[2]
661 deta, dphi, dz0, dd0, dpT,
662 nBlayerHits, nPixelHits, nSctHits, nSiHits,
663 nStrawHits, nTrtHits, bitmap, 0,
664 trackAuthor,
false, uniqueID, -1,
686 unsigned long id = (
unsigned long)(track.get());
694 if ( track==0 )
return 0;
698 double phi = track->phi();
699 double eta = track->eta();
704 double xp[3] = { 0, 0, 0 };
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();
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);
717 double xd[3] = { 0, 0, 0 };
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();
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] );
729 bool final_state =
false;
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;
748 if ( !final_state )
return 0;
761 double q = track->charge();
766 if ( q==-999 ) q = ptype.
charge( track->pdgId() );
769 if ( q==0 )
return 0;
771 double pT = q*track->pt();
786 d0 = xp[1]*std::cos(
phi) - xp[0]*std::sin(
phi);
801 int author = track->pdgId();
805 unsigned long id = (
unsigned long)track;
806 if ( tid!=0 )
id = tid;
830 author,
false, uniqueID, -1,
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 };
852#ifdef TRKPARAMETERS_MEASUREDPERIGEE_H
856 const Trk::Perigee* startPerigee = track->perigeeParameters();
874 double p = 1/startPerigee->parameters()[
Trk::qOverP];
877 double eta = startPerigee->
eta();
879 double z0 = startPerigee->parameters()[
Trk::z0];
880 double d0 = startPerigee->parameters()[
Trk::d0];
882 double pT = (1./qOverPt);
889#ifdef TRKPARAMETERS_MEASUREDPERIGEE_H
896 double dz0 = err.error(
Trk::z0);
897 double dd0 = err.error(
Trk::d0);
904 double dz0 = std::sqrt((*measPer->covariance())(
Trk::z0,
Trk::z0));
905 double dd0 = std::sqrt((*measPer->covariance())(
Trk::d0,
Trk::d0));
908 double deta = 0.5*dtheta/(std::cos(0.5*
theta)*std::cos(0.5*
theta)*std::tan(0.5*
theta));
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;
920 if ( dpT2>0 ) dpT = std::sqrt( dpT2 );
939 bool expectBL =
false;
943 std::cerr <<
"Could not create TrackSummary - Track will likely fail hits requirements" << std::endl;
951 nSiHits = nPixelHits + nSctHits;
953 for (
int ih=0 ; ih<20 ; ih++ ) {
958 unsigned long id = (
unsigned long)track;
963 if(quality==0) std::cerr <<
"Could not create FitQuality - Track will likely fail hits requirements" << std::endl;
969 int trackAuthor = -1;
977 int fitter = track->info().trackFitter();
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;
987 std::cout <<
"\t\t\tSUTT TP track"
993 <<
"\tNsi=" << nSiHits
994 <<
"\tNtrt=" << nTrHits
995 <<
"\tNstr=" << nStrawHits
996 <<
"\tauthor=" << trackAuthor
1001 deta, dphi, dz0, dd0, dpT,
1002 nBlayerHits, nPixelHits, nSctHits, nSiHits,
1003 nStrawHits, nTrHits, bitmap, 0,
1004 trackAuthor,
false, -1, -1,
1028 while ( trackitr!=trackend ) {
1049 double pT = measPer->
pt();
1050 double eta = measPer->
eta();
1052 double z0 = measPer->
z0() + measPer->
vz();
1053 double d0 = measPer->
d0();
1062 if ( measPer->
qOverP()==0 )
throw std::runtime_error(
"probable corrupted track - this should never happen" );
1063 double p = 1/measPer->
qOverP();
1066 if ( measPer->
qOverP()<0 && pT>0 ) pT *= -1;
1072 double deta = 0.5*dtheta/(std::cos(0.5*
theta)*std::cos(0.5*
theta)*std::tan(0.5*
theta));
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;
1089 if ( dpt2>0 ) dpT = std::sqrt( dpt2 );
1096 uint8_t sum_nBlayerHits = 0;
1098 int nBlayerHits = 2*sum_nBlayerHits;
1100 uint8_t sum_nPixelHits = 0;
1102 int nPixelHits = 2*sum_nPixelHits;
1104 uint8_t sum_nSctHits = 0;
1106 int nSctHits = sum_nSctHits;
1108 uint8_t sum_nStrawHits = 0;
1110 int nStrawHits = sum_nStrawHits;
1112 uint8_t sum_nTrtHits = 0;
1114 int nTrtHits = sum_nTrtHits;
1117 uint8_t sum_expectBL = 0;
1119 bool expectBL = ( sum_expectBL ? true : false );
1123 uint8_t sum_sctholes = 0;
1126 uint8_t sum_pixholes = 0;
1133 nSctHits += 1000*sum_sctholes;
1134 nPixelHits += 1000*sum_pixholes;
1137 int nSiHits = nPixelHits + nSctHits;
1141 double chi2 = track->chiSquared();
1142 double dof = track->numberDoF();
1144 unsigned long id = (
unsigned long)track;
1146 unsigned bitmap = track->hitPattern();
1150 double xbeam = track->vx();
1151 double ybeam = track->vy();
1152 double zbeam = track->vz();
1156 int trackAuthor = 0;
1158 int fitter = track->trackFitter();
1159 std::bitset<xAOD::NumberOfTrackRecoInfo> patternrec = track->patternRecoInfo();
1162 for (
unsigned ipr=patternrec.size() ; ipr-- ; ) {
1163 if ( patternrec[ipr] ) {
1165 trackAuthor |= (ipr >> 16);
1174 trackAuthor |= fitter;
1183 std::cout <<
"\t\t\tSUTT TP track"
1189 <<
"\tNsi=" << nSiHits
1192 <<
"\tfitter=" << fitter
1193 <<
"\tauthor=" << trackAuthor
1194 <<
"\tVTX x " << track->vx() <<
"\ty " << track->vy() <<
"\tz " << track->vz()
1201 deta, dphi, dz0, dd0, dpT,
1202 nBlayerHits, nPixelHits, nSctHits, nSiHits,
1203 nStrawHits, nTrtHits, bitmap, 0,
1204 trackAuthor,
false, -1, -1,
1226 while ( trackitr!=trackend ) {
1239 while ( trackitr!=trackend ) {
1255 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
HepMC3::ConstGenParticlePtr 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.