CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes
MuonTrackLoader Class Reference

#include <MuonTrackLoader.h>

Public Types

typedef MuonCandidate::CandidateContainer CandidateContainer
 
typedef MuonCandidate::TrajectoryContainer TrajectoryContainer
 

Public Member Functions

edm::OrphanHandle< reco::TrackCollectionloadTracks (const TrajectoryContainer &, edm::Event &, const TrackerTopology &ttopo, const std::string &="", bool=true)
 Convert the trajectories into tracks and load the tracks in the event. More...
 
edm::OrphanHandle< reco::TrackCollectionloadTracks (const TrajectoryContainer &, edm::Event &, std::vector< bool > &, const TrackerTopology &ttopo, const std::string &="", bool=true)
 Convert the trajectories into tracks and load the tracks in the event. More...
 
edm::OrphanHandle< reco::TrackCollectionloadTracks (const TrajectoryContainer &, edm::Event &, const std::vector< std::pair< Trajectory *, reco::TrackRef > > &, edm::Handle< reco::TrackCollection > const &trackHandle, const TrackerTopology &ttopo, const std::string &="", bool=true)
 Convert the trajectories into tracks and load the tracks in the event. More...
 
edm::OrphanHandle< reco::MuonTrackLinksCollectionloadTracks (const CandidateContainer &, edm::Event &, const TrackerTopology &ttopo)
 Convert the trajectories into tracks and load the tracks in the event. More...
 
 MuonTrackLoader (edm::ParameterSet &parameterSet, edm::ConsumesCollector &iC, const MuonServiceProxy *service=0)
 Constructor for the STA reco the args must be specify! More...
 
virtual ~MuonTrackLoader ()
 Destructor. More...
 

Private Member Functions

std::pair< bool, reco::TrackbuildTrackAtPCA (const Trajectory &trajectory, const reco::BeamSpot &) const
 Build a track at the PCA WITHOUT any vertex constriant. More...
 
reco::TrackExtra buildTrackExtra (const Trajectory &) const
 
std::pair< bool, reco::TrackbuildTrackUpdatedAtPCA (const reco::Track &trackAtPCA, const reco::BeamSpot &) const
 Takes a track at the PCA and applies the vertex constriant. More...
 

Static Private Member Functions

static std::vector< const TrackingRecHit * > unpackHit (const TrackingRecHit &hit)
 

Private Attributes

TkClonerImpl hitCloner
 
bool theAllowNoVtxFlag
 
edm::InputTag theBeamSpotInputTag
 
edm::EDGetTokenT< reco::BeamSpottheBeamSpotToken
 
std::string theL2SeededTkLabel
 Label for L2SeededTracks. More...
 
bool thePutTkTrackFlag
 
const MuonServiceProxytheService
 
std::unique_ptr< TrajectorySmoothertheSmoother
 
std::string theSmootherName
 
bool theSmoothingStep
 
bool theSmoothTkTrackFlag
 
std::string theTrackerRecHitBuilderName
 
bool theTrajectoryFlag
 
bool theUpdatingAtVtx
 
MuonUpdatorAtVertextheUpdatorAtVtx
 

Detailed Description

Class to load the tracks in the event, it provide some common functionalities both for all the RecoMuon producers.

Author
R. Bellan - INFN Torino ricca.nosp@m.rdo..nosp@m.bella.nosp@m.n@ce.nosp@m.rn.ch

Class to load the product in the event

Author
R. Bellan - INFN Torino ricca.nosp@m.rdo..nosp@m.bella.nosp@m.n@ce.nosp@m.rn.ch

Definition at line 40 of file MuonTrackLoader.h.

Member Typedef Documentation

Definition at line 44 of file MuonTrackLoader.h.

Definition at line 43 of file MuonTrackLoader.h.

Constructor & Destructor Documentation

MuonTrackLoader::MuonTrackLoader ( edm::ParameterSet parameterSet,
edm::ConsumesCollector iC,
const MuonServiceProxy service = 0 
)

Constructor for the STA reco the args must be specify!

Definition at line 97 of file MuonTrackLoader.cc.

