test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes
CosmicMuonSmoother Class Reference

#include <CosmicMuonSmoother.h>

Inheritance diagram for CosmicMuonSmoother:
TrajectorySmoother

Public Member Functions

virtual CosmicMuonSmootherclone () const override
 
 CosmicMuonSmoother (const edm::ParameterSet &, const MuonServiceProxy *service)
 
const Chi2MeasurementEstimatorestimator () const
 
std::vector< Trajectoryfit (const Trajectory &) const
 
std::vector< Trajectoryfit (const TrajectorySeed &seed, const ConstRecHitContainer &hits, const TrajectoryStateOnSurface &firstPredTsos) const
 
const PropagatorpropagatorAlong () const
 
const PropagatorpropagatorOpposite () const
 
virtual void setHitCloner (TkCloner const *hc)
 
virtual TrajectoryContainer trajectories (const Trajectory &traj) const override
 
virtual TrajectoryContainer trajectories (const TrajectorySeed &seed, const ConstRecHitContainer &hits, const TrajectoryStateOnSurface &firstPredTsos) const
 refit trajectory More...
 
Trajectory trajectory (const Trajectory &) const override
 
const KFUpdatorupdator () const
 
const CosmicMuonUtilitiesutilities () const
 
virtual ~CosmicMuonSmoother ()
 
- Public Member Functions inherited from TrajectorySmoother
virtual ~TrajectorySmoother ()
 

Private Member Functions

TrajectoryStateOnSurface initialState (const Trajectory &) const
 
std::vector< Trajectorysmooth (const std::vector< Trajectory > &) const
 
std::vector< Trajectorysmooth (const Trajectory &) const
 
void sortHitsAlongMom (ConstRecHitContainer &hits, const TrajectoryStateOnSurface &) const
 

Private Attributes

std::string category_
 
double theErrorRescaling
 
const Chi2MeasurementEstimatortheEstimator
 
std::string thePropagatorAlongName
 
std::string thePropagatorOppositeName
 
const MuonServiceProxytheService
 
const KFUpdatortheUpdator
 
const CosmicMuonUtilitiestheUtilities
 

Additional Inherited Members

- Public Types inherited from TrajectorySmoother
typedef std::vector< TrajectoryTrajectoryContainer
 
typedef
TrajectoryContainer::iterator 
TrajectoryIterator
 

Detailed Description

Definition at line 35 of file CosmicMuonSmoother.h.

Constructor & Destructor Documentation

CosmicMuonSmoother::CosmicMuonSmoother ( const edm::ParameterSet par,
const MuonServiceProxy service 
)

Definition at line 32 of file CosmicMuonSmoother.cc.

References category_, edm::ParameterSet::getParameter(), theErrorRescaling, theEstimator, thePropagatorAlongName, thePropagatorOppositeName, theUpdator, and theUtilities.

Referenced by clone().

32  : theService(service) {
33 
34  theUpdator = new KFUpdator;
37  thePropagatorAlongName = par.getParameter<string>("PropagatorAlong");
38  thePropagatorOppositeName = par.getParameter<string>("PropagatorOpposite");
39  theErrorRescaling = par.getParameter<double>("RescalingFactor");
40 
41  category_ = "Muon|RecoMuon|CosmicMuon|CosmicMuonSmoother";
42 }
T getParameter(std::string const &) const
const MuonServiceProxy * theService
const Chi2MeasurementEstimator * theEstimator
const CosmicMuonUtilities * theUtilities
std::string thePropagatorAlongName
const KFUpdator * theUpdator
std::string thePropagatorOppositeName
CosmicMuonSmoother::~CosmicMuonSmoother ( )
virtual

Definition at line 47 of file CosmicMuonSmoother.cc.

References theEstimator, theUpdator, and theUtilities.

47  {
48 
49  if ( theUpdator ) delete theUpdator;
50  if ( theUtilities ) delete theUtilities;
51  if ( theEstimator ) delete theEstimator;
52 
53 }
const Chi2MeasurementEstimator * theEstimator
const CosmicMuonUtilities * theUtilities
const KFUpdator * theUpdator

Member Function Documentation

