6 const double toleranceInSigmas,
10 std::vector<GlobalPoint> pointBuffer;
13 bool xLess(
false), xIn(
false), xMore(
false);
14 bool yLess(
false), yIn(
false), yMore(
false);
15 bool zLess(
false), zIn(
false), zMore(
false);
22 for ( std::vector<GlobalPoint>::const_iterator it = points.first;
23 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) ) )
return false;
56 float r22 = vector.
z()/
sqrt(1-
pow(vector.
x(),2));
57 float r23 = -vector.
y()/
sqrt(1-
pow(vector.
x(),2));
58 float r31 = vector.
x();
59 float r32 = vector.
y();
60 float r33 = vector.
z();
61 float r11 = r22*r33-r23*
r32;
69 double absoluteTolerance = -1;
70 if ( toleranceInSigmas>0 && initialState ){
74 localErr.
scale(toleranceInSigmas);
75 float xx = localErr.
xx();
76 float xy = localErr.
xy();
77 float yy = localErr.
yy();
79 float denom = yy -
xx;
81 if(xy == 0 && denom==0) phi = M_PI_4;
82 else phi = 0.5 * atan2(2.*xy,denom);
86 float semi1 =
sqrt(rotErr.
xx());
87 float semi2 =
sqrt(rotErr.
yy());
88 absoluteTolerance =
std::max(semi1,semi2);
93 double trajectorySegmentLength = (point2-point1).
mag();
98 bool allBehind =
true;
99 bool allTooFar =
true;
100 std::vector<GlobalPoint>::const_iterator
p = points.first;
101 if ( p == points.second ) {
102 edm::LogWarning(
"TrackAssociator") <<
"calo geometry for element " <<
id.rawId() <<
"is empty. Ignored";
108 if ( localPoint.
z() < 0 )
112 if ( localPoint.
z() < trajectorySegmentLength ) allTooFar =
false;
115 for (; p!=points.second; ++
p){
116 localPoint = plane->toLocal(*p);
117 double localPhi = localPoint.
phi();
118 if ( localPoint.
z() < 0 )
122 if ( localPoint.
z() < trajectorySegmentLength ) allTooFar =
false;
124 if ( localPhi >= minPhi && localPhi <= maxPhi )
continue;
125 if ( localPhi+2*
M_PI >= minPhi && localPhi+2*
M_PI <= maxPhi )
continue;
126 if ( localPhi-2*
M_PI >= minPhi && localPhi-2*
M_PI <= maxPhi )
continue;
128 if ( localPhi > maxPhi ){
129 double delta1 = fabs(localPhi-maxPhi);
130 double delta2 = fabs(localPhi-2*
M_PI-minPhi);
131 if ( delta1 < delta2 )
134 minPhi = localPhi-2*
M_PI;
137 if ( localPhi < minPhi ){
138 double delta1 = fabs(localPhi-minPhi);
139 double delta2 = fabs(localPhi+2*
M_PI-maxPhi);
140 if ( delta1 < delta2 )
143 maxPhi = localPhi+2*
M_PI;
146 cms::Exception(
"FatalError") <<
"Algorithm logic error - this should never happen. Problems with trajectory-volume matching.";
148 if ( allBehind )
return false;
149 if ( allTooFar )
return false;
150 if ( fabs(maxPhi-minPhi)>
M_PI )
return true;
154 if (absoluteTolerance < 0 )
return false;
155 double distanceToClosestLineSegment = 1e9;
156 std::vector<GlobalPoint>::const_iterator
i,j;
157 for ( i = points.first; i != points.second; ++i )
158 for ( j = i+1; j != points.second; ++j )
164 double side1squared =
p1.perp2();
165 double side2squared =
p2.perp2();
166 double side3squared = (
p2.x()-
p1.x())*(
p2.x()-
p1.x()) + (
p2.y()-
p1.y())*(
p2.y()-
p1.y());
167 double area = fabs(
p1.x()*
p2.y()-
p2.x()*
p1.y())/2;
170 if ( side1squared + side2squared > side3squared &&
171 side2squared + side3squared > side1squared &&
172 side1squared + side3squared > side1squared )
174 double h(2*area/
sqrt(side3squared));
175 if ( h < distanceToClosestLineSegment ) distanceToClosestLineSegment =
h;
179 if (
sqrt(side1squared) < distanceToClosestLineSegment ) distanceToClosestLineSegment =
sqrt(side1squared);
180 if (
sqrt(side2squared) < distanceToClosestLineSegment ) distanceToClosestLineSegment =
sqrt(side2squared);
183 if ( distanceToClosestLineSegment < absoluteTolerance )
return true;
206 if ( subDectorIndex!=0 )
cms::Exception(
"FatalError") <<
"Calo sub-dectors are all handle as one sub-system, but subDetectorIndex is not zero.\n";
210 std::pair<DetIdAssociator::const_iterator, DetIdAssociator::const_iterator>
215 LogDebug(
"TrackAssociator") <<
"Cannot find sub-detector geometry for " <<
id.rawId() <<
"\n";
216 return std::pair<const_iterator,const_iterator>(
dummy_.end(),
dummy_.end());
220 LogDebug(
"TrackAssociator") <<
"Cannot find CaloCell geometry for " <<
id.rawId() <<
"\n";
221 return std::pair<const_iterator,const_iterator>(
dummy_.end(),
dummy_.end());
224 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
virtual void check_setup() const override
FWCore Framework interface EventSetupRecordImplementation 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 override
virtual void getValidDetIds(unsigned int subDetectorIndex, std::vector< DetId > &) const override
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.
const DepRecordT & getRecord() const
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
SubDetector subDetGeom[21]
const LocalTrajectoryError & localError() const
virtual GlobalPoint getPosition(const DetId &id) const override
std::vector< GlobalPoint > dummy_
const CaloGeometry * geometry_
virtual std::pair< const_iterator, const_iterator > getDetIdPoints(const DetId &id, std::vector< GlobalPoint > &points) const override
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.
T const * product() const
Power< A, B >::type pow(const A &a, const B &b)
minPhi
set NPt=0 and the vector of double for variable size binning
LocalError scale(float s) const