References edm::ConsumesCollector::consumes(), edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), MuonUpdatorAtVertex_cff::MuonUpdatorAtVertex, AlCaHLTBitMon_QueryRunRegistry::string, theAllowNoVtxFlag, theBeamSpotInputTag, theBeamSpotToken, theL2SeededTkLabel, thePutTkTrackFlag, theSmootherName, theSmoothingStep, theSmoothTkTrackFlag, theTrackerRecHitBuilderName, theTrajectoryFlag, theUpdatingAtVtx, and theUpdatorAtVtx.

97  :
99 
100 
101  // option to do or not the smoothing step.
102  // the trajectories which are passed to the track loader are supposed to be non-smoothed
103  theSmoothingStep = parameterSet.getParameter<bool>("DoSmoothing");
104  if(theSmoothingStep)
105  theSmootherName = parameterSet.getParameter<string>("Smoother");
106 
107  theTrackerRecHitBuilderName = parameterSet.getParameter<std::string>("TTRHBuilder");
108 
109  // update at vertex
110  theUpdatingAtVtx = parameterSet.getParameter<bool>("VertexConstraint");
111 
112  // beam spot input tag
113  theBeamSpotInputTag = parameterSet.getParameter<edm::InputTag>("beamSpot");
115 
116 
117  // Flag to put the trajectory into the event
118  theTrajectoryFlag = parameterSet.getUntrackedParameter<bool>("PutTrajectoryIntoEvent",true);
119 
120  theL2SeededTkLabel = parameterSet.getUntrackedParameter<string>("MuonSeededTracksInstance",string());
121 
122  ParameterSet updatorPar = parameterSet.getParameter<ParameterSet>("MuonUpdatorAtVertexParameters");
123  theUpdatorAtVtx = new MuonUpdatorAtVertex(updatorPar,service);
124 
125  thePutTkTrackFlag = parameterSet.getUntrackedParameter<bool>("PutTkTrackIntoEvent",false);
126  theSmoothTkTrackFlag = parameterSet.getUntrackedParameter<bool>("SmoothTkTrack",false);
127  theAllowNoVtxFlag = parameterSet.getUntrackedParameter<bool>("AllowNoVertex",false);
128 }
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
T getParameter(std::string const &) const
edm::EDGetTokenT< reco::BeamSpot > theBeamSpotToken
T getUntrackedParameter(std::string const &, T const &) const
std::string theSmootherName
edm::InputTag theBeamSpotInputTag
std::string theTrackerRecHitBuilderName
MuonUpdatorAtVertex * theUpdatorAtVtx
std::string theL2SeededTkLabel
Label for L2SeededTracks.
const MuonServiceProxy * theService
MuonTrackLoader::~MuonTrackLoader ( )
virtual

Member Function Documentation

pair< bool, reco::Track > MuonTrackLoader::buildTrackAtPCA ( const Trajectory trajectory,
const reco::BeamSpot beamSpot 
) const
private

Build a track at the PCA WITHOUT any vertex constriant.

Definition at line 695 of file MuonTrackLoader.cc.

References FreeTrajectoryState::charge(), Trajectory::chiSquared(), FreeTrajectoryState::curvilinearError(), debug, MuonPatternRecoDumper::dumpFTS(), TrajectoryStateOnSurface::freeState(), Trajectory::geometricalInnermostState(), TrajectoryStateOnSurface::globalPosition(), TrackerBounds::isInside(), LogTrace, metname, FreeTrajectoryState::momentum(), ndof, Trajectory::ndof(), AlCaHLTBitMon_ParallelJobs::p, FreeTrajectoryState::position(), MuonUpdatorAtVertex::propagate(), theAllowNoVtxFlag, theService, theUpdatorAtVtx, HiIsolationCommonParameters_cff::track, PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), and PV3DBase< T, PVType, FrameType >::z().

Referenced by loadTracks(), and ~MuonTrackLoader().

