CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Private Attributes
StandAloneMuonRefitter Class Reference

#include <StandAloneMuonRefitter.h>

Public Types

typedef std::pair< bool, TrajectoryRefitResult
 

Public Member Functions

RefitResult refit (const Trajectory &)
 
RefitResult singleRefit (const Trajectory &)
 Refit. More...
 
 StandAloneMuonRefitter (const edm::ParameterSet &par, edm::ConsumesCollector col, const MuonServiceProxy *service)
 Constructor. More...
 
virtual ~StandAloneMuonRefitter ()
 Destructor. More...
 

Private Attributes

double errorRescale
 
bool isForceAllIterations
 
edm::ESHandle< TrajectoryFittertheFitter
 
const edm::ESGetToken< TrajectoryFitter, TrajectoryFitter::RecordtheFitterToken
 
double theMaxFractionOfLostHits
 
unsigned int theNumberOfIterations
 
const MuonServiceProxytheService
 

Detailed Description

Class ti interface the muon system rechits with the standard KF tools.

Authors
R. Bellan - INFN Torino ricca.nosp@m.rdo..nosp@m.bella.nosp@m.n@ce.nosp@m.rn.ch D. Trocino - INFN Torino danie.nosp@m.le.t.nosp@m.rocin.nosp@m.o@to.nosp@m..infn.nosp@m..it

Class ti interface the muon system rechits with the standard KF tools.

Authors
R. Bellan - INFN Torino ricca.nosp@m.rdo..nosp@m.bella.nosp@m.n@ce.nosp@m.rn.ch, D. Trocino - INFN Torino danie.nosp@m.le.t.nosp@m.rocin.nosp@m.o@to.nosp@m..infn.nosp@m..it

Definition at line 24 of file StandAloneMuonRefitter.h.

Member Typedef Documentation

◆ RefitResult

Definition at line 26 of file StandAloneMuonRefitter.h.

Constructor & Destructor Documentation

◆ StandAloneMuonRefitter()

StandAloneMuonRefitter::StandAloneMuonRefitter ( const edm::ParameterSet par,
edm::ConsumesCollector  col,
const MuonServiceProxy service 
)

Constructor.

Definition at line 21 of file StandAloneMuonRefitter.cc.

References errorRescale, edm::ParameterSet::getParameter(), isForceAllIterations, LogDebug, theMaxFractionOfLostHits, and theNumberOfIterations.

24  : theService(service), theFitterToken(col.esConsumes(edm::ESInputTag("", par.getParameter<string>("FitterName")))) {
25  LogDebug("Muon|RecoMuon|StandAloneMuonRefitter") << "Constructor called." << endl;
26 
27  theNumberOfIterations = par.getParameter<unsigned int>("NumberOfIterations");
28  isForceAllIterations = par.getParameter<bool>("ForceAllIterations");
29  theMaxFractionOfLostHits = par.getParameter<double>("MaxFractionOfLostHits");
30  errorRescale = par.getParameter<double>("RescaleError");
31 }
const MuonServiceProxy * theService
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
const edm::ESGetToken< TrajectoryFitter, TrajectoryFitter::Record > theFitterToken
col
Definition: cuy.py:1009
#define LogDebug(id)

◆ ~StandAloneMuonRefitter()

StandAloneMuonRefitter::~StandAloneMuonRefitter ( )
virtual

Destructor.

Definition at line 34 of file StandAloneMuonRefitter.cc.

References LogDebug.

34  {
35  LogDebug("Muon|RecoMuon|StandAloneMuonRefitter") << "Destructor called." << endl;
36 }
#define LogDebug(id)

Member Function Documentation

◆ refit()

StandAloneMuonRefitter::RefitResult StandAloneMuonRefitter::refit ( const Trajectory trajectory)

Definition at line 63 of file StandAloneMuonRefitter.cc.

References isForceAllIterations, dqmiolumiharvest::j, LogDebug, Trajectory::recHits(), singleRefit(), theMaxFractionOfLostHits, and theNumberOfIterations.

Referenced by StandAloneMuonTrajectoryBuilder::trajectories().

