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 
12 
14 
17 
19 
24 
28 
29 using namespace reco;
30 using namespace edm;
31 using namespace std;
32 
34 
35 
36 //
37 // constructors
38 //
40 {
41  // service parameters
42  ParameterSet serviceParameters = pset.getParameter<ParameterSet>("ServiceParameters");
43  theService = new MuonServiceProxy(serviceParameters);
44 
45  ParameterSet updatorPar = pset.getParameter<ParameterSet>("MuonUpdatorAtVertexParameters");
46  //theSeedPropagatorName = updatorPar.getParameter<string>("Propagator");
47  theSeedsLabel = pset.getParameter<InputTag>("MuonSeed");
48  theSeedsToken = consumes<TrajectorySeedCollection>(theSeedsLabel);
49  theUpdatorAtVtx = new MuonUpdatorAtVertex(updatorPar,theService);
50 
51  theAllowNoVtxFlag = pset.getUntrackedParameter<bool>("AllowNoVertex",false);
52 
53  //register products
54  setAlias(pset.getParameter<std::string>("@module_label"));
55  produces<reco::TrackCollection>().setBranchAlias(theAlias + "Tracks");
56 
57 }
58 
59 //
60 // destructor
61 //
63 {
64  if (theService) delete theService;
65  if (theUpdatorAtVtx) delete theUpdatorAtVtx;
66 }
67 
68 //
69 // member functions
70 //
71 
75 void
77 {
78  using namespace edm;
79 
80  // Update the services
81  theService->update(eventSetup);
82 
83  // the track collectios; they will be loaded in the event
84  auto_ptr<reco::TrackCollection> trackCollection(new reco::TrackCollection());
85  // ... and its reference into the event
86  reco::TrackRefProd trackCollectionRefProd = event.getRefBeforePut<reco::TrackCollection>();
87 
88 
90  event.getByToken(theSeedsToken, seeds);
91 
92  for ( TrajectorySeedCollection::const_iterator iSeed = seeds->begin();
93  iSeed != seeds->end(); iSeed++ ) {
94  pair<bool,reco::Track> resultOfTrackExtrapAtPCA = buildTrackAtPCA(*iSeed);
95  if(!resultOfTrackExtrapAtPCA.first) continue;
96  // take the "bare" track at PCA
97  reco::Track &track = resultOfTrackExtrapAtPCA.second;
98  // fill the TrackCollection
99  trackCollection->push_back(track);
100  }
101 
102  event.put(trackCollection);
103 
104 }
105 
109 void
111 {
112 }
113 
114 
118 void
120 }
121 
122 
127 
128  // Get the Trajectory State on Det (persistent version of a TSOS) from the seed
129  PTrajectoryStateOnDet pTSOD = seed.startingState();
130 
131  // Transform it in a TrajectoryStateOnSurface
132 
133 
134  DetId seedDetId(pTSOD.detId());
135 
136  const GeomDet* gdet = theService->trackingGeometry()->idToDet( seedDetId );
137 
138  TrajectoryStateOnSurface initialState = trajectoryStateTransform::transientState(pTSOD, &(gdet->surface()), &*theService->magneticField());
139 
140  /*
141  // Get the layer on which the seed relies
142  const DetLayer *initialLayer = theService->detLayerGeometry()->idToLayer( seedDetId );
143 
144  PropagationDirection detLayerOrder = oppositeToMomentum;
145 
146  // ask for compatible layers
147  vector<const DetLayer*> detLayers;
148  detLayers = initialLayer->compatibleLayers( *initialState.freeState(),detLayerOrder);
149 
150  TrajectoryStateOnSurface result = initialState;
151  if(detLayers.size()){
152  const DetLayer* finalLayer = detLayers.back();
153  const TrajectoryStateOnSurface propagatedState = theService->propagator(theSeedPropagatorName)->propagate(initialState, finalLayer->surface());
154  if(propagatedState.isValid())
155  result = propagatedState;
156  }
157 
158  return result;
159  */
160 
161  return initialState;
162 
163 }
164 
165 
170 pair<bool,reco::Track> MuonSeedTrack::buildTrackAtPCA(const TrajectorySeed& seed) const {
171 
172  const string metname = "MuonSeedTrack";
173 
175 
176  TSOS seedTSOS = getSeedTSOS(seed);
177  // This is needed to extrapolate the tsos at vertex
178  LogTrace(metname) << "Propagate to PCA...";
179  pair<bool,FreeTrajectoryState>
180  extrapolationResult = theUpdatorAtVtx->propagateToNominalLine(seedTSOS);
181  FreeTrajectoryState ftsAtVtx;
182 
183  if(extrapolationResult.first) {
184  ftsAtVtx = extrapolationResult.second;
185  } else {
186  if(TrackerBounds::isInside(seedTSOS.globalPosition())){
187  LogWarning(metname) << "Track in the Tracker: taking the innermost state instead of the state at PCA";
188  ftsAtVtx = *seedTSOS.freeState();
189  }
190  else{
191  if ( theAllowNoVtxFlag ) {
192  LogWarning(metname) << "Propagation to PCA failed, taking the innermost state instead of the state at PCA";
193  ftsAtVtx = *seedTSOS.freeState();
194  } else {
195  LogWarning(metname) << "Stand Alone track: this track will be rejected";
196  return pair<bool,reco::Track>(false,reco::Track());
197  }
198  }
199  }
200 
201  LogTrace(metname) << "TSOS after the extrapolation at vtx";
202  LogTrace(metname) << debug.dumpFTS(ftsAtVtx);
203 
204  GlobalPoint pca = ftsAtVtx.position();
205  math::XYZPoint persistentPCA(pca.x(),pca.y(),pca.z());
206  GlobalVector p = ftsAtVtx.momentum();
207  math::XYZVector persistentMomentum(p.x(),p.y(),p.z());
208 
209  double dummyNDOF = 1.0;
210  //double ndof = computeNDOF(seed);
211  double dummyChi2 = 1.0;
212 
213  reco::Track track(dummyChi2,
214  dummyNDOF,
215  persistentPCA,
216  persistentMomentum,
217  ftsAtVtx.charge(),
218  ftsAtVtx.curvilinearError());
219 
220  return pair<bool,reco::Track>(true,track);
221 }
222 
226 double MuonSeedTrack::computeNDOF(const TrajectorySeed& trajectory) const {
227  const string metname = "MuonSeedTrack";
228 
229  BasicTrajectorySeed::const_iterator recHits1 = (trajectory.recHits().first);
230  BasicTrajectorySeed::const_iterator recHits2 = (trajectory.recHits().second);
231 
232  double ndof = 0.;
233 
234  if ((*recHits1).isValid()) ndof += (*recHits1).dimension();
235  if ((*recHits2).isValid()) ndof += (*recHits2).dimension();
236 
237  //const Trajectory::RecHitContainer transRecHits = trajectory.recHits();
238  //for(Trajectory::RecHitContainer::const_iterator rechit = transRecHits.begin();
239  // rechit != transRecHits.end(); ++rechit)
240  //if ((*rechit)->isValid()) ndof += (*rechit)->dimension();
241 
242  // FIXME! in case of Boff is dof - 4
243  return max(ndof - 5., 0.);
244 }
245 
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:13
T y() const
Definition: PV3DBase.h:63
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
recHitContainer::const_iterator const_iterator
FreeTrajectoryState const * freeState(bool withErrors=true) const
T z() const
Definition: PV3DBase.h:64
~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:18
GlobalPoint position() const
TrajectoryStateOnSurface TSOS
Definition: TestHits.cc:19
PTrajectoryStateOnDet const & startingState() const
#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:30
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
TrajectoryStateOnSurface getSeedTSOS(const TrajectorySeed &seed) const
get the TrajectorySeed&#39;s TrajectoryStateOnSurface
range recHits() const
MuonSeedTrack(const edm::ParameterSet &)
constructor with config
T x() const
Definition: PV3DBase.h:62
virtual void endJob()
post-job
virtual void produce(edm::Event &, const edm::EventSetup &)
construct proto-tracks