123 float regOffset =
region.origin().perp();
131 std::vector<NodeInfo> layerTree;
132 std::vector<unsigned int> foundNodes;
133 foundNodes.reserve(100);
136 float rzError[nThirdLayers];
139 const float maxphi =
M_PI + maxDelphi, minphi = -maxphi;
140 const float safePhi =
M_PI - maxDelphi;
149 for (
int il = 0; il < nThirdLayers; ++il) {
150 auto const&
hits = *thirdHitMap[il];
155 corrections[il].init(
region.ptMin(),
158 *thirdLayerDetLayer[il],
165 float minv = 999999.0f, maxv = -minv;
167 for (
unsigned int i = 0;
i !=
hits.size(); ++
i) {
173 float myerr =
hits.dv[
i];
175 layerTree.emplace_back(
i,
angle,
v);
179 else if (
angle < -safePhi)
182 KDTreeBox phiZ(minphi, maxphi, minv - 0.01
f, maxv + 0.01
f);
184 hitTree[il].build(layerTree, phiZ);
185 rzError[il] = maxErr;
189 float imppar =
region.originRBound();
190 float imppartmp =
region.originRBound() +
region.origin().perp();
193 for (std::size_t ip = 0; ip !=
doublets.size(); ip++) {
203 auto toPos = std::signbit(zo - zi);
223 for (
int il = 0; il != nThirdLayers; ++il) {
225 auto barrelLayer =
layer->isBarrel();
227 if ((!barrelLayer) & (toPos != std::signbit(
layer->position().z())))
230 if (hitTree[il].
empty())
233 auto const&
hits = *thirdHitMap[il];
239 auto& predictionRZ = preds[il];
241 predictionRZ.initPropagator(&
line);
242 Range rzRange = predictionRZ();
252 radius = predictionRZ.detRange();
255 Range(
max(rzRange.min(), predictionRZ.detSize().min()),
min(rzRange.max(), predictionRZ.detSize().max()));
262 auto rPhi1 = predictionRPhitmp(
radius.max());
263 bool ok1 = !rPhi1.empty();
266 rPhi1.first /=
radius.max();
267 rPhi1.second /=
radius.max();
269 auto rPhi2 = predictionRPhitmp(
radius.min());
270 bool ok2 = !rPhi2.empty();
273 rPhi2.first /=
radius.min();
274 rPhi2.second /=
radius.min();
279 rPhi1.second =
proxim(rPhi1.second, rPhi1.first);
281 rPhi2.first =
proxim(rPhi2.first, rPhi1.first);
282 rPhi2.second =
proxim(rPhi2.second, rPhi1.first);
283 phiRange = rPhi1.sum(rPhi2);
288 rPhi2.second =
proxim(rPhi2.second, rPhi2.first);
294 constexpr
float nSigmaRZ = 3.46410161514f;
298 float prmin = phiRange.min(), prmax = phiRange.max();
300 if (prmax - prmin > maxDelphi) {
301 auto prm = phiRange.mean();
302 prmin = prm - 0.5f * maxDelphi;
303 prmax = prm + 0.5f * maxDelphi;
307 Range regMax = predictionRZ.detRange();
308 Range regMin = predictionRZ(regMax.min() - regOffset);
309 regMax = predictionRZ(regMax.max() + regOffset);
312 if (regMax.min() < regMin.min()) {
313 swap(regMax, regMin);
316 hitTree[il].search(phiZ, foundNodes);
320 rzRange.min() - regOffset -
nSigmaRZ * rzError[il],
321 rzRange.max() + regOffset +
nSigmaRZ * rzError[il]);
322 hitTree[il].search(phiZ, foundNodes);
328 for (
auto KDdata : foundNodes) {
331 if (tripletLastLayerIndex)
332 tripletLastLayerIndex->clear();
333 edm::LogError(
"TooManyTriplets") <<
" number of triples exceeds maximum. no triplets produced.";
337 float p3_u =
hits.u[KDdata];
338 float p3_v =
hits.v[KDdata];
339 float p3_phi =
hits.lphi[KDdata];
344 Range allowed = predictionRZ(p3_u);
347 Range hitRange(p3_v - vErr, p3_v + vErr);
349 if (crossingRange.empty())
352 float ir = 1.f /
hits.rv(KDdata);
354 constexpr
float maxPhiErr = 0.5 *
M_PI;
356 phiErr =
std::min(maxPhiErr, phiErr);
358 for (
int icharge = -1; icharge <= 1; icharge += 2) {
359 Range rangeRPhi = predictionRPhi(
hits.rv(KDdata), icharge);
360 if (rangeRPhi.first > rangeRPhi.second)
363 if (
checkPhiInRange(p3_phi, rangeRPhi.first * ir - phiErr, rangeRPhi.second * ir + phiErr, maxPhiErr)) {
368 result.push_back(hittriplet);
370 if (tripletLastLayerIndex)
371 tripletLastLayerIndex->push_back(il);
373 LogDebug(
"RejectedTriplet") <<
"rejected triplet from comparitor ";
380 LogDebug(
"RejectedTriplet") <<
"rejected triplet from second phicheck " << p3_phi;
void initLayer(const DetLayer *layer)
PixelRecoRange< float > Range
constexpr T normalizedPhi(T phi)
const float extraHitRZtolerance
Log< level::Error, false > LogError
void swap(Association< C > &lhs, Association< C > &rhs)
T curvature(T InversePt, const MagneticField &field)
const unsigned int theMaxElement
std::unique_ptr< SeedComparitor > theComparitor
constexpr T proxim(T b, T a)
constexpr std::array< uint8_t, layerIndexSize > layer
edm::ESGetToken< MultipleScatteringParametrisationMaker, TrackerMultipleScatteringRecord > msmakerToken_
constexpr double nSigmaRZ
bool getData(T &iHolder) const
constexpr float nSigmaPhi
SeedingHitSet::ConstRecHitPointer Hit
BaseTrackerRecHit const * Hit
const bool useFixedPreFiltering
PixelRecoRange< T > intersection(const PixelRecoRange< T > &r) const
constexpr bool checkPhiInRange(T phi, T phi1, T phi2, float maxDphi=float(M_PI))
#define declareDynArray(T, n, x)
void initTolerance(float tolerance)
const edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > fieldToken_
const float extraHitRPhitolerance
T angle(T x1, T y1, T z1, T x2, T y2, T z2)