virtual CosmicMuonSmoother* CosmicMuonSmoother::clone ( void  ) const
inlineoverridevirtual

Implements TrajectorySmoother.

Definition at line 48 of file CosmicMuonSmoother.h.

References CosmicMuonSmoother().

48  {
49  return new CosmicMuonSmoother(*this);
50  }
CosmicMuonSmoother(const edm::ParameterSet &, const MuonServiceProxy *service)
const Chi2MeasurementEstimator* CosmicMuonSmoother::estimator ( void  ) const
inline

Definition at line 66 of file CosmicMuonSmoother.h.

References theEstimator.

66 {return theEstimator;}
const Chi2MeasurementEstimator * theEstimator
vector< Trajectory > CosmicMuonSmoother::fit ( const Trajectory t) const

Definition at line 94 of file CosmicMuonSmoother.cc.

References category_, Trajectory::empty(), initialState(), TrajectoryStateOnSurface::isValid(), LogTrace, Trajectory::recHits(), Trajectory::seed(), and sortHitsAlongMom().

Referenced by CosmicMuonTrajectoryBuilder::flipTrajectory(), trackingPlots.Iteration::modules(), trajectories(), GlobalCosmicMuonTrajectoryBuilder::trajectories(), and trajectory().

94  {
95 
96  if ( t.empty() ) return vector<Trajectory>();
97 
98  LogTrace(category_)<< "fit begin (trajectory) ";
99 
100  TrajectoryStateOnSurface firstTsos = initialState(t);
101  if ( !firstTsos.isValid() ) {
102  LogTrace(category_)<< "Error: firstTsos invalid. ";
103  return vector<Trajectory>();
104  }
105 
106  LogTrace(category_)<< "firstTsos: "<<firstTsos;
107 
108  ConstRecHitContainer hits = t.recHits();
109  LogTrace(category_)<< "hits: "<<hits.size();
110  LogTrace(category_)<<"hit front" <<hits.front()->globalPosition()<< " hit back"
111  <<hits.back()->globalPosition();
112 
113  sortHitsAlongMom(hits, firstTsos);
114 
115  LogTrace(category_)<<"after sorting hit front" <<hits.front()->globalPosition()<< " hit back"
116  <<hits.back()->globalPosition();
117 
118  return fit(t.seed(), hits, firstTsos);
119 
120 }
bool empty() const
True if trajectory has no measurements.
Definition: Trajectory.h:299
void sortHitsAlongMom(ConstRecHitContainer &hits, const TrajectoryStateOnSurface &) const
TrajectorySeed const & seed() const
Access to the seed used to reconstruct the Trajectory.
Definition: Trajectory.h:330
ConstRecHitContainer recHits() const
Definition: Trajectory.h:258
#define LogTrace(id)
TrajectoryStateOnSurface initialState(const Trajectory &) const
std::vector< Trajectory > fit(const Trajectory &) const
TransientTrackingRecHit::ConstRecHitContainer ConstRecHitContainer
vector< Trajectory > CosmicMuonSmoother::fit ( const TrajectorySeed seed,
const ConstRecHitContainer hits,
const TrajectoryStateOnSurface firstPredTsos 
) const

Definition at line 126 of file CosmicMuonSmoother.cc.

References alongMomentum, category_, alignCSCRings::e, Chi2MeasurementEstimator::estimate(), f, TrajectoryStateOnSurface::globalMomentum(), TrajectoryStateOnSurface::globalPosition(), TrajectoryStateOnSurface::isValid(), LogTrace, PV3DBase< T, PVType, FrameType >::mag2(), Trajectory::measurements(), Propagator::propagate(), propagatorAlong(), Trajectory::push(), edm::second(), CosmicMuonUtilities::stepPropagate(), TrajectoryStateOnSurface::surface(), theEstimator, theService, theUpdator, theUtilities, and KFUpdator::update().

Referenced by trackingPlots.Iteration::modules().

