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 698 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().

698  {
699 
700  const string metname = "Muon|RecoMuon|MuonTrackLoader";
701 
703 
704  // FIXME: check the prop direction
705  TrajectoryStateOnSurface innerTSOS = trajectory.geometricalInnermostState();
706 
707  // This is needed to extrapolate the tsos at vertex
708  LogTrace(metname) << "Propagate to PCA...";
709  pair<bool,FreeTrajectoryState>
710  extrapolationResult = theUpdatorAtVtx->propagate(innerTSOS, beamSpot);
711  FreeTrajectoryState ftsAtVtx;
712 
713  if(extrapolationResult.first)
714  ftsAtVtx = extrapolationResult.second;
715  else{
716  if(TrackerBounds::isInside(innerTSOS.globalPosition())){
717  LogInfo(metname) << "Track in the Tracker: taking the innermost state instead of the state at PCA";
718  ftsAtVtx = *innerTSOS.freeState();
719  }
720  else{
721  if ( theAllowNoVtxFlag ) {
722  LogInfo(metname) << "Propagation to PCA failed, taking the innermost state instead of the state at PCA";
723  ftsAtVtx = *innerTSOS.freeState();
724  } else {
725  LogInfo(metname) << "Stand Alone track: this track will be rejected";
726  return pair<bool,reco::Track>(false,reco::Track());
727  }
728  }
729  }
730 
731  LogTrace(metname) << "TSOS after the extrapolation at vtx";
732  LogTrace(metname) << debug.dumpFTS(ftsAtVtx);
733 
734  GlobalPoint pca = ftsAtVtx.position();
735  math::XYZPoint persistentPCA(pca.x(),pca.y(),pca.z());
736  GlobalVector p = ftsAtVtx.momentum();
737  math::XYZVector persistentMomentum(p.x(),p.y(),p.z());
738 
739  bool bon = true;
740  if(fabs(theService->magneticField()->inTesla(GlobalPoint(0,0,0)).z()) < 0.01) bon=false;
741  double ndof = trajectory.ndof(bon);
742 
743  reco::Track track(trajectory.chiSquared(),
744  ndof,
745  persistentPCA,
746  persistentMomentum,
747  ftsAtVtx.charge(),
748  ftsAtVtx.curvilinearError());
749 
750  return pair<bool,reco::Track>(true,track);
751 }
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 792 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().

792  {
793 
794  const string metname = "Muon|RecoMuon|MuonTrackLoader";
795 
796  const Trajectory::RecHitContainer transRecHits = trajectory.recHits();
797 
798  // put the collection of TrackingRecHit in the event
799 
800  // sets the outermost and innermost TSOSs
801  // FIXME: check it!
802  TrajectoryStateOnSurface outerTSOS;
803  TrajectoryStateOnSurface innerTSOS;
804  unsigned int innerId=0, outerId=0;
806  DetId outerDetId;
807 
808  if (trajectory.direction() == alongMomentum) {
809  LogTrace(metname)<<"alongMomentum";
810  outerTSOS = trajectory.lastMeasurement().updatedState();
811  innerTSOS = trajectory.firstMeasurement().updatedState();
812  outerId = trajectory.lastMeasurement().recHit()->geographicalId().rawId();
813  innerId = trajectory.firstMeasurement().recHit()->geographicalId().rawId();
814  outerRecHit = trajectory.lastMeasurement().recHit();
815  outerDetId = trajectory.lastMeasurement().recHit()->geographicalId();
816  }
817  else if (trajectory.direction() == oppositeToMomentum) {
818  LogTrace(metname)<<"oppositeToMomentum";
819  outerTSOS = trajectory.firstMeasurement().updatedState();
820  innerTSOS = trajectory.lastMeasurement().updatedState();
821  outerId = trajectory.firstMeasurement().recHit()->geographicalId().rawId();
822  innerId = trajectory.lastMeasurement().recHit()->geographicalId().rawId();
823  outerRecHit = trajectory.firstMeasurement().recHit();
824  outerDetId = trajectory.firstMeasurement().recHit()->geographicalId();
825  }
826  else LogError(metname)<<"Wrong propagation direction!";
827 
828  const GeomDet *outerDet = theService->trackingGeometry()->idToDet(outerDetId);
829  GlobalPoint outerTSOSPos = outerTSOS.globalParameters().position();
830  bool inside = outerDet->surface().bounds().inside(outerDet->toLocal(outerTSOSPos));
831 
832 
833  GlobalPoint hitPos = (outerRecHit->isValid()) ? outerRecHit->globalPosition() : outerTSOS.globalParameters().position() ;
834 
835  if(!inside) {
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;
838  }
839 
840 
841  //build the TrackExtra
842  GlobalPoint v = (inside) ? outerTSOSPos : hitPos ;
843  GlobalVector p = outerTSOS.globalParameters().momentum();
844  math::XYZPoint outpos( v.x(), v.y(), v.z() );
845  math::XYZVector outmom( p.x(), p.y(), p.z() );
846 
847  v = innerTSOS.globalParameters().position();
848  p = innerTSOS.globalParameters().momentum();
849  math::XYZPoint inpos( v.x(), v.y(), v.z() );
850  math::XYZVector inmom( p.x(), p.y(), p.z() );
851 
852  reco::TrackExtra trackExtra(outpos, outmom, true, inpos, inmom, true,
853  outerTSOS.curvilinearError(), outerId,
854  innerTSOS.curvilinearError(), innerId,
855  trajectory.direction(),trajectory.seedRef());
856 
857  return trackExtra;
858 
859 }
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 754 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().

754  {
755 
756  const string metname = "Muon|RecoMuon|MuonTrackLoader";
758 
759  // build the transient track
760  reco::TransientTrack transientTrack(track,
761  &*theService->magneticField(),
762  theService->trackingGeometry());
763 
764  LogTrace(metname) << "Apply the vertex constraint";
765  pair<bool,FreeTrajectoryState> updateResult = theUpdatorAtVtx->update(transientTrack,beamSpot);
766 
767  if(!updateResult.first){
768  return pair<bool,reco::Track>(false,reco::Track());
769  }
770 
771  LogTrace(metname) << "FTS after the vertex constraint";
772  FreeTrajectoryState &ftsAtVtx = updateResult.second;
773 
774  LogTrace(metname) << debug.dumpFTS(ftsAtVtx);
775 
776  GlobalPoint pca = ftsAtVtx.position();
777  math::XYZPoint persistentPCA(pca.x(),pca.y(),pca.z());
778  GlobalVector p = ftsAtVtx.momentum();
779  math::XYZVector persistentMomentum(p.x(),p.y(),p.z());
780 
781  reco::Track updatedTrack(track.chi2(),
782  track.ndof(),
783  persistentPCA,
784  persistentMomentum,
785  ftsAtVtx.charge(),
786  ftsAtVtx.curvilinearError());
787 
788  return pair<bool,reco::Track>(true,updatedTrack);
789 }
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 376 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().

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