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 43 of file MuonTrackLoader.h.

Member Typedef Documentation

Definition at line 46 of file MuonTrackLoader.h.

Definition at line 45 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 93 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.

96  : theService(service) {
97  // option to do or not the smoothing step.
98  // the trajectories which are passed to the track loader are supposed to be non-smoothed
99  theSmoothingStep = parameterSet.getParameter<bool>("DoSmoothing");
100  if (theSmoothingStep)
101  theSmootherName = parameterSet.getParameter<string>("Smoother");
102 
103  theTrackerRecHitBuilderName = parameterSet.getParameter<std::string>("TTRHBuilder");
104 
105  // update at vertex
106  theUpdatingAtVtx = parameterSet.getParameter<bool>("VertexConstraint");
107 
108  // beam spot input tag
109  theBeamSpotInputTag = parameterSet.getParameter<edm::InputTag>("beamSpot");
111 
112  // Flag to put the trajectory into the event
113  theTrajectoryFlag = parameterSet.getUntrackedParameter<bool>("PutTrajectoryIntoEvent", true);
114 
115  theL2SeededTkLabel = parameterSet.getUntrackedParameter<string>("MuonSeededTracksInstance", string());
116 
117  ParameterSet updatorPar = parameterSet.getParameter<ParameterSet>("MuonUpdatorAtVertexParameters");
118  theUpdatorAtVtx = new MuonUpdatorAtVertex(updatorPar, service);
119 
120  thePutTkTrackFlag = parameterSet.getUntrackedParameter<bool>("PutTkTrackIntoEvent", false);
121  theSmoothTkTrackFlag = parameterSet.getUntrackedParameter<bool>("SmoothTkTrack", false);
122  theAllowNoVtxFlag = parameterSet.getUntrackedParameter<bool>("AllowNoVertex", false);
123 }
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 692 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, HLT_2018_cff::track, PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), and PV3DBase< T, PVType, FrameType >::z().

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

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

Definition at line 773 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().

773  {
774  const string metname = "Muon|RecoMuon|MuonTrackLoader";
775 
776  const Trajectory::RecHitContainer transRecHits = trajectory.recHits();
777 
778  // put the collection of TrackingRecHit in the event
779 
780  // sets the outermost and innermost TSOSs
781  // FIXME: check it!
782  TrajectoryStateOnSurface outerTSOS;
783  TrajectoryStateOnSurface innerTSOS;
784  unsigned int innerId = 0, outerId = 0;
786  DetId outerDetId;
787 
788  if (trajectory.direction() == alongMomentum) {
789  LogTrace(metname) << "alongMomentum";
790  outerTSOS = trajectory.lastMeasurement().updatedState();
791  innerTSOS = trajectory.firstMeasurement().updatedState();
792  outerId = trajectory.lastMeasurement().recHit()->geographicalId().rawId();
793  innerId = trajectory.firstMeasurement().recHit()->geographicalId().rawId();
794  outerRecHit = trajectory.lastMeasurement().recHit();
795  outerDetId = trajectory.lastMeasurement().recHit()->geographicalId();
796  } else if (trajectory.direction() == oppositeToMomentum) {
797  LogTrace(metname) << "oppositeToMomentum";
798  outerTSOS = trajectory.firstMeasurement().updatedState();
799  innerTSOS = trajectory.lastMeasurement().updatedState();
800  outerId = trajectory.firstMeasurement().recHit()->geographicalId().rawId();
801  innerId = trajectory.lastMeasurement().recHit()->geographicalId().rawId();
802  outerRecHit = trajectory.firstMeasurement().recHit();
803  outerDetId = trajectory.firstMeasurement().recHit()->geographicalId();
804  } else
805  LogError(metname) << "Wrong propagation direction!";
806 
807  const GeomDet* outerDet = theService->trackingGeometry()->idToDet(outerDetId);
808  GlobalPoint outerTSOSPos = outerTSOS.globalParameters().position();
809  bool inside = outerDet->surface().bounds().inside(outerDet->toLocal(outerTSOSPos));
810 
811  GlobalPoint hitPos =
812  (outerRecHit->isValid()) ? outerRecHit->globalPosition() : outerTSOS.globalParameters().position();
813 
814  if (!inside) {
815  LogTrace(metname) << "The Global Muon outerMostMeasurementState is not compatible with the recHit detector! "
816  "Setting outerMost postition to recHit position if recHit isValid: "
817  << outerRecHit->isValid();
818  LogTrace(metname) << "From " << outerTSOSPos << " to " << hitPos;
819  }
820 
821  //build the TrackExtra
822  GlobalPoint v = (inside) ? outerTSOSPos : hitPos;
823  GlobalVector p = outerTSOS.globalParameters().momentum();
824  math::XYZPoint outpos(v.x(), v.y(), v.z());
825  math::XYZVector outmom(p.x(), p.y(), p.z());
826 
827  v = innerTSOS.globalParameters().position();
828  p = innerTSOS.globalParameters().momentum();
829  math::XYZPoint inpos(v.x(), v.y(), v.z());
830  math::XYZVector inmom(p.x(), p.y(), p.z());
831 
832  reco::TrackExtra trackExtra(outpos,
833  outmom,
834  true,
835  inpos,
836  inmom,
837  true,
838  outerTSOS.curvilinearError(),
839  outerId,
840  innerTSOS.curvilinearError(),
841  innerId,
842  trajectory.direction(),
843  trajectory.seedRef());
844 
845  return trackExtra;
846 }
ConstRecHitPointer const & recHit() const
const std::string metname
const CurvilinearTrajectoryError & curvilinearError() const
T y() const
Definition: PV3DBase.h:60
LocalPoint toLocal(const GlobalPoint &gp) const
Conversion to the R.F. of the GeomDet.
Definition: GeomDet.h:58
ConstRecHitContainer recHits() const
Definition: Trajectory.h:186
const Bounds & bounds() const
Definition: Surface.h:89
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:37
PropagationDirection const & direction() const
Definition: Trajectory.cc:133
virtual bool inside(const Local3DPoint &) const =0
Determine if the point is inside the bounds.
TrajectoryMeasurement const & lastMeasurement() const
Definition: Trajectory.h:150
T z() const
Definition: PV3DBase.h:61
edm::RefToBase< TrajectorySeed > seedRef(void) const
Definition: Trajectory.h:303
#define LogTrace(id)
Definition: DetId.h:17
TrajectoryMeasurement const & firstMeasurement() const
Definition: Trajectory.h:166
ConstRecHitContainer RecHitContainer
Definition: Trajectory.h:42
const GlobalTrajectoryParameters & globalParameters() const
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:31
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:59
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 742 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().