695  {
696 
697  const string metname = "Muon|RecoMuon|MuonTrackLoader";
698 
700 
701  // FIXME: check the prop direction
702  TrajectoryStateOnSurface innerTSOS = trajectory.geometricalInnermostState();
703 
704  // This is needed to extrapolate the tsos at vertex
705  LogTrace(metname) << "Propagate to PCA...";
706  pair<bool,FreeTrajectoryState>
707  extrapolationResult = theUpdatorAtVtx->propagate(innerTSOS, beamSpot);
708  FreeTrajectoryState ftsAtVtx;
709 
710  if(extrapolationResult.first)
711  ftsAtVtx = extrapolationResult.second;
712  else{
713  if(TrackerBounds::isInside(innerTSOS.globalPosition())){
714  LogInfo(metname) << "Track in the Tracker: taking the innermost state instead of the state at PCA";
715  ftsAtVtx = *innerTSOS.freeState();
716  }
717  else{
718  if ( theAllowNoVtxFlag ) {
719  LogInfo(metname) << "Propagation to PCA failed, taking the innermost state instead of the state at PCA";
720  ftsAtVtx = *innerTSOS.freeState();
721  } else {
722  LogInfo(metname) << "Stand Alone track: this track will be rejected";
723  return pair<bool,reco::Track>(false,reco::Track());
724  }
725  }
726  }
727 
728  LogTrace(metname) << "TSOS after the extrapolation at vtx";
729  LogTrace(metname) << debug.dumpFTS(ftsAtVtx);
730 
731  GlobalPoint pca = ftsAtVtx.position();
732  math::XYZPoint persistentPCA(pca.x(),pca.y(),pca.z());
733  GlobalVector p = ftsAtVtx.momentum();
734  math::XYZVector persistentMomentum(p.x(),p.y(),p.z());
735 
736  bool bon = true;
737  if(fabs(theService->magneticField()->inTesla(GlobalPoint(0,0,0)).z()) < 0.01) bon=false;
738  double ndof = trajectory.ndof(bon);
739 
740  reco::Track track(trajectory.chiSquared(),
741  ndof,
742  persistentPCA,
743  persistentMomentum,
744  ftsAtVtx.charge(),
745  ftsAtVtx.curvilinearError());
746 
747  return pair<bool,reco::Track>(true,track);
748 }
static bool isInside(const GlobalPoint &)
const std::string metname
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
T y() const
Definition: PV3DBase.h:63
std::pair< bool, FreeTrajectoryState > propagate(const TrajectoryStateOnSurface &tsos, const reco::BeamSpot &beamSpot) const
Propagate the state to the 2D-PCA.
GlobalPoint globalPosition() const
TrackCharge charge() const
TrajectoryStateOnSurface geometricalInnermostState() const
Definition: Trajectory.cc:220
const CurvilinearTrajectoryError & curvilinearError() const
std::string dumpFTS(const FreeTrajectoryState &fts) const
FreeTrajectoryState const * freeState(bool withErrors=true) const
T z() const
Definition: PV3DBase.h:64
MuonUpdatorAtVertex * theUpdatorAtVtx
GlobalVector momentum() const
#define LogTrace(id)
GlobalPoint position() const
int ndof(bool bon=true) const
Definition: Trajectory.cc:102
#define debug
Definition: HDRShower.cc:19
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:30
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
float chiSquared() const
Definition: Trajectory.h:262
const MuonServiceProxy * theService
T x() const
Definition: PV3DBase.h:62
reco::TrackExtra MuonTrackLoader::buildTrackExtra ( const Trajectory trajectory) const
private

Definition at line 789 of file MuonTrackLoader.cc.

References alongMomentum, Surface::bounds(), TrajectoryStateOnSurface::curvilinearError(), Trajectory::direction(), Trajectory::firstMeasurement(), TrajectoryStateOnSurface::globalParameters(), Bounds::inside(), Trajectory::lastMeasurement(), LogTrace, metname, GlobalTrajectoryParameters::momentum(), oppositeToMomentum, AlCaHLTBitMon_ParallelJobs::p, GlobalTrajectoryParameters::position(), TrajectoryMeasurement::recHit(), Trajectory::recHits(), Trajectory::seedRef(), GeomDet::surface(), theService, GeomDet::toLocal(), TrajectoryMeasurement::updatedState(), findQualityFiles::v, PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), and PV3DBase< T, PVType, FrameType >::z().

Referenced by loadTracks(), and ~MuonTrackLoader().

