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 (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 (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 (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 (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=nullptr)
 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
 
edm::ESGetToken< TrajectorySmoother, TrajectoryFitter::RecordtheSmootherToken
 
bool theSmoothingStep
 
bool theSmoothTkTrackFlag
 
edm::ESGetToken< TransientTrackingRecHitBuilder, TransientRecHitRecordtheTrackerRecHitBuilderToken
 
bool theTrajectoryFlag
 
bool theUpdatingAtVtx
 
std::unique_ptr< 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 45 of file MuonTrackLoader.h.

Member Typedef Documentation

◆ CandidateContainer

Definition at line 48 of file MuonTrackLoader.h.

◆ TrajectoryContainer

Definition at line 47 of file MuonTrackLoader.h.

Constructor & Destructor Documentation

◆ MuonTrackLoader()

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

Constructor for the STA reco the args must be specify!

Definition at line 95 of file MuonTrackLoader.cc.

References edm::ConsumesCollector::consumes(), edm::ConsumesCollector::esConsumes(), edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), edm::parameterSet(), AlCaHLTBitMon_QueryRunRegistry::string, theAllowNoVtxFlag, theBeamSpotInputTag, theBeamSpotToken, theL2SeededTkLabel, thePutTkTrackFlag, theSmootherToken, theSmoothingStep, theSmoothTkTrackFlag, theTrackerRecHitBuilderToken, theTrajectoryFlag, theUpdatingAtVtx, and theUpdatorAtVtx.

98  : theService(service) {
99  // option to do or not the smoothing step.
100  // the trajectories which are passed to the track loader are supposed to be non-smoothed
101  theSmoothingStep = parameterSet.getParameter<bool>("DoSmoothing");
102  if (theSmoothingStep) {
103  auto smootherName = parameterSet.getParameter<string>("Smoother");
104  theSmootherToken = iC.esConsumes(edm::ESInputTag("", smootherName));
105 
106  auto trackerRecHitBuilderName = parameterSet.getParameter<std::string>("TTRHBuilder");
107  theTrackerRecHitBuilderToken = iC.esConsumes(edm::ESInputTag("", trackerRecHitBuilderName));
108  }
109 
110  // update at vertex
111  theUpdatingAtVtx = parameterSet.getParameter<bool>("VertexConstraint");
112 
113  // beam spot input tag
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 = std::make_unique<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)
edm::EDGetTokenT< reco::BeamSpot > theBeamSpotToken
std::unique_ptr< MuonUpdatorAtVertex > theUpdatorAtVtx
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
ParameterSet const & parameterSet(StableProvenance const &provenance, ProcessHistory const &history)
Definition: Provenance.cc:11
T getUntrackedParameter(std::string const &, T const &) const
edm::InputTag theBeamSpotInputTag
std::string theL2SeededTkLabel
Label for L2SeededTracks.
edm::ESGetToken< TransientTrackingRecHitBuilder, TransientRecHitRecord > theTrackerRecHitBuilderToken
const MuonServiceProxy * theService
edm::ESGetToken< TrajectorySmoother, TrajectoryFitter::Record > theSmootherToken

◆ ~MuonTrackLoader()

MuonTrackLoader::~MuonTrackLoader ( )
virtual

Destructor.

Definition at line 130 of file MuonTrackLoader.cc.

130 {}

Member Function Documentation

◆ buildTrackAtPCA()

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 674 of file MuonTrackLoader.cc.

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

675  {
676  const string metname = "Muon|RecoMuon|MuonTrackLoader";
677 
679 
680  // FIXME: check the prop direction
681  TrajectoryStateOnSurface innerTSOS = trajectory.geometricalInnermostState();
682 
683  // This is needed to extrapolate the tsos at vertex
684  LogTrace(metname) << "Propagate to PCA...";
685  pair<bool, FreeTrajectoryState> extrapolationResult = theUpdatorAtVtx->propagate(innerTSOS, beamSpot);
686  FreeTrajectoryState ftsAtVtx;
687 
688  if (extrapolationResult.first)
689  ftsAtVtx = extrapolationResult.second;
690  else {
691  if (TrackerBounds::isInside(innerTSOS.globalPosition())) {
692  LogInfo(metname) << "Track in the Tracker: taking the innermost state instead of the state at PCA";
693  ftsAtVtx = *innerTSOS.freeState();
694  } else {
695  if (theAllowNoVtxFlag) {
696  LogInfo(metname) << "Propagation to PCA failed, taking the innermost state instead of the state at PCA";
697  ftsAtVtx = *innerTSOS.freeState();
698  } else {
699  LogInfo(metname) << "Stand Alone track: this track will be rejected";
700  return pair<bool, reco::Track>(false, reco::Track());
701  }
702  }
703  }
704 
705  LogTrace(metname) << "TSOS after the extrapolation at vtx";
706  LogTrace(metname) << debug.dumpFTS(ftsAtVtx);
707 
708  GlobalPoint pca = ftsAtVtx.position();
709  math::XYZPoint persistentPCA(pca.x(), pca.y(), pca.z());
710  GlobalVector p = ftsAtVtx.momentum();
711  math::XYZVector persistentMomentum(p.x(), p.y(), p.z());
712 
713  bool bon = true;
714  if (fabs(theService->magneticField()->inTesla(GlobalPoint(0, 0, 0)).z()) < 0.01)
715  bon = false;
716  double ndof = trajectory.ndof(bon);
717 
719  trajectory.chiSquared(), ndof, persistentPCA, persistentMomentum, ftsAtVtx.charge(), ftsAtVtx.curvilinearError());
720 
721  return pair<bool, reco::Track>(true, track);
722 }
std::unique_ptr< MuonUpdatorAtVertex > theUpdatorAtVtx
static bool isInside(const GlobalPoint &)
const CurvilinearTrajectoryError & curvilinearError() const
T z() const
Definition: PV3DBase.h:61
const std::string metname
TrajectoryStateOnSurface geometricalInnermostState() const
Definition: Trajectory.cc:217
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
float chiSquared() const
Definition: Trajectory.h:241
#define LogTrace(id)
GlobalPoint position() const
T x() const
Definition: PV3DBase.h:59
T y() const
Definition: PV3DBase.h:60
int ndof(bool bon=true) const
Definition: Trajectory.cc:97
GlobalPoint globalPosition() const
TrackCharge charge() const
GlobalVector momentum() const
Log< level::Info, false > LogInfo
#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
FreeTrajectoryState const * freeState(bool withErrors=true) const
const MuonServiceProxy * theService

◆ buildTrackExtra()

reco::TrackExtra MuonTrackLoader::buildTrackExtra ( const Trajectory trajectory) const
private

Definition at line 755 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(), and findQualityFiles::v.

755  {
756  const string metname = "Muon|RecoMuon|MuonTrackLoader";
757 
758  const Trajectory::RecHitContainer transRecHits = trajectory.recHits();
759 
760  // put the collection of TrackingRecHit in the event
761 
762  // sets the outermost and innermost TSOSs
763  // FIXME: check it!
764  TrajectoryStateOnSurface outerTSOS;
765  TrajectoryStateOnSurface innerTSOS;
766  unsigned int innerId = 0, outerId = 0;
768  DetId outerDetId;
769 
770  if (trajectory.direction() == alongMomentum) {
771  LogTrace(metname) << "alongMomentum";
772  outerTSOS = trajectory.lastMeasurement().updatedState();
773  innerTSOS = trajectory.firstMeasurement().updatedState();
774  outerId = trajectory.lastMeasurement().recHit()->geographicalId().rawId();
775  innerId = trajectory.firstMeasurement().recHit()->geographicalId().rawId();
776  outerRecHit = trajectory.lastMeasurement().recHit();
777  outerDetId = trajectory.lastMeasurement().recHit()->geographicalId();
778  } else if (trajectory.direction() == oppositeToMomentum) {
779  LogTrace(metname) << "oppositeToMomentum";
780  outerTSOS = trajectory.firstMeasurement().updatedState();
781  innerTSOS = trajectory.lastMeasurement().updatedState();
782  outerId = trajectory.firstMeasurement().recHit()->geographicalId().rawId();
783  innerId = trajectory.lastMeasurement().recHit()->geographicalId().rawId();
784  outerRecHit = trajectory.firstMeasurement().recHit();
785  outerDetId = trajectory.firstMeasurement().recHit()->geographicalId();
786  } else
787  LogError(metname) << "Wrong propagation direction!";
788 
789  const GeomDet* outerDet = theService->trackingGeometry()->idToDet(outerDetId);
790  GlobalPoint outerTSOSPos = outerTSOS.globalParameters().position();
791  bool inside = outerDet->surface().bounds().inside(outerDet->toLocal(outerTSOSPos));
792 
793  GlobalPoint hitPos =
794  (outerRecHit->isValid()) ? outerRecHit->globalPosition() : outerTSOS.globalParameters().position();
795 
796  if (!inside) {
797  LogTrace(metname) << "The Global Muon outerMostMeasurementState is not compatible with the recHit detector! "
798  "Setting outerMost postition to recHit position if recHit isValid: "
799  << outerRecHit->isValid();
800  LogTrace(metname) << "From " << outerTSOSPos << " to " << hitPos;
801  }
802 
803  //build the TrackExtra
804  GlobalPoint v = (inside) ? outerTSOSPos : hitPos;
805  GlobalVector p = outerTSOS.globalParameters().momentum();
806  math::XYZPoint outpos(v.x(), v.y(), v.z());
807  math::XYZVector outmom(p.x(), p.y(), p.z());
808 
809  v = innerTSOS.globalParameters().position();
810  p = innerTSOS.globalParameters().momentum();
811  math::XYZPoint inpos(v.x(), v.y(), v.z());
812  math::XYZVector inmom(p.x(), p.y(), p.z());
813 
814  reco::TrackExtra trackExtra(outpos,
815  outmom,
816  true,
817  inpos,
818  inmom,
819  true,
820  outerTSOS.curvilinearError(),
821  outerId,
822  innerTSOS.curvilinearError(),
823  innerId,
824  trajectory.direction(),
825  trajectory.seedRef());
826 
827  return trackExtra;
828 }
virtual bool inside(const Local3DPoint &) const =0
Determine if the point is inside the bounds.
LocalPoint toLocal(const GlobalPoint &gp) const
Conversion to the R.F. of the GeomDet.
Definition: GeomDet.h:58
const std::string metname
const GlobalTrajectoryParameters & globalParameters() const
edm::RefToBase< TrajectorySeed > seedRef(void) const
Definition: Trajectory.h:303
Log< level::Error, false > LogError
TrajectoryMeasurement const & lastMeasurement() const
Definition: Trajectory.h:150
#define LogTrace(id)
PropagationDirection const & direction() const
Definition: Trajectory.cc:133
ConstRecHitContainer recHits() const
Definition: Trajectory.h:186
Definition: DetId.h:17
ConstRecHitContainer RecHitContainer
Definition: Trajectory.h:42
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:37
const CurvilinearTrajectoryError & curvilinearError() 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
TrajectoryStateOnSurface const & updatedState() const
TrajectoryMeasurement const & firstMeasurement() const
Definition: Trajectory.h:166
const MuonServiceProxy * theService
ConstRecHitPointer const & recHit() const
const Bounds & bounds() const
Definition: Surface.h:87

◆ buildTrackUpdatedAtPCA()

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 724 of file MuonTrackLoader.cc.

References isoTrack_cff::beamSpot, FreeTrajectoryState::charge(), FreeTrajectoryState::curvilinearError(), debug, LogTrace, metname, FreeTrajectoryState::momentum(), AlCaHLTBitMon_ParallelJobs::p, FreeTrajectoryState::position(), theService, theUpdatorAtVtx, HLT_2024v14_cff::track, PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), and PV3DBase< T, PVType, FrameType >::z().

