36 struct LayerRZPredictions {
54 useMScat(cfg.getParameter<bool>(
"useMultScattering")),
55 useBend(cfg.getParameter<bool>(
"useBending")),
64 desc.
add<
double>(
"extraHitRPhitolerance", 0);
65 desc.
add<
double>(
"extraHitRZtolerance", 0);
66 desc.
add<
bool>(
"useMultScattering",
true);
67 desc.
add<
bool>(
"useBending",
true);
68 desc.
add<
bool>(
"useFixedPreFiltering",
false);
69 desc.
add<
double>(
"phiPreFiltering", 0.3);
76 if ( (range.min() > second.max()) | (range.max() < second.min()) )
78 if (range.first < second.min())
79 range.first = second.min();
80 if (range.second > second.max())
81 range.second = second.max();
82 return range.first < range.second;
91 const std::vector<SeedingLayerSetsHits::SeedingLayer>& thirdLayers)
104 const std::vector<SeedingLayerSetsHits::SeedingLayer>& thirdLayers,
105 std::vector<int> *tripletLastLayerIndex,
107 int size = thirdLayers.size();
109 vector<const DetLayer *> thirdLayerDetLayer(size,0);
110 for (
int il=0; il<
size; ++il)
112 thirdHitMap[il] = &layerCache(thirdLayers[il], region, es);
113 thirdLayerDetLayer[il] = thirdLayers[il].detLayer();
115 hitTriplets(region, result, es, doublets, thirdHitMap, thirdLayerDetLayer, size, tripletLastLayerIndex);
125 const std::vector<const DetLayer *> & thirdLayerDetLayer,
126 const int nThirdLayers)
128 hitTriplets(region, result, es, doublets, thirdHitMap, thirdLayerDetLayer, nThirdLayers,
nullptr);
135 const std::vector<const DetLayer *> & thirdLayerDetLayer,
136 const int nThirdLayers,
137 std::vector<int> *tripletLastLayerIndex) {
150 std::vector<NodeInfo > layerTree;
151 std::vector<unsigned int> foundNodes;
152 foundNodes.reserve(100);
157 float rzError[nThirdLayers];
160 const float maxphi =
M_PI+maxDelphi, minphi = -maxphi;
161 const float safePhi =
M_PI-maxDelphi;
163 for(
int il = 0; il < nThirdLayers; il++) {
165 auto const &
hits = *thirdHitMap[il];
167 const DetLayer *layer = thirdLayerDetLayer[il];
168 LayerRZPredictions &predRZ = mapPred[il];
169 predRZ.line.initLayer(layer);
170 predRZ.helix1.initLayer(layer);
171 predRZ.helix2.initLayer(layer);
180 float minv=999999.0;
float maxv = -999999.0;
182 for (
unsigned int i=0;
i!=
hits.size(); ++
i) {
187 float myerr =
hits.dv[
i];
189 layerTree.emplace_back(
i,
angle,
v);
194 KDTreeBox phiZ(minphi, maxphi, minv-0.01
f, maxv+0.01
f);
196 hitTree[il].build(layerTree, phiZ);
197 rzError[il] = maxErr;
202 for (std::size_t ip =0; ip!=doublets.
size(); ip++) {
214 auto toPos = std::signbit(zo-zi);
221 if (!intersect(generalCurvature,
Range(-curv, curv)))
continue;
223 for(
int il = 0; il < nThirdLayers; il++) {
224 if (hitTree[il].
empty())
continue;
225 const DetLayer *layer = thirdLayerDetLayer[il];
226 bool barrelLayer = layer->
isBarrel();
228 if ( (!barrelLayer) & (toPos != std::signbit(layer->
position().
z())) )
continue;
233 LayerRZPredictions &predRZ = mapPred[il];
234 predRZ.line.initPropagator(&line);
236 auto & correction = predRZ.correction;
237 correction.init(line, point2, outSeq);
261 Range z3s = predRZ.line.detRange();
262 double z3 = z3s.first < 0 ?
std::max(z3s.first, z3s.second)
265 gp1.
z(), gp2.
z(), z3);
266 if (!intersect(curvature,
Range(-maxCurvature, maxCurvature)))
270 HelixRZ helix1(&predictionRPhi, gp1.
z(), gp2.
z(), curvature.first);
271 HelixRZ helix2(&predictionRPhi, gp1.
z(), gp2.
z(), curvature.second);
273 predRZ.helix1.initPropagator(&helix1);
274 predRZ.helix2.initPropagator(&helix2);
276 Range rzRanges[2] = { predRZ.helix1(), predRZ.helix2() };
277 predRZ.helix1.initPropagator(
nullptr);
278 predRZ.helix2.initPropagator(
nullptr);
280 rzRange.first =
std::min(rzRanges[0].
first, rzRanges[1].first);
281 rzRange.second =
std::max(rzRanges[0].
second, rzRanges[1].second);
285 if (curvature.first * curvature.second < 0.0) {
286 Range rzLineRange = predRZ.line();
287 rzRange.first =
std::min(rzRange.first, rzLineRange.first);
288 rzRange.second =
std::max(rzRange.second, rzLineRange.second);
291 rzRange = predRZ.line();
294 if (rzRange.first >= rzRange.second)
297 correction.correctRZRange(rzRange);
307 radius = predRZ.line.detRange();
308 if (!intersect(rzRange, predRZ.line.detSize()))
312 if (!intersect(radius, predRZ.line.detSize()))
317 if ( (curvature.first<0.0f) & (curvature.second<0.0f) ) {
319 }
else if ( (curvature.first>=0.0f) & (curvature.second>=0.0f) ) {;}
321 radius.first=radius.second;
323 auto phi12 = predictionRPhi.phi(curvature.first,radius.first);
324 auto phi22 = predictionRPhi.phi(curvature.second,radius.second);
326 phi22 =
proxim(phi22,phi12);
327 phiRange =
Range(phi12,phi22); phiRange.sort();
328 auto rmean = radius.mean();
329 phiRange.first *= rmean;
330 phiRange.second *= rmean;
331 correction.correctRPhiRange(phiRange);
332 phiRange.first /= rmean;
333 phiRange.second /= rmean;
338 float prmin=phiRange.min(), prmax=phiRange.max();
340 if (prmax-prmin>maxDelphi) {
341 auto prm = phiRange.mean();
342 prmin = prm - 0.5f*maxDelphi;
343 prmax = prm + 0.5f*maxDelphi;
347 Range regMax = predRZ.line.detRange();
348 Range regMin = predRZ.line(regMax.min());
349 regMax = predRZ.line(regMax.max());
350 correction.correctRZRange(regMin);
351 correction.correctRZRange(regMax);
352 if (regMax.min() < regMin.min()) {
std::swap(regMax, regMin);}
356 hitTree[il].search(phiZ, foundNodes);
362 hitTree[il].search(phiZ, foundNodes);
368 auto const &
hits = *thirdHitMap[il];
369 for (
auto KDdata : foundNodes) {
371 double p3_r = p3.
perp();
372 double p3_z = p3.
z();
373 float p3_phi =
hits.phi(KDdata);
375 Range rangeRPhi = predictionRPhi(curvature, p3_r);
376 correction.correctRPhiRange(rangeRPhi);
382 phiErr =
std::min(maxPhiErr, phiErr);
383 if (!
checkPhiInRange(p3_phi, rangeRPhi.first*ir-phiErr, rangeRPhi.second*ir+phiErr, maxPhiErr))
388 auto curv_ = predictionRPhi.curvature(thc);
389 double p2_r = point2.
r();
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);
404 correction.correctRZRange(rangeRZ);
408 rangeRZ.first -= err, rangeRZ.second += err;
410 if (!rangeRZ.inside(barrelLayer ? p3_z : p3_r))
continue;
414 if(tripletLastLayerIndex) tripletLastLayerIndex->clear();
415 edm::LogError(
"TooManyTriplets")<<
" number of triples exceed maximum. no triplets produced.";
420 if(tripletLastLayerIndex) tripletLastLayerIndex->push_back(il);
float originRBound() const
bounds the particle vertex in the transverse plane
static void fillDescriptions(edm::ParameterSetDescription &desc)
const float extraHitRPhitolerance
float x(int i, layer l) const
T r() const
Radius, same as mag()
LineOrigin origin() const
virtual ~PixelTripletLargeTipGenerator()
const unsigned int theMaxElement
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)
bool checkPhiInRange(T phi, T phi1, T phi2, float maxDphi=float(M_PI))
static void fillDescriptions(edm::ParameterSetDescription &desc)
LayerCacheType * theLayerCache
float y(int i, layer l) const
ParameterDescriptionBase * add(U const &iLabel, T const &value)
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
Hit const & hit(int i, layer l) const
PixelTripletLargeTipGenerator(const edm::ParameterSet &cfg, edm::ConsumesCollector &&iC)
#define declareDynArray(T, n, x)
virtual unsigned int size() const
T const * product() const
DetLayer const * detLayer(layer l) const
virtual 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)