128  {
129 
130  LogTrace(category_)<< "fit begin (seed, hit, tsos).";
131 
132  if ( hits.empty() ) {
133  LogTrace(category_)<< "Error: empty hits container.";
134  return vector<Trajectory>();
135  }
136 
137  Trajectory myTraj(seed, alongMomentum);
138 
139  TrajectoryStateOnSurface predTsos(firstPredTsos);
140  LogTrace(category_)<< "first pred TSOS: "<<predTsos;
141 
142  if ( !predTsos.isValid() ) {
143  LogTrace(category_)<< "Error: firstTsos invalid.";
144  return vector<Trajectory>();
145  }
146  TrajectoryStateOnSurface currTsos;
147 
148  if ( hits.front()->isValid() ) {
149 
150  // FIXME FIXME CLONE !!!
151  // TrackingRecHit::RecHitPointer preciseHit = hits.front()->clone(predTsos);
152  auto preciseHit = hits.front();
153 
154  LogTrace(category_)<<"first hit is at det "<< hits.front()->det()->surface().position();
155 
156  currTsos = theUpdator->update(predTsos, *preciseHit);
157  if (!currTsos.isValid()){
159  <<"an updated state is not valid. killing the trajectory.";
160  return vector<Trajectory>();
161  }
162  myTraj.push(TrajectoryMeasurement(predTsos, currTsos, hits.front(),
163  theEstimator->estimate(predTsos, *hits.front()).second));
164  if ( currTsos.isValid() ) LogTrace(category_)<< "first curr TSOS: "<<currTsos;
165 
166  } else {
167 
168  currTsos = predTsos;
169  myTraj.push(TrajectoryMeasurement(predTsos, hits.front()));
170  }
171  //const TransientTrackingRecHit& firsthit = *hits.front();
172 
173  for ( ConstRecHitContainer::const_iterator ihit = hits.begin() + 1;
174  ihit != hits.end(); ++ihit ) {
175 
176  if ( !(**ihit).isValid() ) {
177  LogTrace(category_)<< "Error: invalid hit.";
178  continue;
179  }
180  if (currTsos.isValid() && currTsos.globalMomentum().mag2() > 1e-18f) {
181  LogTrace(category_)<<"current pos "<<currTsos.globalPosition()
182  <<"mom "<<currTsos.globalMomentum();
183  } else {
184  LogTrace(category_)<<"current state invalid or momentum is too low";
185  //logically, there's no way out: can't expect a valid result out of an invalid state
187  <<"Input state is not valid. This loop over hits is doomed: breaking out";
188  break;
189  }
190 
191  predTsos = propagatorAlong()->propagate(currTsos, (**ihit).det()->surface());
192  LogTrace(category_)<<"predicted state propagate directly "<<predTsos.isValid();
193 
194  if ( !predTsos.isValid() ) {
195  LogTrace(category_)<<"step-propagating from "<<currTsos.globalPosition() <<" to position: "<<(*ihit)->globalPosition();
196  predTsos = theUtilities->stepPropagate(currTsos, (*ihit), *propagatorAlong());
197  }
198  if ( !predTsos.isValid() && (fabs(theService->magneticField()->inTesla(GlobalPoint(0,0,0)).z()) < 0.01) && (theService->propagator("StraightLinePropagator").isValid() ) ) {
199  LogTrace(category_)<<"straight-line propagating from "<<currTsos.globalPosition() <<" to position: "<<(*ihit)->globalPosition();
200  predTsos = theService->propagator("StraightLinePropagator")->propagate(currTsos, (**ihit).det()->surface());
201  }
202  if (predTsos.isValid()) {
203  LogTrace(category_)<<"predicted pos "<<predTsos.globalPosition()
204  <<"mom "<<predTsos.globalMomentum();
205  } else {
206  LogTrace(category_)<<"predicted state invalid";
207  }
208  if ( !predTsos.isValid() ) {
209  LogTrace(category_)<< "Error: predTsos is still invalid forward fit.";
210 // return vector<Trajectory>();
211  continue;
212  } else if ( (**ihit).isValid() ) {
213  // FIXME FIXME CLONE !!!
214  // update (FIXME!)
215  // TransientTrackingRecHit::RecHitPointer preciseHit = (**ihit).clone(predTsos);
216  auto preciseHit = *ihit;
217 
218  if ( !preciseHit->isValid() ) {
219  currTsos = predTsos;
220  myTraj.push(TrajectoryMeasurement(predTsos, *ihit));
221  } else {
222  currTsos = theUpdator->update(predTsos, *preciseHit);
223  if (!currTsos.isValid()){
225  <<"an updated state is not valid. killing the trajectory.";
226  return vector<Trajectory>();
227  }
228  myTraj.push(TrajectoryMeasurement(predTsos, currTsos, preciseHit,
229  theEstimator->estimate(predTsos, *preciseHit).second));
230  }
231  } else {
232  currTsos = predTsos;
233  myTraj.push(TrajectoryMeasurement(predTsos, *ihit));
234  }
235 
236  }
237 
238  std::vector<TrajectoryMeasurement> mytms = myTraj.measurements();
239  LogTrace(category_)<<"fit result "<<mytms.size();
240  for (std::vector<TrajectoryMeasurement>::const_iterator itm = mytms.begin();
241  itm != mytms.end(); ++itm ) {
242  LogTrace(category_)<<"updated pos "<<itm->updatedState().globalPosition()
243  <<"mom "<<itm->updatedState().globalMomentum();
244  }
245 
246 
247  return vector<Trajectory>(1, myTraj);
248 
249 }
T mag2() const
Definition: PV3DBase.h:66
const MuonServiceProxy * theService
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
GlobalPoint globalPosition() const
const Propagator * propagatorAlong() const
const Chi2MeasurementEstimator * theEstimator
U second(std::pair< T, U > const &p)
const SurfaceType & surface() const
TrajectoryStateOnSurface update(const TrajectoryStateOnSurface &, const TrackingRecHit &) const
Definition: KFUpdator.cc:75
const CosmicMuonUtilities * theUtilities
double f[11][100]
TrajectoryStateOnSurface stepPropagate(const TrajectoryStateOnSurface &, const ConstRecHitPointer &, const Propagator &) const
#define LogTrace(id)
const KFUpdator * theUpdator
TrajectoryStateOnSurface propagate(STA const &state, SUR const &surface) const
Definition: Propagator.h:53
GlobalVector globalMomentum() const
virtual std::pair< bool, double > estimate(const TrajectoryStateOnSurface &, const TrackingRecHit &) const
TrajectoryStateOnSurface CosmicMuonSmoother::initialState ( const Trajectory t) const
private

