CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 
26 //
27 // destructor
28 //
30 }
31 
32 
34 
36  -tsos.globalMomentum(),
37  -tsos.charge(),
38  mgfield);
39  TrajectoryStateOnSurface newTsos(gtp, tsos.cartesianError(), tsos.surface());
40  tsos = newTsos;
41 
42  return;
43 
44 }
45 
46 
47 //
48 //
49 //
51 
52  stringstream output;
53 
54  for (ConstMuonRecHitContainer::const_iterator ir = hits.begin(); ir != hits.end(); ir++ ) {
55  if ( !(*ir)->isValid() ) {
56  output << "invalid RecHit"<<endl;
57  continue;
58  }
59 
60  const GlobalPoint& pos = (*ir)->globalPosition();
61  output
62  << "pos"<<pos
63  << "radius "<<pos.perp()
64  << " dim " << (*ir)->dimension()
65  << " det " << (*ir)->det()->geographicalId().det()
66  << " sub det " << (*ir)->det()->subDetector()<<endl;
67  }
68 
69  return output.str();
70 
71 }
72 
73 
74 //
75 //
76 //
78 
79  stringstream output;
80 
81  for (MuonRecHitContainer::const_iterator ir = hits.begin(); ir != hits.end(); ir++ ) {
82  if ( !(*ir)->isValid() ) {
83  output << "invalid RecHit"<<endl;
84  continue;
85  }
86 
87  const GlobalPoint& pos = (*ir)->globalPosition();
88  output
89  << "pos"<<pos
90  << "radius "<<pos.perp()
91  << " dim " << (*ir)->dimension()
92  << " det " << (*ir)->det()->geographicalId().det()
93  << " sub det " << (*ir)->det()->subDetector()<<endl;
94  }
95 
96  return output.str();
97 
98 }
99 
100 
101 //
102 //
103 //
105 
106  stringstream output;
107 
108  for (TransientTrackingRecHit::ConstRecHitContainer::const_iterator ir = hits.begin(); ir != hits.end(); ir++ ) {
109  if ( !(*ir)->isValid() ) {
110  output << "invalid RecHit"<<endl;
111  continue;
112  }
113 
114  const GlobalPoint& pos = (*ir)->globalPosition();
115  output
116  << "pos"<<pos
117  << "radius "<<pos.perp()
118  << " dim " << (*ir)->dimension()
119  << " det " << (*ir)->det()->geographicalId().det()
120  << " sub det " << (*ir)->det()->subDetector()<<endl;
121  }
122 
123  return output.str();
124 
125 }
126 
127 
128 //
129 //
130 //
132 
134 
135  if ( hits.empty() ) return false;
136 
137  ConstRecHitContainer::const_iterator frontHit = hits.begin();
138  ConstRecHitContainer::const_iterator backHit = hits.end() - 1;
139 
140  // find first valid hit at both ends of the trajectory
141  while ( !(*frontHit)->isValid() && frontHit != backHit) {++frontHit;}
142  while ( !(*backHit)->isValid() && backHit != frontHit) {--backHit;}
143 
144  if ( frontHit == backHit ) return false;
145 
146  GlobalPoint frontPos = (*frontHit)->globalPosition();
147  GlobalPoint backPos = (*backHit)->globalPosition();
148 
149  // are there separate muon hits in 2 different hemispheres
150  GlobalVector deltaPos(frontPos - backPos);
151  if ( deltaPos.mag() < 100.0 ) return false;
152  if ( fabs(deltaPos.z() ) > 500.0 ) return true;
153  if ( deltaPos.perp() > 350.0 ) return true;
154  GlobalPoint middle((frontPos.x()+backPos.x())/2,
155  (frontPos.y()+backPos.y())/2,
156  (frontPos.z()+backPos.z())/2);
157 
158  return ( (middle.perp() < frontPos.perp()) && (middle.perp() < backPos.perp()) );
159 
160 }
161 
162 
163 //
164 //
165 //
167  const ConstRecHitPointer& hit,
168  const Propagator& prop ) const {
169 
170  const std::string metname = "Muon|RecoMuon|CosmicMuonUtilities";
171 
173  GlobalPoint dest = hit->globalPosition();
174  GlobalVector StepVector = dest - start;
175  GlobalVector UnitStepVector = StepVector.unit();
176  GlobalPoint GP =start;
177  TrajectoryStateOnSurface currTsos(tsos);
178  TrajectoryStateOnSurface predTsos;
179  float totalDis = StepVector.mag();
180  LogTrace(metname)<<"stepPropagate: propagate from: "<<start<<" to "<<dest;
181  LogTrace(metname)<<"stepPropagate: their distance: "<<totalDis;
182 
183  int steps = 3; // need to optimize
184 
185  float oneStep = totalDis/steps;
186  Basic3DVector<float> Basic3DV(StepVector.x(),StepVector.y(),StepVector.z());
187  for ( int istep = 0 ; istep < steps - 1 ; istep++) {
188  GP += oneStep*UnitStepVector;
189  Surface::PositionType pos(GP.x(),GP.y(),GP.z());
190  LogTrace(metname)<<"stepPropagate: a middle plane: "<<pos<<endl;
191  Surface::RotationType rot( Basic3DV , float(0));
192  PlaneBuilder::ReturnType SteppingPlane = PlaneBuilder().plane(pos,rot);
193  TrajectoryStateOnSurface predTsos = prop.propagate(currTsos, *SteppingPlane);
194  if (predTsos.isValid()) {
195  currTsos=predTsos;
196  LogTrace(metname)<<"stepPropagate: middle state "<< currTsos.globalPosition()<<endl;
197  }
198  }
199 
200  predTsos = prop.propagate(currTsos, hit->det()->surface());
201 
202  return predTsos;
203 
204 }
virtual FreeTrajectoryState propagate(const FreeTrajectoryState &ftsStart, const GlobalPoint &pDest) const final
Definition: Propagator.h:119
tuple start
Check for commandline option errors.
Definition: dqm_diff.py:58
T perp() const
Definition: PV3DBase.h:72
const std::string metname
ReturnType plane(const PositionType &pos, const RotationType &rot) const
Definition: PlaneBuilder.h:22
const CartesianTrajectoryError cartesianError() const
T y() const
Definition: PV3DBase.h:63
GlobalPoint globalPosition() const
TransientTrackingRecHit::ConstRecHitPointer ConstRecHitPointer
const SurfaceType & surface() const
T mag() const
Definition: PV3DBase.h:67
std::string print(const ConstMuonRecHitContainer &) const
T z() const
Definition: PV3DBase.h:64
TrajectoryStateOnSurface stepPropagate(const TrajectoryStateOnSurface &, const ConstRecHitPointer &, const Propagator &) const
bool isTraversing(const Trajectory &) const
#define LogTrace(id)
std::vector< ConstMuonRecHitPointer > ConstMuonRecHitContainer
std::vector< ConstRecHitPointer > ConstRecHitContainer
Vector3DBase unit() const
Definition: Vector3DBase.h:57
GlobalVector globalMomentum() const
void reverseDirection(TrajectoryStateOnSurface &, const MagneticField *) const
T x() const
Definition: PV3DBase.h:62
std::vector< MuonRecHitPointer > MuonRecHitContainer