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";
208 std::map<unsigned int, unsigned int> tjTkMap;
216 theTrackerRecHitBuilder.
product();
222 unsigned int tjCnt = 0;
223 for(TrajectoryContainer::const_iterator rawTrajectory =
trajectories.begin();
224 rawTrajectory !=
trajectories.end(); ++rawTrajectory, ++tjCnt){
229 vector<Trajectory> trajectoriesSM =
theSmoother->trajectories(**rawTrajectory);
231 if(!trajectoriesSM.empty()) {
233 trajectory = trajectoriesSM.front();
237 LogInfo(metname)<<
"The trajectory has not been smoothed!"<<endl;
241 trajectoryCollection->
push_back(trajectory);
248 pair<bool,reco::Track> resultOfTrackExtrapAtPCA =
buildTrackAtPCA(trajectory, *beamSpot);
251 if(!resultOfTrackExtrapAtPCA.first) {
252 delete *rawTrajectory;
270 pair<bool,reco::Track> updateResult(
false,
reco::Track());
276 if(!updateResult.first) ++trackIndex;
280 updateResult.second.setExtra(trackExtraRef);
283 trackToTrackmap->insert(
reco::TrackRef(trackCollectionRefProd,trackIndex++),
284 reco::TrackRef(trackUpdatedCollectionRefProd,trackUpdatedIndex++));
293 auto ih = recHitCollection->size();
294 t2t(trajectory,*recHitCollection,trajParams,chi2s);
295 auto ie = recHitCollection->size();
297 trackExtra.
setHits(recHitCollectionRefProd,ih,ie-ih);
304 auto const &
hit = (*recHitCollection)[ih];
306 for (
auto hh :
hits) {
311 for (
auto hh : hits) {
312 if unlikely(!updateResult.second.appendHitPattern(*hh, ttopo))
break;
318 trackExtraCollection->push_back(trackExtra);
323 LogTrace(metname) <<
"Debug Track being loaded pt "<< track.
pt();
326 updatedAtVtxTrackCollection->push_back(updateResult.second);
331 delete *rawTrajectory;
333 if(tkBoolVec.size()>tjCnt) tkBoolVec[tjCnt] =
true;
340 LogTrace(metname) <<
"put the Collections in the event";
349 returnTrackHandle =
event.put(
std::move(updatedAtVtxTrackCollection),
instance+
"UpdatedAtVtx");
353 nonUpdatedHandle = returnTrackHandle;
360 auto trajTrackMap = std::make_unique<TrajTrackAssociationCollection>(rTrajs, nonUpdatedHandle);
363 for ( std::map<unsigned int, unsigned int>::iterator
i = tjTkMap.begin();
364 i != tjTkMap.end();
i++ ) {
365 trajTrackMap->insert(
edm::Ref<std::vector<Trajectory> >( rTrajs, (*i).first ),
371 return returnTrackHandle;
379 const string metname =
"Muon|RecoMuon|MuonTrackLoader";
382 auto trackLinksCollection = std::make_unique<reco::MuonTrackLinksCollection>();
385 if ( muonCands.empty() ) {
386 auto trackExtraCollection = std::make_unique<reco::TrackExtraCollection>();
387 auto recHitCollection = std::make_unique<TrackingRecHitCollection>();
391 event.put(
std::move(trackExtraCollection));
401 return event.put(
std::move(trackLinksCollection));
407 for (CandidateContainer::const_iterator it = muonCands.begin(); it != muonCands.end(); ++it) {
408 LogDebug(metname) <<
"Loader glbSeedRef " << (*it)->trajectory()->seedRef().isNonnull();
409 if ((*it)->trackerTrajectory() )
LogDebug(metname) <<
" " <<
"tkSeedRef " << (*it)->trackerTrajectory()->seedRef().isNonnull();
411 combinedTrajs.push_back((*it)->trajectory());
415 if ((*it)->trackerTrajectory())
delete ((*it)->trackerTrajectory());
428 LogTrace(metname) <<
"Build combinedTracks";
429 std::vector<bool> combTksVec(combinedTrajs.size(),
false);
433 std::vector<bool> trackerTksVec(trackerTrajs.size(),
false);
435 LogTrace(metname) <<
"Build trackerTracks: " 436 << trackerTrajs.size();
439 for (TrajectoryContainer::iterator it = trackerTrajs.begin(); it != trackerTrajs.end(); ++it) {
444 LogTrace(metname) <<
"Set the final links in the MuonTrackLinks collection";
446 unsigned int candposition(0),
position(0), tkposition(0);
450 for (CandidateContainer::const_iterator it = muonCands.begin(); it != muonCands.end(); ++it, ++candposition) {
457 if(combTksVec[candposition]) {
472 trackLinksCollection->push_back(links);
483 LogWarning(metname)<<
"The MuonTrackLinkCollection is incomplete";
486 LogTrace(metname) <<
"put the MuonCollection in the event" <<
"\n";
488 return event.put(
std::move(trackLinksCollection));
497 const string metname =
"Muon|RecoMuon|MuonTrackLoader|TevMuonTrackLoader";
507 auto trackToTrackmap = std::make_unique<reco::TrackToTrackMap>(trackHandle,trackCollectionRefProd);
510 auto trackExtraCollection = std::make_unique<reco::TrackExtraCollection>();
515 auto recHitCollection = std::make_unique<TrackingRecHitCollection>();
520 auto trajectoryCollection = std::make_unique<std::vector<Trajectory>>();
530 auto trajTrackMap = std::make_unique<TrajTrackAssociationCollection>();
537 LogTrace(metname) <<
"Create the collection of Tracks";
548 std::map<unsigned int, unsigned int> tjTkMap;
560 for(TrajectoryContainer::const_iterator rawTrajectory =
trajectories.begin();
564 std::vector<std::pair<Trajectory*,reco::TrackRef> >::const_iterator mmit;
565 for(mmit = miniMap.begin();mmit!=miniMap.end();++mmit){
566 if(mmit->first == *rawTrajectory) glbRef = mmit->second;
572 vector<Trajectory> trajectoriesSM =
theSmoother->trajectories(**rawTrajectory);
574 if(!trajectoriesSM.empty()) {
576 trajectory = trajectoriesSM.front();
579 LogInfo(metname)<<
"The trajectory has not been smoothed!"<<endl;
583 trajectoryCollection->
push_back(trajectory);
589 pair<bool,reco::Track> resultOfTrackExtrapAtPCA =
buildTrackAtPCA(trajectory, *beamSpot);
592 if(!resultOfTrackExtrapAtPCA.first) {
593 delete *rawTrajectory;
610 trackToTrackmap->insert(glbRef,
614 pair<bool,reco::Track> updateResult(
false,
reco::Track());
620 auto ih = recHitCollection->size();
621 t2t(trajectory,*recHitCollection,trajParams,chi2s);
622 auto ie = recHitCollection->size();
624 trackExtra.
setHits(recHitCollectionRefProd,ih,ie-ih);
630 auto const &
hit = (*recHitCollection)[ih];
632 for (
auto hh :
hits) {
637 for (
auto hh : hits) {
638 if unlikely(!updateResult.second.appendHitPattern(*hh, ttopo))
break;
644 trackExtraCollection->push_back(trackExtra);
649 LogTrace(metname) <<
"Debug Track being loaded pt "<< track.
pt();
654 delete *rawTrajectory;
662 LogTrace(metname) <<
"put the Collections in the event";
673 nonUpdatedHandle = returnTrackHandle;
680 auto trajTrackMap = std::make_unique<TrajTrackAssociationCollection>(rTrajs, nonUpdatedHandle);
683 for ( std::map<unsigned int, unsigned int>::iterator
i = tjTkMap.begin();
684 i != tjTkMap.end();
i++ ) {
685 trajTrackMap->insert(
edm::Ref<std::vector<Trajectory> >( rTrajs, (*i).first ),
691 return returnTrackHandle;
697 const string metname =
"Muon|RecoMuon|MuonTrackLoader";
705 LogTrace(metname) <<
"Propagate to PCA...";
706 pair<bool,FreeTrajectoryState>
710 if(extrapolationResult.first)
711 ftsAtVtx = extrapolationResult.second;
714 LogInfo(metname) <<
"Track in the Tracker: taking the innermost state instead of the state at PCA";
719 LogInfo(metname) <<
"Propagation to PCA failed, taking the innermost state instead of the state at PCA";
722 LogInfo(metname) <<
"Stand Alone track: this track will be rejected";
723 return pair<bool,reco::Track>(
false,
reco::Track());
728 LogTrace(metname) <<
"TSOS after the extrapolation at vtx";
747 return pair<bool,reco::Track>(
true,
track);
753 const string metname =
"Muon|RecoMuon|MuonTrackLoader";
761 LogTrace(metname) <<
"Apply the vertex constraint";
764 if(!updateResult.first){
765 return pair<bool,reco::Track>(
false,
reco::Track());
768 LogTrace(metname) <<
"FTS after the vertex constraint";
785 return pair<bool,reco::Track>(
true,updatedTrack);
791 const string metname =
"Muon|RecoMuon|MuonTrackLoader";
801 unsigned int innerId=0, outerId=0;
815 LogTrace(metname)<<
"oppositeToMomentum";
823 else LogError(metname)<<
"Wrong propagation direction!";
833 LogTrace(metname)<<
"The Global Muon outerMostMeasurementState is not compatible with the recHit detector! Setting outerMost postition to recHit position if recHit isValid: " << outerRecHit->isValid();
834 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!
std::remove_cv< typename std::remove_reference< argument_type >::type >::type key_type
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)