35 struct LayerRZPredictions {
43 constexpr
double nSigmaRZ = 3.4641016151377544;
52 useMScat(
cfg.getParameter<
bool>(
"useMultScattering")),
53 useBend(
cfg.getParameter<
bool>(
"useBending")),
68 desc.add<
double>(
"extraHitRPhitolerance", 0);
69 desc.add<
double>(
"extraHitRZtolerance", 0);
70 desc.add<
bool>(
"useMultScattering",
true);
71 desc.add<
bool>(
"useBending",
true);
72 desc.add<
bool>(
"useFixedPreFiltering",
false);
73 desc.add<
double>(
"phiPreFiltering", 0.3);
93 const std::vector<SeedingLayerSetsHits::SeedingLayer>& thirdLayers) {
108 const std::vector<SeedingLayerSetsHits::SeedingLayer>& thirdLayers,
109 std::vector<int>* tripletLastLayerIndex,
111 int size = thirdLayers.size();
113 vector<const DetLayer*> thirdLayerDetLayer(
size,
nullptr);
114 for (
int il = 0; il <
size; ++il) {
115 thirdHitMap[il] = &layerCache(thirdLayers[il],
region);
116 thirdLayerDetLayer[il] = thirdLayers[il].detLayer();
126 const std::vector<const DetLayer*>& thirdLayerDetLayer,
127 const int nThirdLayers) {
136 const std::vector<const DetLayer*>& thirdLayerDetLayer,
137 const int nThirdLayers,
138 std::vector<int>* tripletLastLayerIndex) {
149 std::vector<NodeInfo> layerTree;
150 std::vector<unsigned int> foundNodes;
151 foundNodes.reserve(100);
156 float rzError[nThirdLayers];
159 const float maxphi =
M_PI + maxDelphi, minphi = -maxphi;
160 const float safePhi =
M_PI - maxDelphi;
162 for (
int il = 0; il < nThirdLayers; il++) {
163 auto const&
hits = *thirdHitMap[il];
166 LayerRZPredictions& predRZ = mapPred[il];
167 predRZ.line.initLayer(
layer);
168 predRZ.helix1.initLayer(
layer);
169 predRZ.helix2.initLayer(
layer);
174 predRZ.correction.init(
region.ptMin(),
177 *thirdLayerDetLayer[il],
184 float minv = 999999.0;
185 float maxv = -999999.0;
187 for (
unsigned int i = 0;
i !=
hits.size(); ++
i) {
193 float myerr =
hits.dv[
i];
195 layerTree.emplace_back(
i,
angle,
v);
199 else if (
angle < -safePhi)
202 KDTreeBox phiZ(minphi, maxphi, minv - 0.01
f, maxv + 0.01
f);
204 hitTree[il].build(layerTree, phiZ);
205 rzError[il] = maxErr;
210 for (std::size_t ip = 0; ip !=
doublets.size(); ip++) {
222 auto toPos = std::signbit(zo - zi);
228 Range generalCurvature = predictionRPhi.curvature(
region.originRBound());
229 if (!intersect(generalCurvature,
Range(-curv, curv)))
232 for (
int il = 0; il < nThirdLayers; il++) {
233 if (hitTree[il].
empty())
236 bool barrelLayer =
layer->isBarrel();
238 if ((!barrelLayer) & (toPos != std::signbit(
layer->position().z())))
243 LayerRZPredictions& predRZ = mapPred[il];
244 predRZ.line.initPropagator(&
line);
270 Range z3s = predRZ.line.detRange();
271 double z3 = z3s.first < 0 ?
std::max(z3s.first, z3s.second) :
std::min(z3s.first, z3s.second);
280 predRZ.helix1.initPropagator(&helix1);
281 predRZ.helix2.initPropagator(&helix2);
283 Range rzRanges[2] = {predRZ.helix1(), predRZ.helix2()};
284 predRZ.helix1.initPropagator(
nullptr);
285 predRZ.helix2.initPropagator(
nullptr);
293 Range rzLineRange = predRZ.line();
294 rzRange.first =
std::min(rzRange.first, rzLineRange.first);
295 rzRange.second =
std::max(rzRange.second, rzLineRange.second);
298 rzRange = predRZ.line();
301 if (rzRange.first >= rzRange.second)
314 radius = predRZ.line.detRange();
315 if (!intersect(rzRange, predRZ.line.detSize()))
319 if (!intersect(
radius, predRZ.line.detSize()))
334 phi22 =
proxim(phi22, phi12);
335 phiRange =
Range(phi12, phi22);
337 auto rmean =
radius.mean();
338 phiRange.first *= rmean;
339 phiRange.second *= rmean;
341 phiRange.first /= rmean;
342 phiRange.second /= rmean;
346 float prmin = phiRange.min(), prmax = phiRange.max();
348 if (prmax - prmin > maxDelphi) {
349 auto prm = phiRange.mean();
350 prmin = prm - 0.5f * maxDelphi;
351 prmax = prm + 0.5f * maxDelphi;
355 Range regMax = predRZ.line.detRange();
356 Range regMin = predRZ.line(regMax.min());
357 regMax = predRZ.line(regMax.max());
360 if (regMax.min() < regMin.min()) {
364 hitTree[il].search(phiZ, foundNodes);
367 hitTree[il].search(phiZ, foundNodes);
373 auto const&
hits = *thirdHitMap[il];
374 for (
auto KDdata : foundNodes) {
376 double p3_r =
p3.perp();
377 double p3_z =
p3.z();
378 float p3_phi =
hits.phi(KDdata);
383 float ir = 1.f / p3_r;
385 constexpr
float maxPhiErr = 0.5 *
M_PI;
387 phiErr =
std::min(maxPhiErr, phiErr);
388 if (!
checkPhiInRange(p3_phi, rangeRPhi.first * ir - phiErr, rangeRPhi.second * ir + phiErr, maxPhiErr))
393 auto curv_ = predictionRPhi.curvature(thc);
394 double p2_r = point2.
r();
395 double p2_z = point2.z();
398 l3rzFixup(predictionRPhi, curv_, *
hits.theHits[KDdata].hit(), p3_r, p3_z, tTopo);
402 HelixRZ updatedHelix(&predictionRPhi, gp1.
z(), p2_z, curv_);
403 rangeRZ = predRZ.helix1(barrelLayer ? p3_r : p3_z, updatedHelix);
405 float tIP = predictionRPhi.transverseIP(thc);
408 rangeRZ = predRZ.line(barrelLayer ? p3_r : p3_z,
line);
414 rangeRZ.first -=
err, rangeRZ.second +=
err;
416 if (!rangeRZ.inside(barrelLayer ? p3_z : p3_r))
421 if (tripletLastLayerIndex)
422 tripletLastLayerIndex->clear();
423 edm::LogError(
"TooManyTriplets") <<
" number of triples exceed maximum. no triplets produced.";
429 if (tripletLastLayerIndex)
430 tripletLastLayerIndex->push_back(il);
static void fillDescriptions(edm::ParameterSetDescription &desc)
const float extraHitRPhitolerance
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
~PixelTripletLargeTipGenerator() override
constexpr T normalizedPhi(T phi)
Log< level::Error, false > LogError
T curvature(T InversePt, const MagneticField &field)
const unsigned int theMaxElement
constexpr T proxim(T b, T a)
constexpr std::array< uint8_t, layerIndexSize< TrackerTraits > > layer
U second(std::pair< T, U > const &p)
constexpr float fnSigmaRZ
const bool useFixedPreFiltering
constexpr double nSigmaRZ
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
static void fillDescriptions(edm::ParameterSetDescription &desc)
LayerCacheType * theLayerCache
constexpr float nSigmaPhi
T r() const
Radius, same as mag()
static double maxCurvature(const ThirdHitPredictionFromCircle *circle, double z1, double z2, double z3)
const float extraHitRZtolerance
PixelRecoRange< float > Range
std::unique_ptr< HitPairGeneratorFromLayerPair > thePairGenerator
constexpr bool checkPhiInRange(T phi, T phi1, T phi2, float maxDphi=float(M_PI))
PixelTripletLargeTipGenerator(const edm::ParameterSet &cfg, edm::ConsumesCollector &&iC)
#define declareDynArray(T, n, x)
const edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > fieldESToken_
const edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > trackerTopologyESToken_
edm::ESGetToken< MultipleScatteringParametrisationMaker, TrackerMultipleScatteringRecord > msmakerESToken_
void hitTriplets(const TrackingRegion ®ion, OrderedHitTriplets &trs, const edm::Event &ev, const edm::EventSetup &es, const SeedingLayerSetsHits::SeedingLayerSet &pairLayers, const std::vector< SeedingLayerSetsHits::SeedingLayer > &thirdLayers) override
T angle(T x1, T y1, T z1, T x2, T y2, T z2)