CMS 3D CMS Logo

CosmicMuonUtilities.cc
Go to the documentation of this file.
1 
8 
13 
15 
16 using namespace edm;
17 using namespace std;
18 
19 //
20 // constructor
21 //
23 
24 //
25 // destructor
26 //
28 
30  GlobalTrajectoryParameters gtp(tsos.globalPosition(), -tsos.globalMomentum(), -tsos.charge(), mgfield);
31  TrajectoryStateOnSurface newTsos(gtp, tsos.cartesianError(), tsos.surface());
32  tsos = newTsos;
33 
34  return;
35 }
36 
37 //
38 //
39 //
41  stringstream output;
42 
43  for (ConstMuonRecHitContainer::const_iterator ir = hits.begin(); ir != hits.end(); ir++) {
44  if (!(*ir)->isValid()) {
45  output << "invalid RecHit" << endl;
46  continue;
47  }
48 
49  const GlobalPoint& pos = (*ir)->globalPosition();
50  output << "pos" << pos << "radius " << pos.perp() << " dim " << (*ir)->dimension() << " det "
51  << (*ir)->det()->geographicalId().det() << " sub det " << (*ir)->det()->subDetector() << endl;
52  }
53 
54  return output.str();
55 }
56 
57 //
58 //
59 //
61  stringstream output;
62 
63  for (MuonRecHitContainer::const_iterator ir = hits.begin(); ir != hits.end(); ir++) {
64  if (!(*ir)->isValid()) {
65  output << "invalid RecHit" << endl;
66  continue;
67  }
68 
69  const GlobalPoint& pos = (*ir)->globalPosition();
70  output << "pos" << pos << "radius " << pos.perp() << " dim " << (*ir)->dimension() << " det "
71  << (*ir)->det()->geographicalId().det() << " sub det " << (*ir)->det()->subDetector() << endl;
72  }
73 
74  return output.str();
75 }
76 
77 //
78 //
79 //
81  stringstream output;
82 
83  for (TransientTrackingRecHit::ConstRecHitContainer::const_iterator ir = hits.begin(); ir != hits.end(); ir++) {
84  if (!(*ir)->isValid()) {
85  output << "invalid RecHit" << endl;
86  continue;
87  }
88 
89  const GlobalPoint& pos = (*ir)->globalPosition();
90  output << "pos" << pos << "radius " << pos.perp() << " dim " << (*ir)->dimension() << " det "
91  << (*ir)->det()->geographicalId().det() << " sub det " << (*ir)->det()->subDetector() << endl;
92  }
93 
94  return output.str();
95 }
96 
97 //
98 //
99 //
102 
103  if (hits.empty())
104  return false;
105 
106  ConstRecHitContainer::const_iterator frontHit = hits.begin();
107  ConstRecHitContainer::const_iterator backHit = hits.end() - 1;
108 
109  // find first valid hit at both ends of the trajectory
110  while (!(*frontHit)->isValid() && frontHit != backHit) {
111  ++frontHit;
112  }
113  while (!(*backHit)->isValid() && backHit != frontHit) {
114  --backHit;
115  }
116 
117  if (frontHit == backHit)
118  return false;
119 
120  GlobalPoint frontPos = (*frontHit)->globalPosition();
121  GlobalPoint backPos = (*backHit)->globalPosition();
122 
123  // are there separate muon hits in 2 different hemispheres
124  GlobalVector deltaPos(frontPos - backPos);
125  if (deltaPos.mag() < 100.0)
126  return false;
127  if (fabs(deltaPos.z()) > 500.0)
128  return true;
129  if (deltaPos.perp() > 350.0)
130  return true;
131  GlobalPoint middle(
132  (frontPos.x() + backPos.x()) / 2, (frontPos.y() + backPos.y()) / 2, (frontPos.z() + backPos.z()) / 2);
133 
134  return ((middle.perp() < frontPos.perp()) && (middle.perp() < backPos.perp()));
135 }
136 
137 //
138 //
139 //
141  const ConstRecHitPointer& hit,
142  const Propagator& prop) const {
143  const std::string metname = "Muon|RecoMuon|CosmicMuonUtilities";
144 
146  GlobalPoint dest = hit->globalPosition();
147  GlobalVector StepVector = dest - start;
148  GlobalVector UnitStepVector = StepVector.unit();
149  GlobalPoint GP = start;
150  TrajectoryStateOnSurface currTsos(tsos);
151  TrajectoryStateOnSurface predTsos;
152  float totalDis = StepVector.mag();
153  LogTrace(metname) << "stepPropagate: propagate from: " << start << " to " << dest;
154  LogTrace(metname) << "stepPropagate: their distance: " << totalDis;
155 
156  int steps = 3; // need to optimize
157 
158  float oneStep = totalDis / steps;
159  Basic3DVector<float> Basic3DV(StepVector.x(), StepVector.y(), StepVector.z());
160  for (int istep = 0; istep < steps - 1; istep++) {
161  GP += oneStep * UnitStepVector;
162  Surface::PositionType pos(GP.x(), GP.y(), GP.z());
163  LogTrace(metname) << "stepPropagate: a middle plane: " << pos << endl;
164  Surface::RotationType rot(Basic3DV, float(0));
165  PlaneBuilder::ReturnType SteppingPlane = PlaneBuilder().plane(pos, rot);
166  TrajectoryStateOnSurface predTsos = prop.propagate(currTsos, *SteppingPlane);
167  if (predTsos.isValid()) {
168  currTsos = predTsos;
169  LogTrace(metname) << "stepPropagate: middle state " << currTsos.globalPosition() << endl;
170  }
171  }
172 
173  predTsos = prop.propagate(currTsos, hit->det()->surface());
174 
175  return predTsos;
176 }
Definition: start.py:1
void reverseDirection(TrajectoryStateOnSurface &, const MagneticField *) const
T perp() const
Definition: PV3DBase.h:69
T z() const
Definition: PV3DBase.h:61
const std::string metname
ReturnType plane(const PositionType &pos, const RotationType &rot) const
Definition: PlaneBuilder.h:21
const SurfaceType & surface() const
TrajectoryStateOnSurface propagate(STA const &state, SUR const &surface) const
Definition: Propagator.h:50
bool isTraversing(const Trajectory &) const
const CartesianTrajectoryError cartesianError() const
#define LogTrace(id)
TransientTrackingRecHit::ConstRecHitPointer ConstRecHitPointer
T x() const
Definition: PV3DBase.h:59
T y() const
Definition: PV3DBase.h:60
GlobalPoint globalPosition() const
TrajectoryStateOnSurface stepPropagate(const TrajectoryStateOnSurface &, const ConstRecHitPointer &, const Propagator &) const
T mag() const
Definition: PV3DBase.h:64
std::vector< ConstMuonRecHitPointer > ConstMuonRecHitContainer
std::vector< ConstRecHitPointer > ConstRecHitContainer
GlobalVector globalMomentum() const
std::string print(const ConstMuonRecHitContainer &) const
HLT enums.
Definition: output.py:1
Vector3DBase unit() const
Definition: Vector3DBase.h:54
std::vector< MuonRecHitPointer > MuonRecHitContainer