Definition at line 430 of file CosmicMuonSmoother.cc.

References Trajectory::empty(), PV3DBase< T, PVType, FrameType >::eta(), Trajectory::firstMeasurement(), TrajectoryStateOnSurface::globalMomentum(), TrajectoryStateOnSurface::globalPosition(), TrajectoryStateOnSurface::isValid(), Trajectory::lastMeasurement(), mps_fire::result, CosmicMuonUtilities::reverseDirection(), theService, theUtilities, TrajectoryMeasurement::updatedState(), PV3DBase< T, PVType, FrameType >::y(), and PV3DBase< T, PVType, FrameType >::z().

Referenced by fit().

430  {
431  if ( t.empty() ) return TrajectoryStateOnSurface();
432 
434 
436 
437  bool beamhaloFlag = ( t.firstMeasurement().updatedState().globalMomentum().eta() > 4.0 || t.lastMeasurement().updatedState().globalMomentum().eta() > 4.0 );
438 
439  if ( !beamhaloFlag ) { //initialState is the top one
441  result = t.firstMeasurement().updatedState();
442  } else {
443  result = t.lastMeasurement().updatedState();
444  }
445  if (result.globalMomentum().y()> 1.0 ) //top tsos should pointing down
446  theUtilities->reverseDirection(result,&*theService->magneticField());
447  } else {
448  if ( t.firstMeasurement().updatedState().globalPosition().z() * t.lastMeasurement().updatedState().globalPosition().z() >0 ) { //same side
449  if ( fabs(t.firstMeasurement().updatedState().globalPosition().z()) > fabs(t.lastMeasurement().updatedState().globalPosition().z()) ) {
450  result = t.firstMeasurement().updatedState();
451  } else {
452  result = t.lastMeasurement().updatedState();
453  }
454  } else { //different sides
455 
457  result = t.firstMeasurement().updatedState();
458  } else {
459  result = t.lastMeasurement().updatedState();
460  }
461  }
462 
463  }
464 
465  return result;
466 
467 }
bool empty() const
True if trajectory has no measurements.
Definition: Trajectory.h:299
const MuonServiceProxy * theService
T y() const
Definition: PV3DBase.h:63
GlobalPoint globalPosition() const
tuple result
Definition: mps_fire.py:83
const CosmicMuonUtilities * theUtilities
TrajectoryMeasurement const & lastMeasurement() const
Definition: Trajectory.h:228
T z() const
Definition: PV3DBase.h:64
TrajectoryMeasurement const & firstMeasurement() const
Definition: Trajectory.h:241
T eta() const
Definition: PV3DBase.h:76
GlobalVector globalMomentum() const
TrajectoryStateOnSurface const & updatedState() const
void reverseDirection(TrajectoryStateOnSurface &, const MagneticField *) const
const Propagator* CosmicMuonSmoother::propagatorAlong ( ) const
inline