63  {
64  LogDebug("Muon|RecoMuon|StandAloneMuonRefitter") << "---------------------------------" << endl;
65  LogDebug("Muon|RecoMuon|StandAloneMuonRefitter") << "Starting refitting loop:" << endl;
66 
67  unsigned int nSuccess = 0;
68  unsigned int nOrigHits = trajectory.recHits().size();
69  Trajectory lastFitted = trajectory;
70  bool allIter = true;
71  bool enoughRH = true;
72 
73  for (unsigned int j = 0; j < theNumberOfIterations; ++j) {
74  StandAloneMuonRefitter::RefitResult singleRefitResult = singleRefit(lastFitted);
75  lastFitted = singleRefitResult.second;
76  unsigned int nLastHits = lastFitted.recHits().size();
77 
78  if (!singleRefitResult.first) {
79  allIter = false;
80  LogDebug("Muon|RecoMuon|StandAloneMuonRefitter") << " refit n. " << nSuccess + 1 << ": failed" << endl;
81  break;
82  }
83 
84  double lostFract = 1 - double(nLastHits) / nOrigHits;
85  if (lostFract > theMaxFractionOfLostHits) {
86  enoughRH = false;
87  LogDebug("Muon|RecoMuon|StandAloneMuonRefitter") << " refit n. " << nSuccess + 1 << ": too many RH lost" << endl;
88  LogDebug("Muon|RecoMuon|StandAloneMuonRefitter")
89  << " Survived RecHits: " << nLastHits << "/" << nOrigHits << endl;
90  break;
91  }
92 
93  nSuccess++;
94  LogDebug("Muon|RecoMuon|StandAloneMuonRefitter") << " refit n. " << nSuccess << ": OK" << endl;
95  LogDebug("Muon|RecoMuon|StandAloneMuonRefitter")
96  << " Survived RecHits: " << nLastHits << "/" << nOrigHits << endl;
97 
98  } // end for
99 
100  LogDebug("Muon|RecoMuon|StandAloneMuonRefitter") << nSuccess << " successful refits!" << endl;
101 
102  // if isForceAllIterations==true => 3 successful refits: (true, refitted trajectory)
103  // <3 successful refits: (false, original trajectory)
104  // if isForceAllIterations==false => >0 successful refits: (true, last refitted trajectory)
105  // 0 successful refits: (false, original trajectory)
106  if (!enoughRH)
107  return RefitResult(false, trajectory);
108  else if (isForceAllIterations)
109  return allIter ? RefitResult(allIter, lastFitted) : RefitResult(allIter, trajectory);
110  else
111  return nSuccess == 0 ? RefitResult(false, trajectory) : RefitResult(true, lastFitted);
112 }
std::pair< bool, Trajectory > RefitResult
ConstRecHitContainer recHits() const
Definition: Trajectory.h:186
RefitResult singleRefit(const Trajectory &)
Refit.
#define LogDebug(id)

◆ singleRefit()

StandAloneMuonRefitter::RefitResult StandAloneMuonRefitter::singleRefit ( const Trajectory trajectory)

Refit.

Definition at line 41 of file StandAloneMuonRefitter.cc.

References errorRescale, TrajectoryFitter::fit(), Trajectory::lastMeasurement(), Trajectory::recHits(), TrajectoryStateOnSurface::rescaleError(), groupFilesInBlocks::reverse, Trajectory::seed(), theFitter, theFitterToken, theService, and TrajectoryMeasurement::updatedState().

Referenced by refit().

41  {
42  theFitter = theService->eventSetup().getHandle(theFitterToken);
43 
44  vector<Trajectory> refitted;
45 
46  const TrajectoryMeasurement& lastTM = trajectory.lastMeasurement();
47 
48  TrajectoryStateOnSurface firstTsos(lastTM.updatedState());
49 
50  // Rescale errors before refit, not to bias the result
51  firstTsos.rescaleError(errorRescale);
52 
54  reverse(trajRH.begin(), trajRH.end());
55  refitted = theFitter->fit(trajectory.seed(), trajRH, firstTsos);
56 
57  if (!refitted.empty())
58  return RefitResult(true, refitted.front());
59  else
60  return RefitResult(false, trajectory);
61 }
const MuonServiceProxy * theService
TrajectoryMeasurement const & lastMeasurement() const
Definition: Trajectory.h:150
edm::ESHandle< TrajectoryFitter > theFitter
std::pair< bool, Trajectory > RefitResult
ConstRecHitContainer recHits() const
Definition: Trajectory.h:186
const edm::ESGetToken< TrajectoryFitter, TrajectoryFitter::Record > theFitterToken
std::vector< ConstRecHitPointer > ConstRecHitContainer
TrajectorySeed const & seed() const
Access to the seed used to reconstruct the Trajectory.
Definition: Trajectory.h:263
TrajectoryStateOnSurface const & updatedState() const
std::vector< Trajectory > fit(const Trajectory &traj, fitType type=standard) const

Member Data Documentation

◆ errorRescale

double StandAloneMuonRefitter::errorRescale
private

Definition at line 49 of file StandAloneMuonRefitter.h.

Referenced by singleRefit(), and StandAloneMuonRefitter().

◆ isForceAllIterations

bool StandAloneMuonRefitter::isForceAllIterations
private

Definition at line 47 of file StandAloneMuonRefitter.h.

Referenced by refit(), and StandAloneMuonRefitter().

◆ theFitter

edm::ESHandle<TrajectoryFitter> StandAloneMuonRefitter::theFitter
private

Definition at line 45 of file StandAloneMuonRefitter.h.

Referenced by singleRefit().

◆ theFitterToken

const edm::ESGetToken<TrajectoryFitter, TrajectoryFitter::Record> StandAloneMuonRefitter::theFitterToken
private

Definition at line 44 of file StandAloneMuonRefitter.h.

Referenced by singleRefit().

◆ theMaxFractionOfLostHits

double StandAloneMuonRefitter::theMaxFractionOfLostHits
private

Definition at line 48 of file StandAloneMuonRefitter.h.

Referenced by refit(), and StandAloneMuonRefitter().

◆ theNumberOfIterations

unsigned int StandAloneMuonRefitter::theNumberOfIterations
private

Definition at line 46 of file StandAloneMuonRefitter.h.

Referenced by refit(), and StandAloneMuonRefitter().

◆ theService

const MuonServiceProxy* StandAloneMuonRefitter::theService
private

Definition at line 43 of file StandAloneMuonRefitter.h.

Referenced by singleRefit().