725  {
726  const string metname = "Muon|RecoMuon|MuonTrackLoader";
728 
729  // build the transient track
730  reco::TransientTrack transientTrack(track, &*theService->magneticField(), theService->trackingGeometry());
731 
732  LogTrace(metname) << "Apply the vertex constraint";
733  pair<bool, FreeTrajectoryState> updateResult = theUpdatorAtVtx->update(transientTrack, beamSpot);
734 
735  if (!updateResult.first) {
736  return pair<bool, reco::Track>(false, reco::Track());
737  }
738 
739  LogTrace(metname) << "FTS after the vertex constraint";
740  FreeTrajectoryState& ftsAtVtx = updateResult.second;
741 
742  LogTrace(metname) << debug.dumpFTS(ftsAtVtx);
743 
744  GlobalPoint pca = ftsAtVtx.position();
745  math::XYZPoint persistentPCA(pca.x(), pca.y(), pca.z());
746  GlobalVector p = ftsAtVtx.momentum();
747  math::XYZVector persistentMomentum(p.x(), p.y(), p.z());
748 
749  reco::Track updatedTrack(
750  track.chi2(), track.ndof(), persistentPCA, persistentMomentum, ftsAtVtx.charge(), ftsAtVtx.curvilinearError());
751 
752  return pair<bool, reco::Track>(true, updatedTrack);
753 }
std::unique_ptr< MuonUpdatorAtVertex > theUpdatorAtVtx
const CurvilinearTrajectoryError & curvilinearError() const
T z() const
Definition: PV3DBase.h:61
const std::string metname
#define LogTrace(id)
GlobalPoint position() const
T x() const
Definition: PV3DBase.h:59
T y() const
Definition: PV3DBase.h:60
TrackCharge charge() const
GlobalVector momentum() 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

