CMS 3D CMS Logo

CachedTrajectory.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: TrackAssociator
4 // Class: CachedTrajectory
5 //
6 //
7 //
8 
10 // #include "Utilities/Timing/interface/TimerStack.h"
15 #include <deque>
16 #include <algorithm>
17 
18 std::vector<SteppingHelixStateInfo>
20  const FiducialVolume& volume,int nsteps,
21  float step, float minR, float minZ, float maxR, float maxZ) {
22  CachedTrajectory neckLace;
23  neckLace.setStateAtIP(state);
24  neckLace.reset_trajectory();
25  neckLace.setPropagator(prop);
26  neckLace.setPropagationStep(0.1);
27  neckLace.setMinDetectorRadius(minR);
28  neckLace.setMinDetectorLength(minZ*2.);
29  neckLace.setMaxDetectorRadius(maxR);
30  neckLace.setMaxDetectorLength(maxZ*2.);
31 
32  // Propagate track
33  bool isPropagationSuccessful = neckLace.propagateAll(state);
34 
35  if (!isPropagationSuccessful)
36  return std::vector<SteppingHelixStateInfo> () ;
37 
38  std::vector<SteppingHelixStateInfo> complicatePoints;
39  neckLace.getTrajectory(complicatePoints, volume, nsteps);
40 
41  return complicatePoints;
42 
43 }
44 
45 
46 
54 }
55 
57 {
58  // defined a normal plane wrt the particle trajectory direction
59  // let's hope that I computed the rotation matrix correctly.
60  GlobalVector vector(state.momentum().unit());
61  float r21 = 0;
62  float r22 = vector.z()/sqrt(1-pow(vector.x(),2));
63  float r23 = -vector.y()/sqrt(1-pow(vector.x(),2));
64  float r31 = vector.x();
65  float r32 = vector.y();
66  float r33 = vector.z();
67  float r11 = r22*r33-r23*r32;
68  float r12 = r23*r31;
69  float r13 = -r22*r31;
70 
71  Surface::RotationType rotation(r11, r12, r13,
72  r21, r22, r23,
73  r31, r32, r33);
75  propagate(state, *target);
76 }
77 
79 {
80  if( const SteppingHelixPropagator* shp = dynamic_cast<const SteppingHelixPropagator*>(propagator_) )
81  {
82  try {
83  shp->propagate(state, plane, state);
84  }
85  catch(cms::Exception &ex){
86  edm::LogWarning("TrackAssociator") <<
87  "Caught exception " << ex.category() << ": " << ex.explainSelf();
88  edm::LogWarning("TrackAssociator") << "An exception is caught during the track propagation\n"
89  << state.momentum().x() << ", " << state.momentum().y() << ", " << state.momentum().z();
90  state = SteppingHelixStateInfo();
91  }
92  }
93  else
94  {
96  state.getFreeState( fts );
97  TrajectoryStateOnSurface stateOnSurface = propagator_->propagate(fts, plane);
98  state = SteppingHelixStateInfo( *(stateOnSurface.freeState()) );
99  }
100 }
101 
103 {
104  if( const SteppingHelixPropagator* shp = dynamic_cast<const SteppingHelixPropagator*>(propagator_) )
105  {
106  try {
107  shp->propagate(state, cylinder,state);
108  }
109  catch(cms::Exception &ex){
110  edm::LogWarning("TrackAssociator") <<
111  "Caught exception " << ex.category() << ": " << ex.explainSelf();
112  edm::LogWarning("TrackAssociator") << "An exception is caught during the track propagation\n"
113  << state.momentum().x() << ", " << state.momentum().y() << ", " << state.momentum().z();
114  state = SteppingHelixStateInfo();
115  }
116  }
117  else
118  {
120  state.getFreeState( fts );
121  TrajectoryStateOnSurface stateOnSurface = propagator_->propagate(fts, cylinder);
122  state = SteppingHelixStateInfo( *(stateOnSurface.freeState()) );
123  }
124 }
125 
127 {
128  if ( fullTrajectoryFilled_ ) {
129  edm::LogWarning("TrackAssociator") << "Reseting all trajectories. Please call reset_trajectory() explicitely to avoid this message";
131  }
132 
133 // TimerStack timers(TimerStack::Disableable);
134 
136  if (propagator_==nullptr) throw cms::Exception("FatalError") << "Track propagator is not defined\n";
137  SteppingHelixStateInfo currentState(initialState);
138  fullTrajectory_.push_back(currentState);
139 
140  while (currentState.position().perp()<maxRho_ && fabs(currentState.position().z())<maxZ_ ){
141  LogTrace("TrackAssociator") << "[propagateAll] Propagate outward from (rho, r, z, phi) (" <<
142  currentState.position().perp() << ", " << currentState.position().mag() << ", " <<
143  currentState.position().z() << ", " << currentState.position().phi() << ")";
144  propagateForward(currentState,step_);
145  if (! currentState.isValid() ) {
146  LogTrace("TrackAssociator") << "Failed to propagate the track; moving on\n";
147  break;
148  }
149  LogTrace("TrackAssociator") << "\treached (rho, r, z, phi) (" <<
150  currentState.position().perp() << ", " << currentState.position().mag() << ", " <<
151  currentState.position().z() << ", " << currentState.position().phi() << ")";
152  fullTrajectory_.push_back(currentState);
153  }
154 
155 
156  SteppingHelixStateInfo currentState2(initialState);
157  SteppingHelixStateInfo previousState;
158  while (currentState2.position().perp()>minRho_ || fabs(currentState2.position().z())>minZ_) {
159  previousState=currentState2;
160  propagateForward(currentState2,-step_);
161  if (! currentState2.isValid() ) {
162  LogTrace("TrackAssociator") << "Failed to propagate the track; moving on\n";
163  break;
164  }
165  if(previousState.position().perp()- currentState2.position().perp() < 0) {
166  LogTrace("TrackAssociator") << "Error: TrackAssociator has propogated the particle past the point of closest approach to IP" << std::endl;
167  break;
168  }
169  LogTrace("TrackAssociator") << "[propagateAll] Propagated inward from (rho, r, z, phi) (" <<
170  previousState.position().perp() << ", " << previousState.position().mag() << ", " <<
171  previousState.position().z() << "," << previousState.position().phi() << ") to (" <<
172  currentState2.position().perp() << ", " << currentState2.position().mag() << ", " <<
173  currentState2.position().z() << ", " << currentState2.position().phi() << ")";
174  fullTrajectory_.push_front(currentState2);
175  }
176 
177 
178 
179 
180  // LogTrace("TrackAssociator") << "fullTrajectory_ has " << fullTrajectory_.size() << " states with (R, z):\n";
181  // for(unsigned int i=0; i<fullTrajectory_.size(); i++) {
182  // LogTrace("TrackAssociator") << "state " << i << ": (" << fullTrajectory_[i].position().perp() << ", "
183  // << fullTrajectory_[i].position().z() << ")\n";
184  // }
185 
186 
187 
188 
189 
190  LogTrace("TrackAssociator") << "Done with the track propagation in the detector. Number of steps: " << fullTrajectory_.size();
191  fullTrajectoryFilled_ = true;
192  return ! fullTrajectory_.empty();
193 }
194 
196 {
197  // TimerStack timers(TimerStack::Disableable);
198  // timers.benchmark("CachedTrajectory::propagate::benchmark");
199  // timers.push("CachedTrajectory::propagate",TimerStack::FastMonitoring);
200  // timers.push("CachedTrajectory::propagate::findClosestPoint",TimerStack::FastMonitoring);
201 
202  // Assume that all points along the trajectory are equally spread out.
203  // For simplication assume that the trajectory is just a straight
204  // line and find a point closest to the target plane. Propagate to
205  // the plane from the point.
206 
207  const float matchingDistance = 1;
208  // find the closest point to the plane
209  int leftIndex = 0;
210  int rightIndex = fullTrajectory_.size()-1;
211  int closestPointOnLeft = 0;
212 
213  // check whether the trajectory crossed the plane (signs should be different)
214  if ( sign( distance(plane, leftIndex) ) * sign( distance(plane, rightIndex) ) != -1 ) {
215  LogTrace("TrackAssociator") << "Track didn't cross the plane:\n\tleft distance: "<<distance(plane, leftIndex)
216  <<"\n\tright distance: " << distance(plane, rightIndex);
217  return TrajectoryStateOnSurface();
218  }
219 
220  while (leftIndex + 1 < rightIndex) {
221  closestPointOnLeft = int((leftIndex+rightIndex)/2);
222  float dist = distance(plane,closestPointOnLeft);
223  // LogTrace("TrackAssociator") << "Closest point on left: " << closestPointOnLeft << "\n"
224  // << "Distance to the plane: " << dist;
225  if (fabs(dist)<matchingDistance) {
226  // found close match, verify that we are on the left side
227  if (closestPointOnLeft>0 && sign( distance(plane, closestPointOnLeft-1) ) * dist == -1)
228  closestPointOnLeft--;
229  break;
230  }
231 
232  // check where is the plane
233  if (sign( distance(plane, leftIndex) * dist ) == -1)
234  rightIndex = closestPointOnLeft;
235  else
236  leftIndex = closestPointOnLeft;
237 
238  // LogTrace("TrackAssociator") << "Distance on left: " << distance(plane, leftIndex) << "\n"
239  // << "Distance to closest point: " << distance(plane, closestPointOnLeft) << "\n"
240  // << "Left index: " << leftIndex << "\n"
241  // << "Right index: " << rightIndex;
242 
243  }
244  LogTrace("TrackAssociator") << "closestPointOnLeft: " << closestPointOnLeft
245  << "\n\ttrajectory point (z,R,eta,phi): "
246  << fullTrajectory_[closestPointOnLeft].position().z() << ", "
247  << fullTrajectory_[closestPointOnLeft].position().perp() << " , "
248  << fullTrajectory_[closestPointOnLeft].position().eta() << " , "
249  << fullTrajectory_[closestPointOnLeft].position().phi()
250  << "\n\tplane center (z,R,eta,phi): "
251  << plane->position().z() << ", "
252  << plane->position().perp() << " , "
253  << plane->position().eta() << " , "
254  << plane->position().phi();
255 
256  // propagate to the plane
257  // timers.pop_and_push("CachedTrajectory::propagate::localPropagation",TimerStack::FastMonitoring);
258  if (const SteppingHelixPropagator* shp = dynamic_cast<const SteppingHelixPropagator*>(propagator_))
259  {
261  try {
262  shp->propagate(fullTrajectory_[closestPointOnLeft], *plane, state);
263  }
264  catch(cms::Exception &ex){
265  edm::LogWarning("TrackAssociator") <<
266  "Caught exception " << ex.category() << ": " << ex.explainSelf();
267  edm::LogWarning("TrackAssociator") << "An exception is caught during the track propagation\n"
268  << state.momentum().x() << ", " << state.momentum().y() << ", " << state.momentum().z();
269  return TrajectoryStateOnSurface();
270  }
271  return state.getStateOnSurface(*plane);
272  }
273  else
274  {
276  fullTrajectory_[closestPointOnLeft].getFreeState(fts);
277  return propagator_->propagate(fts, *plane);
278  }
279 }
280 
281 std::pair<float,float> CachedTrajectory::trajectoryDelta( TrajectorType trajectoryType )
282 {
283  // MEaning of trajectory change depends on its usage. In most cases we measure
284  // change in a trajectory as difference between final track position and initial
285  // direction. In some cases such as change of trajectory in the muon detector we
286  // might want to compare theta-phi of two points or even find local maximum and
287  // mimimum. In general it's not essential what defenition of the trajectory change
288  // is used since we use these numbers only as a rough estimate on how much wider
289  // we should make the preselection region.
290  std::pair<float,float> result(0,0);
291  if ( ! stateAtIP_.isValid() ) {
292  edm::LogWarning("TrackAssociator") << "State at IP is not known set. Cannot estimate trajectory change. " <<
293  "Trajectory change is not taken into account in matching";
294  return result;
295  }
296  switch (trajectoryType) {
297  case IpToEcal:
298  if ( ecalTrajectory_.empty() )
299  edm::LogWarning("TrackAssociator") << "ECAL trajector is empty. Cannot estimate trajectory change. " <<
300  "Trajectory change is not taken into account in matching";
301  else return delta( stateAtIP_.momentum().theta(), ecalTrajectory_.front().position().theta(),
302  stateAtIP_.momentum().phi(), ecalTrajectory_.front().position().phi() );
303  break;
304  case IpToHcal:
305  if ( hcalTrajectory_.empty() )
306  edm::LogWarning("TrackAssociator") << "HCAL trajector is empty. Cannot estimate trajectory change. " <<
307  "Trajectory change is not taken into account in matching";
308  else return delta( stateAtIP_.momentum().theta(), hcalTrajectory_.front().position().theta(),
309  stateAtIP_.momentum().phi(), hcalTrajectory_.front().position().phi() );
310  break;
311  case IpToHO:
312  if ( hoTrajectory_.empty() )
313  edm::LogWarning("TrackAssociator") << "HO trajector is empty. Cannot estimate trajectory change. " <<
314  "Trajectory change is not taken into account in matching";
315  else return delta( stateAtIP_.momentum().theta(), hoTrajectory_.front().position().theta(),
316  stateAtIP_.momentum().phi(), hoTrajectory_.front().position().phi() );
317  break;
318  case FullTrajectory:
319  if ( fullTrajectory_.empty() )
320  edm::LogWarning("TrackAssociator") << "Full trajector is empty. Cannot estimate trajectory change. " <<
321  "Trajectory change is not taken into account in matching";
322  else return delta( stateAtIP_.momentum().theta(), fullTrajectory_.back().position().theta(),
323  stateAtIP_.momentum().phi(), fullTrajectory_.back().position().phi() );
324  break;
325  default:
326  edm::LogWarning("TrackAssociator") << "Unkown or not supported trajector type. Cannot estimate trajectory change. " <<
327  "Trajectory change is not taken into account in matching";
328  }
329  return result;
330 }
331 
332 std::pair<float,float> CachedTrajectory::delta(const double& theta1,
333  const double& theta2,
334  const double& phi1,
335  const double& phi2)
336 {
337  std::pair<float,float> result(theta2 - theta1, phi2 - phi1 );
338  // this won't work for loopers, since deltaPhi cannot be larger than Pi.
339  if ( fabs(result.second) > 2*M_PI-fabs(result.second) ) {
340  if (result.second>0)
341  result.second -= 2*M_PI;
342  else
343  result.second += 2*M_PI;
344  }
345  return result;
346 }
347 
348 void CachedTrajectory::getTrajectory(std::vector<SteppingHelixStateInfo>& trajectory,
349  const FiducialVolume& volume,
350  int steps)
351 {
352  if ( ! fullTrajectoryFilled_ ) throw cms::Exception("FatalError") << "trajectory is not defined yet. Please use propagateAll first.";
353  if ( fullTrajectory_.empty() ) {
354  LogTrace("TrackAssociator") << "Trajectory is empty. Move on";
355  return;
356  }
357  if ( ! volume.isValid() ) {
358  LogTrace("TrackAssociator") << "no trajectory is expected to be found since the fiducial volume is not valid";
359  return;
360  }
361  double step = std::max(volume.maxR()-volume.minR(),volume.maxZ()-volume.minZ())/steps;
362 
363  int closestPointOnLeft = -1;
364 
365  // check whether the trajectory crossed the region
366  if ( !
367  ( ( fullTrajectory_.front().position().perp() < volume.maxR() && fabs(fullTrajectory_.front().position().z()) < volume.maxZ() ) &&
368  ( fullTrajectory_.back().position().perp() > volume.minR() || fabs(fullTrajectory_.back().position().z()) > volume.minZ() ) ))
369  {
370  LogTrace("TrackAssociator") << "Track didn't cross the region (R1,R2,L1,L2): " << volume.minR() << ", " << volume.maxR() <<
371  ", " << volume.minZ() << ", " << volume.maxZ();
372  return;
373  }
374 
375  // get distance along momentum to the surface.
376 
377  // the following code can be made faster, but it'll hardly be a significant improvement
378  // simplifications:
379  // 1) direct loop over stored trajectory points instead of some sort
380  // of fast root search (Newton method)
381  // 2) propagate from the closest point outside the region with the
382  // requested step ignoring stored trajectory points.
383  double dZ(-1.);
384  double dR(-1.);
385  int firstPointInside(-1);
386  for(unsigned int i=0; i<fullTrajectory_.size(); i++) {
387  // LogTrace("TrackAssociator") << "Trajectory info (i,perp,r1,r2,z,z1,z2): " << i << ", " << fullTrajectory_[i].position().perp() <<
388  // ", " << volume.minR() << ", " << volume.maxR() << ", " << fullTrajectory_[i].position().z() << ", " << volume.minZ() << ", " <<
389  // volume.maxZ() << ", " << closestPointOnLeft;
390  dR = fullTrajectory_[i].position().perp()-volume.minR();
391  dZ = fabs(fullTrajectory_[i].position().z()) - volume.minZ();
392  if ( dR> 0 || dZ >0 )
393  {
394  if (i>0) {
395  firstPointInside = i;
396  closestPointOnLeft = i - 1;
397  } else {
398  firstPointInside = 0;
399  closestPointOnLeft = 0;
400  }
401  break;
402  }
403  }
404  if (closestPointOnLeft == -1) throw cms::Exception("FatalError") << "This shouls never happen - internal logic error";
405 
406  SteppingHelixStateInfo currentState(fullTrajectory_[closestPointOnLeft]);
407  if ( currentState.position().x()*currentState.momentum().x() +
408  currentState.position().y()*currentState.momentum().y() +
409  currentState.position().z()*currentState.momentum().z() < 0 )
410  step = -step;
411 
412  // propagate to the inner surface of the active volume
413 
414  if (firstPointInside != closestPointOnLeft) {
415  if ( dR > 0 ) {
417  propagate(currentState, *barrel);
418  } else {
420  currentState.position().z()>0?volume.minZ():-volume.minZ()),
421  Plane::RotationType () );
422  propagate(currentState, *endcap);
423  }
424  if ( currentState.isValid() ) trajectory.push_back(currentState);
425  } else
426  LogTrace("TrackAssociator") << "Weird message\n";
427 
428  while (currentState.isValid() &&
429  currentState.position().perp() < volume.maxR() &&
430  fabs(currentState.position().z()) < volume.maxZ() )
431  {
432  propagateForward(currentState,step);
433  if (! currentState.isValid() ) {
434  LogTrace("TrackAssociator") << "Failed to propagate the track; moving on\n";
435  break;
436  }
437  // LogTrace("TrackAssociator") << "New state (perp, z): " << currentState.position().perp() << ", " << currentState.position().z();
438  //if ( ( currentState.position().perp() < volume.maxR() && fabs(currentState.position().z()) < volume.maxZ() ) &&
439  // ( currentState.position().perp()-volume.minR() > 0 || fabs(currentState.position().z()) - volume.minZ() >0 ) )
440  trajectory.push_back(currentState);
441  }
442 }
443 
445  fullTrajectory_.clear();
446  ecalTrajectory_.clear();
447  hcalTrajectory_.clear();
448  hoTrajectory_.clear();
449  preshowerTrajectory_.clear();
450  wideEcalTrajectory_.clear();
451  wideHcalTrajectory_.clear();
452  wideHOTrajectory_.clear();
453  fullTrajectoryFilled_ = false;
454 }
455 
457  LogTrace("TrackAssociator") << "getting trajectory in ECAL";
458  getTrajectory(ecalTrajectory_, volume, 4 );
459  LogTrace("TrackAssociator") << "# of points in ECAL trajectory:" << ecalTrajectory_.size();
460 }
461 
463  LogTrace("TrackAssociator") << "getting trajectory in Preshower";
464  getTrajectory(preshowerTrajectory_, volume, 2 );
465  LogTrace("TrackAssociator") << "# of points in Preshower trajectory:" << preshowerTrajectory_.size();
466 }
467 
468 const std::vector<SteppingHelixStateInfo>& CachedTrajectory::getEcalTrajectory() const{
469  return ecalTrajectory_;
470 }
471 
472 const std::vector<SteppingHelixStateInfo>& CachedTrajectory::getPreshowerTrajectory() const{
473  return preshowerTrajectory_;
474 }
475 
477  LogTrace("TrackAssociator") << "getting trajectory in HCAL";
478  getTrajectory(hcalTrajectory_, volume, 4 ); // more steps to account for different depth
479  LogTrace("TrackAssociator") << "# of points in HCAL trajectory:" << hcalTrajectory_.size();
480 }
481 
482 const std::vector<SteppingHelixStateInfo>& CachedTrajectory::getHcalTrajectory() const{
483  return hcalTrajectory_;
484 }
485 
487  LogTrace("TrackAssociator") << "getting trajectory in HO";
488  getTrajectory(hoTrajectory_, volume, 2 );
489  LogTrace("TrackAssociator") << "# of points in HO trajectory:" << hoTrajectory_.size();
490 }
491 
492 const std::vector<SteppingHelixStateInfo>& CachedTrajectory::getHOTrajectory() const {
493  return hoTrajectory_;
494 }
495 
496 std::vector<GlobalPoint>*
497 CachedTrajectory::getWideTrajectory(const std::vector<SteppingHelixStateInfo>& states,
498  WideTrajectoryType wideTrajectoryType) {
499  std::vector<GlobalPoint>* wideTrajectory = nullptr;
500  switch (wideTrajectoryType) {
501  case Ecal:
502  LogTrace("TrackAssociator") << "Filling ellipses in Ecal trajectory";
503  wideTrajectory = &wideEcalTrajectory_;
504  break;
505  case Hcal:
506  LogTrace("TrackAssociator") << "Filling ellipses in Hcal trajectory";
507  wideTrajectory = &wideHcalTrajectory_;
508  break;
509  case HO:
510  LogTrace("TrackAssociator") << "Filling ellipses in HO trajectory";
511  wideTrajectory = &wideHOTrajectory_;
512  break;
513  }
514  if(!wideTrajectory) return nullptr;
515 
516  for(std::vector<SteppingHelixStateInfo>::const_iterator state= states.begin();
517  state != states.end(); state++) {
518  // defined a normal plane wrt the particle trajectory direction
519  // let's hope that I computed the rotation matrix correctly.
520  GlobalVector vector(state->momentum().unit());
521  float r21 = 0;
522  float r22 = vector.z()/sqrt(1-pow(vector.x(),2));
523  float r23 = -vector.y()/sqrt(1-pow(vector.x(),2));
524  float r31 = vector.x();
525  float r32 = vector.y();
526  float r33 = vector.z();
527  float r11 = r22*r33-r23*r32;
528  float r12 = r23*r31;
529  float r13 = -r22*r31;
530 
531  Plane::RotationType rotation(r11, r12, r13,
532  r21, r22, r23,
533  r31, r32, r33);
534  Plane* target = new Plane(state->position(), rotation);
535 
536  TrajectoryStateOnSurface tsos = state->getStateOnSurface(*target);
537 
538  if (!tsos.isValid()) {
539  LogTrace("TrackAssociator") << "[getWideTrajectory] TSOS not valid";
540  continue;
541  }
542  if (!tsos.hasError()) {
543  LogTrace("TrackAssociator") << "[getWideTrajectory] TSOS does not have Errors";
544  continue;
545  }
546  LocalError localErr = tsos.localError().positionError();
547  localErr.scale(2); // get the 2 sigma ellipse
548  float xx = localErr.xx();
549  float xy = localErr.xy();
550  float yy = localErr.yy();
551 
552  float denom = yy - xx;
553  float phi = 0.;
554  if(xy == 0 && denom==0) phi = M_PI_4;
555  else phi = 0.5 * atan2(2.*xy,denom); // angle of MAJOR axis
556  // Unrotate the error ellipse to get the semimajor and minor axes. Then place points on
557  // the endpoints of semiminor an seminajor axes on original(rotated) error ellipse.
558  LocalError rotErr = localErr.rotate(-phi); // xy covariance of rotErr should be zero
559  float semi1 = sqrt(rotErr.xx());
560  float semi2 = sqrt(rotErr.yy());
561 
562  // Just use one point if the ellipse is small
563  // if(semi1 < 0.1 && semi2 < 0.1) {
564  // LogTrace("TrackAssociator") << "[getWideTrajectory] Error ellipse is small, using one trajectory point";
565  // wideTrajectory->push_back(state->position());
566  // continue;
567  // }
568 
569  Local2DPoint bounds[4];
570  bounds[0] = Local2DPoint(semi1*cos(phi), semi1*sin(phi));
571  bounds[1] = Local2DPoint(semi1*cos(phi+M_PI), semi1*sin(phi+M_PI));
572  phi += M_PI_2; // add pi/2 for the semi2 axis
573  bounds[2] = Local2DPoint(semi2*cos(phi), semi2*sin(phi));
574  bounds[3] = Local2DPoint(semi2*cos(phi+M_PI), semi2*sin(phi+M_PI));
575 
576  // LogTrace("TrackAssociator") << "Axes " << semi1 <<","<< semi2 <<" phi "<< phi;
577  // LogTrace("TrackAssociator") << "Local error ellipse: " << bounds[0] << bounds[1] << bounds[2] << bounds[3];
578 
579  wideTrajectory->push_back(state->position());
580  for(int index=0; index<4; ++index)
581  wideTrajectory->push_back(target->toGlobal(bounds[index]));
582 
583  //LogTrace("TrackAssociator") <<"Global error ellipse: (" << target->toGlobal(bounds[0]) <<","<< target->toGlobal(bounds[1])
584  // <<","<< target->toGlobal(bounds[2]) <<","<< target->toGlobal(bounds[3]) <<","<<state->position() <<")";
585  }
586 
587  return wideTrajectory;
588 }
589 
591 {
592  if ( ecalTrajectory_.empty() )
593  return SteppingHelixStateInfo();
594  else
595  return ecalTrajectory_.front();
596 }
597 
599 {
600  if ( preshowerTrajectory_.empty() )
601  return SteppingHelixStateInfo();
602  else
603  return preshowerTrajectory_.front();
604 }
605 
607 {
608  if ( hcalTrajectory_.empty() )
609  return SteppingHelixStateInfo();
610  else
611  return hcalTrajectory_.front();
612 }
613 
615 {
616  if ( hoTrajectory_.empty() )
617  return SteppingHelixStateInfo();
618  else
619  return hoTrajectory_.front();
620 }
621 
622 
624  if(fullTrajectory_.empty() )
625  return SteppingHelixStateInfo();
626  else
627  return fullTrajectory_.front();
628 }
629 
630 
632  if(fullTrajectory_.empty() )
633  return SteppingHelixStateInfo();
634  else
635  return fullTrajectory_.back();
636 }
637 
GlobalPoint toGlobal(const Point2DBase< Scalar, LocalTag > lp) const
Definition: Surface.h:106
SteppingHelixStateInfo getStateAtHO()
float xx() const
Definition: LocalError.h:24
bool isValid() const
check whether the volume is properly defined
T perp() const
Definition: PV3DBase.h:72
SteppingHelixStateInfo stateAtIP_
std::vector< SteppingHelixStateInfo > ecalTrajectory_
const std::vector< SteppingHelixStateInfo > & getHOTrajectory() const
void findPreshowerTrajectory(const FiducialVolume &)
const std::vector< SteppingHelixStateInfo > & getHcalTrajectory() const
const Propagator * propagator_
void setMinDetectorLength(float l=0.)
virtual std::string explainSelf() const
Definition: Exception.cc:108
void getFreeState(FreeTrajectoryState &fts) const
convert internal structure into the fts
std::vector< SteppingHelixStateInfo > propagateThoughFromIP(const SteppingHelixStateInfo &state, const Propagator *prop, const FiducialVolume &volume, int nsteps, float step, float minR, float minZ, float maxR, float maxZ)
void setMinDetectorRadius(float r=0.)
double maxZ(bool withTolerance=true) const
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
#define nullptr
Geom::Phi< T > phi() const
Definition: PV3DBase.h:69
T y() const
Definition: PV3DBase.h:63
#define M_PI_2
std::string const & category() const
Definition: Exception.cc:143
void setPropagationStep(float s=20.)
void getTrajectory(std::vector< SteppingHelixStateInfo > &, const FiducialVolume &, int steps=4)
std::vector< GlobalPoint > wideHcalTrajectory_
const std::vector< SteppingHelixStateInfo > & getPreshowerTrajectory() const
void findHcalTrajectory(const FiducialVolume &)
double minZ(bool withTolerance=true) const
GlobalVector momentum() const
Definition: Plane.h:17
std::vector< GlobalPoint > wideEcalTrajectory_
Geom::Theta< T > theta() const
Definition: PV3DBase.h:75
SteppingHelixStateInfo getStateAtPreshower()
std::vector< SteppingHelixStateInfo > hoTrajectory_
static CylinderPointer build(const PositionType &pos, const RotationType &rot, Scalar radius, Bounds *bounds=0)
Definition: Cylinder.h:51
std::vector< GlobalPoint > wideHOTrajectory_
float xy() const
Definition: LocalError.h:25
T mag() const
Definition: PV3DBase.h:67
bool propagateAll(const SteppingHelixStateInfo &initialState)
propagate through the whole detector, returns true if successful
const std::vector< SteppingHelixStateInfo > & getEcalTrajectory() const
float yy() const
Definition: LocalError.h:26
GlobalPoint position() const
TrajectoryStateOnSurface getStateOnSurface(const Surface &surf, bool returnTangentPlane=false) const
T sqrt(T t)
Definition: SSEVec.h:18
float distance(const Plane *plane, int index)
static PlanePointer build(Args &&...args)
Definition: Plane.h:33
FreeTrajectoryState const * freeState(bool withErrors=true) const
T z() const
Definition: PV3DBase.h:64
SteppingHelixStateInfo getInnerState()
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
std::pair< float, float > trajectoryDelta(TrajectorType)
std::vector< SteppingHelixStateInfo > preshowerTrajectory_
std::vector< GlobalPoint > * getWideTrajectory(const std::vector< SteppingHelixStateInfo > &, WideTrajectoryType)
#define LogTrace(id)
SteppingHelixStateInfo getOuterState()
#define M_PI
double minR(bool withTolerance=true) const
Vector3DBase unit() const
Definition: Vector3DBase.h:57
void setPropagator(const Propagator *ptr)
std::pair< float, float > delta(const double &theta1, const double &theta2, const double &phi1, const double &phi2)
void propagate(SteppingHelixStateInfo &state, const Plane &plane)
std::deque< SteppingHelixStateInfo > fullTrajectory_
void findEcalTrajectory(const FiducialVolume &)
Point3DBase< float, GlobalTag > PositionType
TrajectoryStateOnSurface propagate(STA const &state, SUR const &surface) const
Definition: Propagator.h:53
T eta() const
Definition: PV3DBase.h:76
SteppingHelixStateInfo getStateAtEcal()
static int position[264][3]
Definition: ReadPGInfo.cc:509
TkRotation< float > RotationType
void findHOTrajectory(const FiducialVolume &)
Point2DBase< float, LocalTag > Local2DPoint
Definition: LocalPoint.h:8
step
Definition: StallMonitor.cc:94
void propagateForward(SteppingHelixStateInfo &state, float distance)
LocalError rotate(float x, float y) const
Return a new LocalError, rotated by an angle defined by the direction (x,y)
Definition: LocalError.h:39
void setStateAtIP(const SteppingHelixStateInfo &state)
T x() const
Definition: PV3DBase.h:62
const PositionType & position() const
static int sign(float number)
void setMaxDetectorLength(float l=2200.)
double maxR(bool withTolerance=true) const
SteppingHelixStateInfo getStateAtHcal()
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
std::vector< SteppingHelixStateInfo > hcalTrajectory_
void setMaxDetectorRadius(float r=800.)
LocalError scale(float s) const
Definition: LocalError.h:33