35 struct LayerRZPredictions {
52 useMScat(cfg.getParameter<
bool>(
"useMultScattering")),
53 useBend(cfg.getParameter<
bool>(
"useBending")),
62 desc.
add<
double>(
"extraHitRPhitolerance", 0);
63 desc.
add<
double>(
"extraHitRZtolerance", 0);
64 desc.
add<
bool>(
"useMultScattering",
true);
65 desc.
add<
bool>(
"useBending",
true);
66 desc.
add<
bool>(
"useFixedPreFiltering",
false);
67 desc.
add<
double>(
"phiPreFiltering", 0.3);
72 if ((range.min() > second.max()) | (range.max() < second.min()))
74 if (range.first < second.min())
75 range.first = second.min();
76 if (range.second > second.max())
77 range.second = second.max();
78 return range.first < range.second;
87 const std::vector<SeedingLayerSetsHits::SeedingLayer>& thirdLayers) {
102 const std::vector<SeedingLayerSetsHits::SeedingLayer>& thirdLayers,
103 std::vector<int>* tripletLastLayerIndex,
105 int size = thirdLayers.size();
107 vector<const DetLayer*> thirdLayerDetLayer(size,
nullptr);
108 for (
int il = 0; il <
size; ++il) {
109 thirdHitMap[il] = &layerCache(thirdLayers[il], region, es);
110 thirdLayerDetLayer[il] = thirdLayers[il].detLayer();
112 hitTriplets(region, result, es, doublets, thirdHitMap, thirdLayerDetLayer, size, tripletLastLayerIndex);
120 const std::vector<const DetLayer*>& thirdLayerDetLayer,
121 const int nThirdLayers) {
122 hitTriplets(region, result, es, doublets, thirdHitMap, thirdLayerDetLayer, nThirdLayers,
nullptr);
130 const std::vector<const DetLayer*>& thirdLayerDetLayer,
131 const int nThirdLayers,
132 std::vector<int>* tripletLastLayerIndex) {
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];
160 const DetLayer* layer = thirdLayerDetLayer[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);
223 if (!intersect(generalCurvature,
Range(-curv, curv)))
226 for (
int il = 0; il < nThirdLayers; il++) {
227 if (hitTree[il].
empty())
229 const DetLayer* layer = thirdLayerDetLayer[il];
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();
265 double z3 = z3s.first < 0 ?
std::max(z3s.first, z3s.second) :
std::min(z3s.first, z3s.second);
267 if (!intersect(curvature,
Range(-maxCurvature, maxCurvature)))
271 HelixRZ helix1(&predictionRPhi, gp1.
z(), gp2.
z(), curvature.first);
272 HelixRZ helix2(&predictionRPhi, gp1.
z(), gp2.
z(), curvature.second);
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);
281 rzRange.first =
std::min(rzRanges[0].
first, rzRanges[1].first);
282 rzRange.second =
std::max(rzRanges[0].
second, rzRanges[1].second);
286 if (curvature.first * curvature.second < 0.0) {
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()))
318 if ((curvature.first < 0.0f) & (curvature.second < 0.0f)) {
320 }
else if ((curvature.first >= 0.0f) & (curvature.second >= 0.0f)) {
323 radius.first = radius.second;
325 auto phi12 = predictionRPhi.phi(curvature.first, radius.first);
326 auto phi22 = predictionRPhi.phi(curvature.second, radius.second);
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);
374 Range rangeRPhi = predictionRPhi(curvature, p3_r);
377 float ir = 1.f / p3_r;
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);
#define declareDynArray(T, n, x)
float originRBound() const
bounds the particle vertex in the transverse plane
static void fillDescriptions(edm::ParameterSetDescription &desc)
const float extraHitRPhitolerance
~PixelTripletLargeTipGenerator() override
constexpr T normalizedPhi(T phi)
float x(int i, layer l) const
T r() const
Radius, same as mag()
LineOrigin origin() const
const unsigned int theMaxElement
constexpr T proxim(T b, T a)
float z(int i, layer l) const
U second(std::pair< T, U > const &p)
const bool useFixedPreFiltering
T curvature(T InversePt, const edm::EventSetup &iSetup)
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
static void fillDescriptions(edm::ParameterSetDescription &desc)
LayerCacheType * theLayerCache
float y(int i, layer l) const
ParameterDescriptionBase * add(U const &iLabel, T const &value)
unsigned int size() const override
static double maxCurvature(const ThirdHitPredictionFromCircle *circle, double z1, double z2, double z3)
const float extraHitRZtolerance
float phi(int i, layer l) const
PixelRecoRange< float > Range
std::unique_ptr< HitPairGeneratorFromLayerPair > thePairGenerator
virtual const Surface::PositionType & position() const
Returns position of the surface.
float ptMin() const
minimal pt of interest
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)
T const * product() const
DetLayer const * detLayer(layer l) const
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)