CMS 3D CMS Logo

MuonSeedTrack.cc
Go to the documentation of this file.
1 
12 
15 
18 
20 
25 
29 
30 using namespace reco;
31 using namespace edm;
32 using namespace std;
33 
35 
36 //
37 // constructors
38 //
40  // service parameters
41  ParameterSet serviceParameters = pset.getParameter<ParameterSet>("ServiceParameters");
42  theService = new MuonServiceProxy(serviceParameters, consumesCollector());
43 
44  ParameterSet updatorPar = pset.getParameter<ParameterSet>("MuonUpdatorAtVertexParameters");
45  //theSeedPropagatorName = updatorPar.getParameter<string>("Propagator");
46  theSeedsLabel = pset.getParameter<InputTag>("MuonSeed");
47  theSeedsToken = consumes<TrajectorySeedCollection>(theSeedsLabel);
48  theUpdatorAtVtx = new MuonUpdatorAtVertex(updatorPar, theService);
49 
50  theAllowNoVtxFlag = pset.getUntrackedParameter<bool>("AllowNoVertex", false);
51 
52  //register products
53  setAlias(pset.getParameter<std::string>("@module_label"));
54  produces<reco::TrackCollection>().setBranchAlias(theAlias + "Tracks");
55 }
56 
57 //
58 // destructor
59 //
61  if (theService)
62  delete theService;
63  if (theUpdatorAtVtx)
64  delete theUpdatorAtVtx;
65 }
66 
67 //
68 // member functions
69 //
70 
75  using namespace edm;
76 
77  // Update the services
78  theService->update(eventSetup);
79 
80  // the track collectios; they will be loaded in the event
81  unique_ptr<reco::TrackCollection> trackCollection(new reco::TrackCollection());
82  // ... and its reference into the event
83  reco::TrackRefProd trackCollectionRefProd = event.getRefBeforePut<reco::TrackCollection>();
84 
86  event.getByToken(theSeedsToken, seeds);
87 
88  for (TrajectorySeedCollection::const_iterator iSeed = seeds->begin(); iSeed != seeds->end(); iSeed++) {
89  pair<bool, reco::Track> resultOfTrackExtrapAtPCA = buildTrackAtPCA(*iSeed);
90  if (!resultOfTrackExtrapAtPCA.first)
91  continue;
92  // take the "bare" track at PCA
93  reco::Track& track = resultOfTrackExtrapAtPCA.second;
94  // fill the TrackCollection
95  trackCollection->push_back(track);
96  }
97 
98  event.put(std::move(trackCollection));
99 }
100 
105 
110 
115  // Get the Trajectory State on Det (persistent version of a TSOS) from the seed
116  PTrajectoryStateOnDet pTSOD = seed.startingState();
117 
118  // Transform it in a TrajectoryStateOnSurface
119 
120  DetId seedDetId(pTSOD.detId());
121 
122  const GeomDet* gdet = theService->trackingGeometry()->idToDet(seedDetId);
123 
124  TrajectoryStateOnSurface initialState =
125  trajectoryStateTransform::transientState(pTSOD, &(gdet->surface()), &*theService->magneticField());
126 
127  /*
128  // Get the layer on which the seed relies
129  const DetLayer *initialLayer = theService->detLayerGeometry()->idToLayer( seedDetId );
130 
131  PropagationDirection detLayerOrder = oppositeToMomentum;
132 
133  // ask for compatible layers
134  vector<const DetLayer*> detLayers;
135  detLayers = initialLayer->compatibleLayers( *initialState.freeState(),detLayerOrder);
136 
137  TrajectoryStateOnSurface result = initialState;
138  if(detLayers.size()){
139  const DetLayer* finalLayer = detLayers.back();
140  const TrajectoryStateOnSurface propagatedState = theService->propagator(theSeedPropagatorName)->propagate(initialState, finalLayer->surface());
141  if(propagatedState.isValid())
142  result = propagatedState;
143  }
144 
145  return result;
146  */
147 
148  return initialState;
149 }
150 
155 pair<bool, reco::Track> MuonSeedTrack::buildTrackAtPCA(const TrajectorySeed& seed) const {
156  const string metname = "MuonSeedTrack";
157 
159 
160  TSOS seedTSOS = getSeedTSOS(seed);
161  // This is needed to extrapolate the tsos at vertex
162  LogTrace(metname) << "Propagate to PCA...";
163  pair<bool, FreeTrajectoryState> extrapolationResult = theUpdatorAtVtx->propagateToNominalLine(seedTSOS);
164  FreeTrajectoryState ftsAtVtx;
165 
166  if (extrapolationResult.first) {
167  ftsAtVtx = extrapolationResult.second;
168  } else {
169  if (TrackerBounds::isInside(seedTSOS.globalPosition())) {
170  LogWarning(metname) << "Track in the Tracker: taking the innermost state instead of the state at PCA";
171  ftsAtVtx = *seedTSOS.freeState();
172  } else {
173  if (theAllowNoVtxFlag) {
174  LogWarning(metname) << "Propagation to PCA failed, taking the innermost state instead of the state at PCA";
175  ftsAtVtx = *seedTSOS.freeState();
176  } else {
177  LogWarning(metname) << "Stand Alone track: this track will be rejected";
178  return pair<bool, reco::Track>(false, reco::Track());
179  }
180  }
181  }
182 
183  LogTrace(metname) << "TSOS after the extrapolation at vtx";
184  LogTrace(metname) << debug.dumpFTS(ftsAtVtx);
185 
186  GlobalPoint pca = ftsAtVtx.position();
187  math::XYZPoint persistentPCA(pca.x(), pca.y(), pca.z());
188  GlobalVector p = ftsAtVtx.momentum();
189  math::XYZVector persistentMomentum(p.x(), p.y(), p.z());
190 
191  double dummyNDOF = 1.0;
192  double dummyChi2 = 1.0;
193 
195  dummyChi2, dummyNDOF, persistentPCA, persistentMomentum, ftsAtVtx.charge(), ftsAtVtx.curvilinearError());
196 
197  return pair<bool, reco::Track>(true, track);
198 }
Vector3DBase
Definition: Vector3DBase.h:8
edm::RefProd< TrackCollection >
MuonUpdatorAtVertex.h
TrackExtra.h
FreeTrajectoryState::momentum
GlobalVector momentum() const
Definition: FreeTrajectoryState.h:68
TSOS
TrajectoryStateOnSurface TSOS
Definition: MuonSeedTrack.cc:34
FreeTrajectoryState.h
HLT_FULL_cff.track
track
Definition: HLT_FULL_cff.py:11713
MessageLogger.h
MuonSeedTrack::~MuonSeedTrack
~MuonSeedTrack() override
destructor
Definition: MuonSeedTrack.cc:60
MuonPatternRecoDumper.h
GeomDet
Definition: GeomDet.h:27
MuonSeedTrack::getSeedTSOS
TrajectoryStateOnSurface getSeedTSOS(const TrajectorySeed &seed) const
get the TrajectorySeed's TrajectoryStateOnSurface
Definition: MuonSeedTrack.cc:114
PV3DBase::x
T x() const
Definition: PV3DBase.h:59
edm
HLT enums.
Definition: AlignableModifier.h:19
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
TrajectoryStateOnSurface::globalPosition
GlobalPoint globalPosition() const
Definition: TrajectoryStateOnSurface.h:65
FreeTrajectoryState::charge
TrackCharge charge() const
Definition: FreeTrajectoryState.h:69
MuonSeedTrack.h
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:45
FreeTrajectoryState::position
GlobalPoint position() const
Definition: FreeTrajectoryState.h:67
MuonSeedTrack::buildTrackAtPCA
std::pair< bool, reco::Track > buildTrackAtPCA(const TrajectorySeed &) const
Build a track at the PCA WITHOUT any vertex constriant.
Definition: MuonSeedTrack.cc:155
edm::Handle
Definition: AssociativeIterator.h:50
MuonSeedTrack::beginJob
void beginJob() override
pre-job booking
Definition: MuonSeedTrack.cc:104
edm::LogWarning
Log< level::Warning, false > LogWarning
Definition: MessageLogger.h:122
MuonServiceProxy_cff.MuonServiceProxy
MuonServiceProxy
Definition: MuonServiceProxy_cff.py:14
TrackerBounds::isInside
static bool isInside(const GlobalPoint &)
Definition: TrackerBounds.cc:37
PV3DBase::z
T z() const
Definition: PV3DBase.h:61
MuonSeedTrack::MuonSeedTrack
MuonSeedTrack(const edm::ParameterSet &)
constructor with config
Definition: MuonSeedTrack.cc:39
fileCollector.seed
seed
Definition: fileCollector.py:127
DetId
Definition: DetId.h:17
MuonSeedTrack::endJob
void endJob() override
post-job
Definition: MuonSeedTrack.cc:109
TrajectoryStateOnSurface
Definition: TrajectoryStateOnSurface.h:16
debug
#define debug
Definition: HDRShower.cc:19
PTrajectoryStateOnDet::detId
unsigned int detId() const
Definition: PTrajectoryStateOnDet.h:65
TrajectoryStateOnSurface::freeState
FreeTrajectoryState const * freeState(bool withErrors=true) const
Definition: TrajectoryStateOnSurface.h:58
Track.h
TrackerBounds.h
MuonPatternRecoDumper
Definition: MuonPatternRecoDumper.h:18
FreeTrajectoryState::curvilinearError
const CurvilinearTrajectoryError & curvilinearError() const
Definition: FreeTrajectoryState.h:89
reco::Track
Definition: Track.h:27
Point3DBase< float, GlobalTag >
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
InitialStep_cff.seeds
seeds
Definition: InitialStep_cff.py:230
edm::ParameterSet
Definition: ParameterSet.h:47
math::XYZPoint
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
duplicaterechits_cfi.trackCollection
trackCollection
Definition: duplicaterechits_cfi.py:4
math::XYZVector
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:31
PV3DBase::y
T y() const
Definition: PV3DBase.h:60
trajectoryStateTransform::transientState
TrajectoryStateOnSurface transientState(const PTrajectoryStateOnDet &ts, const Surface *surface, const MagneticField *field)
Definition: TrajectoryStateTransform.cc:35
MuonUpdatorAtVertex_cff.MuonUpdatorAtVertex
MuonUpdatorAtVertex
Definition: MuonUpdatorAtVertex_cff.py:3
edm::EventSetup
Definition: EventSetup.h:57
GeomDet.h
eostools.move
def move(src, dest)
Definition: eostools.py:511
std
Definition: JetResolutionObject.h:76
FreeTrajectoryState
Definition: FreeTrajectoryState.h:27
MuonSeedTrack::produce
void produce(edm::Event &, const edm::EventSetup &) override
construct proto-tracks
Definition: MuonSeedTrack.cc:74
MuonServiceProxy.h
DetLayer.h
TrajectorySeed
Definition: TrajectorySeed.h:18
TrajectoryStateTransform.h
ConsumesCollector.h
LogTrace
#define LogTrace(id)
Definition: MessageLogger.h:224
PTrajectoryStateOnDet
Definition: PTrajectoryStateOnDet.h:10
event
Definition: event.py:1
edm::Event
Definition: Event.h:73
edm::InputTag
Definition: InputTag.h:15
reco::TrackCollection
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:14
muonDTDigis_cfi.pset
pset
Definition: muonDTDigis_cfi.py:27
metname
const std::string metname
Definition: MuonSeedOrcaPatternRecognition.cc:40