789  {
790 
791  const string metname = "Muon|RecoMuon|MuonTrackLoader";
792 
793  const Trajectory::RecHitContainer transRecHits = trajectory.recHits();
794 
795  // put the collection of TrackingRecHit in the event
796 
797  // sets the outermost and innermost TSOSs
798  // FIXME: check it!
799  TrajectoryStateOnSurface outerTSOS;
800  TrajectoryStateOnSurface innerTSOS;
801  unsigned int innerId=0, outerId=0;
803  DetId outerDetId;
804 
805  if (trajectory.direction() == alongMomentum) {
806  LogTrace(metname)<<"alongMomentum";
807  outerTSOS = trajectory.lastMeasurement().updatedState();
808  innerTSOS = trajectory.firstMeasurement().updatedState();
809  outerId = trajectory.lastMeasurement().recHit()->geographicalId().rawId();
810  innerId = trajectory.firstMeasurement().recHit()->geographicalId().rawId();
811  outerRecHit = trajectory.lastMeasurement().recHit();
812  outerDetId = trajectory.lastMeasurement().recHit()->geographicalId();
813  }
814  else if (trajectory.direction() == oppositeToMomentum) {
815  LogTrace(metname)<<"oppositeToMomentum";
816  outerTSOS = trajectory.firstMeasurement().updatedState();
817  innerTSOS = trajectory.lastMeasurement().updatedState();
818  outerId = trajectory.firstMeasurement().recHit()->geographicalId().rawId();
819  innerId = trajectory.lastMeasurement().recHit()->geographicalId().rawId();
820  outerRecHit = trajectory.firstMeasurement().recHit();
821  outerDetId = trajectory.firstMeasurement().recHit()->geographicalId();
822  }
823  else LogError(metname)<<"Wrong propagation direction!";
824 
825  const GeomDet *outerDet = theService->trackingGeometry()->idToDet(outerDetId);
826  GlobalPoint outerTSOSPos = outerTSOS.globalParameters().position();
827  bool inside = outerDet->surface().bounds().inside(outerDet->toLocal(outerTSOSPos));
828 
829 
830  GlobalPoint hitPos = (outerRecHit->isValid()) ? outerRecHit->globalPosition() : outerTSOS.globalParameters().position() ;
831 
832  if(!inside) {
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;
835  }
836 
837 
838  //build the TrackExtra
839  GlobalPoint v = (inside) ? outerTSOSPos : hitPos ;
840  GlobalVector p = outerTSOS.globalParameters().momentum();
841  math::XYZPoint outpos( v.x(), v.y(), v.z() );
842  math::XYZVector outmom( p.x(), p.y(), p.z() );
843 
844  v = innerTSOS.globalParameters().position();
845  p = innerTSOS.globalParameters().momentum();
846  math::XYZPoint inpos( v.x(), v.y(), v.z() );
847  math::XYZVector inmom( p.x(), p.y(), p.z() );
848 
849  reco::TrackExtra trackExtra(outpos, outmom, true, inpos, inmom, true,
850  outerTSOS.curvilinearError(), outerId,
851  innerTSOS.curvilinearError(), innerId,
852  trajectory.direction(),trajectory.seedRef());
853 
854  return trackExtra;
855 
856 }
ConstRecHitPointer const & recHit() const
const std::string metname
const CurvilinearTrajectoryError & curvilinearError() const
T y() const
Definition: PV3DBase.h:63
LocalPoint toLocal(const GlobalPoint &gp) const
Conversion to the R.F. of the GeomDet.
Definition: GeomDet.h:69
ConstRecHitContainer recHits() const
Definition: Trajectory.h:204
const Bounds & bounds() const
Definition: Surface.h:120
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:42
PropagationDirection const & direction() const
Definition: Trajectory.cc:140
virtual bool inside(const Local3DPoint &) const =0
Determine if the point is inside the bounds.
TrajectoryMeasurement const & lastMeasurement() const
Definition: Trajectory.h:174
T z() const
Definition: PV3DBase.h:64
edm::RefToBase< TrajectorySeed > seedRef(void) const
Definition: Trajectory.h:321
#define LogTrace(id)
Definition: DetId.h:18
TrajectoryMeasurement const & firstMeasurement() const
Definition: Trajectory.h:187
ConstRecHitContainer RecHitContainer
Definition: Trajectory.h:46
const GlobalTrajectoryParameters & globalParameters() const
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:30
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
TrackingRecHit::ConstRecHitPointer ConstRecHitPointer
const MuonServiceProxy * theService
TrajectoryStateOnSurface const & updatedState() const
T x() const
Definition: PV3DBase.h:62
pair< bool, reco::Track > MuonTrackLoader::buildTrackUpdatedAtPCA ( const reco::Track trackAtPCA,
const reco::BeamSpot beamSpot 
) const
private

