122 float regOffset =
region.origin().perp();
130 std::vector<NodeInfo> layerTree;
131 std::vector<unsigned int> foundNodes;
132 foundNodes.reserve(100);
135 float rzError[nThirdLayers];
138 const float maxphi =
M_PI + maxDelphi, minphi = -maxphi;
139 const float safePhi =
M_PI - maxDelphi;
142 for (
int il = 0; il < nThirdLayers; ++il) {
143 auto const&
hits = *thirdHitMap[il];
148 corrections[il].init(es,
152 *thirdLayerDetLayer[il],
157 float minv = 999999.0f, maxv = -minv;
159 for (
unsigned int i = 0;
i !=
hits.size(); ++
i) {
165 float myerr =
hits.dv[
i];
167 layerTree.emplace_back(
i,
angle,
v);
171 else if (
angle < -safePhi)
174 KDTreeBox phiZ(minphi, maxphi, minv - 0.01
f, maxv + 0.01
f);
176 hitTree[il].build(layerTree, phiZ);
177 rzError[il] = maxErr;
181 float imppar =
region.originRBound();
182 float imppartmp =
region.originRBound() +
region.origin().perp();
185 for (std::size_t ip = 0; ip !=
doublets.size(); ip++) {
195 auto toPos = std::signbit(zo - zi);
215 for (
int il = 0; il != nThirdLayers; ++il) {
216 const DetLayer* layer = thirdLayerDetLayer[il];
217 auto barrelLayer = layer->
isBarrel();
219 if ((!barrelLayer) & (toPos != std::signbit(layer->
position().
z())))
222 if (hitTree[il].
empty())
225 auto const&
hits = *thirdHitMap[il];
231 auto& predictionRZ = preds[il];
233 predictionRZ.initPropagator(&
line);
234 Range rzRange = predictionRZ();
244 radius = predictionRZ.detRange();
247 Range(
max(rzRange.min(), predictionRZ.detSize().min()),
min(rzRange.max(), predictionRZ.detSize().max()));
254 auto rPhi1 = predictionRPhitmp(
radius.max());
255 bool ok1 = !rPhi1.empty();
258 rPhi1.first /=
radius.max();
259 rPhi1.second /=
radius.max();
261 auto rPhi2 = predictionRPhitmp(
radius.min());
262 bool ok2 = !rPhi2.empty();
265 rPhi2.first /=
radius.min();
266 rPhi2.second /=
radius.min();
271 rPhi1.second =
proxim(rPhi1.second, rPhi1.first);
273 rPhi2.first =
proxim(rPhi2.first, rPhi1.first);
274 rPhi2.second =
proxim(rPhi2.second, rPhi1.first);
275 phiRange = rPhi1.sum(rPhi2);
280 rPhi2.second =
proxim(rPhi2.second, rPhi2.first);
286 constexpr
float nSigmaRZ = 3.46410161514f;
290 float prmin = phiRange.min(), prmax = phiRange.max();
292 if (prmax - prmin > maxDelphi) {
293 auto prm = phiRange.mean();
294 prmin = prm - 0.5f * maxDelphi;
295 prmax = prm + 0.5f * maxDelphi;
299 Range regMax = predictionRZ.detRange();
300 Range regMin = predictionRZ(regMax.min() - regOffset);
301 regMax = predictionRZ(regMax.max() + regOffset);
304 if (regMax.min() < regMin.min()) {
305 swap(regMax, regMin);
308 hitTree[il].search(phiZ, foundNodes);
312 rzRange.min() - regOffset -
nSigmaRZ * rzError[il],
313 rzRange.max() + regOffset +
nSigmaRZ * rzError[il]);
314 hitTree[il].search(phiZ, foundNodes);
320 for (
auto KDdata : foundNodes) {
323 if (tripletLastLayerIndex)
324 tripletLastLayerIndex->clear();
325 edm::LogError(
"TooManyTriplets") <<
" number of triples exceeds maximum. no triplets produced.";
329 float p3_u =
hits.u[KDdata];
330 float p3_v =
hits.v[KDdata];
331 float p3_phi =
hits.lphi[KDdata];
336 Range allowed = predictionRZ(p3_u);
339 Range hitRange(p3_v - vErr, p3_v + vErr);
341 if (crossingRange.empty())
344 float ir = 1.f /
hits.rv(KDdata);
346 constexpr
float maxPhiErr = 0.5 *
M_PI;
348 phiErr =
std::min(maxPhiErr, phiErr);
350 for (
int icharge = -1; icharge <= 1; icharge += 2) {
351 Range rangeRPhi = predictionRPhi(
hits.rv(KDdata), icharge);
352 if (rangeRPhi.first > rangeRPhi.second)
355 if (
checkPhiInRange(p3_phi, rangeRPhi.first * ir - phiErr, rangeRPhi.second * ir + phiErr, maxPhiErr)) {
360 result.push_back(hittriplet);
362 if (tripletLastLayerIndex)
363 tripletLastLayerIndex->push_back(il);
365 LogDebug(
"RejectedTriplet") <<
"rejected triplet from comparitor ";
372 LogDebug(
"RejectedTriplet") <<
"rejected triplet from second phicheck " << p3_phi;