Definition at line 58 of file CosmicMuonSmoother.h.

References MuonServiceProxy::propagator(), thePropagatorAlongName, and theService.

Referenced by fit().

const MuonServiceProxy * theService
std::string thePropagatorAlongName
edm::ESHandle< Propagator > propagator(std::string propagatorName) const
get the propagator
const Propagator* CosmicMuonSmoother::propagatorOpposite ( ) const
inline

Definition at line 60 of file CosmicMuonSmoother.h.

References MuonServiceProxy::propagator(), thePropagatorOppositeName, and theService.

Referenced by smooth().

const MuonServiceProxy * theService
edm::ESHandle< Propagator > propagator(std::string propagatorName) const
get the propagator
std::string thePropagatorOppositeName
virtual void CosmicMuonSmoother::setHitCloner ( TkCloner const *  hc)
inlinevirtual

Implements TrajectorySmoother.

Definition at line 74 of file CosmicMuonSmoother.h.

74 {}
vector< Trajectory > CosmicMuonSmoother::smooth ( const std::vector< Trajectory > &  tc) const
private

Definition at line 255 of file CosmicMuonSmoother.cc.

References mps_fire::result.

Referenced by trajectories(), and trajectory().

255  {
256 
257  vector<Trajectory> result;
258 
259  for ( vector<Trajectory>::const_iterator it = tc.begin(); it != tc.end(); ++it ) {
260  vector<Trajectory> smoothed = smooth(*it);
261  result.insert(result.end(), smoothed.begin(), smoothed.end());
262  }
263 
264  return result;
265 
266 }
tuple result
Definition: mps_fire.py:83
std::vector< Trajectory > smooth(const std::vector< Trajectory > &) const
vector< Trajectory > CosmicMuonSmoother::smooth ( const Trajectory t) const
private

Definition at line 272 of file CosmicMuonSmoother.cc.

References category_, heavyFlavorValidationHarvestingSequence_cff::combiner, Trajectory::empty(), Chi2MeasurementEstimator::estimate(), TrajectoryMeasurement::estimate(), TrajectoryStateOnSurface::globalMomentum(), TrajectoryStateOnSurface::globalPosition(), TrajectoryStateOnSurface::isValid(), LogTrace, Trajectory::measurements(), oppositeToMomentum, Propagator::propagate(), propagatorOpposite(), TrajectoryStateOnSurface::rescaleError(), Trajectory::seed(), CosmicMuonUtilities::stepPropagate(), TrajectoryStateOnSurface::surface(), theErrorRescaling, theEstimator, theUpdator, theUtilities, and KFUpdator::update().

