26 using namespace ctfseeding;
33 struct LayerRZPredictions {
45 : thePairGenerator(0),
50 useMScat(cfg.getParameter<bool>(
"useMultScattering")),
51 useBend(cfg.getParameter<bool>(
"useBending"))
58 const std::vector<SeedingLayer> &layers,
71 if (range.first > second.max() || range.second < second.min())
73 if (range.first < second.min())
74 range.first = second.min();
75 if (range.second > second.max())
76 range.second = second.max();
77 return range.first < range.second;
96 if (doublets.empty())
return;
105 std::vector<NodeInfo > layerTree;
106 std::vector<unsigned int> foundNodes;
107 foundNodes.reserve(100);
113 LayerRZPredictions mapPred[
size];
117 for(
int il = 0; il <
size; il++) {
118 thirdHitMap[il] = &(*theLayerCache)(&
theLayers[il], region, ev, es);
119 auto const & hits = *thirdHitMap[il];
121 const DetLayer *layer = theLayers[il].detLayer();
122 LayerRZPredictions &predRZ = mapPred[il];
123 predRZ.line.initLayer(layer);
124 predRZ.helix1.initLayer(layer);
125 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);
147 KDTreeBox phiZ(minphi, maxphi, minv-0.01
f, maxv+0.01
f);
149 hitTree[il].
build(layerTree, phiZ);
150 rzError[il] = maxErr;
155 for (std::size_t ip =0; ip!=doublets.size(); ip++) {
172 if (!intersect(generalCurvature,
Range(-curv, curv)))
continue;
174 for(
int il = 0; il <
size; il++) {
175 if (hitTree[il].
empty())
continue;
177 bool barrelLayer = layer->
isBarrel();
182 LayerRZPredictions &predRZ = mapPred[il];
183 predRZ.line.initPropagator(&line);
206 Range z3s = predRZ.line.detRange();
207 double z3 = z3s.first < 0 ?
std::max(z3s.first, z3s.second)
210 gp1.
z(), gp2.
z(), z3);
211 if (!intersect(curvature,
Range(-maxCurvature, maxCurvature)))
215 HelixRZ helix1(&predictionRPhi, gp1.
z(), gp2.
z(), curvature.first);
216 HelixRZ helix2(&predictionRPhi, gp1.
z(), gp2.
z(), curvature.second);
218 predRZ.helix1.initPropagator(&helix1);
219 predRZ.helix2.initPropagator(&helix2);
221 Range rzRanges[2] = { predRZ.helix1(), predRZ.helix2() };
222 predRZ.helix1.initPropagator(
nullptr);
223 predRZ.helix2.initPropagator(
nullptr);
225 rzRange.first =
std::min(rzRanges[0].
first, rzRanges[1].first);
226 rzRange.second =
std::max(rzRanges[0].second, rzRanges[1].second);
230 if (curvature.first * curvature.second < 0.0) {
231 Range rzLineRange = predRZ.line();
232 rzRange.first =
std::min(rzRange.first, rzLineRange.first);
233 rzRange.second =
std::max(rzRange.second, rzLineRange.second);
236 rzRange = predRZ.line();
239 if (rzRange.first >= rzRange.second)
242 correction.correctRZRange(rzRange);
252 radius = predRZ.line.detRange();
253 if (!intersect(rzRange, predRZ.line.detSize()))
257 if (!intersect(radius, predRZ.line.detSize()))
261 Range rPhi1 = predictionRPhi(curvature, radius.first);
262 Range rPhi2 = predictionRPhi(curvature, radius.second);
263 correction.correctRPhiRange(rPhi1);
264 correction.correctRPhiRange(rPhi2);
265 rPhi1.first /= radius.first;
266 rPhi1.second /= radius.first;
267 rPhi2.first /= radius.second;
268 rPhi2.second /= radius.second;
273 float prmin=phiRange.min(), prmax=phiRange.max();
282 Range regMax = predRZ.line.detRange();
283 Range regMin = predRZ.line(regMax.min());
284 regMax = predRZ.line(regMax.max());
285 correction.correctRZRange(regMin);
286 correction.correctRZRange(regMax);
287 if (regMax.min() < regMin.min()) {
swap(regMax, regMin);}
291 hitTree[il].
search(phiZ, foundNodes);
297 hitTree[il].
search(phiZ, foundNodes);
303 thirdHitMap[il] = &(*theLayerCache)(&
theLayers[il], region, ev, es);
304 auto const & hits = *thirdHitMap[il];
305 for (
auto KDdata : foundNodes) {
307 double p3_r = p3.
perp();
308 double p3_z = p3.
z();
309 float p3_phi = hits.phi(KDdata);
311 Range rangeRPhi = predictionRPhi(curvature, p3_r);
312 correction.correctRPhiRange(rangeRPhi);
315 float phiErr =
nSigmaPhi * hits.drphi[KDdata]*ir;
316 if (!
checkPhiInRange(p3_phi, rangeRPhi.first*ir-phiErr, rangeRPhi.second*ir+phiErr))
321 auto curv_ = predictionRPhi.curvature(thc);
322 double p2_r = point2.
r();
double p2_z = point2.z();
324 l2rzFixup(predictionRPhi, curv_, *doublets.hit(ip,
HitDoublets::outer), p2_r, p2_z, tTopo);
325 l3rzFixup(predictionRPhi, curv_, *hits.theHits[KDdata].hit(), p3_r, p3_z, tTopo);
329 HelixRZ updatedHelix(&predictionRPhi, gp1.
z(), p2_z, curv_);
330 rangeRZ = predRZ.helix1(barrelLayer ? p3_r : p3_z, updatedHelix);
332 float tIP = predictionRPhi.transverseIP(thc);
335 rangeRZ = predRZ.line(barrelLayer ? p3_r : p3_z, line);
337 correction.correctRZRange(rangeRZ);
339 double err =
nSigmaRZ * hits.dv[KDdata];
341 rangeRZ.first -= err, rangeRZ.second += err;
343 if (!rangeRZ.inside(barrelLayer ? p3_z : p3_r))
continue;
347 edm::LogError(
"TooManyTriplets")<<
" number of triples exceed maximum. no triplets produced.";
358 {
while (phi > phi2) phi -= 2. *
M_PI;
359 while (phi < phi1) phi += 2. *
M_PI;
363 std::pair<float, float>
365 const std::pair<float, float> &
r2)
const
366 {
float r2Min = r2.first;
367 float r2Max = r2.second;
368 while (r1.first - r2Min > +
M_PI) r2Min += 2. *
M_PI, r2Max += 2. *
M_PI;
369 while (r1.first - r2Min < -
M_PI) r2Min -= 2. *
M_PI, r2Max -= 2. *
M_PI;
370 return std::make_pair(
min(r1.first, r2Min),
max(r1.second, r2Max));
float originRBound() const
bounds the particle vertex in the transverse plane
void swap(ora::Record &rh, ora::Record &lh)
T getParameter(std::string const &) const
tuple extraHitRPhitolerance
virtual HitPairGenerator * clone() const =0
void build(std::vector< KDTreeNodeInfo > &eltList, const KDTreeBox ®ion)
tuple useFixedPreFiltering
ThirdHitPredictionFromCircle::HelixRZ HelixRZ
T r() const
Radius, same as mag()
bool useFixedPreFiltering
void search(const KDTreeBox &searchBox, std::vector< KDTreeNodeInfo > &resRecHitList)
LayerCacheType * theLayerCache
float extraHitRPhitolerance
U second(std::pair< T, U > const &p)
bool checkPhiInRange(float phi, float phi1, float phi2) const
tuple extraHitRZtolerance
T curvature(T InversePt, const edm::EventSetup &iSetup)
const T & max(const T &a, const T &b)
constexpr double nSigmaRZ
unsigned int theMaxElement
virtual HitDoublets doublets(const TrackingRegion ®, const edm::Event &ev, const edm::EventSetup &es)
virtual void hitTriplets(const TrackingRegion ®ion, OrderedHitTriplets &trs, const edm::Event &ev, const edm::EventSetup &es)
constexpr double nSigmaPhi
std::pair< float, float > mergePhiRanges(const std::pair< float, float > &r1, const std::pair< float, float > &r2) const
float extraHitRZtolerance
HitPairGenerator * thePairGenerator
PixelRecoRange< float > Range
static double maxCurvature(const ThirdHitPredictionFromCircle *circle, double z1, double z2, double z3)
std::vector< ctfseeding::SeedingLayer > theLayers
T const * product() const
float ptMin() const
minimal pt of interest
PixelTripletLargeTipGenerator(const edm::ParameterSet &cfg)
virtual void init(const HitPairGenerator &pairs, const std::vector< ctfseeding::SeedingLayer > &layers, LayerCacheType *layerCache)
virtual unsigned int size() const
DetLayer const * detLayer(layer l) const
tuple size
Write out results.
T angle(T x1, T y1, T z1, T x2, T y2, T z2)