CMS 3D CMS Logo

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