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 shp->propagate(state, plane, state);
88 edm::LogWarning(
"TrackAssociator") <<
"An exception is caught during the track propagation\n" 107 shp->propagate(state, cylinder,state);
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 =
nullptr;
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 nullptr;
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;
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
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)
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_
static CylinderPointer build(const PositionType &pos, const RotationType &rot, Scalar radius, Bounds *bounds=0)
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_
std::vector< GlobalPoint > * getWideTrajectory(const std::vector< SteppingHelixStateInfo > &, WideTrajectoryType)
SteppingHelixStateInfo getOuterState()
double minR(bool withTolerance=true) const
Vector3DBase unit() 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)
std::deque< SteppingHelixStateInfo > fullTrajectory_
void findEcalTrajectory(const FiducialVolume &)
Point3DBase< float, GlobalTag > PositionType
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
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)
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