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 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 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 > > &, 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 &)
 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
 
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 38 of file MuonTrackLoader.h.

Member Typedef Documentation

Definition at line 42 of file MuonTrackLoader.h.

Definition at line 41 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 87 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, theTrajectoryFlag, theUpdatingAtVtx, and theUpdatorAtVtx.

87  :
88  theService(service){
89 
90 
91  // option to do or not the smoothing step.
92  // the trajectories which are passed to the track loader are supposed to be non-smoothed
93  theSmoothingStep = parameterSet.getParameter<bool>("DoSmoothing");
95  theSmootherName = parameterSet.getParameter<string>("Smoother");
96 
97  // update at vertex
98  theUpdatingAtVtx = parameterSet.getParameter<bool>("VertexConstraint");
99 
100  // beam spot input tag
101  theBeamSpotInputTag = parameterSet.getParameter<edm::InputTag>("beamSpot");
103 
104 
105  // Flag to put the trajectory into the event
106  theTrajectoryFlag = parameterSet.getUntrackedParameter<bool>("PutTrajectoryIntoEvent",true);
107 
108  theL2SeededTkLabel = parameterSet.getUntrackedParameter<string>("MuonSeededTracksInstance",string());
109 
110  ParameterSet updatorPar = parameterSet.getParameter<ParameterSet>("MuonUpdatorAtVertexParameters");
111  theUpdatorAtVtx = new MuonUpdatorAtVertex(updatorPar,service);
112 
113  thePutTkTrackFlag = parameterSet.getUntrackedParameter<bool>("PutTkTrackIntoEvent",false);
114  theSmoothTkTrackFlag = parameterSet.getUntrackedParameter<bool>("SmoothTkTrack",false);
115  theAllowNoVtxFlag = parameterSet.getUntrackedParameter<bool>("AllowNoVertex",false);
116 }
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
MuonUpdatorAtVertex * theUpdatorAtVtx
std::string theL2SeededTkLabel
Label for L2SeededTracks.
const MuonServiceProxy * theService
MuonTrackLoader::~MuonTrackLoader ( )
virtual

Destructor.

Definition at line 118 of file MuonTrackLoader.cc.

References theUpdatorAtVtx.

118  {
119  if(theUpdatorAtVtx) delete theUpdatorAtVtx;
120 }
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 692 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(), 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().

692  {
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>
704  extrapolationResult = theUpdatorAtVtx->propagate(innerTSOS, beamSpot);
705  FreeTrajectoryState ftsAtVtx;
706 
707  if(extrapolationResult.first)
708  ftsAtVtx = extrapolationResult.second;
709  else{
710  if(TrackerBounds::isInside(innerTSOS.globalPosition())){
711  LogInfo(metname) << "Track in the Tracker: taking the innermost state instead of the state at PCA";
712  ftsAtVtx = *innerTSOS.freeState();
713  }
714  else{
715  if ( theAllowNoVtxFlag ) {
716  LogInfo(metname) << "Propagation to PCA failed, taking the innermost state instead of the state at PCA";
717  ftsAtVtx = *innerTSOS.freeState();
718  } else {
719  LogInfo(metname) << "Stand Alone track: this track will be rejected";
720  return pair<bool,reco::Track>(false,reco::Track());
721  }
722  }
723  }
724 
725  LogTrace(metname) << "TSOS after the extrapolation at vtx";
726  LogTrace(metname) << debug.dumpFTS(ftsAtVtx);
727 
728  GlobalPoint pca = ftsAtVtx.position();
729  math::XYZPoint persistentPCA(pca.x(),pca.y(),pca.z());
730  GlobalVector p = ftsAtVtx.momentum();
731  math::XYZVector persistentMomentum(p.x(),p.y(),p.z());
732 
733  bool bon = true;
734  if(fabs(theService->magneticField()->inTesla(GlobalPoint(0,0,0)).z()) < 0.01) bon=false;
735  double ndof = trajectory.ndof(bon);
736 
737  reco::Track track(trajectory.chiSquared(),
738  ndof,
739  persistentPCA,
740  persistentMomentum,
741  ftsAtVtx.charge(),
742  ftsAtVtx.curvilinearError());
743 
744  return pair<bool,reco::Track>(true,track);
745 }
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:155
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:78
#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:252
const MuonServiceProxy * theService
T x() const
Definition: PV3DBase.h:62
reco::TrackExtra MuonTrackLoader::buildTrackExtra ( const Trajectory trajectory) const
private

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

