CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
MuonBestMeasurementFinder.cc
Go to the documentation of this file.
1 
15 
18 
23 
25 
26 using namespace std;
27 
29 
31 
32 TrajectoryMeasurement* MuonBestMeasurementFinder::findBestMeasurement(std::vector<TrajectoryMeasurement>& measC,
33  const Propagator* propagator) {
34  const std::string metname = "Muon|RecoMuon|MuonBestMeasurementFinder";
35 
36  TMContainer validMeasurements;
37 
38  TrajectoryMeasurement* bestMeasurement = nullptr;
39 
40  // consider only valid TM
41  int NumValidMeas = 0;
42  for (vector<TrajectoryMeasurement>::iterator measurement = measC.begin(); measurement != measC.end(); ++measurement) {
43  if ((*measurement).recHit()->isValid()) {
44  ++NumValidMeas;
45  bestMeasurement = &(*measurement);
46  validMeasurements.push_back(&(*measurement));
47  }
48  }
49 
50  // If we have just one (or zero) valid meas, return it at once
51  // (or return null measurement)
52  if (NumValidMeas <= 1) {
53  LogTrace(metname) << "MuonBestMeasurement: just " << NumValidMeas << " valid measurement ";
54  return bestMeasurement;
55  }
56 
57  TMIterator measurement;
58  double minChi2PerNDoF = 1.E6;
59 
60  // if there are more than one valid measurement, then sort them.
61  for (measurement = validMeasurements.begin(); measurement != validMeasurements.end(); measurement++) {
62  TransientTrackingRecHit::ConstRecHitPointer muonRecHit = (*measurement)->recHit();
63 
64  // FIXME!! FIXME !! FIXME !!
65  pair<double, int> chi2Info = lookAtSubRecHits(*measurement, propagator);
66 
67  double chi2PerNDoF = chi2Info.first / chi2Info.second;
68  LogTrace(metname) << " The measurement has a chi2/npts " << chi2PerNDoF << " with dof = " << chi2Info.second
69  << " \n Till now the best chi2 is " << minChi2PerNDoF;
70 
71  if (chi2PerNDoF && chi2PerNDoF < minChi2PerNDoF) {
72  minChi2PerNDoF = chi2PerNDoF;
73  bestMeasurement = *measurement;
74  }
75  }
76  LogTrace(metname) << "The final best chi2 is " << minChi2PerNDoF << endl;
77  return bestMeasurement;
78 }
79 
81  const Propagator* propagator) {
82  const std::string metname = "Muon|RecoMuon|MuonBestMeasurementFinder";
83 
84  unsigned int npts = 0;
85  // unused double thisChi2 = 0.;
86 
87  const TransientTrackingRecHit::ConstRecHitPointer& muonRecHit = measurement->recHit();
88  const TrajectoryStateOnSurface& predState = measurement->predictedState(); // temporarily introduced by DT
89  std::pair<bool, double> sing_chi2 =
90  estimator()->estimate(predState, *(muonRecHit.get())); // temporarily introduced by DT
91  npts = 1; // temporarily introduced by DT
92  std::pair<double, int> result = pair<double, int>(sing_chi2.second, npts); // temporarily introduced by DT
93 
94  // // ask for the 2D-segments/2D-rechit // temporarily excluded by DT
95  // TransientTrackingRecHit::ConstRecHitContainer rhits_list = muonRecHit->transientHits();
96 
97  // LogTrace(metname)<<"Number of rechits in the measurement rechit: "<<rhits_list.size()<<endl;
98 
99  // // loop over them
100  // for (TransientTrackingRecHit::ConstRecHitContainer::const_iterator rhit = rhits_list.begin();
101  // rhit!= rhits_list.end(); ++rhit)
102  // if ((*rhit)->isValid() ) {
103  // LogTrace(metname)<<"Rechit dimension: "<<(*rhit)->dimension()<<endl;
104  // npts+=(*rhit)->dimension();
105 
106  // TrajectoryStateOnSurface predState;
107 
108  // if (!( (*rhit)->geographicalId() == muonRecHit->geographicalId() ) ){
109  // predState = propagator->propagate(*measurement->predictedState().freeState(),
110  // (*rhit)->det()->surface());
111  // }
112  // else predState = measurement->predictedState();
113 
114  // if ( predState.isValid() ) {
115  // std::pair<bool,double> sing_chi2 = estimator()->estimate( predState, *((*rhit).get()));
116  // thisChi2 += sing_chi2.second ;
117  // LogTrace(metname) << " single incremental chi2: " << sing_chi2.second;
118  // }
119  // }
120 
121  // pair<double,int> result = pair<double,int>(thisChi2,npts);
122  return result;
123 }
tuple propagator
virtual ~MuonBestMeasurementFinder()
Destructor.
TrajectoryStateOnSurface const & predictedState() const
ConstRecHitPointer const & recHit() const
const std::string metname
#define LogTrace(id)
tuple result
Definition: mps_fire.py:311
std::shared_ptr< TrackingRecHit const > ConstRecHitPointer
std::vector< TrajectoryMeasurement * > TMContainer
TrajectoryMeasurement * findBestMeasurement(std::vector< TrajectoryMeasurement > &measC, const Propagator *propagator)
return the Tm with the best chi2: no cut applied.
std::pair< double, int > lookAtSubRecHits(TrajectoryMeasurement *measurement, const Propagator *propagator)