6 const double toleranceInSigmas,
8 std::vector<GlobalPoint> pointBuffer;
9 const std::pair<const_iterator, const_iterator>& points =
getDetIdPoints(
id, pointBuffer);
11 bool xLess(
false), xIn(
false), xMore(
false);
12 bool yLess(
false), yIn(
false), yMore(
false);
13 bool zLess(
false), zIn(
false), zMore(
false);
14 double xMin(point1.
x()), xMax(point2.
x());
16 double zMin(point1.
z()), zMax(point2.
z());
23 for (std::vector<GlobalPoint>::const_iterator it = points.first; it != points.second; ++it) {
49 if (((xLess && !xIn && !xMore) || (!xLess && !xIn && xMore)) ||
50 ((yLess && !yIn && !yMore) || (!yLess && !yIn && yMore)) ||
51 ((zLess && !zIn && !zMore) || (!zLess && !zIn && zMore)))
57 float r22 = vector.
z() /
sqrt(1 -
pow(vector.
x(), 2));
58 float r23 = -vector.
y() /
sqrt(1 -
pow(vector.
x(), 2));
59 float r31 = vector.
x();
60 float r32 = vector.
y();
61 float r33 = vector.
z();
62 float r11 = r22 * r33 - r23 *
r32;
63 float r12 = r23 * r31;
64 float r13 = -r22 * r31;
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)
83 phi = 0.5 * atan2(2. * xy, denom);
87 float semi1 =
sqrt(rotErr.
xx());
88 float semi2 =
sqrt(rotErr.
yy());
89 absoluteTolerance =
std::max(semi1, semi2);
94 double trajectorySegmentLength = (point2 - point1).
mag();
99 bool allBehind =
true;
100 bool allTooFar =
true;
101 std::vector<GlobalPoint>::const_iterator
p = points.first;
102 if (p == points.second) {
103 edm::LogWarning(
"TrackAssociator") <<
"calo geometry for element " <<
id.rawId() <<
"is empty. Ignored";
109 if (localPoint.
z() < 0)
113 if (localPoint.
z() < trajectorySegmentLength)
117 for (; p != points.second; ++
p) {
118 localPoint = plane->toLocal(*p);
119 double localPhi = localPoint.
phi();
120 if (localPoint.
z() < 0)
124 if (localPoint.
z() < trajectorySegmentLength)
127 if (localPhi >= minPhi && localPhi <= maxPhi)
129 if (localPhi + 2 *
M_PI >= minPhi && localPhi + 2 *
M_PI <= maxPhi)
131 if (localPhi - 2 *
M_PI >= minPhi && localPhi - 2 *
M_PI <= maxPhi)
134 if (localPhi > maxPhi) {
135 double delta1 = fabs(localPhi - maxPhi);
136 double delta2 = fabs(localPhi - 2 *
M_PI - minPhi);
140 minPhi = localPhi - 2 *
M_PI;
143 if (localPhi < minPhi) {
144 double delta1 = fabs(localPhi - minPhi);
145 double delta2 = fabs(localPhi + 2 *
M_PI - maxPhi);
149 maxPhi = localPhi + 2 *
M_PI;
153 <<
"Algorithm logic error - this should never happen. Problems with trajectory-volume matching.";
159 if (fabs(maxPhi - minPhi) >
M_PI)
164 if (absoluteTolerance < 0)
166 double distanceToClosestLineSegment = 1e9;
167 std::vector<GlobalPoint>::const_iterator
i,
j;
168 for (i = points.first; i != points.second; ++i)
169 for (j = i + 1; j != points.second; ++
j) {
174 double side1squared =
p1.perp2();
175 double side2squared =
p2.perp2();
176 double side3squared = (
p2.x() -
p1.x()) * (
p2.x() -
p1.x()) + (
p2.y() -
p1.y()) * (
p2.y() -
p1.y());
177 double area = fabs(
p1.x() *
p2.y() -
p2.x() *
p1.y()) / 2;
180 if (side1squared + side2squared > side3squared && side2squared + side3squared > side1squared &&
181 side1squared + side3squared > side1squared) {
182 double h(2 * area /
sqrt(side3squared));
183 if (h < distanceToClosestLineSegment)
184 distanceToClosestLineSegment =
h;
186 if (
sqrt(side1squared) < distanceToClosestLineSegment)
187 distanceToClosestLineSegment =
sqrt(side1squared);
188 if (
sqrt(side2squared) < distanceToClosestLineSegment)
189 distanceToClosestLineSegment =
sqrt(side2squared);
192 if (distanceToClosestLineSegment < absoluteTolerance)
208 if (subDectorIndex != 0)
210 <<
"Calo sub-dectors are all handle as one sub-system, but subDetectorIndex is not zero.\n";
215 const DetId&
id, std::vector<GlobalPoint>& points)
const {
218 LogDebug(
"TrackAssociator") <<
"Cannot find sub-detector geometry for " <<
id.rawId() <<
"\n";
219 return std::pair<const_iterator, const_iterator>(
dummy_.end(),
dummy_.end());
223 LogDebug(
"TrackAssociator") <<
"Cannot find CaloCell geometry for " <<
id.rawId() <<
"\n";
224 return std::pair<const_iterator, const_iterator>(
dummy_.end(),
dummy_.end());
227 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
constexpr SubDetector subDetGeom[21]
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
Geom::Phi< T > phi() const
LocalError positionError() const
GlobalPoint getPosition(const DetId &id) const override
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
TrajectoryStateOnSurface getStateOnSurface(const Surface &surf, bool returnTangentPlane=false) const
static PlanePointer build(Args &&...args)
void check_setup() const override
virtual void check_setup() const
const LocalTrajectoryError & localError() const
std::vector< GlobalPoint > dummy_
const CaloGeometry * geometry_
Basic2DVector< T > xy() const
virtual std::shared_ptr< const CaloCellGeometry > getGeometry(const DetId &id) const
Get the cell geometry of a given detector id. Should return false if not found.
void getValidDetIds(unsigned int subDetectorIndex, std::vector< DetId > &) const override
std::vector< DetId > getValidDetIds() const
Get the list of all valid detector ids.
std::pair< const_iterator, const_iterator > getDetIdPoints(const DetId &id, std::vector< GlobalPoint > &points) const override
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)
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
bool crossedElement(const GlobalPoint &, const GlobalPoint &, const DetId &id, const double tolerance=-1, const SteppingHelixStateInfo *=nullptr) const override
Power< A, B >::type pow(const A &a, const B &b)
Basic3DVector unit() const
LocalError scale(float s) const