272  {
273 
274  if ( t.empty() ) {
275  LogTrace(category_)<< "Error: smooth: empty trajectory.";
276  return vector<Trajectory>();
277  }
278 
279  Trajectory myTraj(t.seed(), oppositeToMomentum);
280 
281  vector<TrajectoryMeasurement> avtm = t.measurements();
282 
283  if ( avtm.size() < 2 ) {
284  LogTrace(category_)<< "Error: smooth: too little TM. ";
285  return vector<Trajectory>();
286  }
287 
288  TrajectoryStateOnSurface predTsos = avtm.back().forwardPredictedState();
290 
291  if ( !predTsos.isValid() ) {
292  LogTrace(category_)<< "Error: smooth: first TSOS from back invalid. ";
293  return vector<Trajectory>();
294  }
295 
296  TrajectoryStateOnSurface currTsos;
297 
298  // first smoothed TrajectoryMeasurement is last fitted
299  if ( avtm.back().recHit()->isValid() ) {
300  currTsos = theUpdator->update(predTsos, (*avtm.back().recHit()));
301  if (!currTsos.isValid()){
303  <<"an updated state is not valid. killing the trajectory.";
304  return vector<Trajectory>();
305  }
306  myTraj.push(TrajectoryMeasurement(avtm.back().forwardPredictedState(),
307  predTsos,
308  avtm.back().updatedState(),
309  avtm.back().recHit(),
310  avtm.back().estimate()//,
311  /*avtm.back().layer()*/),
312  avtm.back().estimate());
313 
314  } else {
315  currTsos = predTsos;
316  myTraj.push(TrajectoryMeasurement(avtm.back().forwardPredictedState(),
317  avtm.back().recHit()//,
318  /*avtm.back().layer()*/));
319 
320  }
321 
323 
324 
325  for ( vector<TrajectoryMeasurement>::reverse_iterator itm = avtm.rbegin() + 1;
326  itm != avtm.rend() - 1; ++itm ) {
327 
328  if (currTsos.isValid()) {
329  LogTrace(category_)<<"current pos "<<currTsos.globalPosition()
330  <<"mom "<<currTsos.globalMomentum();
331  } else {
332  LogTrace(category_)<<"current state invalid";
333  }
334 
335  predTsos = propagatorOpposite()->propagate(currTsos,(*itm).recHit()->det()->surface());
336 
337  if ( !predTsos.isValid() ) {
338  LogTrace(category_)<<"step-propagating from "<<currTsos.globalPosition() <<" to position: "<<(*itm).recHit()->globalPosition();
339  predTsos = theUtilities->stepPropagate(currTsos, (*itm).recHit(), *propagatorOpposite());
340  }
341  if (predTsos.isValid()) {
342  LogTrace(category_)<<"predicted pos "<<predTsos.globalPosition()
343  <<"mom "<<predTsos.globalMomentum();
344  } else {
345  LogTrace(category_)<<"predicted state invalid";
346  }
347 
348  if ( !predTsos.isValid() ) {
349  LogTrace(category_)<< "Error: predTsos is still invalid backward smooth.";
350  return vector<Trajectory>();
351  // continue;
352  } else if ( (*itm).recHit()->isValid() ) {
353  //update
354  currTsos = theUpdator->update(predTsos, (*(*itm).recHit()));
355  if (!currTsos.isValid()){
357  <<"an updated state is not valid. killing the trajectory.";
358  return vector<Trajectory>();
359  }
360  TrajectoryStateOnSurface combTsos = combiner(predTsos, (*itm).forwardPredictedState());
361  if ( !combTsos.isValid() ) {
362  LogTrace(category_)<< "Error: smooth: combining pred TSOS failed. ";
363  return vector<Trajectory>();
364  }
365 
366  TrajectoryStateOnSurface smooTsos = combiner((*itm).updatedState(), predTsos);
367 
368  if ( !smooTsos.isValid() ) {
369  LogTrace(category_)<< "Error: smooth: combining smooth TSOS failed. ";
370  return vector<Trajectory>();
371  }
372 
373  myTraj.push(TrajectoryMeasurement((*itm).forwardPredictedState(),
374  predTsos,
375  smooTsos,
376  (*itm).recHit(),
377  theEstimator->estimate(combTsos, (*(*itm).recHit())).second//,
378  /*(*itm).layer()*/),
379  (*itm).estimate());
380  } else {
381  currTsos = predTsos;
382  TrajectoryStateOnSurface combTsos = combiner(predTsos, (*itm).forwardPredictedState());
383 
384  if ( !combTsos.isValid() ) {
385  LogTrace(category_)<< "Error: smooth: combining TSOS failed. ";
386  return vector<Trajectory>();
387  }
388 
389  myTraj.push(TrajectoryMeasurement((*itm).forwardPredictedState(),
390  predTsos,
391  combTsos,
392  (*itm).recHit()//,
393  /*(*itm).layer()*/));
394  }
395  }
396 
397  // last smoothed TrajectoryMeasurement is last filtered
398  predTsos = propagatorOpposite()->propagate(currTsos, avtm.front().recHit()->det()->surface());
399 
400  if ( !predTsos.isValid() ){
401  LogTrace(category_)<< "Error: last predict TSOS failed, use original one. ";
402  // return vector<Trajectory>();
403  myTraj.push(TrajectoryMeasurement(avtm.front().forwardPredictedState(),
404  avtm.front().recHit()));
405  } else {
406  if ( avtm.front().recHit()->isValid() ) {
407  //update
408  currTsos = theUpdator->update(predTsos, (*avtm.front().recHit()));
409  if (currTsos.isValid())
410  myTraj.push(TrajectoryMeasurement(avtm.front().forwardPredictedState(),
411  predTsos,
412  currTsos,
413  avtm.front().recHit(),
414  theEstimator->estimate(predTsos, (*avtm.front().recHit())).second//,
415  /*avtm.front().layer()*/),
416  avtm.front().estimate());
417  }
418  }
419  LogTrace(category_)<< "myTraj foundHits. "<<myTraj.foundHits();
420 
421  if (myTraj.foundHits() >= 3)
422  return vector<Trajectory>(1, myTraj);
423  else {
424  LogTrace(category_)<< "Error: smooth: No enough hits in trajctory. ";
425  return vector<Trajectory>();
426  }
427 
428 }
bool empty() const
True if trajectory has no measurements.
Definition: Trajectory.h:299
TrajectorySeed const & seed() const
Access to the seed used to reconstruct the Trajectory.
Definition: Trajectory.h:330
GlobalPoint globalPosition() const
const Propagator * propagatorOpposite() const
const Chi2MeasurementEstimator * theEstimator
DataContainer const & measurements() const
Definition: Trajectory.h:250
const SurfaceType & surface() const
TrajectoryStateOnSurface update(const TrajectoryStateOnSurface &, const TrackingRecHit &) const
Definition: KFUpdator.cc:75
const CosmicMuonUtilities * theUtilities
TrajectoryStateOnSurface stepPropagate(const TrajectoryStateOnSurface &, const ConstRecHitPointer &, const Propagator &) const
#define LogTrace(id)
const KFUpdator * theUpdator
TrajectoryStateOnSurface propagate(STA const &state, SUR const &surface) const
Definition: Propagator.h:53
GlobalVector globalMomentum() const
virtual std::pair< bool, double > estimate(const TrajectoryStateOnSurface &, const TrackingRecHit &) const
void CosmicMuonSmoother::sortHitsAlongMom ( ConstRecHitContainer hits,
const TrajectoryStateOnSurface tsos 
) const
private

