38 bool isPropagationSuccessful = neckLace.
propagateAll(state);
40 if (!isPropagationSuccessful)
41 return std::vector<SteppingHelixStateInfo>();
43 std::vector<SteppingHelixStateInfo> complicatePoints;
46 return complicatePoints;
68 float r11 = r22 * r33 - r23 *
r32;
69 float r12 = r23 * r31;
70 float r13 = -r22 * r31;
80 shp->propagate(state, plane, state);
83 edm::LogWarning(
"TrackAssociator") <<
"An exception is caught during the track propagation\n"
99 shp->propagate(state, cylinder, state);
102 edm::LogWarning(
"TrackAssociator") <<
"An exception is caught during the track propagation\n"
118 <<
"Reseting all trajectories. Please call reset_trajectory() explicitely to avoid this message";
126 throw cms::Exception(
"FatalError") <<
"Track propagator is not defined\n";
131 LogTrace(
"TrackAssociator") <<
"[propagateAll] Propagate outward from (rho, r, z, phi) ("
136 LogTrace(
"TrackAssociator") <<
"Failed to propagate the track; moving on\n";
139 LogTrace(
"TrackAssociator") <<
"\treached (rho, r, z, phi) (" << currentState.
position().
perp() <<
", "
148 previousState = currentState2;
150 if (!currentState2.
isValid()) {
151 LogTrace(
"TrackAssociator") <<
"Failed to propagate the track; moving on\n";
156 <<
"Error: TrackAssociator has propogated the particle past the point of closest approach to IP" << std::endl;
159 LogTrace(
"TrackAssociator") <<
"[propagateAll] Propagated inward from (rho, r, z, phi) ("
173 LogTrace(
"TrackAssociator") <<
"Done with the track propagation in the detector. Number of steps: "
190 const float matchingDistance = 1;
194 int closestPointOnLeft = 0;
198 LogTrace(
"TrackAssociator") <<
"Track didn't cross the plane:\n\tleft distance: " <<
distance(plane, leftIndex)
199 <<
"\n\tright distance: " <<
distance(plane, rightIndex);
203 while (leftIndex + 1 < rightIndex) {
204 closestPointOnLeft = int((leftIndex + rightIndex) / 2);
205 float dist =
distance(plane, closestPointOnLeft);
208 if (fabs(dist) < matchingDistance) {
210 if (closestPointOnLeft > 0 &&
sign(
distance(plane, closestPointOnLeft - 1)) * dist == -1)
211 closestPointOnLeft--;
217 rightIndex = closestPointOnLeft;
219 leftIndex = closestPointOnLeft;
226 LogTrace(
"TrackAssociator") <<
"closestPointOnLeft: " << closestPointOnLeft <<
"\n\ttrajectory point (z,R,eta,phi): "
231 <<
"\n\tplane center (z,R,eta,phi): " << plane->
position().
z() <<
", "
243 edm::LogWarning(
"TrackAssociator") <<
"An exception is caught during the track propagation\n"
264 std::pair<float, float>
result(0, 0);
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";
270 switch (trajectoryType) {
273 edm::LogWarning(
"TrackAssociator") <<
"ECAL trajector is empty. Cannot estimate trajectory change. "
274 <<
"Trajectory change is not taken into account in matching";
283 edm::LogWarning(
"TrackAssociator") <<
"HCAL trajector is empty. Cannot estimate trajectory change. "
284 <<
"Trajectory change is not taken into account in matching";
293 edm::LogWarning(
"TrackAssociator") <<
"HO trajector is empty. Cannot estimate trajectory change. "
294 <<
"Trajectory change is not taken into account in matching";
303 edm::LogWarning(
"TrackAssociator") <<
"Full trajector is empty. Cannot estimate trajectory change. "
304 <<
"Trajectory change is not taken into account in matching";
313 <<
"Unkown or not supported trajector type. Cannot estimate trajectory change. "
314 <<
"Trajectory change is not taken into account in matching";
320 const double& theta2,
322 const double& phi2) {
323 std::pair<float, float>
result(theta2 - theta1, phi2 - phi1);
325 if (fabs(result.second) > 2 *
M_PI - fabs(result.second)) {
326 if (result.second > 0)
327 result.second -= 2 *
M_PI;
329 result.second += 2 *
M_PI;
338 throw cms::Exception(
"FatalError") <<
"trajectory is not defined yet. Please use propagateAll first.";
340 LogTrace(
"TrackAssociator") <<
"Trajectory is empty. Move on";
344 LogTrace(
"TrackAssociator") <<
"no trajectory is expected to be found since the fiducial volume is not valid";
349 int closestPointOnLeft = -1;
356 LogTrace(
"TrackAssociator") <<
"Track didn't cross the region (R1,R2,L1,L2): " << volume.
minR() <<
", "
357 << volume.
maxR() <<
", " << volume.
minZ() <<
", " << volume.
maxZ();
371 int firstPointInside(-1);
378 if (dR > 0 || dZ > 0) {
380 firstPointInside =
i;
381 closestPointOnLeft =
i - 1;
383 firstPointInside = 0;
384 closestPointOnLeft = 0;
389 if (closestPointOnLeft == -1)
390 throw cms::Exception(
"FatalError") <<
"This shouls never happen - internal logic error";
401 if (firstPointInside != closestPointOnLeft) {
413 trajectory.push_back(currentState);
415 LogTrace(
"TrackAssociator") <<
"Weird message\n";
421 LogTrace(
"TrackAssociator") <<
"Failed to propagate the track; moving on\n";
427 trajectory.push_back(currentState);
444 LogTrace(
"TrackAssociator") <<
"getting trajectory in ECAL";
450 LogTrace(
"TrackAssociator") <<
"getting trajectory in Preshower";
462 LogTrace(
"TrackAssociator") <<
"getting trajectory in HCAL";
470 LogTrace(
"TrackAssociator") <<
"getting trajectory in HO";
479 std::vector<GlobalPoint>* wideTrajectory =
nullptr;
480 switch (wideTrajectoryType) {
482 LogTrace(
"TrackAssociator") <<
"Filling ellipses in Ecal trajectory";
486 LogTrace(
"TrackAssociator") <<
"Filling ellipses in Hcal trajectory";
490 LogTrace(
"TrackAssociator") <<
"Filling ellipses in HO trajectory";
497 for (std::vector<SteppingHelixStateInfo>::const_iterator
state = states.begin();
state != states.end();
state++) {
507 float r11 = r22 * r33 - r23 *
r32;
508 float r12 = r23 * r31;
509 float r13 = -r22 * r31;
516 if (!tsos.isValid()) {
517 LogTrace(
"TrackAssociator") <<
"[getWideTrajectory] TSOS not valid";
520 if (!tsos.hasError()) {
521 LogTrace(
"TrackAssociator") <<
"[getWideTrajectory] TSOS does not have Errors";
524 LocalError localErr = tsos.localError().positionError();
526 float xx = localErr.
xx();
527 float xy = localErr.
xy();
528 float yy = localErr.
yy();
530 float denom = yy - xx;
532 if (xy == 0 && denom == 0)
535 phi = 0.5 * atan2(2. * xy, denom);
539 float semi1 =
sqrt(rotErr.
xx());
540 float semi2 =
sqrt(rotErr.
yy());
559 wideTrajectory->push_back(
state->position());
567 return wideTrajectory;
GlobalPoint toGlobal(const Point2DBase< Scalar, LocalTag > lp) const
SteppingHelixStateInfo getStateAtHO()
bool fullTrajectoryFilled_
bool isValid() const
check whether the volume is properly defined
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
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)
Geom::Phi< T > phi() const
std::string const & category() const
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
std::vector< GlobalPoint > wideEcalTrajectory_
Geom::Theta< T > theta() const
SteppingHelixStateInfo getStateAtPreshower()
std::vector< SteppingHelixStateInfo > hoTrajectory_
std::vector< GlobalPoint > wideHOTrajectory_
bool propagateAll(const SteppingHelixStateInfo &initialState)
propagate through the whole detector, returns true if successful
const std::vector< SteppingHelixStateInfo > & getEcalTrajectory() const
GlobalPoint position() const
TrajectoryStateOnSurface getStateOnSurface(const Surface &surf, bool returnTangentPlane=false) const
float distance(const Plane *plane, int index)
static PlanePointer build(Args &&...args)
FreeTrajectoryState const * freeState(bool withErrors=true) const
SteppingHelixStateInfo getInnerState()
Cos< T >::type cos(const T &t)
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()
double minR(bool withTolerance=true) const
Vector3DBase unit() const
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)
std::deque< SteppingHelixStateInfo > fullTrajectory_
void findEcalTrajectory(const FiducialVolume &)
TrajectoryStateOnSurface propagate(STA const &state, SUR const &surface) const
SteppingHelixStateInfo getStateAtEcal()
static int position[264][3]
TkRotation< float > RotationType
void findHOTrajectory(const FiducialVolume &)
Point2DBase< float, LocalTag > Local2DPoint
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 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)
void setStateAtIP(const SteppingHelixStateInfo &state)
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)
std::vector< SteppingHelixStateInfo > hcalTrajectory_
void setMaxDetectorRadius(float r=800.)
LocalError scale(float s) const