Takes a track at the PCA and applies the vertex constriant.

Definition at line 751 of file MuonTrackLoader.cc.

References FreeTrajectoryState::charge(), reco::TrackBase::chi2(), FreeTrajectoryState::curvilinearError(), debug, MuonPatternRecoDumper::dumpFTS(), LogTrace, metname, FreeTrajectoryState::momentum(), reco::TrackBase::ndof(), AlCaHLTBitMon_ParallelJobs::p, FreeTrajectoryState::position(), theService, theUpdatorAtVtx, MuonUpdatorAtVertex::update(), PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), and PV3DBase< T, PVType, FrameType >::z().

Referenced by ~MuonTrackLoader().

751  {
752 
753  const string metname = "Muon|RecoMuon|MuonTrackLoader";
755 
756  // build the transient track
757  reco::TransientTrack transientTrack(track,
758  &*theService->magneticField(),
759  theService->trackingGeometry());
760 
761  LogTrace(metname) << "Apply the vertex constraint";
762  pair<bool,FreeTrajectoryState> updateResult = theUpdatorAtVtx->update(transientTrack,beamSpot);
763 
764  if(!updateResult.first){
765  return pair<bool,reco::Track>(false,reco::Track());
766  }
767 
768  LogTrace(metname) << "FTS after the vertex constraint";
769  FreeTrajectoryState &ftsAtVtx = updateResult.second;
770 
771  LogTrace(metname) << debug.dumpFTS(ftsAtVtx);
772 
773  GlobalPoint pca = ftsAtVtx.position();
774  math::XYZPoint persistentPCA(pca.x(),pca.y(),pca.z());
775  GlobalVector p = ftsAtVtx.momentum();
776  math::XYZVector persistentMomentum(p.x(),p.y(),p.z());
777 
778  reco::Track updatedTrack(track.chi2(),
779  track.ndof(),
780  persistentPCA,
781  persistentMomentum,
782  ftsAtVtx.charge(),
783  ftsAtVtx.curvilinearError());
784 
785  return pair<bool,reco::Track>(true,updatedTrack);
786 }
const std::string metname
T y() const
Definition: PV3DBase.h:63
TrackCharge charge() const
const CurvilinearTrajectoryError & curvilinearError() const
std::string dumpFTS(const FreeTrajectoryState &fts) const
std::pair< bool, FreeTrajectoryState > update(const reco::TransientTrack &track, const reco::BeamSpot &beamSpot) const
Applies the vertex constraint.
T z() const
Definition: PV3DBase.h:64
MuonUpdatorAtVertex * theUpdatorAtVtx
GlobalVector momentum() const
#define LogTrace(id)
GlobalPoint position() const
#define debug
Definition: HDRShower.cc:19
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:30
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
const MuonServiceProxy * theService
T x() const
Definition: PV3DBase.h:62
edm::OrphanHandle<reco::TrackCollection> MuonTrackLoader::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.

Referenced by MuonTrackFinder::load(), loadTracks(), and ~MuonTrackLoader().

edm::OrphanHandle<reco::TrackCollection> MuonTrackLoader::loadTracks ( const TrajectoryContainer ,
edm::Event ,
std::vector< bool > &  ,
const TrackerTopology ttopo,
const std::string &  = "",
bool  = true 
)

Convert the trajectories into tracks and load the tracks in the event.

edm::OrphanHandle<reco::TrackCollection> MuonTrackLoader::loadTracks ( const TrajectoryContainer ,
edm::Event ,
const std::vector< std::pair< Trajectory *, reco::TrackRef > > &  ,
edm::Handle< reco::TrackCollection > const &  trackHandle,
const TrackerTopology ttopo,
const std::string &  = "",
bool  = true 
)

Convert the trajectories into tracks and load the tracks in the event.

OrphanHandle< reco::MuonTrackLinksCollection > MuonTrackLoader::loadTracks ( const CandidateContainer muonCands,
edm::Event event,
const TrackerTopology ttopo 
)

Convert the trajectories into tracks and load the tracks in the event.

