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));
127 std::vector<bool> dummyVecBool;
128 return loadTracks(trajectories, event, dummyVecBool, ttopo, instance, reallyDoSmoothing);
135 const string&
instance,
bool reallyDoSmoothing) {
139 const string metname =
"Muon|RecoMuon|MuonTrackLoader";
153 auto_ptr<reco:: TrackToTrackMap> trackToTrackmap(
new reco::TrackToTrackMap(trackCollectionRefProd, trackUpdatedCollectionRefProd));
166 auto_ptr<vector<Trajectory> > trajectoryCollection(
new vector<Trajectory>);
169 if ( trajectories.empty() ) {
170 event.put(recHitCollection,instance);
171 event.put(trackExtraCollection,instance);
173 event.put(trajectoryCollection,instance);
177 event.put( trajTrackMap, instance );
180 event.put(trackToTrackmap);
181 event.put(updatedAtVtxTrackCollection,instance+
"UpdatedAtVtx");
189 LogTrace(metname) <<
"Create the collection of Tracks";
199 std::map<unsigned int, unsigned int> tjTkMap;
207 theTrackerRecHitBuilder.
product();
213 unsigned int tjCnt = 0;
214 for(TrajectoryContainer::const_iterator rawTrajectory = trajectories.begin();
215 rawTrajectory != trajectories.end(); ++rawTrajectory, ++tjCnt){
220 vector<Trajectory> trajectoriesSM =
theSmoother->trajectories(**rawTrajectory);
222 if(!trajectoriesSM.empty()) {
224 trajectory = trajectoriesSM.front();
228 LogInfo(metname)<<
"The trajectory has not been smoothed!"<<endl;
232 trajectoryCollection->push_back(trajectory);
240 reverse(transHits.begin(),transHits.end());
244 pair<bool,reco::Track> resultOfTrackExtrapAtPCA =
buildTrackAtPCA(trajectory, *beamSpot);
247 if(!resultOfTrackExtrapAtPCA.first) {
248 delete *rawTrajectory;
253 reco::Track &track = resultOfTrackExtrapAtPCA.second;
265 pair<bool,reco::Track> updateResult(
false,
reco::Track());
271 if(!updateResult.first) ++trackIndex;
275 updateResult.second.setExtra(trackExtraRef);
278 trackToTrackmap->insert(
reco::TrackRef(trackCollectionRefProd,trackIndex++),
279 reco::TrackRef(trackUpdatedCollectionRefProd,trackUpdatedIndex++));
284 unsigned int nHitsAdded = 0;
285 for (Trajectory::RecHitContainer::const_iterator recHit = transHits.begin(); recHit != transHits.end(); ++recHit) {
288 for (std::vector<const TrackingRecHit*>::const_iterator it = hits.begin(); it != hits.end(); ++it) {
296 for (std::vector<const TrackingRecHit*>::const_iterator it = hits.begin(); it != hits.end(); ++it) {
297 if unlikely(!updateResult.second.appendHitPattern(**it, ttopo)){
302 recHitCollection->push_back( singleHit );
306 trackExtra.
setHits(recHitCollectionRefProd, recHitsIndex, nHitsAdded);
307 recHitsIndex +=nHitsAdded;
310 trackExtraCollection->push_back(trackExtra);
315 LogTrace(metname) <<
"Debug Track being loaded pt "<< track.
pt();
318 updatedAtVtxTrackCollection->push_back(updateResult.second);
323 delete *rawTrajectory;
325 if(tkBoolVec.size()>tjCnt) tkBoolVec[tjCnt] =
true;
332 LogTrace(metname) <<
"put the Collections in the event";
333 event.put(recHitCollection,instance);
334 event.put(trackExtraCollection,instance);
340 event.put(trackToTrackmap);
341 returnTrackHandle =
event.put(updatedAtVtxTrackCollection,instance+
"UpdatedAtVtx");
345 nonUpdatedHandle = returnTrackHandle;
355 for ( std::map<unsigned int, unsigned int>::iterator
i = tjTkMap.begin();
356 i != tjTkMap.end();
i++ ) {
357 trajTrackMap->insert(
edm::Ref<std::vector<Trajectory> >( rTrajs, (*i).first ),
360 event.put( trajTrackMap, instance );
363 return returnTrackHandle;
371 const string metname =
"Muon|RecoMuon|MuonTrackLoader";
377 if ( muonCands.empty() ) {
382 event.put(recHitCollection);
383 event.put(trackExtraCollection);
384 event.put(trackCollection);
393 return event.put(trackLinksCollection);
399 for (CandidateContainer::const_iterator it = muonCands.begin(); it != muonCands.end(); ++it) {
400 LogDebug(metname) <<
"Loader glbSeedRef " << (*it)->trajectory()->seedRef().isNonnull();
401 if ((*it)->trackerTrajectory() )
LogDebug(metname) <<
" " <<
"tkSeedRef " << (*it)->trackerTrajectory()->seedRef().isNonnull();
403 combinedTrajs.push_back((*it)->trajectory());
407 if ((*it)->trackerTrajectory())
delete ((*it)->trackerTrajectory());
420 LogTrace(metname) <<
"Build combinedTracks";
421 std::vector<bool> combTksVec(combinedTrajs.size(),
false);
425 std::vector<bool> trackerTksVec(trackerTrajs.size(),
false);
427 LogTrace(metname) <<
"Build trackerTracks: "
428 << trackerTrajs.size();
431 for (TrajectoryContainer::iterator it = trackerTrajs.begin(); it != trackerTrajs.end(); ++it) {
436 LogTrace(metname) <<
"Set the final links in the MuonTrackLinks collection";
438 unsigned int candposition(0),
position(0), tkposition(0);
442 for (CandidateContainer::const_iterator it = muonCands.begin(); it != muonCands.end(); ++it, ++candposition) {
449 if(combTksVec[candposition]) {
464 trackLinksCollection->push_back(links);
475 LogWarning(metname)<<
"The MuonTrackLinkCollection is incomplete";
478 LogTrace(metname) <<
"put the MuonCollection in the event" <<
"\n";
480 return event.put(trackLinksCollection);
489 const string metname =
"Muon|RecoMuon|MuonTrackLoader|TevMuonTrackLoader";
499 auto_ptr<reco:: TrackToTrackMap> trackToTrackmap(
new reco::TrackToTrackMap(trackHandle,trackCollectionRefProd ));
512 auto_ptr<vector<Trajectory> > trajectoryCollection(
new vector<Trajectory>);
515 if ( trajectories.empty() ) {
516 event.put(recHitCollection,instance);
517 event.put(trackExtraCollection,instance);
519 event.put(trajectoryCollection,instance);
523 event.put( trajTrackMap, instance );
525 event.put(trackToTrackmap, instance);
529 LogTrace(metname) <<
"Create the collection of Tracks";
542 std::map<unsigned int, unsigned int> tjTkMap;
554 for(TrajectoryContainer::const_iterator rawTrajectory = trajectories.begin();
555 rawTrajectory != trajectories.end(); ++rawTrajectory){
558 std::vector<std::pair<Trajectory*,reco::TrackRef> >::const_iterator mmit;
559 for(mmit = miniMap.begin();mmit!=miniMap.end();++mmit){
560 if(mmit->first == *rawTrajectory) glbRef = mmit->second;
566 vector<Trajectory> trajectoriesSM =
theSmoother->trajectories(**rawTrajectory);
568 if(!trajectoriesSM.empty()) {
570 trajectory = trajectoriesSM.front();
573 LogInfo(metname)<<
"The trajectory has not been smoothed!"<<endl;
577 trajectoryCollection->push_back(trajectory);
585 reverse(transHits.begin(),transHits.end());
589 pair<bool,reco::Track> resultOfTrackExtrapAtPCA =
buildTrackAtPCA(trajectory, *beamSpot);
592 if(!resultOfTrackExtrapAtPCA.first) {
594 delete *rawTrajectory;
599 reco::Track &track = resultOfTrackExtrapAtPCA.second;
611 trackToTrackmap->insert(glbRef,
615 pair<bool,reco::Track> updateResult(
false,
reco::Track());
618 unsigned int nHitsAdded = 0;
619 for (Trajectory::RecHitContainer::const_iterator recHit = transHits.begin();
620 recHit != transHits.end(); ++recHit) {
624 for (std::vector<const TrackingRecHit*>::const_iterator it = hits.begin(); it != hits.end(); ++it) {
632 for (std::vector<const TrackingRecHit*>::const_iterator it = hits.begin(); it != hits.end(); ++it) {
633 if unlikely(!updateResult.second.appendHitPattern(**it, ttopo)){
638 recHitCollection->push_back( singleHit );
642 trackExtra.
setHits(recHitCollectionRefProd, recHitsIndex, nHitsAdded);
643 recHitsIndex += nHitsAdded;
646 trackExtraCollection->push_back(trackExtra);
651 LogTrace(metname) <<
"Debug Track being loaded pt "<< track.
pt();
656 delete *rawTrajectory;
664 LogTrace(metname) <<
"put the Collections in the event";
665 event.put(recHitCollection,instance);
666 event.put(trackExtraCollection,instance);
673 event.put(trackToTrackmap,instance);
675 nonUpdatedHandle = returnTrackHandle;
685 for ( std::map<unsigned int, unsigned int>::iterator
i = tjTkMap.begin();
686 i != tjTkMap.end();
i++ ) {
687 trajTrackMap->insert(
edm::Ref<std::vector<Trajectory> >( rTrajs, (*i).first ),
690 event.put( trajTrackMap, instance );
693 return returnTrackHandle;
699 const string metname =
"Muon|RecoMuon|MuonTrackLoader";
707 LogTrace(metname) <<
"Propagate to PCA...";
708 pair<bool,FreeTrajectoryState>
712 if(extrapolationResult.first)
713 ftsAtVtx = extrapolationResult.second;
716 LogInfo(metname) <<
"Track in the Tracker: taking the innermost state instead of the state at PCA";
721 LogInfo(metname) <<
"Propagation to PCA failed, taking the innermost state instead of the state at PCA";
724 LogInfo(metname) <<
"Stand Alone track: this track will be rejected";
725 return pair<bool,reco::Track>(
false,
reco::Track());
730 LogTrace(metname) <<
"TSOS after the extrapolation at vtx";
749 return pair<bool,reco::Track>(
true,track);
755 const string metname =
"Muon|RecoMuon|MuonTrackLoader";
763 LogTrace(metname) <<
"Apply the vertex constraint";
766 if(!updateResult.first){
767 return pair<bool,reco::Track>(
false,
reco::Track());
770 LogTrace(metname) <<
"FTS after the vertex constraint";
787 return pair<bool,reco::Track>(
true,updatedTrack);
793 const string metname =
"Muon|RecoMuon|MuonTrackLoader";
803 unsigned int innerId=0, outerId=0;
817 LogTrace(metname)<<
"oppositeToMomentum";
825 else LogError(metname)<<
"Wrong propagation direction!";
835 LogTrace(metname)<<
"The Global Muon outerMostMeasurementState is not compatible with the recHit detector! Setting outerMost postition to recHit position if recHit isValid: " << outerRecHit->isValid();
836 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!
virtual int dimension() const =0
static bool isInside(const GlobalPoint &)
ConstRecHitPointer const & recHit() const
virtual bool inside(const Local3DPoint &) const =0
Determine if the point is inside the bounds.
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
std::vector< MuonTrackLinks > MuonTrackLinksCollection
collection of MuonTrackLinks
MuonCandidate::CandidateContainer CandidateContainer
const MuonServiceProxy * theService
void setGlobalTrack(reco::TrackRef glb)
set the ref to combined track
std::string dumpFTS(const FreeTrajectoryState &fts) const
PropagationDirection const & direction() const
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 ~MuonTrackLoader()
Destructor.
TrajectoryMeasurement const & lastMeasurement() const
double pt() const
track transverse momentum
FreeTrajectoryState const * freeState(bool withErrors=true) const
GlobalVector momentum() const
virtual std::vector< const TrackingRecHit * > recHits() const =0
Access to component RecHits (if any)
tuple MuonUpdatorAtVertex
edm::RefToBase< TrajectorySeed > seedRef(void) const
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
edm::AssociationMap< edm::OneToOne< std::vector< Trajectory >, reco::TrackCollection, unsigned short > > TrajTrackAssociationCollection
MuonUpdatorAtVertex * theUpdatorAtVtx
GlobalVector momentum() const
MuonCandidate::TrajectoryContainer TrajectoryContainer
GlobalPoint position() const
virtual TrackingRecHit * clone() const =0
GlobalPoint position() const
int ndof(bool bon=true) const
virtual TrackingRecHit const * hit() const
std::vector< TrackExtra > TrackExtraCollection
collection of TrackExtra objects
edm::OwnVector< TrackingRecHit > TrackingRecHitCollection
collection of TrackingRecHits
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
T const * product() const
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.
ParameterSet const & parameterSet(Provenance const &provenance)
boost::remove_cv< typename boost::remove_reference< argument_type >::type >::type key_type