CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
MuonSeedTrack.cc
Go to the documentation of this file.
1 
14 
16 
20 
22 
27 
31 
32 using namespace reco;
33 using namespace edm;
34 using namespace std;
35 
37 
38 
39 //
40 // constructors
41 //
43 {
44  // service parameters
45  ParameterSet serviceParameters = pset.getParameter<ParameterSet>("ServiceParameters");
46  theService = new MuonServiceProxy(serviceParameters);
47 
48  ParameterSet updatorPar = pset.getParameter<ParameterSet>("MuonUpdatorAtVertexParameters");
49  //theSeedPropagatorName = updatorPar.getParameter<string>("Propagator");
50  theSeedsLabel = pset.getParameter<InputTag>("MuonSeed");
51  theUpdatorAtVtx = new MuonUpdatorAtVertex(updatorPar,theService);
52 
53  theAllowNoVtxFlag = pset.getUntrackedParameter<bool>("AllowNoVertex",false);
54 
55  //register products
56  setAlias(pset.getParameter<std::string>("@module_label"));
57  produces<reco::TrackCollection>().setBranchAlias(theAlias + "Tracks");
58 
59 }
60 
61 //
62 // destructor
63 //
65 {
66  if (theService) delete theService;
67  if (theUpdatorAtVtx) delete theUpdatorAtVtx;
68 }
69 
70 //
71 // member functions
72 //
73 
77 void
79 {
80  using namespace edm;
81 
82  // Update the services
83  theService->update(eventSetup);
84 
85  // the track collectios; they will be loaded in the event
86  auto_ptr<reco::TrackCollection> trackCollection(new reco::TrackCollection());
87  // ... and its reference into the event
88  reco::TrackRefProd trackCollectionRefProd = event.getRefBeforePut<reco::TrackCollection>();
89 
90 
92  event.getByLabel(theSeedsLabel, seeds);
93 
94  for ( TrajectorySeedCollection::const_iterator iSeed = seeds->begin();
95  iSeed != seeds->end(); iSeed++ ) {
96  pair<bool,reco::Track> resultOfTrackExtrapAtPCA = buildTrackAtPCA(*iSeed);
97  if(!resultOfTrackExtrapAtPCA.first) continue;
98  // take the "bare" track at PCA
99  reco::Track &track = resultOfTrackExtrapAtPCA.second;
100  // fill the TrackCollection
101  trackCollection->push_back(track);
102  }
103 
104  event.put(trackCollection);
105 
106 }
107 
111 void
113 {
114 }
115 
116 
120 void
122 }
123 
124 
129 
130  // Get the Trajectory State on Det (persistent version of a TSOS) from the seed
131  PTrajectoryStateOnDet pTSOD = seed.startingState();
132 
133  // Transform it in a TrajectoryStateOnSurface
134 
135 
136  DetId seedDetId(pTSOD.detId());
137 
138  const GeomDet* gdet = theService->trackingGeometry()->idToDet( seedDetId );
139 
140  TrajectoryStateOnSurface initialState = trajectoryStateTransform::transientState(pTSOD, &(gdet->surface()), &*theService->magneticField());
141 
142  /*
143  // Get the layer on which the seed relies
144  const DetLayer *initialLayer = theService->detLayerGeometry()->idToLayer( seedDetId );
145 
146  PropagationDirection detLayerOrder = oppositeToMomentum;
147 
148  // ask for compatible layers
149  vector<const DetLayer*> detLayers;
150  detLayers = initialLayer->compatibleLayers( *initialState.freeState(),detLayerOrder);
151 
152  TrajectoryStateOnSurface result = initialState;
153  if(detLayers.size()){
154  const DetLayer* finalLayer = detLayers.back();
155  const TrajectoryStateOnSurface propagatedState = theService->propagator(theSeedPropagatorName)->propagate(initialState, finalLayer->surface());
156  if(propagatedState.isValid())
157  result = propagatedState;
158  }
159 
160  return result;
161  */
162 
163  return initialState;
164 
165 }
166 
167 
172 pair<bool,reco::Track> MuonSeedTrack::buildTrackAtPCA(const TrajectorySeed& seed) const {
173 
174  const string metname = "MuonSeedTrack";
175 
177 
178  TSOS seedTSOS = getSeedTSOS(seed);
179  // This is needed to extrapolate the tsos at vertex
180  LogTrace(metname) << "Propagate to PCA...";
181  pair<bool,FreeTrajectoryState>
182  extrapolationResult = theUpdatorAtVtx->propagateToNominalLine(seedTSOS);
183  FreeTrajectoryState ftsAtVtx;
184 
185  if(extrapolationResult.first) {
186  ftsAtVtx = extrapolationResult.second;
187  } else {
188  if(TrackerBounds::isInside(seedTSOS.globalPosition())){
189  LogWarning(metname) << "Track in the Tracker: taking the innermost state instead of the state at PCA";
190  ftsAtVtx = *seedTSOS.freeState();
191  }
192  else{
193  if ( theAllowNoVtxFlag ) {
194  LogWarning(metname) << "Propagation to PCA failed, taking the innermost state instead of the state at PCA";
195  ftsAtVtx = *seedTSOS.freeState();
196  } else {
197  LogWarning(metname) << "Stand Alone track: this track will be rejected";
198  return pair<bool,reco::Track>(false,reco::Track());
199  }
200  }
201  }
202 
203  LogTrace(metname) << "TSOS after the extrapolation at vtx";
204  LogTrace(metname) << debug.dumpFTS(ftsAtVtx);
205 
206  GlobalPoint pca = ftsAtVtx.position();
207  math::XYZPoint persistentPCA(pca.x(),pca.y(),pca.z());
208  GlobalVector p = ftsAtVtx.momentum();
209  math::XYZVector persistentMomentum(p.x(),p.y(),p.z());
210 
211  double dummyNDOF = 1.0;
212  //double ndof = computeNDOF(seed);
213  double dummyChi2 = 1.0;
214 
215  reco::Track track(dummyChi2,
216  dummyNDOF,
217  persistentPCA,
218  persistentMomentum,
219  ftsAtVtx.charge(),
220  ftsAtVtx.curvilinearError());
221 
222  return pair<bool,reco::Track>(true,track);
223 }
224 
228 double MuonSeedTrack::computeNDOF(const TrajectorySeed& trajectory) const {
229  const string metname = "MuonSeedTrack";
230 
231  BasicTrajectorySeed::const_iterator recHits1 = (trajectory.recHits().first);
232  BasicTrajectorySeed::const_iterator recHits2 = (trajectory.recHits().second);
233 
234  double ndof = 0.;
235 
236  if ((*recHits1).isValid()) ndof += (*recHits1).dimension();
237  if ((*recHits2).isValid()) ndof += (*recHits2).dimension();
238 
239  //const Trajectory::RecHitContainer transRecHits = trajectory.recHits();
240  //for(Trajectory::RecHitContainer::const_iterator rechit = transRecHits.begin();
241  // rechit != transRecHits.end(); ++rechit)
242  //if ((*rechit)->isValid()) ndof += (*rechit)->dimension();
243 
244  // FIXME! in case of Boff is dof - 4
245  return max(ndof - 5., 0.);
246 }
247 
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
static bool isInside(const GlobalPoint &)
const std::string metname
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:10
T y() const
Definition: PV3DBase.h:62
GlobalPoint globalPosition() const
TrackCharge charge() const
virtual void beginJob()
pre-job booking
double computeNDOF(const TrajectorySeed &) const
compute the TrajectorySeed&#39;s degree of freedom
const CurvilinearTrajectoryError & curvilinearError() const
std::string dumpFTS(const FreeTrajectoryState &fts) const
FreeTrajectoryState * freeState(bool withErrors=true) const
const T & max(const T &a, const T &b)
recHitContainer::const_iterator const_iterator
T z() const
Definition: PV3DBase.h:63
~MuonSeedTrack()
destructor
std::pair< bool, reco::Track > buildTrackAtPCA(const TrajectorySeed &) const
Build a track at the PCA WITHOUT any vertex constriant.
unsigned int detId() const
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
GlobalVector momentum() const
#define LogTrace(id)
Definition: DetId.h:20
GlobalPoint position() const
TrajectoryStateOnSurface TSOS
Definition: TestHits.cc:23
PTrajectoryStateOnDet const & startingState() const
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:13
TrajectoryStateOnSurface getSeedTSOS(const TrajectorySeed &seed) const
get the TrajectorySeed&#39;s TrajectoryStateOnSurface
range recHits() const
MuonSeedTrack(const edm::ParameterSet &)
constructor with config
#define debug
Definition: MEtoEDMFormat.h:34
T x() const
Definition: PV3DBase.h:61
virtual void endJob()
post-job
virtual void produce(edm::Event &, const edm::EventSetup &)
construct proto-tracks