Definition at line 375 of file MuonTrackLoader.cc.

References reco::TrackBase::appendHitPattern(), ecalDrivenElectronSeedsParameters_cff::beamSpot, buildTrackAtPCA(), buildTrackExtra(), TrajectorySmoother::clone(), hitCloner, hfClusterShapes_cfi::hits, mps_fire::i, instance, edm::OrphanHandleBase::isValid(), loadTracks(), LogDebug, LogTrace, metname, eostools::move(), position, edm::ESHandle< T >::product(), reco::TrackBase::pt(), edm::OwnVector< T, P >::push_back(), reco::TrackExtraBase::recHitsSize(), reco::Track::setExtra(), reco::MuonTrackLinks::setGlobalTrack(), reco::TrackExtraBase::setHits(), Trajectory::setSeedRef(), reco::MuonTrackLinks::setStandAloneTrack(), reco::MuonTrackLinks::setTrackerTrack(), reco::TrackExtraBase::setTrajParams(), theBeamSpotToken, theL2SeededTkLabel, thePutTkTrackFlag, theService, theSmoother, theSmootherName, theSmoothingStep, theSmoothTkTrackFlag, theTrackerRecHitBuilderName, theTrajectoryFlag, theUpdatingAtVtx, HiIsolationCommonParameters_cff::track, findElectronsInSiStrips_cfi::trackCollection, HiRegitMuonDetachedTripletStep_cff::trajectories, reco::TrackExtraBase::trajParams(), unlikely, and unpackHit().

377  {
378 
379  const string metname = "Muon|RecoMuon|MuonTrackLoader";
380 
381  // the muon collection, it will be loaded in the event
382  auto trackLinksCollection = std::make_unique<reco::MuonTrackLinksCollection>();
383 
384  // don't waste any time...
385  if ( muonCands.empty() ) {
386  auto trackExtraCollection = std::make_unique<reco::TrackExtraCollection>();
387  auto recHitCollection = std::make_unique<TrackingRecHitCollection>();
388  auto trackCollection = std::make_unique<reco::TrackCollection>();
389 
390  event.put(std::move(recHitCollection));
391  event.put(std::move(trackExtraCollection));
392  event.put(std::move(trackCollection));
393 
394  //need to also put the tracker tracks collection if requested
395  if(thePutTkTrackFlag){
396  //will take care of putting nothing in the event but the empty collection
397  TrajectoryContainer trackerTrajs;
398  loadTracks(trackerTrajs, event, ttopo, theL2SeededTkLabel, theSmoothTkTrackFlag);
399  }
400 
401  return event.put(std::move(trackLinksCollection));
402  }
403 
404  // get combined Trajectories
405  TrajectoryContainer combinedTrajs;
406  TrajectoryContainer trackerTrajs;
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();
410 
411  combinedTrajs.push_back((*it)->trajectory());
412  if ( thePutTkTrackFlag ) trackerTrajs.push_back((*it)->trackerTrajectory());
413 
414  else {
415  if ((*it)->trackerTrajectory()) delete ((*it)->trackerTrajectory());
416  }
417 
418  // // Create the links between sta and tracker tracks
419  // reco::MuonTrackLinks links;
420  // links.setStandAloneTrack((*it)->muonTrack());
421  // links.setTrackerTrack((*it)->trackerTrack());
422  // trackLinksCollection->push_back(links);
423  // delete *it;
424  }
425 
426  // create the TrackCollection of combined Trajectories
427  // FIXME: could this be done one track at a time in the previous loop?
428  LogTrace(metname) << "Build combinedTracks";
429  std::vector<bool> combTksVec(combinedTrajs.size(), false);
430  OrphanHandle<reco::TrackCollection> combinedTracks = loadTracks(combinedTrajs, event, combTksVec, ttopo);
431 
433  std::vector<bool> trackerTksVec(trackerTrajs.size(), false);
434  if(thePutTkTrackFlag) {
435  LogTrace(metname) << "Build trackerTracks: "
436  << trackerTrajs.size();
437  trackerTracks = loadTracks(trackerTrajs, event, trackerTksVec, ttopo, theL2SeededTkLabel, theSmoothTkTrackFlag);
438  } else {
439  for (TrajectoryContainer::iterator it = trackerTrajs.begin(); it != trackerTrajs.end(); ++it) {
440  if(*it) delete *it;
441  }
442  }
443 
444  LogTrace(metname) << "Set the final links in the MuonTrackLinks collection";
445 
446  unsigned int candposition(0), position(0), tkposition(0);
447  //reco::TrackCollection::const_iterator glIt = combinedTracks->begin(),
448  // glEnd = combinedTracks->end();
449 
450  for (CandidateContainer::const_iterator it = muonCands.begin(); it != muonCands.end(); ++it, ++candposition) {
451 
452  // The presence of the global track determines whether to fill the MuonTrackLinks or not
453  // N.B. We are assuming here that the global tracks in "combinedTracks"
454  // have the same order as the muon candidates in "muonCands"
455  // (except for possible missing tracks), which should always be the case...
456  //if( glIt == glEnd ) break;
457  if(combTksVec[candposition]) {
458  reco::TrackRef combinedTR(combinedTracks, position++);
459  //++glIt;
460 
461  // Create the links between sta and tracker tracks
462  reco::MuonTrackLinks links;
463  links.setStandAloneTrack((*it)->muonTrack());
464  links.setTrackerTrack((*it)->trackerTrack());
465  links.setGlobalTrack(combinedTR);
466 
467  if(thePutTkTrackFlag && trackerTksVec[candposition]) {
468  reco::TrackRef trackerTR(trackerTracks, tkposition++);
469  links.setTrackerTrack(trackerTR);
470  }
471 
472  trackLinksCollection->push_back(links);
473  }
474 
475  else { // if no global track, still increment the tracker-track counter when appropriate
476  if(thePutTkTrackFlag && trackerTksVec[candposition]) tkposition++;
477  }
478 
479  delete *it;
480  }
481 
482  if( thePutTkTrackFlag && trackerTracks.isValid() && !(!combinedTracks->empty() && !trackerTracks->empty() ) )
483  LogWarning(metname)<<"The MuonTrackLinkCollection is incomplete";
484 
485  // put the MuonCollection in the event
486  LogTrace(metname) << "put the MuonCollection in the event" << "\n";
487 
488  return event.put(std::move(trackLinksCollection));
489 }
#define LogDebug(id)
const std::string metname
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.
#define LogTrace(id)
MuonCandidate::TrajectoryContainer TrajectoryContainer
std::string theL2SeededTkLabel
Label for L2SeededTracks.
static int position[264][3]
Definition: ReadPGInfo.cc:509
def move(src, dest)
Definition: eostools.py:510
std::vector< const TrackingRecHit * > MuonTrackLoader::unpackHit ( const TrackingRecHit hit)
staticprivate

