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