18 std::vector<SteppingHelixStateInfo>
21 float step,
float minR,
float minZ,
float maxR,
float maxZ) {
33 bool isPropagationSuccessful = neckLace.
propagateAll(state);
35 if (!isPropagationSuccessful)
36 return std::vector<SteppingHelixStateInfo> () ;
38 std::vector<SteppingHelixStateInfo> complicatePoints;
41 return complicatePoints;
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;
83 state = shp->propagate(state, plane);
88 edm::LogWarning(
"TrackAssociator") <<
"An exception is caught during the track propagation\n"
107 state = shp->propagate(state, cylinder);
112 edm::LogWarning(
"TrackAssociator") <<
"An exception is caught during the track propagation\n"
129 edm::LogWarning(
"TrackAssociator") <<
"Reseting all trajectories. Please call reset_trajectory() explicitely to avoid this message";
141 LogTrace(
"TrackAssociator") <<
"[propagateAll] Propagate outward from (rho, r, z, phi) (" <<
145 if (! currentState.
isValid() ) {
146 LogTrace(
"TrackAssociator") <<
"Failed to propagate the track; moving on\n";
149 LogTrace(
"TrackAssociator") <<
"\treached (rho, r, z, phi) (" <<
159 previousState=currentState2;
161 if (! currentState2.
isValid() ) {
162 LogTrace(
"TrackAssociator") <<
"Failed to propagate the track; moving on\n";
166 LogTrace(
"TrackAssociator") <<
"Error: TrackAssociator has propogated the particle past the point of closest approach to IP" << std::endl;
169 LogTrace(
"TrackAssociator") <<
"[propagateAll] Propagated inward from (rho, r, z, phi) (" <<
190 LogTrace(
"TrackAssociator") <<
"Done with the track propagation in the detector. Number of steps: " <<
fullTrajectory_.size();
207 const float matchingDistance = 1;
211 int closestPointOnLeft = 0;
215 LogTrace(
"TrackAssociator") <<
"Track didn't cross the plane:\n\tleft distance: "<<
distance(plane, leftIndex)
216 <<
"\n\tright distance: " <<
distance(plane, rightIndex);
220 while (leftIndex + 1 < rightIndex) {
221 closestPointOnLeft = int((leftIndex+rightIndex)/2);
222 float dist =
distance(plane,closestPointOnLeft);
225 if (fabs(dist)<matchingDistance) {
227 if (closestPointOnLeft>0 &&
sign(
distance(plane, closestPointOnLeft-1) ) * dist == -1)
228 closestPointOnLeft--;
234 rightIndex = closestPointOnLeft;
236 leftIndex = closestPointOnLeft;
244 LogTrace(
"TrackAssociator") <<
"closestPointOnLeft: " << closestPointOnLeft
245 <<
"\n\ttrajectory point (z,R,eta,phi): "
250 <<
"\n\tplane center (z,R,eta,phi): "
267 edm::LogWarning(
"TrackAssociator") <<
"An exception is caught during the track propagation\n"
290 std::pair<float,float>
result(0,0);
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";
296 switch (trajectoryType) {
299 edm::LogWarning(
"TrackAssociator") <<
"ECAL trajector is empty. Cannot estimate trajectory change. " <<
300 "Trajectory change is not taken into account in matching";
306 edm::LogWarning(
"TrackAssociator") <<
"HCAL trajector is empty. Cannot estimate trajectory change. " <<
307 "Trajectory change is not taken into account in matching";
313 edm::LogWarning(
"TrackAssociator") <<
"HO trajector is empty. Cannot estimate trajectory change. " <<
314 "Trajectory change is not taken into account in matching";
320 edm::LogWarning(
"TrackAssociator") <<
"Full trajector is empty. Cannot estimate trajectory change. " <<
321 "Trajectory change is not taken into account in matching";
326 edm::LogWarning(
"TrackAssociator") <<
"Unkown or not supported trajector type. Cannot estimate trajectory change. " <<
327 "Trajectory change is not taken into account in matching";
333 const double& theta2,
337 std::pair<float,float>
result(theta2 - theta1, phi2 - phi1 );
339 if ( fabs(result.second) > 2*
M_PI-fabs(result.second) ) {
341 result.second -= 2*
M_PI;
343 result.second += 2*
M_PI;
354 LogTrace(
"TrackAssociator") <<
"Trajectory is empty. Move on";
358 LogTrace(
"TrackAssociator") <<
"no trajectory is expected to be found since the fiducial volume is not valid";
363 int closestPointOnLeft = -1;
370 LogTrace(
"TrackAssociator") <<
"Track didn't cross the region (R1,R2,L1,L2): " << volume.
minR() <<
", " << volume.
maxR() <<
371 ", " << volume.
minZ() <<
", " << volume.
maxZ();
385 int firstPointInside(-1);
392 if ( dR> 0 || dZ >0 )
395 firstPointInside =
i;
396 closestPointOnLeft =
i - 1;
398 firstPointInside = 0;
399 closestPointOnLeft = 0;
404 if (closestPointOnLeft == -1)
throw cms::Exception(
"FatalError") <<
"This shouls never happen - internal logic error";
414 if (firstPointInside != closestPointOnLeft) {
424 if ( currentState.
isValid() ) trajectory.push_back(currentState);
426 LogTrace(
"TrackAssociator") <<
"Weird message\n";
428 while (currentState.
isValid() &&
433 if (! currentState.
isValid() ) {
434 LogTrace(
"TrackAssociator") <<
"Failed to propagate the track; moving on\n";
440 trajectory.push_back(currentState);
457 LogTrace(
"TrackAssociator") <<
"getting trajectory in ECAL";
463 LogTrace(
"TrackAssociator") <<
"getting trajectory in Preshower";
477 LogTrace(
"TrackAssociator") <<
"getting trajectory in HCAL";
487 LogTrace(
"TrackAssociator") <<
"getting trajectory in HO";
496 std::vector<GlobalPoint>*
499 std::vector<GlobalPoint>* wideTrajectory = 0;
500 switch (wideTrajectoryType) {
502 LogTrace(
"TrackAssociator") <<
"Filling ellipses in Ecal trajectory";
506 LogTrace(
"TrackAssociator") <<
"Filling ellipses in Hcal trajectory";
510 LogTrace(
"TrackAssociator") <<
"Filling ellipses in HO trajectory";
514 if(!wideTrajectory)
return 0;
516 for(std::vector<SteppingHelixStateInfo>::const_iterator state= states.begin();
517 state != states.end(); state++) {
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;
529 float r13 = -r22*r31;
538 if (!tsos.isValid()) {
539 LogTrace(
"TrackAssociator") <<
"[getWideTrajectory] TSOS not valid";
542 if (!tsos.hasError()) {
543 LogTrace(
"TrackAssociator") <<
"[getWideTrajectory] TSOS does not have Errors";
546 LocalError localErr = tsos.localError().positionError();
548 float xx = localErr.
xx();
549 float xy = localErr.
xy();
550 float yy = localErr.
yy();
552 float denom = yy - xx;
554 if(xy == 0 && denom==0) phi = M_PI_4;
555 else phi = 0.5 * atan2(2.*xy,denom);
559 float semi1 =
sqrt(rotErr.
xx());
560 float semi2 =
sqrt(rotErr.
yy());
579 wideTrajectory->push_back(state->position());
587 return wideTrajectory;
TkRotation< Scalar > RotationType
GlobalPoint toGlobal(const Point2DBase< Scalar, LocalTag > lp) const
bool fullTrajectoryFilled_
void setMaxDetectorLength(float l=2200.) dso_internal
std::pair< float, float > trajectoryDelta(TrajectorType) dso_internal
bool isValid() const
check whether the volume is properly defined
void findEcalTrajectory(const FiducialVolume &) dso_internal
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
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)
Geom::Phi< T > phi() const
void findHcalTrajectory(const FiducialVolume &) dso_internal
std::string const & category() const
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
static int position[TOTALCHAMBERS][3]
std::vector< GlobalPoint > wideEcalTrajectory_
Geom::Theta< T > theta() const
Point3DBase< Scalar, GlobalTag > PositionType
std::vector< GlobalPoint > * getWideTrajectory(const std::vector< SteppingHelixStateInfo > &, WideTrajectoryType) dso_internal
std::vector< SteppingHelixStateInfo > hoTrajectory_
std::vector< GlobalPoint > wideHOTrajectory_
const std::vector< SteppingHelixStateInfo > & getEcalTrajectory() const
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
static PlanePointer build(Args &&...args)
FreeTrajectoryState const * freeState(bool withErrors=true) const
Cos< T >::type cos(const T &t)
std::vector< SteppingHelixStateInfo > preshowerTrajectory_
SteppingHelixStateInfo getStateAtPreshower() dso_internal
virtual TrajectoryStateOnSurface propagate(const FreeTrajectoryState &, const Surface &) const
double minR(bool withTolerance=true) const
void findPreshowerTrajectory(const FiducialVolume &) dso_internal
Vector3DBase unit() const
void getTrajectory(std::vector< SteppingHelixStateInfo > &, const FiducialVolume &, int steps=4) dso_internal
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
void setStateAtIP(const SteppingHelixStateInfo &state) dso_internal
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
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)
SteppingHelixStateInfo getStateAtEcal() dso_internal
void propagate(SteppingHelixStateInfo &state, const Plane &plane) dso_internal
void setMinDetectorLength(float l=0.) dso_internal
const PositionType & position() const
double maxR(bool withTolerance=true) const
Power< A, B >::type pow(const A &a, const B &b)
static int sign(float number) dso_internal
void setMaxDetectorRadius(float r=800.) dso_internal
std::vector< SteppingHelixStateInfo > hcalTrajectory_
LocalError scale(float s) const