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 }
~MuonSeedTrack() override
destructor
TrajectoryStateOnSurface TSOS
static bool isInside(const GlobalPoint &)
const CurvilinearTrajectoryError & curvilinearError() const
T z() const
Definition: PV3DBase.h:61
const std::string metname
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:14
unsigned int detId() const
#define LogTrace(id)
GlobalPoint position() const
TrajectoryStateOnSurface getSeedTSOS(const TrajectorySeed &seed) const
get the TrajectorySeed&#39;s TrajectoryStateOnSurface
T x() const
Definition: PV3DBase.h:59
T y() const
Definition: PV3DBase.h:60
GlobalPoint globalPosition() const
TrackCharge charge() const
GlobalVector momentum() const
std::pair< bool, reco::Track > buildTrackAtPCA(const TrajectorySeed &) const
Build a track at the PCA WITHOUT any vertex constriant.
trackCollection
Definition: JetHT_cfg.py:51
Definition: DetId.h:17
#define debug
Definition: HDRShower.cc:19
TrajectoryStateOnSurface transientState(const PTrajectoryStateOnDet &ts, const Surface *surface, const MagneticField *field)
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
fixed size matrix
HLT enums.
void endJob() override
post-job
FreeTrajectoryState const * freeState(bool withErrors=true) const
MuonSeedTrack(const edm::ParameterSet &)
constructor with config
void produce(edm::Event &, const edm::EventSetup &) override
construct proto-tracks
Log< level::Warning, false > LogWarning
def move(src, dest)
Definition: eostools.py:511
Definition: event.py:1
void beginJob() override
pre-job booking