test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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::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. More...
 
edm::OrphanHandle
< reco::TrackCollection
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. More...
 
edm::OrphanHandle
< reco::TrackCollection
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. More...
 
edm::OrphanHandle
< reco::MuonTrackLinksCollection
loadTracks (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
< TrajectorySmoother
theSmoother
 
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  :
98  theService(service){
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

Destructor.

Definition at line 130 of file MuonTrackLoader.cc.

References theUpdatorAtVtx.

130  {
131  if(theUpdatorAtVtx) delete theUpdatorAtVtx;
132 }
MuonUpdatorAtVertex * theUpdatorAtVtx

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

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

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

References alongMomentum, Surface::bounds(), TrajectoryStateOnSurface::curvilinearError(), Trajectory::direction(), Trajectory::firstMeasurement(), TrajectoryStateOnSurface::globalParameters(), Bounds::inside(), Trajectory::lastMeasurement(), LogTrace, 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().

801  {
802 
803  const string metname = "Muon|RecoMuon|MuonTrackLoader";
804 
805  const Trajectory::RecHitContainer transRecHits = trajectory.recHits();
806 
807  // put the collection of TrackingRecHit in the event
808 
809  // sets the outermost and innermost TSOSs
810  // FIXME: check it!
811  TrajectoryStateOnSurface outerTSOS;
812  TrajectoryStateOnSurface innerTSOS;
813  unsigned int innerId=0, outerId=0;
815  DetId outerDetId;
816 
817  if (trajectory.direction() == alongMomentum) {
818  LogTrace(metname)<<"alongMomentum";
819  outerTSOS = trajectory.lastMeasurement().updatedState();
820  innerTSOS = trajectory.firstMeasurement().updatedState();
821  outerId = trajectory.lastMeasurement().recHit()->geographicalId().rawId();
822  innerId = trajectory.firstMeasurement().recHit()->geographicalId().rawId();
823  outerRecHit = trajectory.lastMeasurement().recHit();
824  outerDetId = trajectory.lastMeasurement().recHit()->geographicalId();
825  }
826  else if (trajectory.direction() == oppositeToMomentum) {
827  LogTrace(metname)<<"oppositeToMomentum";
828  outerTSOS = trajectory.firstMeasurement().updatedState();
829  innerTSOS = trajectory.lastMeasurement().updatedState();
830  outerId = trajectory.firstMeasurement().recHit()->geographicalId().rawId();
831  innerId = trajectory.lastMeasurement().recHit()->geographicalId().rawId();
832  outerRecHit = trajectory.firstMeasurement().recHit();
833  outerDetId = trajectory.firstMeasurement().recHit()->geographicalId();
834  }
835  else LogError(metname)<<"Wrong propagation direction!";
836 
837  const GeomDet *outerDet = theService->trackingGeometry()->idToDet(outerDetId);
838  GlobalPoint outerTSOSPos = outerTSOS.globalParameters().position();
839  bool inside = outerDet->surface().bounds().inside(outerDet->toLocal(outerTSOSPos));
840 
841 
842  GlobalPoint hitPos = (outerRecHit->isValid()) ? outerRecHit->globalPosition() : outerTSOS.globalParameters().position() ;
843 
844  if(!inside) {
845  LogTrace(metname)<<"The Global Muon outerMostMeasurementState is not compatible with the recHit detector! Setting outerMost postition to recHit position if recHit isValid: " << outerRecHit->isValid();
846  LogTrace(metname)<<"From " << outerTSOSPos << " to " << hitPos;
847  }
848 
849 
850  //build the TrackExtra
851  GlobalPoint v = (inside) ? outerTSOSPos : hitPos ;
852  GlobalVector p = outerTSOS.globalParameters().momentum();
853  math::XYZPoint outpos( v.x(), v.y(), v.z() );
854  math::XYZVector outmom( p.x(), p.y(), p.z() );
855 
856  v = innerTSOS.globalParameters().position();
857  p = innerTSOS.globalParameters().momentum();
858  math::XYZPoint inpos( v.x(), v.y(), v.z() );
859  math::XYZVector inmom( p.x(), p.y(), p.z() );
860 
861  reco::TrackExtra trackExtra(outpos, outmom, true, inpos, inmom, true,
862  outerTSOS.curvilinearError(), outerId,
863  innerTSOS.curvilinearError(), innerId,
864  trajectory.direction(),trajectory.seedRef());
865 
866  return trackExtra;
867 
868 }
ConstRecHitPointer const & recHit() const
virtual bool inside(const Local3DPoint &) const =0
Determine if the point is inside the bounds.
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
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 763 of file MuonTrackLoader.cc.

References FreeTrajectoryState::charge(), reco::TrackBase::chi2(), FreeTrajectoryState::curvilinearError(), debug, MuonPatternRecoDumper::dumpFTS(), LogTrace, 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().

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

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

References edm::OrphanHandleBase::isValid(), electronStore::links, loadTracks(), LogDebug, LogTrace, eostools::move(), position, reco::MuonTrackLinks::setGlobalTrack(), reco::MuonTrackLinks::setStandAloneTrack(), reco::MuonTrackLinks::setTrackerTrack(), theL2SeededTkLabel, thePutTkTrackFlag, theSmoothTkTrackFlag, and HLT_25ns10e33_v2_cff::trackCollection.

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

Definition at line 47 of file MuonTrackLoader.cc.

References filterCSVwithJSON::copy, MuonSubdetId::CSC, DetId::det(), TrackingRecHit::dimension(), MuonSubdetId::DT, MuonSubdetId::GEM, TrackingRecHit::geographicalId(), MuonSubdetId::ME0, DetId::Muon, TrackingRecHit::recHits(), 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  }
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 }
virtual int dimension() const =0
static const int GEM
Definition: MuonSubdetId.h:15
static const int ME0
Definition: MuonSubdetId.h:16
static const int CSC
Definition: MuonSubdetId.h:13
virtual std::vector< const TrackingRecHit * > recHits() const =0
Access to component RecHits (if any)
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.

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 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

Definition at line 90 of file MuonTrackLoader.h.

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

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

Definition at line 100 of file MuonTrackLoader.h.

std::string MuonTrackLoader::theSmootherName
private

Definition at line 98 of file MuonTrackLoader.h.

Referenced by MuonTrackLoader().

bool MuonTrackLoader::theSmoothingStep
private

Definition at line 97 of file MuonTrackLoader.h.

Referenced by 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 MuonTrackLoader().

bool MuonTrackLoader::theTrajectoryFlag
private

Definition at line 95 of file MuonTrackLoader.h.

Referenced by MuonTrackLoader().

bool MuonTrackLoader::theUpdatingAtVtx
private

Definition at line 92 of file MuonTrackLoader.h.

Referenced by MuonTrackLoader().

MuonUpdatorAtVertex* MuonTrackLoader::theUpdatorAtVtx
private