144 std::vector<NodeInfo> layerTree;
145 std::vector<unsigned int> foundNodes;
146 foundNodes.reserve(100);
151 float rzError[nThirdLayers];
154 const float maxphi =
M_PI + maxDelphi, minphi = -maxphi;
155 const float safePhi =
M_PI - maxDelphi;
157 for (
int il = 0; il < nThirdLayers; il++) {
158 auto const&
hits = *thirdHitMap[il];
161 LayerRZPredictions& predRZ = mapPred[il];
162 predRZ.line.initLayer(
layer);
163 predRZ.helix1.initLayer(
layer);
164 predRZ.helix2.initLayer(
layer);
169 predRZ.correction.init(es,
173 *thirdLayerDetLayer[il],
178 float minv = 999999.0;
179 float maxv = -999999.0;
181 for (
unsigned int i = 0;
i !=
hits.size(); ++
i) {
187 float myerr =
hits.dv[
i];
189 layerTree.emplace_back(
i,
angle,
v);
193 else if (
angle < -safePhi)
196 KDTreeBox phiZ(minphi, maxphi, minv - 0.01
f, maxv + 0.01
f);
198 hitTree[il].build(layerTree, phiZ);
199 rzError[il] = maxErr;
204 for (std::size_t ip = 0; ip !=
doublets.size(); ip++) {
216 auto toPos = std::signbit(zo - zi);
222 Range generalCurvature = predictionRPhi.curvature(
region.originRBound());
223 if (!intersect(generalCurvature,
Range(-curv, curv)))
226 for (
int il = 0; il < nThirdLayers; il++) {
227 if (hitTree[il].
empty())
230 bool barrelLayer =
layer->isBarrel();
232 if ((!barrelLayer) & (toPos != std::signbit(
layer->position().z())))
237 LayerRZPredictions& predRZ = mapPred[il];
238 predRZ.line.initPropagator(&
line);
264 Range z3s = predRZ.line.detRange();
274 predRZ.helix1.initPropagator(&helix1);
275 predRZ.helix2.initPropagator(&helix2);
277 Range rzRanges[2] = {predRZ.helix1(), predRZ.helix2()};
278 predRZ.helix1.initPropagator(
nullptr);
279 predRZ.helix2.initPropagator(
nullptr);
287 Range rzLineRange = predRZ.line();
288 rzRange.first =
std::min(rzRange.first, rzLineRange.first);
289 rzRange.second =
std::max(rzRange.second, rzLineRange.second);
292 rzRange = predRZ.line();
295 if (rzRange.first >= rzRange.second)
308 radius = predRZ.line.detRange();
309 if (!intersect(rzRange, predRZ.line.detSize()))
313 if (!intersect(
radius, predRZ.line.detSize()))
328 phi22 =
proxim(phi22, phi12);
329 phiRange =
Range(phi12, phi22);
331 auto rmean =
radius.mean();
332 phiRange.first *= rmean;
333 phiRange.second *= rmean;
335 phiRange.first /= rmean;
336 phiRange.second /= rmean;
340 float prmin = phiRange.min(), prmax = phiRange.max();
342 if (prmax - prmin > maxDelphi) {
343 auto prm = phiRange.mean();
344 prmin = prm - 0.5f * maxDelphi;
345 prmax = prm + 0.5f * maxDelphi;
349 Range regMax = predRZ.line.detRange();
350 Range regMin = predRZ.line(regMax.min());
351 regMax = predRZ.line(regMax.max());
354 if (regMax.min() < regMin.min()) {
358 hitTree[il].search(phiZ, foundNodes);
361 hitTree[il].search(phiZ, foundNodes);
367 auto const&
hits = *thirdHitMap[il];
368 for (
auto KDdata : foundNodes) {
370 double p3_r =
p3.perp();
371 double p3_z =
p3.z();
372 float p3_phi =
hits.phi(KDdata);
377 float ir = 1.f / p3_r;
379 constexpr
float maxPhiErr = 0.5 *
M_PI;
381 phiErr =
std::min(maxPhiErr, phiErr);
382 if (!
checkPhiInRange(p3_phi, rangeRPhi.first * ir - phiErr, rangeRPhi.second * ir + phiErr, maxPhiErr))
387 auto curv_ = predictionRPhi.curvature(thc);
388 double p2_r = point2.
r();
389 double p2_z = point2.z();
392 l3rzFixup(predictionRPhi, curv_, *
hits.theHits[KDdata].hit(), p3_r, p3_z, tTopo);
396 HelixRZ updatedHelix(&predictionRPhi, gp1.z(), p2_z, curv_);
397 rangeRZ = predRZ.helix1(barrelLayer ? p3_r : p3_z, updatedHelix);
399 float tIP = predictionRPhi.transverseIP(thc);
402 rangeRZ = predRZ.line(barrelLayer ? p3_r : p3_z,
line);
408 rangeRZ.first -=
err, rangeRZ.second +=
err;
410 if (!rangeRZ.inside(barrelLayer ? p3_z : p3_r))
415 if (tripletLastLayerIndex)
416 tripletLastLayerIndex->clear();
417 edm::LogError(
"TooManyTriplets") <<
" number of triples exceed maximum. no triplets produced.";
423 if (tripletLastLayerIndex)
424 tripletLastLayerIndex->push_back(il);