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;
119 while ( trackitr!=trackend ) {
145 std::vector<double> xpos(Nx,0);
146 std::vector<double> ypos(Ny,0);
149 std::vector<int> xn(Nx,0);
150 std::vector<int> yn(Ny,0);
155 double deltax = 3.0/Nx;
156 double deltay = 3.0/Ny;
163 for ( ; trackitr!=trackend ; ++trackitr ) {
167 if ( !
MC::isStable(track) || !track->hasProdVtx() )
continue;
171 double xp[3] = { track->prodVtx()->x(), track->prodVtx()->y(), track->prodVtx()->z() };
175 int ix = xp[0]/deltax + xoffset;
176 int iy = xp[1]/deltay + yoffset;
178 if ( ix<0 || ix>=Nx || iy<0 || iy>=Nx )
continue;
193 for (
size_t i=0 ; i<xpos.size() ; i++ ) {
194 if ( xn[i]>xn[imx] ) imx = i;
195 if ( yn[i]>yn[imy] ) imy = i;
201 if ( xn[imx]>1 ) x0 = xpos[imx]/xn[imx];
202 if ( yn[imy]>1 ) y0 = ypos[imy]/yn[imy];
220 for ( ; trackitr!=trackend; ++trackitr) {
224 double q = (*trackitr)->charge();
228 if ( q==-999 ) q = ptype.
charge( (*trackitr)->pdgId() );
235 bool gotPdgId =
true;
239 bool gotParentPdgId =
true;
244 if ( gotParentPdgId && gotPdgId )
selectTrack( *trackitr, x0, y0);
260 m_id = (
unsigned long)(track.get());
281 if ( t == 0 )
return false;
301 double pT = measPer->
pt();
302 double eta = measPer->
eta();
303 double phi = measPer->
phi();
306 if ( measPer->
charge()<0 && pT>0 ) pT *= -1;
307 double q = track->charge();
312 if ( q==-999 ) q = ptype.
charge( track->pdgId() );
315 if ( q==0 )
return 0;
324 if ( !track->hasProdVtx() )
return false;
329 double xb[3] = { xp[0]-x0, xp[1]-y0, measPer->
prodVtx()->
z() };
330 double xd[3] = { 0, 0, 0 };
332 if ( track->hasDecayVtx() ) {
333 xd[0] = track->decayVtx()->x();
334 xd[1] = track->decayVtx()->y();
335 xd[2] = track->decayVtx()->z();
338 double rp = std::sqrt( xp[0]*xp[0] + xp[1]*xp[1] );
339 double rd = std::sqrt( xd[0]*xd[0] + xd[1]*xd[1] );
343 double theta = 2*std::atan( std::exp( -
eta ) );
344 double z0 = xb[2] - (xb[0]*std::cos(
phi) + xb[1]*std::sin(
phi))/std::tan(
theta);
345 double d0 = xb[1]*std::cos(
phi) - xb[0]*std::sin(
phi);
347 bool final_state =
false;
360 const double inner_radius =
m_radius;
361 const double outer_radius =
m_radius;
363 if ( ( track->hasProdVtx() &&
rp<=inner_radius ) &&
364 ( !track->hasDecayVtx() || rd>outer_radius ) ) final_state =
true;
366 if ( !final_state )
return false;
384 bool expectBL =
false;
392 unsigned long id = (
unsigned long)track;
396 int trackAuthor = track->pdgId();
400 std::cout <<
"\t\t\tSUTT TP track"
406 <<
"\tauthor=" << trackAuthor
407 <<
"\tVTX x " << xp[0]<<
"\ty " << xp[1] <<
"\tz " << xp[2]
414 deta, dphi, dz0, dd0, dpT,
415 nBlayerHits, nPixelHits, nSctHits, nSiHits,
416 nStrawHits, nTrtHits, bitmap, 0,
417 trackAuthor,
false, uniqueID, -1,
439 unsigned long id = (
unsigned long)(track.get());
447 if ( track==0 )
return 0;
451 double phi = track->phi();
452 double eta = track->eta();
457 double xp[3] = { 0, 0, 0 };
459 if ( track->genParticle()->production_vertex() ) {
460 xp[0] = track->genParticle()->production_vertex()->position().x();
461 xp[1] = track->genParticle()->production_vertex()->position().y();
462 xp[2] = track->genParticle()->production_vertex()->position().z();
467 double theta = 2*std::atan( exp( (-1)*
eta ) );
468 double z0 = xp[2] - (xp[0]*std::cos(
phi) + xp[1]*std::sin(
phi))/std::tan(
theta);
470 double xd[3] = { 0, 0, 0 };
472 if ( track->genParticle()->end_vertex() ) {
473 xd[0] = track->genParticle()->end_vertex()->position().x();
474 xd[1] = track->genParticle()->end_vertex()->position().y();
475 xd[2] = track->genParticle()->end_vertex()->position().z();
478 double rp = std::sqrt( xp[0]*xp[0] + xp[1]*xp[1] );
479 double rd = std::sqrt( xd[0]*xd[0] + xd[1]*xd[1] );
482 bool final_state =
false;
495 const double inner_radius =
m_radius;
496 const double outer_radius =
m_radius;
497 if ( ( track->genParticle()->production_vertex() &&
rp<=inner_radius ) &&
498 ( track->genParticle()->end_vertex()==0 || rd>outer_radius ) ) final_state =
true;
501 if ( !final_state )
return 0;
514 double q = track->charge();
519 if ( q==-999 ) q = ptype.
charge( track->pdgId() );
522 if ( q==0 )
return 0;
524 double pT = q*track->pt();
539 d0 = xp[1]*std::cos(
phi) - xp[0]*std::sin(
phi);
554 int author = track->pdgId();
558 unsigned long id = (
unsigned long)track;
559 if ( tid!=0 )
id = tid;
583 author,
false, uniqueID, -1,
598 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 };
605#ifdef TRKPARAMETERS_MEASUREDPERIGEE_H
609 const Trk::Perigee* startPerigee = track->perigeeParameters();
627 double p = 1/startPerigee->parameters()[
Trk::qOverP];
630 double eta = startPerigee->
eta();
632 double z0 = startPerigee->parameters()[
Trk::z0];
633 double d0 = startPerigee->parameters()[
Trk::d0];
635 double pT = (1./qOverPt);
642#ifdef TRKPARAMETERS_MEASUREDPERIGEE_H
649 double dz0 = err.error(
Trk::z0);
650 double dd0 = err.error(
Trk::d0);
657 double dz0 = std::sqrt((*measPer->covariance())(
Trk::z0,
Trk::z0));
658 double dd0 = std::sqrt((*measPer->covariance())(
Trk::d0,
Trk::d0));
661 double deta = 0.5*dtheta/(std::cos(0.5*
theta)*std::cos(0.5*
theta)*std::tan(0.5*
theta));
669 double sintheta = std::sin(
theta);
670 double costheta = std::cos(
theta);
671 double dpT2 = (p*p*sintheta)*(p*p*sintheta)*dqovp*dqovp + (p*costheta)*(p*costheta)*dtheta*dtheta - 2*(p*p*sintheta)*(p*costheta)*covthetaOvP;
673 if ( dpT2>0 ) dpT = std::sqrt( dpT2 );
692 bool expectBL =
false;
696 std::cerr <<
"Could not create TrackSummary - Track will likely fail hits requirements" << std::endl;
704 nSiHits = nPixelHits + nSctHits;
706 for (
int ih=0 ; ih<20 ; ih++ ) {
711 unsigned long id = (
unsigned long)track;
716 if(quality==0) std::cerr <<
"Could not create FitQuality - Track will likely fail hits requirements" << std::endl;
722 int trackAuthor = -1;
730 int fitter = track->info().trackFitter();
734 if ((track->info().dumpInfo()).find(
"TRTStandalone") != std::string::npos) trackAuthor = 2;
735 else if ((track->info().dumpInfo()).find(
"TRTSeededTrackFinder") != std::string::npos) trackAuthor = 1;
736 else trackAuthor = 0;
740 std::cout <<
"\t\t\tSUTT TP track"
746 <<
"\tNsi=" << nSiHits
747 <<
"\tNtrt=" << nTrHits
748 <<
"\tNstr=" << nStrawHits
749 <<
"\tauthor=" << trackAuthor
754 deta, dphi, dz0, dd0, dpT,
755 nBlayerHits, nPixelHits, nSctHits, nSiHits,
756 nStrawHits, nTrHits, bitmap, 0,
757 trackAuthor,
false, -1, -1,
781 while ( trackitr!=trackend ) {
802 double pT = measPer->
pt();
803 double eta = measPer->
eta();
805 double z0 = measPer->
z0() + measPer->
vz();
806 double d0 = measPer->
d0();
815 if ( measPer->
qOverP()==0 )
throw std::runtime_error(
"probable corrupted track - this should never happen" );
816 double p = 1/measPer->
qOverP();
819 if ( measPer->
qOverP()<0 && pT>0 ) pT *= -1;
825 double deta = 0.5*dtheta/(std::cos(0.5*
theta)*std::cos(0.5*
theta)*std::tan(0.5*
theta));
838 double sintheta = std::sin(
theta);
839 double costheta = std::cos(
theta);
840 double dpt2 = (p*p*sintheta)*(p*p*sintheta)*dqovp*dqovp + (p*costheta)*(p*costheta)*dtheta*dtheta - 2*(p*p*sintheta)*(p*costheta)*covthetaOvP;
842 if ( dpt2>0 ) dpT = std::sqrt( dpt2 );
849 uint8_t sum_nBlayerHits = 0;
851 int nBlayerHits = 2*sum_nBlayerHits;
853 uint8_t sum_nPixelHits = 0;
855 int nPixelHits = 2*sum_nPixelHits;
857 uint8_t sum_nSctHits = 0;
859 int nSctHits = sum_nSctHits;
861 uint8_t sum_nStrawHits = 0;
863 int nStrawHits = sum_nStrawHits;
865 uint8_t sum_nTrtHits = 0;
867 int nTrtHits = sum_nTrtHits;
870 uint8_t sum_expectBL = 0;
872 bool expectBL = ( sum_expectBL ? true : false );
876 uint8_t sum_sctholes = 0;
879 uint8_t sum_pixholes = 0;
886 nSctHits += 1000*sum_sctholes;
887 nPixelHits += 1000*sum_pixholes;
890 int nSiHits = nPixelHits + nSctHits;
894 double chi2 = track->chiSquared();
895 double dof = track->numberDoF();
897 unsigned long id = (
unsigned long)track;
899 unsigned bitmap = track->hitPattern();
903 double xbeam = track->vx();
904 double ybeam = track->vy();
905 double zbeam = track->vz();
911 int fitter = track->trackFitter();
912 std::bitset<xAOD::NumberOfTrackRecoInfo> patternrec = track->patternRecoInfo();
915 for (
unsigned ipr=patternrec.size() ; ipr-- ; ) {
916 if ( patternrec[ipr] ) {
918 trackAuthor |= (ipr >> 16);
927 trackAuthor |= fitter;
936 std::cout <<
"\t\t\tSUTT TP track"
942 <<
"\tNsi=" << nSiHits
945 <<
"\tfitter=" << fitter
946 <<
"\tauthor=" << trackAuthor
947 <<
"\tVTX x " << track->vx() <<
"\ty " << track->vy() <<
"\tz " << track->vz()
954 deta, dphi, dz0, dd0, dpT,
955 nBlayerHits, nPixelHits, nSctHits, nSiHits,
956 nStrawHits, nTrtHits, bitmap, 0,
957 trackAuthor,
false, -1, -1,
979 while ( trackitr!=trackend ) {
992 while ( trackitr!=trackend ) {
1008 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
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(HepMC::ConstGenParticlePtr track)
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,...
TIDA::Track * makeTrack(HepMC::ConstGenParticlePtr track)
void correctToBeamline(double &z0, double &dz0, double &d0, double &dd0, double theta, double phi)
void selectTracks(const TruthParticleContainer *truthtracks)
neater code to make use of vector function also for a single ancestor pdgid, instead of the full code...
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.
@ 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)
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.