786  {
787 
788  const string metname = "Muon|RecoMuon|MuonTrackLoader";
789 
790  const Trajectory::RecHitContainer transRecHits = trajectory.recHits();
791 
792  // put the collection of TrackingRecHit in the event
793 
794  // sets the outermost and innermost TSOSs
795  // FIXME: check it!
796  TrajectoryStateOnSurface outerTSOS;
797  TrajectoryStateOnSurface innerTSOS;
798  unsigned int innerId=0, outerId=0;
800  DetId outerDetId;
801 
802  if (trajectory.direction() == alongMomentum) {
803  LogTrace(metname)<<"alongMomentum";
804  outerTSOS = trajectory.lastMeasurement().updatedState();
805  innerTSOS = trajectory.firstMeasurement().updatedState();
806  outerId = trajectory.lastMeasurement().recHit()->geographicalId().rawId();
807  innerId = trajectory.firstMeasurement().recHit()->geographicalId().rawId();
808  outerRecHit = trajectory.lastMeasurement().recHit();
809  outerDetId = trajectory.lastMeasurement().recHit()->geographicalId();
810  }
811  else if (trajectory.direction() == oppositeToMomentum) {
812  LogTrace(metname)<<"oppositeToMomentum";
813  outerTSOS = trajectory.firstMeasurement().updatedState();
814  innerTSOS = trajectory.lastMeasurement().updatedState();
815  outerId = trajectory.firstMeasurement().recHit()->geographicalId().rawId();
816  innerId = trajectory.lastMeasurement().recHit()->geographicalId().rawId();
817  outerRecHit = trajectory.firstMeasurement().recHit();
818  outerDetId = trajectory.firstMeasurement().recHit()->geographicalId();
819  }
820  else LogError(metname)<<"Wrong propagation direction!";
821 
822  const GeomDet *outerDet = theService->trackingGeometry()->idToDet(outerDetId);
823  GlobalPoint outerTSOSPos = outerTSOS.globalParameters().position();
824  bool inside = outerDet->surface().bounds().inside(outerDet->toLocal(outerTSOSPos));
825 
826 
827  GlobalPoint hitPos = (outerRecHit->isValid()) ? outerRecHit->globalPosition() : outerTSOS.globalParameters().position() ;
828 
829  if(!inside) {
830  LogTrace(metname)<<"The Global Muon outerMostMeasurementState is not compatible with the recHit detector! Setting outerMost postition to recHit position if recHit isValid: " << outerRecHit->isValid();
831  LogTrace(metname)<<"From " << outerTSOSPos << " to " << hitPos;
832  }
833 
834 
835  //build the TrackExtra
836  GlobalPoint v = (inside) ? outerTSOSPos : hitPos ;
837  GlobalVector p = outerTSOS.globalParameters().momentum();
838  math::XYZPoint outpos( v.x(), v.y(), v.z() );
839  math::XYZVector outmom( p.x(), p.y(), p.z() );
840 
841  v = innerTSOS.globalParameters().position();
842  p = innerTSOS.globalParameters().momentum();
843  math::XYZPoint inpos( v.x(), v.y(), v.z() );
844  math::XYZVector inmom( p.x(), p.y(), p.z() );
845 
846  reco::TrackExtra trackExtra(outpos, outmom, true, inpos, inmom, true,
847  outerTSOS.curvilinearError(), outerId,
848  innerTSOS.curvilinearError(), innerId,
849  trajectory.direction(),trajectory.seedRef());
850 
851  return trackExtra;
852 
853 }
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:67
const Bounds & bounds() const
Definition: Surface.h:128
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:40
PropagationDirection const & direction() const
Definition: Trajectory.cc:118
TrajectoryMeasurement const & lastMeasurement() const
Definition: Trajectory.h:181
T z() const
Definition: PV3DBase.h:64
TrackingRecHit::ConstRecHitPointer ConstRecHitPointer
edm::RefToBase< TrajectorySeed > seedRef(void) const
Definition: Trajectory.h:306
#define LogTrace(id)
Definition: DetId.h:18
TrajectoryMeasurement const & firstMeasurement() const
Definition: Trajectory.h:194
const GlobalTrajectoryParameters & globalParameters() const
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:30
ConstRecHitContainer RecHitContainer
Definition: Trajectory.h:48
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
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 748 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().

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

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

Definition at line 363 of file MuonTrackLoader.cc.

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

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

Member Data Documentation

TkClonerImpl MuonTrackLoader::hitCloner
private

Definition at line 92 of file MuonTrackLoader.h.

bool MuonTrackLoader::theAllowNoVtxFlag
private

Definition at line 102 of file MuonTrackLoader.h.

Referenced by buildTrackAtPCA(), and MuonTrackLoader().

edm::InputTag MuonTrackLoader::theBeamSpotInputTag
private

Definition at line 95 of file MuonTrackLoader.h.

Referenced by MuonTrackLoader().

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

Definition at line 96 of file MuonTrackLoader.h.

Referenced by MuonTrackLoader().

std::string MuonTrackLoader::theL2SeededTkLabel
private

Label for L2SeededTracks.

Definition at line 99 of file MuonTrackLoader.h.

Referenced by loadTracks(), and MuonTrackLoader().

bool MuonTrackLoader::thePutTkTrackFlag
private

Definition at line 100 of file MuonTrackLoader.h.

Referenced by loadTracks(), and MuonTrackLoader().

const MuonServiceProxy* MuonTrackLoader::theService
private

Definition at line 82 of file MuonTrackLoader.h.

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

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

Definition at line 91 of file MuonTrackLoader.h.

std::string MuonTrackLoader::theSmootherName
private

Definition at line 90 of file MuonTrackLoader.h.

Referenced by MuonTrackLoader().

bool MuonTrackLoader::theSmoothingStep
private

Definition at line 89 of file MuonTrackLoader.h.

Referenced by MuonTrackLoader().

bool MuonTrackLoader::theSmoothTkTrackFlag
private

Definition at line 101 of file MuonTrackLoader.h.

Referenced by loadTracks(), and MuonTrackLoader().

bool MuonTrackLoader::theTrajectoryFlag
private

Definition at line 87 of file MuonTrackLoader.h.

Referenced by MuonTrackLoader().

bool MuonTrackLoader::theUpdatingAtVtx
private

Definition at line 84 of file MuonTrackLoader.h.

Referenced by MuonTrackLoader().

MuonUpdatorAtVertex* MuonTrackLoader::theUpdatorAtVtx
private