34 float r22 = vector.
z()/
sqrt(1-
pow(vector.x(),2));
35 float r23 = -vector.y()/
sqrt(1-
pow(vector.x(),2));
36 float r31 = vector.x();
37 float r32 = vector.y();
38 float r33 = vector.z();
39 float r11 = r22*r33-r23*
r32;
55 state = shp->propagate(state, plane);
60 edm::LogWarning(
"TrackAssociator") <<
"An exception is caught during the track propagation\n"
79 state = shp->propagate(state, cylinder);
84 edm::LogWarning(
"TrackAssociator") <<
"An exception is caught during the track propagation\n"
101 edm::LogWarning(
"TrackAssociator") <<
"Reseting all trajectories. Please call reset_trajectory() explicitely to avoid this message";
113 LogTrace(
"TrackAssociator") <<
"[propagateAll] Propagate outward from (rho, r, z, phi) (" <<
117 if (! currentState.
isValid() ) {
118 LogTrace(
"TrackAssociator") <<
"Failed to propagate the track; moving on\n";
121 LogTrace(
"TrackAssociator") <<
"\treached (rho, r, z, phi) (" <<
131 previousState=currentState2;
133 if (! currentState2.
isValid() ) {
134 LogTrace(
"TrackAssociator") <<
"Failed to propagate the track; moving on\n";
138 LogTrace(
"TrackAssociator") <<
"Error: TrackAssociator has propogated the particle past the point of closest approach to IP" << std::endl;
141 LogTrace(
"TrackAssociator") <<
"[propagateAll] Propagated inward from (rho, r, z, phi) (" <<
162 LogTrace(
"TrackAssociator") <<
"Done with the track propagation in the detector. Number of steps: " <<
fullTrajectory_.size();
179 const float matchingDistance = 1;
183 int closestPointOnLeft = 0;
187 LogTrace(
"TrackAssociator") <<
"Track didn't cross the plane:\n\tleft distance: "<<
distance(plane, leftIndex)
188 <<
"\n\tright distance: " <<
distance(plane, rightIndex);
192 while (leftIndex + 1 < rightIndex) {
193 closestPointOnLeft = int((leftIndex+rightIndex)/2);
194 float dist =
distance(plane,closestPointOnLeft);
197 if (fabs(dist)<matchingDistance) {
199 if (closestPointOnLeft>0 &&
sign(
distance(plane, closestPointOnLeft-1) ) * dist == -1)
200 closestPointOnLeft--;
206 rightIndex = closestPointOnLeft;
208 leftIndex = closestPointOnLeft;
216 LogTrace(
"TrackAssociator") <<
"closestPointOnLeft: " << closestPointOnLeft
217 <<
"\n\ttrajectory point (z,R,eta,phi): "
222 <<
"\n\tplane center (z,R,eta,phi): "
239 edm::LogWarning(
"TrackAssociator") <<
"An exception is caught during the track propagation\n"
262 std::pair<float,float>
result(0,0);
264 edm::LogWarning(
"TrackAssociator") <<
"State at IP is not known set. Cannot estimate trajectory change. " <<
265 "Trajectory change is not taken into account in matching";
268 switch (trajectoryType) {
271 edm::LogWarning(
"TrackAssociator") <<
"ECAL trajector is empty. Cannot estimate trajectory change. " <<
272 "Trajectory change is not taken into account in matching";
278 edm::LogWarning(
"TrackAssociator") <<
"HCAL trajector is empty. Cannot estimate trajectory change. " <<
279 "Trajectory change is not taken into account in matching";
285 edm::LogWarning(
"TrackAssociator") <<
"HO trajector is empty. Cannot estimate trajectory change. " <<
286 "Trajectory change is not taken into account in matching";
292 edm::LogWarning(
"TrackAssociator") <<
"Full trajector is empty. Cannot estimate trajectory change. " <<
293 "Trajectory change is not taken into account in matching";
298 edm::LogWarning(
"TrackAssociator") <<
"Unkown or not supported trajector type. Cannot estimate trajectory change. " <<
299 "Trajectory change is not taken into account in matching";
305 const double& theta2,
309 std::pair<float,float>
result(theta2 - theta1, phi2 - phi1 );
311 if ( fabs(result.second) > 2*
M_PI-fabs(result.second) ) {
313 result.second -= 2*
M_PI;
315 result.second += 2*
M_PI;
326 LogTrace(
"TrackAssociator") <<
"Trajectory is empty. Move on";
330 LogTrace(
"TrackAssociator") <<
"no trajectory is expected to be found since the fiducial volume is not valid";
335 int closestPointOnLeft = -1;
342 LogTrace(
"TrackAssociator") <<
"Track didn't cross the region (R1,R2,L1,L2): " << volume.
minR() <<
", " << volume.
maxR() <<
343 ", " << volume.
minZ() <<
", " << volume.
maxZ();
357 int firstPointInside(-1);
364 if ( dR> 0 || dZ >0 )
367 firstPointInside =
i;
368 closestPointOnLeft =
i - 1;
370 firstPointInside = 0;
371 closestPointOnLeft = 0;
376 if (closestPointOnLeft == -1)
throw cms::Exception(
"FatalError") <<
"This shouls never happen - internal logic error";
386 if (firstPointInside != closestPointOnLeft) {
396 if ( currentState.
isValid() ) trajectory.push_back(currentState);
398 LogTrace(
"TrackAssociator") <<
"Weird message\n";
400 while (currentState.
isValid() &&
405 if (! currentState.
isValid() ) {
406 LogTrace(
"TrackAssociator") <<
"Failed to propagate the track; moving on\n";
412 trajectory.push_back(currentState);
429 LogTrace(
"TrackAssociator") <<
"getting trajectory in ECAL";
435 LogTrace(
"TrackAssociator") <<
"getting trajectory in Preshower";
449 LogTrace(
"TrackAssociator") <<
"getting trajectory in HCAL";
459 LogTrace(
"TrackAssociator") <<
"getting trajectory in HO";
468 std::vector<GlobalPoint>*
471 std::vector<GlobalPoint>* wideTrajectory = 0;
472 switch (wideTrajectoryType) {
474 LogTrace(
"TrackAssociator") <<
"Filling ellipses in Ecal trajectory";
478 LogTrace(
"TrackAssociator") <<
"Filling ellipses in Hcal trajectory";
482 LogTrace(
"TrackAssociator") <<
"Filling ellipses in HO trajectory";
486 if(!wideTrajectory)
return 0;
488 for(std::vector<SteppingHelixStateInfo>::const_iterator
state= states.begin();
494 float r22 = vector.
z()/
sqrt(1-
pow(vector.x(),2));
495 float r23 = -vector.y()/
sqrt(1-
pow(vector.x(),2));
496 float r31 = vector.x();
497 float r32 = vector.y();
498 float r33 = vector.z();
499 float r11 = r22*r33-r23*
r32;
501 float r13 = -r22*r31;
510 if (!tsos.isValid()) {
511 LogTrace(
"TrackAssociator") <<
"[getWideTrajectory] TSOS not valid";
514 if (!tsos.hasError()) {
515 LogTrace(
"TrackAssociator") <<
"[getWideTrajectory] TSOS does not have Errors";
518 LocalError localErr = tsos.localError().positionError();
520 float xx = localErr.
xx();
521 float xy = localErr.
xy();
522 float yy = localErr.
yy();
524 float denom = yy - xx;
525 float phi = 0., phi_temp=0.;
526 if(xy == 0 && denom==0) phi = M_PI_4;
527 else phi = 0.5 * atan2(2.*xy,denom);
532 float semi1 =
sqrt(rotErr.
xx());
533 float semi2 =
sqrt(rotErr.
yy());
552 wideTrajectory->push_back(
state->position());
560 return wideTrajectory;
GlobalPoint toGlobal(const Point2DBase< Scalar, LocalTag > lp) const
SteppingHelixStateInfo getStateAtHO()
const std::vector< SteppingHelixStateInfo > & getHcalTrajectory()
bool fullTrajectoryFilled_
bool isValid() const
check whether the volume is properly defined
SteppingHelixStateInfo stateAtIP_
std::vector< SteppingHelixStateInfo > ecalTrajectory_
void findPreshowerTrajectory(const FiducialVolume &)
const Propagator * propagator_
void setMinDetectorLength(float l=0.)
virtual std::string explainSelf() const
void getFreeState(FreeTrajectoryState &fts) const
convert internal structure into the fts
const std::vector< SteppingHelixStateInfo > & getEcalTrajectory()
void setMinDetectorRadius(float r=0.)
double maxZ(bool withTolerance=true) const
Sin< T >::type sin(const T &t)
Geom::Phi< T > phi() const
static PlanePointer build(const PositionType &pos, const RotationType &rot, MediumProperties *mp=0)
void setPropagationStep(float s=20.)
void getTrajectory(std::vector< SteppingHelixStateInfo > &, const FiducialVolume &, int steps=4)
std::vector< GlobalPoint > wideHcalTrajectory_
void findHcalTrajectory(const FiducialVolume &)
double minZ(bool withTolerance=true) const
GlobalVector momentum() const
static int position[TOTALCHAMBERS][3]
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
FreeTrajectoryState * freeState(bool withErrors=true) const
const T & max(const T &a, const T &b)
GlobalPoint position() const
TrajectoryStateOnSurface getStateOnSurface(const Surface &surf, bool returnTangentPlane=false) const
float distance(const Plane *plane, int index)
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()
virtual TrajectoryStateOnSurface propagate(const FreeTrajectoryState &, const Surface &) const
double minR(bool withTolerance=true) const
Vector3DBase unit() const
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 &)
static CylinderPointer build(const PositionType &pos, const RotationType &rot, Scalar radius, MediumProperties *mp=0)
const std::vector< SteppingHelixStateInfo > & getHOTrajectory()
SteppingHelixStateInfo getStateAtEcal()
void findHOTrajectory(const FiducialVolume &)
Point2DBase< float, LocalTag > Local2DPoint
const std::vector< SteppingHelixStateInfo > & getPreshowerTrajectory()
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)
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_
Basic2DVector< T > xy() const
void setMaxDetectorRadius(float r=800.)
LocalError scale(float s) const
std::string category() const