◆ loadTracks() [1/4]

edm::OrphanHandle<reco::TrackCollection> MuonTrackLoader::loadTracks ( 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 loadTracks().

◆ loadTracks() [2/4]

edm::OrphanHandle<reco::TrackCollection> MuonTrackLoader::loadTracks ( 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.

◆ loadTracks() [3/4]

edm::OrphanHandle<reco::TrackCollection> MuonTrackLoader::loadTracks ( 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.

◆ loadTracks() [4/4]

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

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

Definition at line 362 of file MuonTrackLoader.cc.

References edm::OrphanHandleBase::isValid(), ALPAKA_ACCELERATOR_NAMESPACE::vertexFinder::it, electronStore::links, loadTracks(), LogDebug, LogTrace, metname, eostools::move(), position, theL2SeededTkLabel, thePutTkTrackFlag, theSmoothTkTrackFlag, and JetHT_cfg::trackCollection.

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

◆ unpackHit()

std::vector< const TrackingRecHit * > MuonTrackLoader::unpackHit ( const TrackingRecHit hit)
staticprivate

Definition at line 48 of file MuonTrackLoader.cc.

References filterCSVwithJSON::copy, MuonSubdetId::CSC, ALCARECOPPSCalTrackBasedSel_cff::detid, MuonSubdetId::DT, MuonSubdetId::GEM, hfClusterShapes_cfi::hits, ALPAKA_ACCELERATOR_NAMESPACE::vertexFinder::it, MuonSubdetId::ME0, DetId::Muon, MuonSubdetId::RPC, and DetId::Tracker.

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  } else if (subdet == (uint16_t)MuonSubdetId::GEM) {
82  if (hit.dimension() == 2) { // GEM rechit
83  hits.push_back(&hit);
84  } else if (hit.dimension() == 4) { // GEM segment
85  hits = hit.recHits();
86  }
87  } else if (subdet == (uint16_t)MuonSubdetId::ME0) { //segment
88  hits = hit.recHits();
89  }
90  }
91  return hits;
92 }
static constexpr int GEM
Definition: MuonSubdetId.h:14
static constexpr int ME0
Definition: MuonSubdetId.h:15
Definition: DetId.h:17
static constexpr int RPC
Definition: MuonSubdetId.h:13
static constexpr int DT
Definition: MuonSubdetId.h:11
static constexpr int CSC
Definition: MuonSubdetId.h:12

