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);
79 #if defined(__clang__) && defined(__has_warning) 80 #if __has_warning("-Wbitwise-instead-of-logical") 81 #pragma clang diagnostic push 82 #pragma clang diagnostic ignored "-Wbitwise-instead-of-logical" 98 #if defined(__clang__) && defined(__has_warning) 99 #if __has_warning("-Wbitwise-instead-of-logical") 100 #pragma clang diagnostic pop 109 const std::vector<SeedingLayerSetsHits::SeedingLayer>& thirdLayers) {
124 const std::vector<SeedingLayerSetsHits::SeedingLayer>& thirdLayers,
125 std::vector<int>* tripletLastLayerIndex,
127 int size = thirdLayers.size();
129 vector<const DetLayer*> thirdLayerDetLayer(
size,
nullptr);
130 for (
int il = 0; il <
size; ++il) {
131 thirdHitMap[il] = &layerCache(thirdLayers[il],
region);
132 thirdLayerDetLayer[il] = thirdLayers[il].detLayer();
142 const std::vector<const DetLayer*>& thirdLayerDetLayer,
143 const int nThirdLayers) {
152 const std::vector<const DetLayer*>& thirdLayerDetLayer,
153 const int nThirdLayers,
154 std::vector<int>* tripletLastLayerIndex) {
165 std::vector<NodeInfo> layerTree;
166 std::vector<unsigned int> foundNodes;
167 foundNodes.reserve(100);
172 float rzError[nThirdLayers];
175 const float maxphi =
M_PI + maxDelphi, minphi = -maxphi;
176 const float safePhi =
M_PI - maxDelphi;
178 for (
int il = 0; il < nThirdLayers; il++) {
179 auto const&
hits = *thirdHitMap[il];
182 LayerRZPredictions& predRZ = mapPred[il];
183 predRZ.line.initLayer(
layer);
184 predRZ.helix1.initLayer(
layer);
185 predRZ.helix2.initLayer(
layer);
190 predRZ.correction.init(
region.ptMin(),
193 *thirdLayerDetLayer[il],
200 float minv = 999999.0;
201 float maxv = -999999.0;
203 for (
unsigned int i = 0;
i !=
hits.size(); ++
i) {
209 float myerr =
hits.dv[
i];
211 layerTree.emplace_back(
i,
angle,
v);
215 else if (
angle < -safePhi)
218 KDTreeBox phiZ(minphi, maxphi, minv - 0.01
f, maxv + 0.01
f);
220 hitTree[il].build(layerTree, phiZ);
221 rzError[il] = maxErr;
226 for (std::size_t ip = 0; ip !=
doublets.size(); ip++) {
238 auto toPos = std::signbit(zo - zi);
244 Range generalCurvature = predictionRPhi.curvature(
region.originRBound());
245 if (!intersect(generalCurvature,
Range(-curv, curv)))
248 for (
int il = 0; il < nThirdLayers; il++) {
249 if (hitTree[il].
empty())
252 bool barrelLayer =
layer->isBarrel();
254 if ((!barrelLayer) & (toPos != std::signbit(
layer->position().z())))
259 LayerRZPredictions& predRZ = mapPred[il];
260 predRZ.line.initPropagator(&
line);
286 Range z3s = predRZ.line.detRange();
287 double z3 = z3s.first < 0 ?
std::max(z3s.first, z3s.second) :
std::min(z3s.first, z3s.second);
296 predRZ.helix1.initPropagator(&helix1);
297 predRZ.helix2.initPropagator(&helix2);
299 Range rzRanges[2] = {predRZ.helix1(), predRZ.helix2()};
300 predRZ.helix1.initPropagator(
nullptr);
301 predRZ.helix2.initPropagator(
nullptr);
309 Range rzLineRange = predRZ.line();
310 rzRange.first =
std::min(rzRange.first, rzLineRange.first);
311 rzRange.second =
std::max(rzRange.second, rzLineRange.second);
314 rzRange = predRZ.line();
317 if (rzRange.first >= rzRange.second)
330 radius = predRZ.line.detRange();
331 if (!intersect(rzRange, predRZ.line.detSize()))
335 if (!intersect(
radius, predRZ.line.detSize()))
350 phi22 =
proxim(phi22, phi12);
351 phiRange =
Range(phi12, phi22);
353 auto rmean =
radius.mean();
354 phiRange.first *= rmean;
355 phiRange.second *= rmean;
357 phiRange.first /= rmean;
358 phiRange.second /= rmean;
362 float prmin = phiRange.min(), prmax = phiRange.max();
364 if (prmax - prmin > maxDelphi) {
365 auto prm = phiRange.mean();
366 prmin = prm - 0.5f * maxDelphi;
367 prmax = prm + 0.5f * maxDelphi;
371 Range regMax = predRZ.line.detRange();
372 Range regMin = predRZ.line(regMax.min());
373 regMax = predRZ.line(regMax.max());
376 if (regMax.min() < regMin.min()) {
380 hitTree[il].search(phiZ, foundNodes);
383 hitTree[il].search(phiZ, foundNodes);
389 auto const&
hits = *thirdHitMap[il];
390 for (
auto KDdata : foundNodes) {
392 double p3_r =
p3.perp();
393 double p3_z =
p3.z();
394 float p3_phi =
hits.phi(KDdata);
399 float ir = 1.f / p3_r;
401 constexpr
float maxPhiErr = 0.5 *
M_PI;
403 phiErr =
std::min(maxPhiErr, phiErr);
404 if (!
checkPhiInRange(p3_phi, rangeRPhi.first * ir - phiErr, rangeRPhi.second * ir + phiErr, maxPhiErr))
409 auto curv_ = predictionRPhi.curvature(thc);
410 double p2_r = point2.
r();
411 double p2_z = point2.z();
414 l3rzFixup(predictionRPhi, curv_, *
hits.theHits[KDdata].hit(), p3_r, p3_z, tTopo);
418 HelixRZ updatedHelix(&predictionRPhi, gp1.
z(), p2_z, curv_);
419 rangeRZ = predRZ.helix1(barrelLayer ? p3_r : p3_z, updatedHelix);
421 float tIP = predictionRPhi.transverseIP(thc);
424 rangeRZ = predRZ.line(barrelLayer ? p3_r : p3_z,
line);
430 rangeRZ.first -=
err, rangeRZ.second +=
err;
432 if (!rangeRZ.inside(barrelLayer ? p3_z : p3_r))
437 if (tripletLastLayerIndex)
438 tripletLastLayerIndex->clear();
439 edm::LogError(
"TooManyTriplets") <<
" number of triples exceed maximum. no triplets produced.";
445 if (tripletLastLayerIndex)
446 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)