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