Member Data Documentation

◆ hitCloner

TkClonerImpl MuonTrackLoader::hitCloner
private

Definition at line 106 of file MuonTrackLoader.h.

◆ theAllowNoVtxFlag

bool MuonTrackLoader::theAllowNoVtxFlag
private

Definition at line 115 of file MuonTrackLoader.h.

Referenced by buildTrackAtPCA(), and MuonTrackLoader().

◆ theBeamSpotInputTag

edm::InputTag MuonTrackLoader::theBeamSpotInputTag
private

Definition at line 108 of file MuonTrackLoader.h.

Referenced by MuonTrackLoader().

◆ theBeamSpotToken

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

Definition at line 109 of file MuonTrackLoader.h.

Referenced by MuonTrackLoader().

◆ theL2SeededTkLabel

std::string MuonTrackLoader::theL2SeededTkLabel
private

Label for L2SeededTracks.

Definition at line 112 of file MuonTrackLoader.h.

Referenced by loadTracks(), and MuonTrackLoader().

◆ thePutTkTrackFlag

bool MuonTrackLoader::thePutTkTrackFlag
private

Definition at line 113 of file MuonTrackLoader.h.

Referenced by loadTracks(), and MuonTrackLoader().

◆ theService

const MuonServiceProxy* MuonTrackLoader::theService
private

