6 const double toleranceInSigmas,
10 const std::pair<const_iterator,const_iterator>& points =
getDetIdPoints(
id);
12 bool xLess(
false), xIn(
false), xMore(
false);
13 bool yLess(
false), yIn(
false), yMore(
false);
14 bool zLess(
false), zIn(
false), zMore(
false);
15 double xMin(point1.
x()), xMax(point2.
x());
16 double yMin(point1.
y()), yMax(point2.
y());
17 double zMin(point1.
z()), zMax(point2.
z());
21 for ( std::vector<GlobalPoint>::const_iterator it = points.first;
22 it != points.second; ++it ){
48 if ( ( (xLess && !xIn && !xMore) || (!xLess && !xIn && xMore) ) ||
49 ( (yLess && !yIn && !yMore) || (!yLess && !yIn && yMore) ) ||
50 ( (zLess && !zIn && !zMore) || (!zLess && !zIn && zMore) ) )
return false;
55 float r22 = vector.
z()/
sqrt(1-
pow(vector.
x(),2));
56 float r23 = -vector.
y()/
sqrt(1-
pow(vector.
x(),2));
57 float r31 = vector.
x();
58 float r32 = vector.
y();
59 float r33 = vector.
z();
60 float r11 = r22*r33-r23*
r32;
68 double absoluteTolerance = -1;
69 if ( toleranceInSigmas>0 && initialState ){
73 localErr.
scale(toleranceInSigmas);
74 float xx = localErr.
xx();
75 float xy = localErr.
xy();
76 float yy = localErr.
yy();
78 float denom = yy - xx;
80 if(xy == 0 && denom==0) phi = M_PI_4;
81 else phi = 0.5 * atan2(2.*xy,denom);
85 float semi1 =
sqrt(rotErr.
xx());
86 float semi2 =
sqrt(rotErr.
yy());
87 absoluteTolerance =
std::max(semi1,semi2);
92 double trajectorySegmentLength = (point2-point1).
mag();
97 bool allBehind =
true;
98 bool allTooFar =
true;
99 std::vector<GlobalPoint>::const_iterator
p = points.first;
100 if ( p == points.second ) {
101 edm::LogWarning(
"TrackAssociator") <<
"calo geometry for element " <<
id.rawId() <<
"is empty. Ignored";
105 double minPhi = localPoint.
phi();
106 double maxPhi = localPoint.
phi();
107 if ( localPoint.
z() < 0 )
111 if ( localPoint.
z() < trajectorySegmentLength ) allTooFar =
false;
114 for (; p!=points.second; ++
p){
115 localPoint = plane->toLocal(*p);
116 double localPhi = localPoint.
phi();
117 if ( localPoint.
z() < 0 )
121 if ( localPoint.
z() < trajectorySegmentLength ) allTooFar =
false;
123 if ( localPhi >= minPhi && localPhi <= maxPhi )
continue;
124 if ( localPhi+2*
M_PI >= minPhi && localPhi+2*
M_PI <= maxPhi )
continue;
125 if ( localPhi-2*
M_PI >= minPhi && localPhi-2*
M_PI <= maxPhi )
continue;
127 if ( localPhi > maxPhi ){
128 double delta1 = fabs(localPhi-maxPhi);
129 double delta2 = fabs(localPhi-2*
M_PI-minPhi);
130 if ( delta1 < delta2 )
133 minPhi = localPhi-2*
M_PI;
136 if ( localPhi < minPhi ){
137 double delta1 = fabs(localPhi-minPhi);
138 double delta2 = fabs(localPhi+2*
M_PI-maxPhi);
139 if ( delta1 < delta2 )
142 maxPhi = localPhi+2*
M_PI;
145 cms::Exception(
"FatalError") <<
"Algorithm logic error - this should never happen. Problems with trajectory-volume matching.";
147 if ( allBehind )
return false;
148 if ( allTooFar )
return false;
149 if ( fabs(maxPhi-minPhi)>
M_PI )
return true;
153 if (absoluteTolerance < 0 )
return false;
154 double distanceToClosestLineSegment = 1e9;
155 std::vector<GlobalPoint>::const_iterator
i,
j;
156 for ( i = points.first; i != points.second; ++i )
157 for ( j = i+1; j != points.second; ++
j )
163 double side1squared =
p1.perp2();
164 double side2squared =
p2.perp2();
165 double side3squared = (
p2.x()-
p1.x())*(
p2.x()-
p1.x()) + (
p2.y()-
p1.y())*(
p2.y()-
p1.y());
166 double area = fabs(
p1.x()*
p2.y()-
p2.x()*
p1.y())/2;
169 if ( side1squared + side2squared > side3squared &&
170 side2squared + side3squared > side1squared &&
171 side1squared + side3squared > side1squared )
173 double h(2*area/
sqrt(side3squared));
174 if ( h < distanceToClosestLineSegment ) distanceToClosestLineSegment =
h;
178 if (
sqrt(side1squared) < distanceToClosestLineSegment ) distanceToClosestLineSegment =
sqrt(side1squared);
179 if (
sqrt(side2squared) < distanceToClosestLineSegment ) distanceToClosestLineSegment =
sqrt(side2squared);
182 if ( distanceToClosestLineSegment < absoluteTolerance )
return true;
205 if ( subDectorIndex!=0 )
cms::Exception(
"FatalError") <<
"Calo sub-dectors are all handle as one sub-system, but subDetectorIndex is not zero.\n";
209 std::pair<DetIdAssociator::const_iterator, DetIdAssociator::const_iterator>
214 LogDebug(
"TrackAssociator") <<
"Cannot find sub-detector geometry for " <<
id.rawId() <<
"\n";
215 return std::pair<const_iterator,const_iterator>(
dummy_.end(),
dummy_.end());
219 LogDebug(
"TrackAssociator") <<
"Cannot find CaloCell geometry for " <<
id.rawId() <<
"\n";
220 return std::pair<const_iterator,const_iterator>(
dummy_.end(),
dummy_.end());
223 return std::pair<const_iterator,const_iterator>( cor.begin(), cor.end() ) ;
const CaloSubdetectorGeometry * getSubdetectorGeometry(const DetId &id) const
access the subdetector geometry for the given subdetector directly
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
Geom::Phi< T > phi() const
LocalError positionError() const
virtual const CaloCellGeometry * getGeometry(const DetId &id) const
Get the cell geometry of a given detector id. Should return false if not found.
virtual GlobalPoint getPosition(const DetId &id) const
const DepRecordT & getRecord() const
const T & max(const T &a, const T &b)
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
TrajectoryStateOnSurface getStateOnSurface(const Surface &surf, bool returnTangentPlane=false) const
static PlanePointer build(Args &&...args)
virtual void check_setup() const
const LocalTrajectoryError & localError() const
virtual std::pair< const_iterator, const_iterator > getDetIdPoints(const DetId &id) const
std::vector< GlobalPoint > dummy_
virtual void check_setup() const
const CaloGeometry * geometry_
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
virtual bool crossedElement(const GlobalPoint &, const GlobalPoint &, const DetId &id, const double tolerance=-1, const SteppingHelixStateInfo *=0) const
T const * product() const
std::vector< DetId > getValidDetIds() const
Get the list of all valid detector ids.
virtual void setGeometry(const CaloGeometry *ptr)
LocalError rotate(float x, float y) const
Return a new LocalError, rotated by an angle defined by the direction (x,y)
const GlobalPoint & getPosition() const
Returns the position of reference for this cell.
Power< A, B >::type pow(const A &a, const B &b)
virtual const CornersVec & getCorners() const =0
Returns the corner points of this cell's volume.
LocalError scale(float s) const
virtual const std::vector< DetId > & getValidDetIds(unsigned int subDetectorIndex) const