743  {
744  const string metname = "Muon|RecoMuon|MuonTrackLoader";
746 
747  // build the transient track
748  reco::TransientTrack transientTrack(track, &*theService->magneticField(), theService->trackingGeometry());
749 
750  LogTrace(metname) << "Apply the vertex constraint";
751  pair<bool, FreeTrajectoryState> updateResult = theUpdatorAtVtx->update(transientTrack, beamSpot);
752 
753  if (!updateResult.first) {
754  return pair<bool, reco::Track>(false, reco::Track());
755  }
756 
757  LogTrace(metname) << "FTS after the vertex constraint";
758  FreeTrajectoryState& ftsAtVtx = updateResult.second;
759 
760  LogTrace(metname) << debug.dumpFTS(ftsAtVtx);
761 
762  GlobalPoint pca = ftsAtVtx.position();
763  math::XYZPoint persistentPCA(pca.x(), pca.y(), pca.z());
764  GlobalVector p = ftsAtVtx.momentum();
765  math::XYZVector persistentMomentum(p.x(), p.y(), p.z());
766 
767  reco::Track updatedTrack(
768  track.chi2(), track.ndof(), persistentPCA, persistentMomentum, ftsAtVtx.charge(), ftsAtVtx.curvilinearError());
769 
770  return pair<bool, reco::Track>(true, updatedTrack);
771 }
const std::string metname
T y() const
Definition: PV3DBase.h:60
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:61
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:31
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
const MuonServiceProxy * theService
T x() const
Definition: PV3DBase.h:59
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 367 of file MuonTrackLoader.cc.

References reco::TrackBase::appendHitPattern(), pwdgSkimBPark_cfi::beamSpot, buildTrackAtPCA(), buildTrackExtra(), TrajectorySmoother::clone(), watchdog::const, hitCloner, hfClusterShapes_cfi::hits, mps_fire::i, instance, edm::OrphanHandleBase::isValid(), electronStore::links, 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, HLT_2018_cff::track, duplicaterechits_cfi::trackCollection, FastTrackerRecHitMaskProducer_cfi::trajectories, reco::TrackExtraBase::trajParams(), UNLIKELY, and unpackHit().

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

Definition at line 46 of file MuonTrackLoader.cc.

References filterCSVwithJSON::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().

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

Member Data Documentation

TkClonerImpl MuonTrackLoader::hitCloner
private

Definition at line 104 of file MuonTrackLoader.h.

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

bool MuonTrackLoader::theAllowNoVtxFlag
private

Definition at line 113 of file MuonTrackLoader.h.

Referenced by buildTrackAtPCA(), and MuonTrackLoader().

edm::InputTag MuonTrackLoader::theBeamSpotInputTag
private

Definition at line 106 of file MuonTrackLoader.h.

Referenced by MuonTrackLoader().

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

Definition at line 107 of file MuonTrackLoader.h.

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

std::string MuonTrackLoader::theL2SeededTkLabel
private

Label for L2SeededTracks.

Definition at line 110 of file MuonTrackLoader.h.

Referenced by loadTracks(), and MuonTrackLoader().

bool MuonTrackLoader::thePutTkTrackFlag
private

Definition at line 111 of file MuonTrackLoader.h.

Referenced by loadTracks(), and MuonTrackLoader().

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

Definition at line 103 of file MuonTrackLoader.h.

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

std::string MuonTrackLoader::theSmootherName
private

Definition at line 101 of file MuonTrackLoader.h.

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

bool MuonTrackLoader::theSmoothingStep
private

Definition at line 100 of file MuonTrackLoader.h.

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

bool MuonTrackLoader::theSmoothTkTrackFlag
private

Definition at line 112 of file MuonTrackLoader.h.

Referenced by loadTracks(), and MuonTrackLoader().

std::string MuonTrackLoader::theTrackerRecHitBuilderName
private

Definition at line 102 of file MuonTrackLoader.h.

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

bool MuonTrackLoader::theTrajectoryFlag
private

Definition at line 98 of file MuonTrackLoader.h.

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

bool MuonTrackLoader::theUpdatingAtVtx
private

Definition at line 95 of file MuonTrackLoader.h.

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

MuonUpdatorAtVertex* MuonTrackLoader::theUpdatorAtVtx
private