Definition at line 95 of file MuonTrackLoader.h.

Referenced by buildTrackAtPCA(), buildTrackExtra(), and buildTrackUpdatedAtPCA().

◆ theSmoother

std::unique_ptr<TrajectorySmoother> MuonTrackLoader::theSmoother
private

Definition at line 105 of file MuonTrackLoader.h.

◆ theSmootherToken

edm::ESGetToken<TrajectorySmoother, TrajectoryFitter::Record> MuonTrackLoader::theSmootherToken
private

Definition at line 103 of file MuonTrackLoader.h.

Referenced by MuonTrackLoader().

◆ theSmoothingStep

bool MuonTrackLoader::theSmoothingStep
private

Definition at line 102 of file MuonTrackLoader.h.

Referenced by MuonTrackLoader().

◆ theSmoothTkTrackFlag

bool MuonTrackLoader::theSmoothTkTrackFlag
private

Definition at line 114 of file MuonTrackLoader.h.

Referenced by loadTracks(), and MuonTrackLoader().

◆ theTrackerRecHitBuilderToken

edm::ESGetToken<TransientTrackingRecHitBuilder, TransientRecHitRecord> MuonTrackLoader::theTrackerRecHitBuilderToken
private

Definition at line 104 of file MuonTrackLoader.h.

Referenced by MuonTrackLoader().

◆ theTrajectoryFlag

bool MuonTrackLoader::theTrajectoryFlag
private

Definition at line 100 of file MuonTrackLoader.h.

Referenced by MuonTrackLoader().

◆ theUpdatingAtVtx

bool MuonTrackLoader::theUpdatingAtVtx
private

Definition at line 97 of file MuonTrackLoader.h.

Referenced by MuonTrackLoader().

◆ theUpdatorAtVtx

std::unique_ptr<MuonUpdatorAtVertex> MuonTrackLoader::theUpdatorAtVtx
private

Definition at line 98 of file MuonTrackLoader.h.

Referenced by buildTrackAtPCA(), buildTrackUpdatedAtPCA(), and MuonTrackLoader().