Definition at line 469 of file CosmicMuonSmoother.cc.

References TrajectoryStateOnSurface::globalPosition(), and mag().

Referenced by fit().

469  {
470 
471  if (hits.size() < 2) return;
472  float dis1 = (hits.front()->globalPosition() - tsos.globalPosition()).mag();
473  float dis2 = (hits.back()->globalPosition() - tsos.globalPosition()).mag();
474 
475  if ( dis1 > dis2 )
476  std::reverse(hits.begin(),hits.end());
477 
478  return;
479 }
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
GlobalPoint globalPosition() const
virtual TrajectoryContainer CosmicMuonSmoother::trajectories ( const Trajectory traj) const
inlineoverridevirtual

Reimplemented from TrajectorySmoother.

Definition at line 44 of file CosmicMuonSmoother.h.

References TrajectorySmoother::trajectories().

Referenced by CosmicMuonTrajectoryBuilder::estimateDirection(), CosmicMuonTrajectoryBuilder::trajectories(), and GlobalCosmicMuonTrajectoryBuilder::trajectories().

44  {
46  }
virtual TrajectoryContainer trajectories(const Trajectory &traj) const
std::vector< Trajectory > CosmicMuonSmoother::trajectories ( const TrajectorySeed seed,
const ConstRecHitContainer hits,
const TrajectoryStateOnSurface firstPredTsos 
) const
virtual

