35 struct LayerRZPredictions {
50 useFixedPreFiltering(cfg.getParameter<bool>(
"useFixedPreFiltering")),
51 extraHitRZtolerance(cfg.getParameter<double>(
"extraHitRZtolerance")),
52 extraHitRPhitolerance(cfg.getParameter<double>(
"extraHitRPhitolerance")),
53 useMScat(cfg.getParameter<bool>(
"useMultScattering")),
54 useBend(cfg.getParameter<bool>(
"useBending")),
55 dphi(useFixedPreFiltering ? cfg.getParameter<double>(
"phiPreFiltering") : 0) {}
63 if ( (range.min() > second.max()) | (range.max() < second.min()) )
65 if (range.first < second.min())
66 range.first = second.min();
67 if (range.second > second.max())
68 range.second = second.max();
69 return range.first < range.second;
78 const std::vector<SeedingLayerSetsHits::SeedingLayer>& thirdLayers)
88 auto const & doublets =
thePairGenerator->doublets(region,ev,es, pairLayers);
90 if (doublets.empty())
return;
95 int size = thirdLayers.size();
99 std::vector<NodeInfo > layerTree;
100 std::vector<unsigned int> foundNodes;
101 foundNodes.reserve(100);
108 const float maxDelphi = region.
ptMin() < 0.3f ? float(
M_PI)/4.f : float(
M_PI)/8.f;
109 const float maxphi =
M_PI+maxDelphi, minphi = -maxphi;
110 const float safePhi =
M_PI-maxDelphi;
115 for(
int il = 0; il <
size; il++) {
116 thirdHitMap[il] = &(*theLayerCache)(thirdLayers[il],
region,
ev, es);
117 auto const & hits = *thirdHitMap[il];
119 const DetLayer *layer = thirdLayers[il].detLayer();
120 LayerRZPredictions &predRZ = mapPred[il];
121 predRZ.line.initLayer(layer);
122 predRZ.helix1.initLayer(layer);
123 predRZ.helix2.initLayer(layer);
132 float minv=999999.0;
float maxv = -999999.0;
134 for (
unsigned int i=0;
i!=hits.size(); ++
i) {
139 float myerr = hits.dv[
i];
141 layerTree.emplace_back(
i,
angle,
v);
146 KDTreeBox phiZ(minphi, maxphi, minv-0.01
f, maxv+0.01
f);
148 hitTree[il].build(layerTree, phiZ);
149 rzError[il] = maxErr;
154 for (std::size_t ip =0; ip!=doublets.size(); ip++) {
166 auto toPos = std::signbit(zo-zi);
173 if (!intersect(generalCurvature,
Range(-curv, curv)))
continue;
175 for(
int il = 0; il <
size; il++) {
176 if (hitTree[il].
empty())
continue;
177 const DetLayer *layer = thirdLayers[il].detLayer();
178 bool barrelLayer = layer->
isBarrel();
180 if ( (!barrelLayer) & (toPos != std::signbit(layer->
position().
z())) )
continue;
185 LayerRZPredictions &predRZ = mapPred[il];
186 predRZ.line.initPropagator(&line);
188 auto & correction = predRZ.correction;
189 correction.init(line, point2, outSeq);
213 Range z3s = predRZ.line.detRange();
214 double z3 = z3s.first < 0 ?
std::max(z3s.first, z3s.second)
217 gp1.
z(), gp2.
z(), z3);
218 if (!intersect(curvature,
Range(-maxCurvature, maxCurvature)))
222 HelixRZ helix1(&predictionRPhi, gp1.
z(), gp2.
z(), curvature.first);
223 HelixRZ helix2(&predictionRPhi, gp1.
z(), gp2.
z(), curvature.second);
225 predRZ.helix1.initPropagator(&helix1);
226 predRZ.helix2.initPropagator(&helix2);
228 Range rzRanges[2] = { predRZ.helix1(), predRZ.helix2() };
229 predRZ.helix1.initPropagator(
nullptr);
230 predRZ.helix2.initPropagator(
nullptr);
232 rzRange.first =
std::min(rzRanges[0].
first, rzRanges[1].first);
233 rzRange.second =
std::max(rzRanges[0].second, rzRanges[1].second);
237 if (curvature.first * curvature.second < 0.0) {
238 Range rzLineRange = predRZ.line();
239 rzRange.first =
std::min(rzRange.first, rzLineRange.first);
240 rzRange.second =
std::max(rzRange.second, rzLineRange.second);
243 rzRange = predRZ.line();
246 if (rzRange.first >= rzRange.second)
249 correction.correctRZRange(rzRange);
259 radius = predRZ.line.detRange();
260 if (!intersect(rzRange, predRZ.line.detSize()))
264 if (!intersect(radius, predRZ.line.detSize()))
269 if ( (curvature.first<0.0f) & (curvature.second<0.0f) ) {
271 }
else if ( (curvature.first>=0.0f) & (curvature.second>=0.0f) ) {;}
273 radius.first=radius.second;
275 auto phi12 = predictionRPhi.phi(curvature.first,radius.first);
276 auto phi22 = predictionRPhi.phi(curvature.second,radius.second);
278 phi22 =
proxim(phi22,phi12);
279 phiRange =
Range(phi12,phi22); phiRange.sort();
280 auto rmean = radius.mean();
281 phiRange.first *= rmean;
282 phiRange.second *= rmean;
283 correction.correctRPhiRange(phiRange);
284 phiRange.first /= rmean;
285 phiRange.second /= rmean;
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 = predRZ.line.detRange();
300 Range regMin = predRZ.line(regMax.min());
301 regMax = predRZ.line(regMax.max());
302 correction.correctRZRange(regMin);
303 correction.correctRZRange(regMax);
304 if (regMax.min() < regMin.min()) {
std::swap(regMax, regMin);}
308 hitTree[il].search(phiZ, foundNodes);
314 hitTree[il].search(phiZ, foundNodes);
320 thirdHitMap[il] = &(*theLayerCache)(thirdLayers[il],
region,
ev, es);
321 auto const & hits = *thirdHitMap[il];
322 for (
auto KDdata : foundNodes) {
324 double p3_r = p3.
perp();
325 double p3_z = p3.
z();
326 float p3_phi = hits.phi(KDdata);
328 Range rangeRPhi = predictionRPhi(curvature, p3_r);
329 correction.correctRPhiRange(rangeRPhi);
332 float phiErr =
nSigmaPhi * hits.drphi[KDdata]*ir;
333 if (!
checkPhiInRange(p3_phi, rangeRPhi.first*ir-phiErr, rangeRPhi.second*ir+phiErr))
338 auto curv_ = predictionRPhi.curvature(thc);
339 double p2_r = point2.
r();
double p2_z = point2.z();
341 l2rzFixup(predictionRPhi, curv_, *doublets.hit(ip,
HitDoublets::outer), p2_r, p2_z, tTopo);
342 l3rzFixup(predictionRPhi, curv_, *hits.theHits[KDdata].hit(), p3_r, p3_z, tTopo);
346 HelixRZ updatedHelix(&predictionRPhi, gp1.
z(), p2_z, curv_);
347 rangeRZ = predRZ.helix1(barrelLayer ? p3_r : p3_z, updatedHelix);
349 float tIP = predictionRPhi.transverseIP(thc);
352 rangeRZ = predRZ.line(barrelLayer ? p3_r : p3_z, line);
354 correction.correctRZRange(rangeRZ);
356 double err =
nSigmaRZ * hits.dv[KDdata];
358 rangeRZ.first -= err, rangeRZ.second += err;
360 if (!rangeRZ.inside(barrelLayer ? p3_z : p3_r))
continue;
364 edm::LogError(
"TooManyTriplets")<<
" number of triples exceed maximum. no triplets produced.";
float originRBound() const
bounds the particle vertex in the transverse plane
const float extraHitRPhitolerance
PixelRecoRange< float > Range
virtual void hitTriplets(const TrackingRegion ®ion, OrderedHitTriplets &trs, const edm::Event &ev, const edm::EventSetup &es, SeedingLayerSetsHits::SeedingLayerSet pairLayers, const std::vector< SeedingLayerSetsHits::SeedingLayer > &thirdLayers) override
T r() const
Radius, same as mag()
LineOrigin origin() const
virtual ~PixelTripletLargeTipGenerator()
const unsigned int theMaxElement
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)
PixelTripletLargeTipGenerator(const edm::ParameterSet &cfg, edm::ConsumesCollector &iC)
static double maxCurvature(const ThirdHitPredictionFromCircle *circle, double z1, double z2, double z3)
const float extraHitRZtolerance
std::unique_ptr< HitPairGeneratorFromLayerPair > thePairGenerator
virtual const Surface::PositionType & position() const
Returns position of the surface.
T const * product() const
float ptMin() const
minimal pt of interest
#define declareDynArray(T, n, x)
virtual unsigned int size() const
tuple size
Write out results.
T angle(T x1, T y1, T z1, T x2, T y2, T z2)