51 uint16_t detid =
id.det();
53 std::vector<const TrackingRecHit*>
hits;
58 uint16_t subdet =
id.subdetId();
60 if (
hit.dimension() == 1) {
62 }
else if (
hit.dimension() > 1) {
65 std::vector<const TrackingRecHit*> seg2D =
hit.recHits();
67 for (std::vector<const TrackingRecHit*>::const_iterator
it = seg2D.begin();
it != seg2D.end(); ++
it) {
68 std::vector<const TrackingRecHit*> hits1D = (*it)->recHits();
69 copy(hits1D.begin(), hits1D.end(), back_inserter(
hits));
73 if (
hit.dimension() == 2) {
75 }
else if (
hit.dimension() == 4) {
82 if (
hit.dimension() == 2) {
84 }
else if (
hit.dimension() == 4) {
136 bool reallyDoSmoothing) {
137 std::vector<bool> dummyVecBool;
143 std::vector<bool>& tkBoolVec,
146 bool reallyDoSmoothing) {
149 const string metname =
"Muon|RecoMuon|MuonTrackLoader";
157 auto updatedAtVtxTrackCollection = std::make_unique<reco::TrackCollection>();
164 auto trackToTrackmap = std::make_unique<reco::TrackToTrackMap>(trackCollectionRefProd, trackUpdatedCollectionRefProd);
167 auto trackExtraCollection = std::make_unique<reco::TrackExtraCollection>();
172 auto recHitCollection = std::make_unique<TrackingRecHitCollection>();
177 auto trajectoryCollection = std::make_unique<vector<Trajectory>>();
187 auto trajTrackMap = std::make_unique<TrajTrackAssociationCollection>();
209 std::map<unsigned int, unsigned int> tjTkMap;
220 unsigned int tjCnt = 0;
222 ++itRawTrajectory, ++tjCnt) {
223 auto rawTrajectory =
std::move(*itRawTrajectory);
227 vector<Trajectory> trajectoriesSM =
theSmoother->trajectories(*rawTrajectory);
229 if (!trajectoriesSM.empty()) {
231 trajectory = trajectoriesSM.front();
235 LogInfo(
metname) <<
"The trajectory has not been smoothed!" << endl;
239 trajectoryCollection->
push_back(trajectory);
248 if (!resultOfTrackExtrapAtPCA.first) {
262 track.setExtra(trackExtraRef);
265 pair<bool, reco::Track> updateResult(
false,
reco::Track());
271 if (!updateResult.first)
275 updateResult.second.setExtra(trackExtraRef);
278 trackToTrackmap->insert(
reco::TrackRef(trackCollectionRefProd, trackIndex++),
279 reco::TrackRef(trackUpdatedCollectionRefProd, trackUpdatedIndex++));
287 auto ih = recHitCollection->size();
288 t2t(trajectory, *recHitCollection, trajParams, chi2s);
289 auto ie = recHitCollection->size();
291 trackExtra.
setHits(recHitCollectionRefProd, ih, ie - ih);
296 for (; ih < ie; ++ih) {
297 auto const&
hit = (*recHitCollection)[ih];
306 if UNLIKELY (!updateResult.second.appendHitPattern(*
hh, ttopo))
313 trackExtraCollection->push_back(trackExtra);
321 updatedAtVtxTrackCollection->push_back(updateResult.second);
323 if (tkBoolVec.size() > tjCnt)
324 tkBoolVec[tjCnt] =
true;
326 tjTkMap[iTjRef - 1] = iTkRef - 1;
339 returnTrackHandle =
event.put(
std::move(updatedAtVtxTrackCollection),
instance +
"UpdatedAtVtx");
342 nonUpdatedHandle = returnTrackHandle;
349 auto trajTrackMap = std::make_unique<TrajTrackAssociationCollection>(rTrajs, nonUpdatedHandle);
352 for (std::map<unsigned int, unsigned int>::iterator
i = tjTkMap.begin();
i != tjTkMap.end();
i++) {
353 trajTrackMap->insert(
edm::Ref<std::vector<Trajectory>>(rTrajs, (*i).first),
359 return returnTrackHandle;
365 const string metname =
"Muon|RecoMuon|MuonTrackLoader";
368 auto trackLinksCollection = std::make_unique<reco::MuonTrackLinksCollection>();
371 if (muonCands.empty()) {
372 auto trackExtraCollection = std::make_unique<reco::TrackExtraCollection>();
373 auto recHitCollection = std::make_unique<TrackingRecHitCollection>();
377 event.put(
std::move(trackExtraCollection));
387 return event.put(
std::move(trackLinksCollection));
393 for (CandidateContainer::iterator
it = muonCands.begin();
it != muonCands.end(); ++
it) {
394 LogDebug(
metname) <<
"Loader glbSeedRef " << (*it)->trajectory()->seedRef().isNonnull();
395 if ((*it)->trackerTrajectory())
397 <<
"tkSeedRef " << (*it)->trackerTrajectory()->seedRef().isNonnull();
399 combinedTrajs.push_back((*it)->releaseTrajectory());
401 auto tt = (*it)->releaseTrackerTrajectory();
417 std::vector<bool> combTksVec(combinedTrajs.size(),
false);
421 std::vector<bool> trackerTksVec(trackerTrajs.size(),
false);
427 trackerTrajs.clear();
429 LogTrace(
metname) <<
"Set the final links in the MuonTrackLinks collection";
431 unsigned int candposition(0),
position(0), tkposition(0);
435 for (CandidateContainer::const_iterator
it = muonCands.begin();
it != muonCands.end(); ++
it, ++candposition) {
441 if (combTksVec[candposition]) {
447 links.setStandAloneTrack((*it)->muonTrack());
448 links.setTrackerTrack((*it)->trackerTrack());
449 links.setGlobalTrack(combinedTR);
453 links.setTrackerTrack(trackerTR);
456 trackLinksCollection->push_back(
links);
472 return event.put(
std::move(trackLinksCollection));
478 const std::vector<std::pair<Trajectory*, reco::TrackRef>>& miniMap,
482 bool reallyDoSmoothing) {
485 const string metname =
"Muon|RecoMuon|MuonTrackLoader|TevMuonTrackLoader";
495 auto trackToTrackmap = std::make_unique<reco::TrackToTrackMap>(trackHandle, trackCollectionRefProd);
498 auto trackExtraCollection = std::make_unique<reco::TrackExtraCollection>();
503 auto recHitCollection = std::make_unique<TrackingRecHitCollection>();
508 auto trajectoryCollection = std::make_unique<std::vector<Trajectory>>();
518 auto trajTrackMap = std::make_unique<TrajTrackAssociationCollection>();
536 std::map<unsigned int, unsigned int> tjTkMap;
549 auto rawTrajectory =
std::move(*itRawTrajectory);
551 std::vector<std::pair<Trajectory*, reco::TrackRef>>::const_iterator mmit;
552 for (mmit = miniMap.begin(); mmit != miniMap.end(); ++mmit) {
553 if (mmit->first == rawTrajectory.get())
554 glbRef = mmit->second;
560 vector<Trajectory> trajectoriesSM =
theSmoother->trajectories(*rawTrajectory);
562 if (!trajectoriesSM.empty()) {
564 trajectory = trajectoriesSM.front();
567 LogInfo(
metname) <<
"The trajectory has not been smoothed!" << endl;
571 trajectoryCollection->
push_back(trajectory);
580 if (!resultOfTrackExtrapAtPCA.first) {
594 track.setExtra(trackExtraRef);
597 trackToTrackmap->insert(glbRef,
reco::TrackRef(trackCollectionRefProd, trackIndex++));
600 pair<bool, reco::Track> updateResult(
false,
reco::Track());
606 auto ih = recHitCollection->size();
607 t2t(trajectory, *recHitCollection, trajParams, chi2s);
608 auto ie = recHitCollection->size();
610 trackExtra.
setHits(recHitCollectionRefProd, ih, ie - ih);
615 for (; ih < ie; ++ih) {
616 auto const&
hit = (*recHitCollection)[ih];
625 if UNLIKELY (!updateResult.second.appendHitPattern(*
hh, ttopo))
632 trackExtraCollection->push_back(trackExtra);
640 tjTkMap[iTjRef - 1] = iTkRef - 1;
654 nonUpdatedHandle = returnTrackHandle;
661 auto trajTrackMap = std::make_unique<TrajTrackAssociationCollection>(rTrajs, nonUpdatedHandle);
664 for (std::map<unsigned int, unsigned int>::iterator
i = tjTkMap.begin();
i != tjTkMap.end();
i++) {
665 trajTrackMap->insert(
edm::Ref<std::vector<Trajectory>>(rTrajs, (*i).first),
671 return returnTrackHandle;
676 const string metname =
"Muon|RecoMuon|MuonTrackLoader";
688 if (extrapolationResult.first)
689 ftsAtVtx = extrapolationResult.second;
692 LogInfo(
metname) <<
"Track in the Tracker: taking the innermost state instead of the state at PCA";
696 LogInfo(
metname) <<
"Propagation to PCA failed, taking the innermost state instead of the state at PCA";
699 LogInfo(
metname) <<
"Stand Alone track: this track will be rejected";
700 return pair<bool, reco::Track>(
false,
reco::Track());
721 return pair<bool, reco::Track>(
true,
track);
726 const string metname =
"Muon|RecoMuon|MuonTrackLoader";
735 if (!updateResult.first) {
736 return pair<bool, reco::Track>(
false,
reco::Track());
752 return pair<bool, reco::Track>(
true, updatedTrack);
756 const string metname =
"Muon|RecoMuon|MuonTrackLoader";
766 unsigned int innerId = 0, outerId = 0;
797 LogTrace(
metname) <<
"The Global Muon outerMostMeasurementState is not compatible with the recHit detector! " 798 "Setting outerMost postition to recHit position if recHit isValid: " 799 << outerRecHit->isValid();
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
edm::EDGetTokenT< reco::BeamSpot > theBeamSpotToken
std::unique_ptr< TrajectorySmoother > theSmoother
MuonTrackLoader(edm::ParameterSet ¶meterSet, edm::ConsumesCollector &iC, const MuonServiceProxy *service=nullptr)
Constructor for the STA reco the args must be specify!
std::unique_ptr< MuonUpdatorAtVertex > theUpdatorAtVtx
T getParameter(std::string const &) const
std::remove_cv< typename std::remove_reference< argument_type >::type >::type key_type
std::pair< bool, reco::Track > buildTrackAtPCA(const Trajectory &trajectory, const reco::BeamSpot &) const
Build a track at the PCA WITHOUT any vertex constriant.
static bool isInside(const GlobalPoint &)
const CurvilinearTrajectoryError & curvilinearError() const
virtual bool inside(const Local3DPoint &) const =0
Determine if the point is inside the bounds.
LocalPoint toLocal(const GlobalPoint &gp) const
Conversion to the R.F. of the GeomDet.
GlobalPoint position() const
static PFTauRenderPlugin instance
const std::string metname
reco::TrackExtra buildTrackExtra(const Trajectory &) const
bool isNonnull() const
Checks for non-null.
TrajectoryStateOnSurface geometricalInnermostState() const
bool theSmoothTkTrackFlag
const GlobalTrajectoryParameters & globalParameters() const
Global3DPoint GlobalPoint
std::vector< Track > TrackCollection
collection of Tracks
static std::vector< const TrackingRecHit * > unpackHit(const TrackingRecHit &hit)
edm::RefToBase< TrajectorySeed > seedRef(void) const
Log< level::Error, false > LogError
ParameterSet const & parameterSet(StableProvenance const &provenance, ProcessHistory const &history)
TrajectoryMeasurement const & lastMeasurement() const
MuonCandidate::CandidateContainer CandidateContainer
const MuonServiceProxy * theService
T getUntrackedParameter(std::string const &, T const &) const
GlobalPoint position() const
GlobalVector momentum() const
int ndof(bool bon=true) const
GlobalPoint globalPosition() const
edm::InputTag theBeamSpotInputTag
edm::OrphanHandle< reco::TrackCollection > loadTracks(TrajectoryContainer &, edm::Event &, const TrackerTopology &ttopo, const std::string &="", bool=true)
Convert the trajectories into tracks and load the tracks in the event.
PropagationDirection const & direction() const
virtual ~MuonTrackLoader()
Destructor.
TrackCharge charge() const
ConstRecHitContainer recHits() const
GlobalVector momentum() const
virtual TrajectorySmoother * clone() const =0
ALPAKA_FN_ACC ALPAKA_FN_INLINE void uint32_t const uint32_t CACellT< TrackerTraits > uint32_t CellNeighborsVector< TrackerTraits > CellTracksVector< TrackerTraits > HitsConstView< TrackerTraits > hh
MuonCandidate::TrajectoryContainer TrajectoryContainer
Log< level::Info, false > LogInfo
std::vector< TrackExtra > TrackExtraCollection
collection of TrackExtra objects
ConstRecHitContainer RecHitContainer
const Plane & surface() const
The nominal surface of the GeomDet.
const CurvilinearTrajectoryError & curvilinearError() const
std::string theL2SeededTkLabel
Label for L2SeededTracks.
XYZVectorD XYZVector
spatial vector with cartesian internal representation
XYZPointD XYZPoint
point in space with cartesian internal representation
TrackingRecHit::ConstRecHitPointer ConstRecHitPointer
void setSeedRef(const edm::RefToBase< TrajectorySeed > &seedRef)
TrajectoryStateOnSurface const & updatedState() const
TrajectoryMeasurement const & firstMeasurement() const
edm::ESGetToken< TransientTrackingRecHitBuilder, TransientRecHitRecord > theTrackerRecHitBuilderToken
static int position[264][3]
FreeTrajectoryState const * freeState(bool withErrors=true) const
const MuonServiceProxy * theService
edm::ESGetToken< TrajectorySmoother, TrajectoryFitter::Record > theSmootherToken
std::pair< bool, reco::Track > buildTrackUpdatedAtPCA(const reco::Track &trackAtPCA, const reco::BeamSpot &) const
Takes a track at the PCA and applies the vertex constriant.
Log< level::Warning, false > LogWarning
ConstRecHitPointer const & recHit() const
const Bounds & bounds() const