772 auto output = std::make_unique<TrackCollection>();
773 auto extras = std::make_unique<reco::TrackExtraCollection>();
774 auto outhits = std::make_unique<edm::OwnVector<TrackingRecHit>>();
776 std::vector<float> btlMatchChi2;
777 std::vector<float> etlMatchChi2;
778 std::vector<float> btlMatchTimeChi2;
779 std::vector<float> etlMatchTimeChi2;
780 std::vector<int> npixBarrel;
781 std::vector<int> npixEndcap;
782 std::vector<float> outermostHitPosition;
783 std::vector<float> pOrigTrkRaw;
784 std::vector<float> betaOrigTrkRaw;
785 std::vector<float> t0OrigTrkRaw;
786 std::vector<float> sigmat0OrigTrkRaw;
787 std::vector<float> pathLengthsOrigTrkRaw;
788 std::vector<float> tmtdOrigTrkRaw;
789 std::vector<float> sigmatmtdOrigTrkRaw;
790 std::vector<GlobalPoint> tmtdPosOrigTrkRaw;
791 std::vector<float> tofpiOrigTrkRaw;
792 std::vector<float> tofkOrigTrkRaw;
793 std::vector<float> tofpOrigTrkRaw;
794 std::vector<float> sigmatofpiOrigTrkRaw;
795 std::vector<float> sigmatofkOrigTrkRaw;
796 std::vector<float> sigmatofpOrigTrkRaw;
797 std::vector<int> assocOrigTrkRaw;
816 std::unique_ptr<math::XYZTLorentzVectorF> genPV(
nullptr);
820 genPV = std::make_unique<math::XYZTLorentzVectorF>(
821 genVtxPosition.x(), genVtxPosition.y(), genVtxPosition.z(), genVtxTime);
827 vtxTime = genPV->t();
832 std::vector<unsigned> track_indices;
835 for (
const auto& trjtrk : trjtrks) {
839 LogTrace(
"TrackExtenderWithMTD") <<
"TrackExtenderWithMTD: extrapolating track " << itrack
840 <<
" p/pT = " <<
track->p() <<
" " <<
track->pt() <<
" eta = " <<
track->eta();
841 LogTrace(
"TrackExtenderWithMTD") <<
"TrackExtenderWithMTD: sigma_p = " 843 <<
" sigma_p/p = " <<
sqrt(
track->covariance()(0, 0)) *
track->p() * 100 <<
" %";
845 float trackVtxTime = 0.f;
854 trackVtxTime = vtxTime;
860 MTDHitMatchingInfo mBTL, mETL;
866 bool tscbl_status = getTrajectoryStateClosestToBeamLine(trajs,
bs, prop, tscbl);
872 trackPathLength(trajs, tscbl, prop, pathlength0, trs0);
887 mtdthits.insert(mtdthits.end(), btlhits.begin(), btlhits.end());
904 mtdthits.insert(mtdthits.end(), etlhits.begin(), etlhits.end());
908 LogTrace(
"TrackExtenderWithMTD") <<
"Failing getTrajectoryStateClosestToBeamLine, no search for hits in MTD!";
915 thits.insert(thits.end(), mtdthits.begin(), mtdthits.end());
918 mtdthits.insert(mtdthits.end(), thits.begin(), thits.end());
919 thits.swap(mtdthits);
922 const auto& trajwithmtd =
923 mtdthits.empty() ? std::vector<Trajectory>(1, trajs) :
theTransformer->transform(ttrack, thits);
924 float pMap = 0.f, betaMap = 0.f, t0Map = 0.f, sigmat0Map = -1.f, pathLengthMap = -1.f, tmtdMap = 0.f,
925 sigmatmtdMap = -1.f, tofpiMap = 0.f, tofkMap = 0.f, tofpMap = 0.f, sigmatofpiMap = -1.f, sigmatofkMap = -1.f,
930 for (
const auto& trj : trajwithmtd) {
932 float pathLength = 0.f, tmtd = 0.f, sigmatmtd = -1.f, tofpi = 0.f, tofk = 0.f, tofp = 0.f, sigmatofpi = -1.f,
933 sigmatofk = -1.f, sigmatofp = -1.f;
935 LogTrace(
"TrackExtenderWithMTD") <<
"TrackExtenderWithMTD: refit track " << itrack <<
" p/pT = " <<
track->p()
936 <<
" " <<
track->pt() <<
" eta = " <<
track->eta();
943 !trajwithmtd.empty() && !mtdthits.empty(),
958 size_t hitsstart = outhits->size();
960 t2t(trj, *outhits, trajParams, chi2s);
962 t2t(thetrj, *outhits, trajParams, chi2s);
964 size_t hitsend = outhits->size();
966 extras->back().setHits(hitsRefProd, hitsstart, hitsend - hitsstart);
967 extras->back().setTrajParams(trajParams, chi2s);
970 btlMatchChi2.push_back(mBTL.hit ? mBTL.estChi2 : -1.f);
971 etlMatchChi2.push_back(mETL.hit ? mETL.estChi2 : -1.f);
972 btlMatchTimeChi2.push_back(mBTL.hit ? mBTL.timeChi2 : -1.f);
973 etlMatchTimeChi2.push_back(mETL.hit ? mETL.timeChi2 : -1.f);
974 pathLengthMap = pathLength;
976 sigmatmtdMap = sigmatmtd;
977 tmtdPosMap = tmtdPos;
978 auto& backtrack =
output->back();
979 iMap =
output->size() - 1;
980 pMap = backtrack.p();
981 betaMap = backtrack.beta();
982 t0Map = backtrack.t0();
983 sigmat0Map = std::copysign(
std::sqrt(
std::abs(backtrack.covt0t0())), backtrack.covt0t0());
987 sigmatofpiMap = sigmatofpi;
988 sigmatofkMap = sigmatofk;
989 sigmatofpMap = sigmatofp;
992 for (
unsigned ihit = hitsstart; ihit < hitsend; ++ihit) {
993 backtrack.appendHitPattern((*outhits)[ihit], ttopo);
996 LogTrace(
"TrackExtenderWithMTD") <<
"TrackExtenderWithMTD: hit pattern of refitted track";
1000 LogTrace(
"TrackExtenderWithMTD") <<
"TrackExtenderWithMTD: missing hit pattern of refitted track";
1005 npixBarrel.push_back(backtrack.hitPattern().numberOfValidPixelBarrelHits());
1006 npixEndcap.push_back(backtrack.hitPattern().numberOfValidPixelEndcapHits());
1007 outermostHitPosition.push_back(
1008 mBTL.hit ? (
float)(*track).outerRadius()
1009 : (
float)(*track).outerZ());
1011 LogTrace(
"TrackExtenderWithMTD") <<
"TrackExtenderWithMTD: tmtd " << tmtdMap <<
" +/- " << sigmatmtdMap
1012 <<
" t0 " << t0Map <<
" +/- " << sigmat0Map <<
" tof pi/K/p " << tofpiMap
1013 <<
"+/-" <<
fmt::format(
"{:0.2g}", sigmatofpiMap) <<
" (" 1014 <<
fmt::format(
"{:0.2g}", sigmatofpiMap / tofpiMap * 100) <<
"%) " << tofkMap
1015 <<
"+/-" <<
fmt::format(
"{:0.2g}", sigmatofkMap) <<
" (" 1016 <<
fmt::format(
"{:0.2g}", sigmatofkMap / tofkMap * 100) <<
"%) " << tofpMap
1017 <<
"+/-" <<
fmt::format(
"{:0.2g}", sigmatofpMap) <<
" (" 1018 <<
fmt::format(
"{:0.2g}", sigmatofpMap / tofpMap * 100) <<
"%) ";
1020 LogTrace(
"TrackExtenderWithMTD") <<
"Error in the MTD track refitting. This should not happen";
1024 pOrigTrkRaw.push_back(pMap);
1025 betaOrigTrkRaw.push_back(betaMap);
1026 t0OrigTrkRaw.push_back(t0Map);
1027 sigmat0OrigTrkRaw.push_back(sigmat0Map);
1028 pathLengthsOrigTrkRaw.push_back(pathLengthMap);
1029 tmtdOrigTrkRaw.push_back(tmtdMap);
1030 sigmatmtdOrigTrkRaw.push_back(sigmatmtdMap);
1031 tmtdPosOrigTrkRaw.push_back(tmtdPosMap);
1032 tofpiOrigTrkRaw.push_back(tofpiMap);
1033 tofkOrigTrkRaw.push_back(tofkMap);
1034 tofpOrigTrkRaw.push_back(tofpMap);
1035 sigmatofpiOrigTrkRaw.push_back(sigmatofpiMap);
1036 sigmatofkOrigTrkRaw.push_back(sigmatofkMap);
1037 sigmatofpOrigTrkRaw.push_back(sigmatofpMap);
1038 assocOrigTrkRaw.push_back(iMap);
1041 btlMatchChi2.push_back(-1.
f);
1042 etlMatchChi2.push_back(-1.
f);
1043 btlMatchTimeChi2.push_back(-1.
f);
1044 etlMatchTimeChi2.push_back(-1.
f);
1045 npixBarrel.push_back(-1.
f);
1046 npixEndcap.push_back(-1.
f);
1047 outermostHitPosition.push_back(0.);
edm::EDPutToken btlMatchTimeChi2Token_
edm::EDPutToken pOrigTrkToken_
edm::ESGetToken< TransientTrackingRecHitBuilder, TransientRecHitRecord > hitbuilderToken_
edm::EDPutToken t0OrigTrkToken_
edm::EDPutToken btlMatchChi2Token_
edm::EDPutToken tofpOrigTrkToken_
edm::ESGetToken< GlobalTrackingGeometry, GlobalTrackingGeometryRecord > gtgToken_
edm::EDPutToken sigmatofkOrigTrkToken_
edm::EDGetTokenT< reco::BeamSpot > bsToken_
edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > ttopoToken_
edm::EDPutToken etlMatchChi2Token_
const bool updatePattern_
edm::EDGetTokenT< GlobalPoint > genVtxPositionToken_
edm::EDPutToken tofkOrigTrkToken_
edm::EDPutToken etlMatchTimeChi2Token_
edm::EDPutToken sigmat0OrigTrkToken_
void fillValueMap(edm::Event &iEvent, const H &handle, const std::vector< T > &vec, const edm::EDPutToken &token) const
edm::EDPutToken tmtdOrigTrkToken_
edm::EDGetTokenT< MTDTrackingDetSetVector > hitsToken_
TransientTrackingRecHit::ConstRecHitContainer tryETLLayers(const TrajectoryStateOnSurface &, const Trajectory &traj, const float, const float, const TrackSegments &, const MTDTrackingDetSetVector &, const MTDDetLayerGeometry *, const MagneticField *field, const Propagator *prop, const reco::BeamSpot &bs, const float vtxTime, const bool matchVertex, MTDHitMatchingInfo &bestHit) const
reco::TransientTrack build(const reco::Track *p) const
edm::EDPutToken sigmatofpiOrigTrkToken_
edm::EDPutToken tmtdPosOrigTrkToken_
edm::ESGetToken< TransientTrackBuilder, TransientTrackRecord > builderToken_
TrajectoryStateOnSurface outermostMeasurementState() const
reco::Track buildTrack(const reco::TrackRef &, const Trajectory &, const Trajectory &, const reco::BeamSpot &, const MagneticField *field, const Propagator *prop, bool hasMTD, float &pathLength, float &tmtdOut, float &sigmatmtdOut, GlobalPoint &tmtdPosOut, float &tofpi, float &tofk, float &tofp, float &sigmatofpi, float &sigmatofk, float &sigmatofp) const
GlobalVector momentum() const
Abs< T >::type abs(const T &t)
FTS const & trackStateAtPCA() const
edm::EDPutToken assocOrigTrkToken_
edm::EDPutToken outermostHitPositionToken_
edm::ESGetToken< Propagator, TrackingComponentsRecord > propToken_
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
edm::ESHandle< TransientTrackingRecHitBuilder > hitbuilder_
std::vector< ConstRecHitPointer > ConstRecHitContainer
std::vector< TrackExtra > TrackExtraCollection
collection of TrackExtra objects
XYZPointD XYZPoint
point in space with cartesian internal representation
reco::TrackExtra buildTrackExtra(const Trajectory &trajectory) const
edm::ESHandle< TransientTrackBuilder > builder_
std::unique_ptr< TrackTransformer > theTransformer
edm::EDPutToken npixBarrelToken_
edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > magfldToken_
edm::EDPutToken npixEndcapToken_
edm::EDPutToken betaOrigTrkToken_
ESTransientHandle< T > getTransientHandle(const ESGetToken< T, R > &iToken) const
edm::EDGetTokenT< TrajTrackAssociationCollection > trajTrackAToken_
edm::EDPutToken pathLengthOrigTrkToken_
edm::ESHandle< GlobalTrackingGeometry > gtg_
edm::EDPutToken sigmatmtdOrigTrkToken_
TransientTrackingRecHit::ConstRecHitContainer tryBTLLayers(const TrajectoryStateOnSurface &, const Trajectory &traj, const float, const float, const TrackSegments &, const MTDTrackingDetSetVector &, const MTDDetLayerGeometry *, const MagneticField *field, const Propagator *prop, const reco::BeamSpot &bs, const float vtxTime, const bool matchVertex, MTDHitMatchingInfo &bestHit) const
edm::EDPutToken tofpiOrigTrkToken_
edm::EDGetTokenT< float > genVtxTimeToken_
edm::EDGetTokenT< VertexCollection > vtxToken_
edm::EDGetTokenT< InputCollection > tracksToken_
RefitDirection::GeometricalDirection checkRecHitsOrdering(TransientTrackingRecHit::ConstRecHitContainer const &recHits) const
edm::EDPutToken sigmatofpOrigTrkToken_
edm::ESGetToken< MTDDetLayerGeometry, MTDRecoGeometryRecord > dlgeoToken_