Definition at line 47 of file MuonTrackLoader.cc.

References popcon2dropbox::copy(), MuonSubdetId::CSC, DetId::det(), TrackingRecHit::dimension(), MuonSubdetId::DT, MuonSubdetId::GEM, TrackingRecHit::geographicalId(), hfClusterShapes_cfi::hits, MuonSubdetId::ME0, DetId::Muon, TrackingRecHit::recHits(), MuonSubdetId::RPC, and DetId::Tracker.

Referenced by loadTracks(), and ~MuonTrackLoader().

48 {
49  // get rec hit det id and rec hit type
50  DetId id = hit.geographicalId();
51  uint16_t detid = id.det();
52 
53  std::vector<const TrackingRecHit*> hits;
54 
55  if (detid == DetId::Tracker) {
56  hits.push_back(&hit);
57  } else if (detid == DetId::Muon) {
58  uint16_t subdet = id.subdetId();
59  if (subdet == (uint16_t) MuonSubdetId::DT) {
60  if (hit.dimension() == 1) { // DT rechit (granularity 2)
61  hits.push_back(&hit);
62  } else if (hit.dimension() > 1) { // 4D segment (granularity 0).
63  // Both 2 and 4 dim cases. MB4s have 2D, but formatted in 4D segment
64  // 4D --> 2D
65  std::vector<const TrackingRecHit*> seg2D = hit.recHits();
66  // load 1D hits (2D --> 1D)
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));
70  }
71  }
72  } else if (subdet == (uint16_t) MuonSubdetId::CSC) {
73  if (hit.dimension() == 2) { // CSC rechit (granularity 2)
74  hits.push_back(&hit);
75  } else if (hit.dimension() == 4) { // 4D segment (granularity 0)
76  // load 2D hits (4D --> 1D)
77  hits = hit.recHits();
78  }
79  } else if (subdet == (uint16_t) MuonSubdetId::RPC) {
80  hits.push_back(&hit);
81  }
82  else if (subdet == (uint16_t) MuonSubdetId::GEM) {
83  if (hit.dimension() == 2) { // GEM rechit
84  hits.push_back(&hit);
85  } else if (hit.dimension() == 4) { // GEM segment
86  hits = hit.recHits();
87  }
88  }
89  else if (subdet == (uint16_t) MuonSubdetId::ME0) { //segment
90  hits = hit.recHits();
91  }
92  }
93  return hits;
94 }
static const int GEM
Definition: MuonSubdetId.h:15
virtual std::vector< const TrackingRecHit * > recHits() const =0
Access to component RecHits (if any)
static const int ME0
Definition: MuonSubdetId.h:16
static const int CSC
Definition: MuonSubdetId.h:13
virtual int dimension() const =0
Definition: DetId.h:18
static const int RPC
Definition: MuonSubdetId.h:14
static const int DT
Definition: MuonSubdetId.h:12
DetId geographicalId() const
Detector det() const
get the detector field from this detid
Definition: DetId.h:35