refit trajectory

Definition at line 69 of file CosmicMuonSmoother.cc.

References category_, fit(), TrajectoryStateOnSurface::isValid(), LogTrace, TrajectoryStateOnSurface::rescaleError(), smooth(), and theErrorRescaling.

71  {
72 
73  if ( hits.empty() ||!firstPredTsos.isValid() ) return vector<Trajectory>();
74 
75  LogTrace(category_)<< "trajectory begin (seed hits tsos)";
76 
77  TrajectoryStateOnSurface firstTsos = firstPredTsos;
79 
80  LogTrace(category_)<< "first TSOS: "<<firstTsos;
81 
82  vector<Trajectory> fitted = fit(seed, hits, firstTsos);
83  LogTrace(category_)<< "fitted: "<<fitted.size();
84  vector<Trajectory> smoothed = smooth(fitted);
85  LogTrace(category_)<< "smoothed: "<<smoothed.size();
86 
87  return smoothed;
88 
89 }
std::vector< Trajectory > smooth(const std::vector< Trajectory > &) const
#define LogTrace(id)
std::vector< Trajectory > fit(const Trajectory &) const
Trajectory CosmicMuonSmoother::trajectory ( const Trajectory t) const
overridevirtual

Implements TrajectorySmoother.

Definition at line 59 of file CosmicMuonSmoother.cc.

References fit(), and smooth().

59  {
60  std::vector<Trajectory> && fitted = fit(t);
61  if (fitted.empty()) return Trajectory();
62  std::vector<Trajectory> && smoothed = smooth(fitted);
63  return smoothed.empty() ? Trajectory() : smoothed.front();
64 }
std::vector< Trajectory > smooth(const std::vector< Trajectory > &) const
std::vector< Trajectory > fit(const Trajectory &) const
const KFUpdator* CosmicMuonSmoother::updator ( ) const
inline

Definition at line 62 of file CosmicMuonSmoother.h.

References theUpdator.

62 {return theUpdator;}
const KFUpdator * theUpdator
const CosmicMuonUtilities* CosmicMuonSmoother::utilities ( ) const
inline

Definition at line 64 of file CosmicMuonSmoother.h.

References theUtilities.

Referenced by CosmicMuonTrajectoryBuilder::utilities(), and GlobalCosmicMuonTrajectoryBuilder::utilities().

64 {return theUtilities; }
const CosmicMuonUtilities * theUtilities

Member Data Documentation

std::string CosmicMuonSmoother::category_
private

Definition at line 93 of file CosmicMuonSmoother.h.

Referenced by CosmicMuonSmoother(), fit(), smooth(), and trajectories().

double CosmicMuonSmoother::theErrorRescaling
private

Definition at line 92 of file CosmicMuonSmoother.h.

Referenced by CosmicMuonSmoother(), smooth(), and trajectories().

const Chi2MeasurementEstimator* CosmicMuonSmoother::theEstimator
private

Definition at line 85 of file CosmicMuonSmoother.h.

Referenced by CosmicMuonSmoother(), estimator(), fit(), smooth(), and ~CosmicMuonSmoother().

std::string CosmicMuonSmoother::thePropagatorAlongName
private

Definition at line 90 of file CosmicMuonSmoother.h.

Referenced by CosmicMuonSmoother(), and propagatorAlong().

std::string CosmicMuonSmoother::thePropagatorOppositeName
private

Definition at line 91 of file CosmicMuonSmoother.h.

Referenced by CosmicMuonSmoother(), and propagatorOpposite().

const MuonServiceProxy* CosmicMuonSmoother::theService
private

Definition at line 88 of file CosmicMuonSmoother.h.

Referenced by fit(), initialState(), propagatorAlong(), and propagatorOpposite().

const KFUpdator* CosmicMuonSmoother::theUpdator
private

Definition at line 84 of file CosmicMuonSmoother.h.

Referenced by CosmicMuonSmoother(), fit(), smooth(), updator(), and ~CosmicMuonSmoother().

const CosmicMuonUtilities* CosmicMuonSmoother::theUtilities
private