CMS 3D CMS Logo

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