CMS 3D CMS Logo

MuonUpdatorAtVertex.cc
Go to the documentation of this file.
1 
11 
18 
20 
24 
25 using namespace std;
26 
29  : theService(service) {
30  thePropagatorName = pset.getParameter<string>("Propagator");
31 
32  // Errors on the Beam spot position
33  vector<double> errors = pset.getParameter<vector<double> >("BeamSpotPositionErrors");
34  if (errors.size() != 3)
35  edm::LogError("Muon|RecoMuon|MuonUpdatorAtVertex")
36  << "MuonUpdatorAtVertex::BeamSpotPositionErrors wrong number of parameters!!";
37 
38  // assume:
39  // errors[0] = sigma(x)
40  // errors[1] = sigma(y)
41  // errors[2] = sigma(z)
42 
44  mat(0, 0) = errors[0] * errors[0];
45  mat(1, 1) = errors[1] * errors[1];
46  mat(2, 2) = errors[2] * errors[2];
47  GlobalError glbErrPos(mat);
48 
49  thePositionErrors = glbErrPos;
50 
51  // cut on chi^2
52  theChi2Cut = pset.getParameter<double>("MaxChi2");
53 }
54 
57 
58 // Operations
59 
61 pair<bool, FreeTrajectoryState> MuonUpdatorAtVertex::propagate(const TrajectoryStateOnSurface &tsos,
62  const reco::BeamSpot &beamSpot) const {
63  const string metname = "Muon|RecoMuon|MuonUpdatorAtVertex";
64 
66  LogTrace(metname) << "Trajectory inside the Tracker";
67 
68  TSCBLBuilderNoMaterial tscblBuilder;
69  TrajectoryStateClosestToBeamLine tscbl = tscblBuilder(*(tsos.freeState()), beamSpot);
70 
71  if (tscbl.isValid())
72  return pair<bool, FreeTrajectoryState>(true, tscbl.trackStateAtPCA());
73  else
74  edm::LogWarning(metname) << "Propagation to the PCA using TSCPBuilderNoMaterial failed!"
75  << " This can cause a severe bug.";
76  } else {
77  LogTrace(metname) << "Trajectory inside the muon system";
78 
79  FreeTrajectoryState result = theService->propagator(thePropagatorName)->propagate(*tsos.freeState(), beamSpot);
80 
81  LogTrace(metname) << "MuonUpdatorAtVertex::propagate, path: " << result << " parameters: " << result.parameters();
82 
83  if (result.hasError())
84  return pair<bool, FreeTrajectoryState>(true, result);
85  else
86  edm::LogInfo(metname) << "Propagation to the PCA failed!";
87  }
88  return pair<bool, FreeTrajectoryState>(false, FreeTrajectoryState());
89 }
90 
91 pair<bool, FreeTrajectoryState> MuonUpdatorAtVertex::update(const reco::TransientTrack &track,
92  const reco::BeamSpot &beamSpot) const {
93  const std::string metname = "Muon|RecoMuon|MuonUpdatorAtVertex";
94 
95  pair<bool, FreeTrajectoryState> result(false, FreeTrajectoryState());
96 
97  GlobalPoint spotPos(beamSpot.x0(), beamSpot.y0(), beamSpot.z0());
98 
99  SingleTrackVertexConstraint::BTFtuple constrainedTransientTrack;
100 
101  // Temporary hack here. A fix in the SingleTrackVertexConstraint code
102  // is needed. Once available try&catch will be removed
103  try {
104  constrainedTransientTrack = theConstrictor.constrain(track, spotPos, thePositionErrors);
105  } catch (cms::Exception &e) {
106  edm::LogWarning(metname) << "cms::Exception caught in MuonUpdatorAtVertex::update\n"
107  << "Exception from SingleTrackVertexConstraint\n"
108  << e.explainSelf();
109  return result;
110  }
111 
112  if (constrainedTransientTrack.get<0>())
113  if (constrainedTransientTrack.get<2>() <= theChi2Cut) {
114  result.first = true;
115  result.second = *constrainedTransientTrack.get<1>().impactPointState().freeState();
116  } else
117  LogTrace(metname) << "Constraint at vertex failed: too large chi2";
118  else
119  LogTrace(metname) << "Constraint at vertex failed";
120 
121  return result;
122 }
123 
124 pair<bool, FreeTrajectoryState> MuonUpdatorAtVertex::update(const FreeTrajectoryState &ftsAtVtx,
125  const reco::BeamSpot &beamSpot) const {
126  return update(theTransientTrackFactory.build(ftsAtVtx), beamSpot);
127 }
128 
129 pair<bool, FreeTrajectoryState> MuonUpdatorAtVertex::propagateWithUpdate(const TrajectoryStateOnSurface &tsos,
130  const reco::BeamSpot &beamSpot) const {
131  pair<bool, FreeTrajectoryState> propagationResult = propagate(tsos, beamSpot);
132 
133  if (propagationResult.first) {
134  return update(propagationResult.second, beamSpot);
135  } else {
136  edm::LogInfo("Muon|RecoMuon|MuonUpdatorAtVertex") << "Constraint at vertex failed";
137  return pair<bool, FreeTrajectoryState>(false, FreeTrajectoryState());
138  }
139 }
140 
141 std::pair<bool, FreeTrajectoryState> MuonUpdatorAtVertex::propagateToNominalLine(
142  const TrajectoryStateOnSurface &tsos) const {
143  const string metname = "Muon|RecoMuon|MuonUpdatorAtVertex";
144 
146  LogTrace(metname) << "Trajectory inside the Tracker";
147 
148  TSCPBuilderNoMaterial tscpBuilder;
149  TrajectoryStateClosestToPoint tscp = tscpBuilder(*(tsos.freeState()), GlobalPoint(0., 0., 0.));
150 
151  if (tscp.isValid())
152  return pair<bool, FreeTrajectoryState>(true, tscp.theState());
153  else
154  edm::LogWarning(metname) << "Propagation to the PCA using TSCPBuilderNoMaterial failed!"
155  << " This can cause a severe bug.";
156  } else {
157  LogTrace(metname) << "Trajectory inside the muon system";
158 
159  // Define a line using two 3D-points
160  GlobalPoint p1(0., 0., -1500);
161  GlobalPoint p2(0., 0., 1500);
162 
163  pair<FreeTrajectoryState, double> result =
164  theService->propagator(thePropagatorName)->propagateWithPath(*tsos.freeState(), p1, p2);
165 
166  LogTrace(metname) << "MuonUpdatorAtVertex::propagate, path: " << result.second
167  << " parameters: " << result.first.parameters();
168 
169  if (result.first.hasError())
170  return pair<bool, FreeTrajectoryState>(true, result.first);
171  else
172  edm::LogInfo(metname) << "Propagation to the PCA failed! Path: " << result.second;
173  }
174  return pair<bool, FreeTrajectoryState>(false, FreeTrajectoryState());
175 }
176 
177 std::pair<bool, FreeTrajectoryState> MuonUpdatorAtVertex::propagate(const TrajectoryStateOnSurface &tsos) const {
178  return propagateToNominalLine(tsos);
179 }
MuonUpdatorAtVertex.h
MuonUpdatorAtVertex::MuonUpdatorAtVertex
MuonUpdatorAtVertex(const edm::ParameterSet &pset, const MuonServiceProxy *service)
Constructor.
Definition: MuonUpdatorAtVertex.cc:28
TSCBLBuilderNoMaterial.h
MuonUpdatorAtVertex::theChi2Cut
double theChi2Cut
Definition: MuonUpdatorAtVertex.h:81
TrajectoryStateClosestToBeamLine
Definition: TrajectoryStateClosestToBeamLine.h:15
TrajectoryStateOnSurface.h
service
Definition: service.py:1
AlgebraicSymMatrix33
ROOT::Math::SMatrix< double, 3, 3, ROOT::Math::MatRepSym< double, 3 > > AlgebraicSymMatrix33
Definition: AlgebraicROOTObjects.h:21
MuonUpdatorAtVertex::~MuonUpdatorAtVertex
virtual ~MuonUpdatorAtVertex()
Destructor.
Definition: MuonUpdatorAtVertex.cc:56
FreeTrajectoryState.h
pwdgSkimBPark_cfi.beamSpot
beamSpot
Definition: pwdgSkimBPark_cfi.py:5
MessageLogger.h
TrajectoryStateOnSurface::globalPosition
GlobalPoint globalPosition() const
Definition: TrajectoryStateOnSurface.h:65
edm::LogInfo
Definition: MessageLogger.h:254
MuonUpdatorAtVertex::theConstrictor
SingleTrackVertexConstraint theConstrictor
Definition: MuonUpdatorAtVertex.h:80
MuonUpdatorAtVertex::propagateToNominalLine
std::pair< bool, FreeTrajectoryState > propagateToNominalLine(const TrajectoryStateOnSurface &tsos) const
Propagate the state to the 2D-PCA (nominal CMS axis)
Definition: MuonUpdatorAtVertex.cc:141
SingleTrackVertexConstraint::BTFtuple
boost::tuple< bool, reco::TransientTrack, float > BTFtuple
Definition: SingleTrackVertexConstraint.h:22
MuonServiceProxy_cff.MuonServiceProxy
MuonServiceProxy
Definition: MuonServiceProxy_cff.py:15
TrackerBounds::isInside
static bool isInside(const GlobalPoint &)
Definition: TrackerBounds.cc:37
TrajectoryStateOnSurface
Definition: TrajectoryStateOnSurface.h:16
TransientTrackFromFTSFactory.h
TrajectoryStateOnSurface::freeState
FreeTrajectoryState const * freeState(bool withErrors=true) const
Definition: TrajectoryStateOnSurface.h:58
TrackerBounds.h
BeamSpot.h
errors
Definition: errors.py:1
SingleTrackVertexConstraint::constrain
BTFtuple constrain(const reco::TransientTrack &track, const GlobalPoint &priorPos, const GlobalError &priorError) const
Definition: SingleTrackVertexConstraint.cc:21
reco::BeamSpot
Definition: BeamSpot.h:21
p2
double p2[4]
Definition: TauolaWrapper.h:90
MuonSegmentMatcher::theService
const MuonServiceProxy * theService
Definition: MuonSegmentMatcher.h:46
MuonUpdatorAtVertex::theService
const MuonServiceProxy * theService
Definition: MuonUpdatorAtVertex.h:76
GlobalPoint
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
Point3DBase< float, GlobalTag >
MuonUpdatorAtVertex::propagateWithUpdate
std::pair< bool, FreeTrajectoryState > propagateWithUpdate(const TrajectoryStateOnSurface &tsos, const reco::BeamSpot &beamSpot) const
Propagate to the 2D-PCA and apply the vertex constraint.
Definition: MuonUpdatorAtVertex.cc:129
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::LogWarning
Definition: MessageLogger.h:141
MuonUpdatorAtVertex::thePositionErrors
GlobalError thePositionErrors
Definition: MuonUpdatorAtVertex.h:83
edm::ParameterSet
Definition: ParameterSet.h:36
edm::LogError
Definition: MessageLogger.h:183
MuonUpdatorAtVertex::thePropagatorName
std::string thePropagatorName
Definition: MuonUpdatorAtVertex.h:77
TransientTrackFromFTSFactory::build
reco::TransientTrack build(const FreeTrajectoryState &fts) const
Definition: TransientTrackFromFTSFactory.cc:7
p1
double p1[4]
Definition: TauolaWrapper.h:89
GlobalErrorBase< double, ErrorMatrixTag >
TrajectoryStateClosestToPoint
Definition: TrajectoryStateClosestToPoint.h:18
TSCPBuilderNoMaterial.h
MuonUpdatorAtVertex::propagate
std::pair< bool, FreeTrajectoryState > propagate(const TrajectoryStateOnSurface &tsos, const reco::BeamSpot &beamSpot) const
Propagate the state to the 2D-PCA.
Definition: MuonUpdatorAtVertex.cc:61
std
Definition: JetResolutionObject.h:76
TSCPBuilderNoMaterial
Definition: TSCPBuilderNoMaterial.h:17
reco::TransientTrack
Definition: TransientTrack.h:19
FreeTrajectoryState
Definition: FreeTrajectoryState.h:27
TSCBLBuilderNoMaterial
Definition: TSCBLBuilderNoMaterial.h:13
MuonServiceProxy.h
Exception.h
TrajectoryStateClosestToPoint::isValid
bool isValid() const
Definition: TrajectoryStateClosestToPoint.h:111
MuonUpdatorAtVertex::update
std::pair< bool, FreeTrajectoryState > update(const reco::TransientTrack &track, const reco::BeamSpot &beamSpot) const
Applies the vertex constraint.
Definition: MuonUpdatorAtVertex.cc:91
HLT_2018_cff.track
track
Definition: HLT_2018_cff.py:10352
mps_fire.result
result
Definition: mps_fire.py:303
cms::Exception
Definition: Exception.h:70
LogTrace
#define LogTrace(id)
Definition: MessageLogger.h:671
TrajectoryStateClosestToBeamLine::isValid
bool isValid() const
Definition: TrajectoryStateClosestToBeamLine.h:50
ParameterSet.h
TrajectoryStateClosestToBeamLine::trackStateAtPCA
FTS const & trackStateAtPCA() const
Definition: TrajectoryStateClosestToBeamLine.h:32
TrajectoryStateClosestToPoint::theState
const FreeTrajectoryState & theState() const
Definition: TrajectoryStateClosestToPoint.h:96
MuonUpdatorAtVertex::theTransientTrackFactory
TransientTrackFromFTSFactory theTransientTrackFactory
Definition: MuonUpdatorAtVertex.h:79
muonDTDigis_cfi.pset
pset
Definition: muonDTDigis_cfi.py:27
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37
metname
const std::string metname
Definition: MuonSeedOrcaPatternRecognition.cc:43