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);
78 if ((range.min() > second.max()) | (range.max() < second.min()))
80 if (range.first < second.min())
81 range.first = second.min();
82 if (range.second > second.max())
83 range.second = second.max();
84 return range.first < range.second;
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();
118 hitTriplets(region, result, es, doublets, thirdHitMap, thirdLayerDetLayer, size, tripletLastLayerIndex);
126 const std::vector<const DetLayer*>& thirdLayerDetLayer,
127 const int nThirdLayers) {
128 hitTriplets(region, result, es, doublets, thirdHitMap, thirdLayerDetLayer, nThirdLayers,
nullptr);
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];
158 const float maxDelphi = region.
ptMin() < 0.3f ? float(
M_PI) / 4.f : float(
M_PI) / 8.f;
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);
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);
273 if (!intersect(curvature,
Range(-maxCurvature, maxCurvature)))
277 HelixRZ helix1(&predictionRPhi, gp1.
z(), gp2.
z(), curvature.first);
278 HelixRZ helix2(&predictionRPhi, gp1.
z(), gp2.
z(), curvature.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);
287 rzRange.first =
std::min(rzRanges[0].
first, rzRanges[1].first);
288 rzRange.second =
std::max(rzRanges[0].second, rzRanges[1].second);
292 if (curvature.first * curvature.second < 0.0) {
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()))
324 if ((curvature.first < 0.0f) & (curvature.second < 0.0f)) {
326 }
else if ((curvature.first >= 0.0f) & (curvature.second >= 0.0f)) {
329 radius.first = radius.second;
331 auto phi12 = predictionRPhi.phi(curvature.first, radius.first);
332 auto phi22 = predictionRPhi.phi(curvature.second, radius.second);
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);
380 Range rangeRPhi = predictionRPhi(curvature, p3_r);
383 float ir = 1.f / p3_r;
385 constexpr
float maxPhiErr = 0.5 *
M_PI;
386 float phiErr =
nSigmaPhi * hits.drphi[KDdata] * ir;
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);
float originRBound() const
bounds the particle vertex in the transverse plane
static void fillDescriptions(edm::ParameterSetDescription &desc)
const float extraHitRPhitolerance
~PixelTripletLargeTipGenerator() override
PixelRecoRange< float > Range
constexpr T normalizedPhi(T phi)
float x(int i, layer l) const
T r() const
Radius, same as mag()
Log< level::Error, false > LogError
LineOrigin origin() const
T curvature(T InversePt, const MagneticField &field)
const unsigned int theMaxElement
constexpr T proxim(T b, T a)
constexpr std::array< uint8_t, layerIndexSize > layer
tuple extraHitRZtolerance
const uint16_t range(const Frame &aFrame)
float z(int i, layer l) const
bool getData(T &iHolder) const
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
tuple extraHitRPhitolerance
float y(int i, layer l) const
ParameterDescriptionBase * add(U const &iLabel, T const &value)
constexpr float nSigmaPhi
static double maxCurvature(const ThirdHitPredictionFromCircle *circle, double z1, double z2, double z3)
const float extraHitRZtolerance
float phi(int i, layer l) const
std::unique_ptr< HitPairGeneratorFromLayerPair > thePairGenerator
virtual const Surface::PositionType & position() const
Returns position of the surface.
float ptMin() const
minimal pt of interest
constexpr float correction(int sizeM1, int q_f, int q_l, uint16_t upper_edge_first_pix, uint16_t lower_edge_last_pix, float lorentz_shift, float theThickness, float cot_angle, float pitch, bool first_is_big, bool last_is_big)
constexpr bool checkPhiInRange(T phi, T phi1, T phi2, float maxDphi=float(M_PI))
Hit const & hit(int i, layer l) const
PixelTripletLargeTipGenerator(const edm::ParameterSet &cfg, edm::ConsumesCollector &&iC)
#define declareDynArray(T, n, x)
const edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > fieldESToken_
DetLayer const * detLayer(layer l) const
unsigned int size() const override
tuple size
Write out results.
const edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > trackerTopologyESToken_
tuple useFixedPreFiltering
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)