Member Data Documentation

TkClonerImpl MuonTrackLoader::hitCloner
private

Definition at line 101 of file MuonTrackLoader.h.

Referenced by loadTracks(), and ~MuonTrackLoader().

bool MuonTrackLoader::theAllowNoVtxFlag
private

Definition at line 111 of file MuonTrackLoader.h.

Referenced by buildTrackAtPCA(), and MuonTrackLoader().

edm::InputTag MuonTrackLoader::theBeamSpotInputTag
private

Definition at line 104 of file MuonTrackLoader.h.

Referenced by MuonTrackLoader().

edm::EDGetTokenT<reco::BeamSpot> MuonTrackLoader::theBeamSpotToken
private

Definition at line 105 of file MuonTrackLoader.h.

Referenced by loadTracks(), MuonTrackLoader(), and ~MuonTrackLoader().

std::string MuonTrackLoader::theL2SeededTkLabel
private

Label for L2SeededTracks.

Definition at line 108 of file MuonTrackLoader.h.

Referenced by loadTracks(), and MuonTrackLoader().

bool MuonTrackLoader::thePutTkTrackFlag
private

Definition at line 109 of file MuonTrackLoader.h.

Referenced by loadTracks(), and MuonTrackLoader().

const MuonServiceProxy* MuonTrackLoader::theService
private
std::unique_ptr<TrajectorySmoother> MuonTrackLoader::theSmoother
private

Definition at line 100 of file MuonTrackLoader.h.

Referenced by loadTracks(), and ~MuonTrackLoader().

std::string MuonTrackLoader::theSmootherName
private

Definition at line 98 of file MuonTrackLoader.h.

Referenced by loadTracks(), MuonTrackLoader(), and ~MuonTrackLoader().

bool MuonTrackLoader::theSmoothingStep
private

Definition at line 97 of file MuonTrackLoader.h.

Referenced by loadTracks(), MuonTrackLoader(), and ~MuonTrackLoader().

bool MuonTrackLoader::theSmoothTkTrackFlag
private

Definition at line 110 of file MuonTrackLoader.h.

Referenced by loadTracks(), and MuonTrackLoader().

std::string MuonTrackLoader::theTrackerRecHitBuilderName
private

Definition at line 99 of file MuonTrackLoader.h.

Referenced by loadTracks(), MuonTrackLoader(), and ~MuonTrackLoader().

bool MuonTrackLoader::theTrajectoryFlag
private

Definition at line 95 of file MuonTrackLoader.h.

Referenced by loadTracks(), MuonTrackLoader(), and ~MuonTrackLoader().

bool MuonTrackLoader::theUpdatingAtVtx
private

Definition at line 92 of file MuonTrackLoader.h.

Referenced by loadTracks(), MuonTrackLoader(), and ~MuonTrackLoader().

MuonUpdatorAtVertex* MuonTrackLoader::theUpdatorAtVtx
private