CMS 3D CMS Logo

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 }
Propagator.h
Chi2MeasurementEstimator.h
MessageLogger.h
MuonPatternRecoDumper.h
MuonBestMeasurementFinder::~MuonBestMeasurementFinder
virtual ~MuonBestMeasurementFinder()
Destructor.
Definition: MuonBestMeasurementFinder.cc:30
TrajectoryMeasurement.h
TransientTrackingRecHit.h
MuonTransientTrackingRecHit.h
MuonBestMeasurementFinder::TMIterator
TMContainer::iterator TMIterator
Definition: MuonBestMeasurementFinder.h:26
Propagator
Definition: Propagator.h:44
TrajectoryStateOnSurface
Definition: TrajectoryStateOnSurface.h:16
TrajectoryMeasurement::predictedState
TrajectoryStateOnSurface const & predictedState() const
Definition: TrajectoryMeasurement.h:174
PVValHelper::estimator
estimator
Definition: PVValidationHelpers.h:44
TrackCandidateProducer_cfi.propagator
propagator
Definition: TrackCandidateProducer_cfi.py:17
Chi2MeasurementEstimator_cfi.Chi2MeasurementEstimator
Chi2MeasurementEstimator
Definition: Chi2MeasurementEstimator_cfi.py:5
MuonBestMeasurementFinder.h
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
MuonBestMeasurementFinder::lookAtSubRecHits
std::pair< double, int > lookAtSubRecHits(TrajectoryMeasurement *measurement, const Propagator *propagator)
Definition: MuonBestMeasurementFinder.cc:80
TrackingRecHit::ConstRecHitPointer
std::shared_ptr< TrackingRecHit const > ConstRecHitPointer
Definition: TrackingRecHit.h:25
MuonBestMeasurementFinder::TMContainer
std::vector< TrajectoryMeasurement * > TMContainer
Definition: MuonBestMeasurementFinder.h:25
TrajectoryMeasurement::recHit
ConstRecHitPointer const & recHit() const
Definition: TrajectoryMeasurement.h:190
std
Definition: JetResolutionObject.h:76
MuonBestMeasurementFinder::MuonBestMeasurementFinder
MuonBestMeasurementFinder()
Constructor.
Definition: MuonBestMeasurementFinder.cc:28
mps_fire.result
result
Definition: mps_fire.py:311
LogTrace
#define LogTrace(id)
Definition: MessageLogger.h:224
MuonBestMeasurementFinder::findBestMeasurement
TrajectoryMeasurement * findBestMeasurement(std::vector< TrajectoryMeasurement > &measC, const Propagator *propagator)
return the Tm with the best chi2: no cut applied.
Definition: MuonBestMeasurementFinder.cc:32
TrajectoryMeasurement
Definition: TrajectoryMeasurement.h:25
metname
const std::string metname
Definition: MuonSeedOrcaPatternRecognition.cc:40