CMS 3D CMS Logo

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