51 uint16_t detid =
id.
det();
53 std::vector<const TrackingRecHit*>
hits;
58 uint16_t subdet =
id.subdetId();
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));
137 std::vector<bool> dummyVecBool;
143 Event& event, std::vector<bool>& tkBoolVec,
145 const string&
instance,
bool reallyDoSmoothing) {
149 const string metname =
"Muon|RecoMuon|MuonTrackLoader";
157 auto updatedAtVtxTrackCollection = std::make_unique<reco::TrackCollection>();
163 auto trackToTrackmap = std::make_unique<reco::TrackToTrackMap>(trackCollectionRefProd, trackUpdatedCollectionRefProd);
166 auto trackExtraCollection = std::make_unique<reco::TrackExtraCollection>();
171 auto recHitCollection = std::make_unique<TrackingRecHitCollection>();
176 auto trajectoryCollection = std::make_unique<vector<Trajectory>>();
186 auto trajTrackMap = std::make_unique<TrajTrackAssociationCollection>();
199 LogTrace(metname) <<
"Create the collection of Tracks";
209 std::map<unsigned int, unsigned int> tjTkMap;
217 theTrackerRecHitBuilder.
product();
223 unsigned int tjCnt = 0;
224 for(TrajectoryContainer::const_iterator rawTrajectory =
trajectories.begin();
225 rawTrajectory !=
trajectories.end(); ++rawTrajectory, ++tjCnt){
230 vector<Trajectory> trajectoriesSM =
theSmoother->trajectories(**rawTrajectory);
232 if(!trajectoriesSM.empty()) {
234 trajectory = trajectoriesSM.front();
238 LogInfo(metname)<<
"The trajectory has not been smoothed!"<<endl;
242 trajectoryCollection->
push_back(trajectory);
249 pair<bool,reco::Track> resultOfTrackExtrapAtPCA =
buildTrackAtPCA(trajectory, *beamSpot);
252 if(!resultOfTrackExtrapAtPCA.first) {
253 delete *rawTrajectory;
271 pair<bool,reco::Track> updateResult(
false,
reco::Track());
277 if(!updateResult.first) ++trackIndex;
281 updateResult.second.setExtra(trackExtraRef);
284 trackToTrackmap->insert(
reco::TrackRef(trackCollectionRefProd,trackIndex++),
285 reco::TrackRef(trackUpdatedCollectionRefProd,trackUpdatedIndex++));
294 auto ih = recHitCollection->size();
295 t2t(trajectory,*recHitCollection,trajParams,chi2s);
296 auto ie = recHitCollection->size();
298 trackExtra.
setHits(recHitCollectionRefProd,ih,ie-ih);
305 auto const &
hit = (*recHitCollection)[ih];
307 for (
auto hh :
hits) {
312 for (
auto hh : hits) {
313 if unlikely(!updateResult.second.appendHitPattern(*hh, ttopo))
break;
319 trackExtraCollection->push_back(trackExtra);
324 LogTrace(metname) <<
"Debug Track being loaded pt "<< track.
pt();
327 updatedAtVtxTrackCollection->push_back(updateResult.second);
332 delete *rawTrajectory;
334 if(tkBoolVec.size()>tjCnt) tkBoolVec[tjCnt] =
true;
341 LogTrace(metname) <<
"put the Collections in the event";
350 returnTrackHandle =
event.put(
std::move(updatedAtVtxTrackCollection),
instance+
"UpdatedAtVtx");
354 nonUpdatedHandle = returnTrackHandle;
361 auto trajTrackMap = std::make_unique<TrajTrackAssociationCollection>(rTrajs, nonUpdatedHandle);
364 for ( std::map<unsigned int, unsigned int>::iterator
i = tjTkMap.begin();
365 i != tjTkMap.end();
i++ ) {
366 trajTrackMap->insert(
edm::Ref<std::vector<Trajectory> >( rTrajs, (*i).first ),
372 return returnTrackHandle;
380 const string metname =
"Muon|RecoMuon|MuonTrackLoader";
383 auto trackLinksCollection = std::make_unique<reco::MuonTrackLinksCollection>();
386 if ( muonCands.empty() ) {
387 auto trackExtraCollection = std::make_unique<reco::TrackExtraCollection>();
388 auto recHitCollection = std::make_unique<TrackingRecHitCollection>();
392 event.put(
std::move(trackExtraCollection));
402 return event.put(
std::move(trackLinksCollection));
408 for (CandidateContainer::const_iterator it = muonCands.begin(); it != muonCands.end(); ++it) {
409 LogDebug(metname) <<
"Loader glbSeedRef " << (*it)->trajectory()->seedRef().isNonnull();
410 if ((*it)->trackerTrajectory() )
LogDebug(metname) <<
" " <<
"tkSeedRef " << (*it)->trackerTrajectory()->seedRef().isNonnull();
412 combinedTrajs.push_back((*it)->trajectory());
416 if ((*it)->trackerTrajectory())
delete ((*it)->trackerTrajectory());
429 LogTrace(metname) <<
"Build combinedTracks";
430 std::vector<bool> combTksVec(combinedTrajs.size(),
false);
434 std::vector<bool> trackerTksVec(trackerTrajs.size(),
false);
436 LogTrace(metname) <<
"Build trackerTracks: " 437 << trackerTrajs.size();
440 for (TrajectoryContainer::iterator it = trackerTrajs.begin(); it != trackerTrajs.end(); ++it) {
445 LogTrace(metname) <<
"Set the final links in the MuonTrackLinks collection";
447 unsigned int candposition(0),
position(0), tkposition(0);
451 for (CandidateContainer::const_iterator it = muonCands.begin(); it != muonCands.end(); ++it, ++candposition) {
458 if(combTksVec[candposition]) {
473 trackLinksCollection->push_back(links);
484 LogWarning(metname)<<
"The MuonTrackLinkCollection is incomplete";
487 LogTrace(metname) <<
"put the MuonCollection in the event" <<
"\n";
489 return event.put(
std::move(trackLinksCollection));
498 const string metname =
"Muon|RecoMuon|MuonTrackLoader|TevMuonTrackLoader";
508 auto trackToTrackmap = std::make_unique<reco::TrackToTrackMap>(trackHandle,trackCollectionRefProd);
511 auto trackExtraCollection = std::make_unique<reco::TrackExtraCollection>();
516 auto recHitCollection = std::make_unique<TrackingRecHitCollection>();
521 auto trajectoryCollection = std::make_unique<std::vector<Trajectory>>();
531 auto trajTrackMap = std::make_unique<TrajTrackAssociationCollection>();
538 LogTrace(metname) <<
"Create the collection of Tracks";
551 std::map<unsigned int, unsigned int> tjTkMap;
563 for(TrajectoryContainer::const_iterator rawTrajectory =
trajectories.begin();
567 std::vector<std::pair<Trajectory*,reco::TrackRef> >::const_iterator mmit;
568 for(mmit = miniMap.begin();mmit!=miniMap.end();++mmit){
569 if(mmit->first == *rawTrajectory) glbRef = mmit->second;
575 vector<Trajectory> trajectoriesSM =
theSmoother->trajectories(**rawTrajectory);
577 if(!trajectoriesSM.empty()) {
579 trajectory = trajectoriesSM.front();
582 LogInfo(metname)<<
"The trajectory has not been smoothed!"<<endl;
586 trajectoryCollection->
push_back(trajectory);
592 pair<bool,reco::Track> resultOfTrackExtrapAtPCA =
buildTrackAtPCA(trajectory, *beamSpot);
595 if(!resultOfTrackExtrapAtPCA.first) {
596 delete *rawTrajectory;
613 trackToTrackmap->insert(glbRef,
617 pair<bool,reco::Track> updateResult(
false,
reco::Track());
623 auto ih = recHitCollection->size();
624 t2t(trajectory,*recHitCollection,trajParams,chi2s);
625 auto ie = recHitCollection->size();
627 trackExtra.
setHits(recHitCollectionRefProd,ih,ie-ih);
633 auto const &
hit = (*recHitCollection)[ih];
635 for (
auto hh :
hits) {
640 for (
auto hh : hits) {
641 if unlikely(!updateResult.second.appendHitPattern(*hh, ttopo))
break;
647 trackExtraCollection->push_back(trackExtra);
652 LogTrace(metname) <<
"Debug Track being loaded pt "<< track.
pt();
657 delete *rawTrajectory;
665 LogTrace(metname) <<
"put the Collections in the event";
676 nonUpdatedHandle = returnTrackHandle;
683 auto trajTrackMap = std::make_unique<TrajTrackAssociationCollection>(rTrajs, nonUpdatedHandle);
686 for ( std::map<unsigned int, unsigned int>::iterator
i = tjTkMap.begin();
687 i != tjTkMap.end();
i++ ) {
688 trajTrackMap->insert(
edm::Ref<std::vector<Trajectory> >( rTrajs, (*i).first ),
694 return returnTrackHandle;
700 const string metname =
"Muon|RecoMuon|MuonTrackLoader";
708 LogTrace(metname) <<
"Propagate to PCA...";
709 pair<bool,FreeTrajectoryState>
713 if(extrapolationResult.first)
714 ftsAtVtx = extrapolationResult.second;
717 LogInfo(metname) <<
"Track in the Tracker: taking the innermost state instead of the state at PCA";
722 LogInfo(metname) <<
"Propagation to PCA failed, taking the innermost state instead of the state at PCA";
725 LogInfo(metname) <<
"Stand Alone track: this track will be rejected";
726 return pair<bool,reco::Track>(
false,
reco::Track());
731 LogTrace(metname) <<
"TSOS after the extrapolation at vtx";
750 return pair<bool,reco::Track>(
true,
track);
756 const string metname =
"Muon|RecoMuon|MuonTrackLoader";
764 LogTrace(metname) <<
"Apply the vertex constraint";
767 if(!updateResult.first){
768 return pair<bool,reco::Track>(
false,
reco::Track());
771 LogTrace(metname) <<
"FTS after the vertex constraint";
788 return pair<bool,reco::Track>(
true,updatedTrack);
794 const string metname =
"Muon|RecoMuon|MuonTrackLoader";
804 unsigned int innerId=0, outerId=0;
818 LogTrace(metname)<<
"oppositeToMomentum";
826 else LogError(metname)<<
"Wrong propagation direction!";
836 LogTrace(metname)<<
"The Global Muon outerMostMeasurementState is not compatible with the recHit detector! Setting outerMost postition to recHit position if recHit isValid: " << outerRecHit->isValid();
837 LogTrace(metname)<<
"From " << outerTSOSPos <<
" to " << hitPos;
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
T getParameter(std::string const &) const
edm::EDGetTokenT< reco::BeamSpot > theBeamSpotToken
std::unique_ptr< TrajectorySmoother > theSmoother
T getUntrackedParameter(std::string const &, T const &) const
MuonTrackLoader(edm::ParameterSet ¶meterSet, edm::ConsumesCollector &iC, const MuonServiceProxy *service=0)
Constructor for the STA reco the args must be specify!
static bool isInside(const GlobalPoint &)
ConstRecHitPointer const & recHit() const
static PFTauRenderPlugin instance
const std::string metname
const CurvilinearTrajectoryError & curvilinearError() const
bool theSmoothTkTrackFlag
Global3DPoint GlobalPoint
std::vector< Track > TrackCollection
collection of Tracks
std::string theSmootherName
std::pair< bool, FreeTrajectoryState > propagate(const TrajectoryStateOnSurface &tsos, const reco::BeamSpot &beamSpot) const
Propagate the state to the 2D-PCA.
GlobalPoint globalPosition() const
LocalPoint toLocal(const GlobalPoint &gp) const
Conversion to the R.F. of the GeomDet.
ConstRecHitContainer recHits() const
static std::vector< const TrackingRecHit * > unpackHit(const TrackingRecHit &hit)
const Bounds & bounds() const
bool isNonnull() const
Checks for non-null.
TrackCharge charge() const
TrajectoryStateOnSurface geometricalInnermostState() const
const Plane & surface() const
The nominal surface of the GeomDet.
const CurvilinearTrajectoryError & curvilinearError() const
MuonCandidate::CandidateContainer CandidateContainer
const MuonServiceProxy * theService
void setGlobalTrack(reco::TrackRef glb)
set the ref to combined track
virtual TrajectorySmoother * clone() const =0
std::string dumpFTS(const FreeTrajectoryState &fts) const
PropagationDirection const & direction() const
virtual std::vector< const TrackingRecHit * > recHits() const =0
Access to component RecHits (if any)
virtual bool inside(const Local3DPoint &) const =0
Determine if the point is inside the bounds.
edm::InputTag theBeamSpotInputTag
double chi2() const
chi-squared of the fit
void setTrackerTrack(reco::TrackRef tk)
set the ref to tracker's track
edm::OrphanHandle< reco::TrackCollection > loadTracks(const TrajectoryContainer &, edm::Event &, const TrackerTopology &ttopo, const std::string &="", bool=true)
Convert the trajectories into tracks and load the tracks in the event.
std::string theTrackerRecHitBuilderName
std::pair< bool, FreeTrajectoryState > update(const reco::TransientTrack &track, const reco::BeamSpot &beamSpot) const
Applies the vertex constraint.
double ndof() const
number of degrees of freedom of the fit
virtual int dimension() const =0
virtual ~MuonTrackLoader()
Destructor.
TrajectoryMeasurement const & lastMeasurement() const
double pt() const
track transverse momentum
FreeTrajectoryState const * freeState(bool withErrors=true) const
GlobalVector momentum() const
edm::RefToBase< TrajectorySeed > seedRef(void) const
MuonUpdatorAtVertex * theUpdatorAtVtx
GlobalVector momentum() const
MuonCandidate::TrajectoryContainer TrajectoryContainer
GlobalPoint position() const
GlobalPoint position() const
int ndof(bool bon=true) const
std::vector< TrackExtra > TrackExtraCollection
collection of TrackExtra objects
void setExtra(const TrackExtraRef &ref)
set reference to "extra" object
TrajectoryMeasurement const & firstMeasurement() const
ConstRecHitContainer RecHitContainer
const GlobalTrajectoryParameters & globalParameters() 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
reco::TrackExtra buildTrackExtra(const Trajectory &) const
bool appendHitPattern(const TrackingRecHit &hit, const TrackerTopology &ttopo)
append a single hit to the HitPattern
void setSeedRef(const edm::RefToBase< TrajectorySeed > &seedRef)
std::pair< bool, reco::Track > buildTrackAtPCA(const Trajectory &trajectory, const reco::BeamSpot &) const
Build a track at the PCA WITHOUT any vertex constriant.
void setStandAloneTrack(reco::TrackRef sta)
set the ref to stand alone track
static int position[264][3]
const MuonServiceProxy * theService
TrajectoryStateOnSurface const & updatedState() const
DetId geographicalId() const
Detector det() const
get the detector field from this detid
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.
T const * product() const
ParameterSet const & parameterSet(Provenance const &provenance)
boost::remove_cv< typename boost::remove_reference< argument_type >::type >::type key_type