34 using namespace ctfseeding;
39 useFixedPreFiltering(cfg.getParameter<bool>(
"useFixedPreFiltering")),
40 extraHitRZtolerance(cfg.getParameter<double>(
"extraHitRZtolerance")),
41 extraHitRPhitolerance(cfg.getParameter<double>(
"extraHitRPhitolerance")),
42 useMScat(cfg.getParameter<bool>(
"useMultScattering")),
43 useBend(cfg.getParameter<bool>(
"useBending")),
44 dphi(useFixedPreFiltering ? cfg.getParameter<double>(
"phiPreFiltering") : 0)
49 if(comparitorName !=
"none") {
61 const std::vector<SeedingLayerSetsHits::SeedingLayer>& thirdLayers)
66 auto const & doublets =
thePairGenerator->doublets(region,ev,es, pairLayers);
68 if (doublets.empty())
return;
76 int size = thirdLayers.size();
85 std::vector<NodeInfo > layerTree;
86 std::vector<unsigned int> foundNodes;
87 foundNodes.reserve(100);
93 const float maxDelphi = region.
ptMin() < 0.3f ? float(
M_PI)/4.f : float(
M_PI)/8.f;
94 const float maxphi =
M_PI+maxDelphi, minphi = -maxphi;
95 const float safePhi =
M_PI-maxDelphi;
99 for (
int il=0; il<
size; ++il) {
100 thirdHitMap[il] = &(*theLayerCache)(thirdLayers[il],
region,
ev, es);
101 auto const & hits = *thirdHitMap[il];
103 pred.
initLayer(thirdLayers[il].detLayer());
110 float minv=999999.0f, maxv= -minv;
112 for (
unsigned int i=0;
i!=hits.size(); ++
i) {
117 float myerr = hits.dv[
i];
119 layerTree.emplace_back(
i,
angle,
v);
124 KDTreeBox phiZ(minphi, maxphi, minv-0.01
f, maxv+0.01
f);
126 hitTree[il].build(layerTree, phiZ);
127 rzError[il] = maxErr;
135 for (std::size_t ip =0; ip!=doublets.size(); ip++) {
145 auto toPos = std::signbit(zo-zi);
161 for (
int il=0; il!=
size; ++il) {
162 const DetLayer * layer = thirdLayers[il].detLayer();
163 auto barrelLayer = layer->
isBarrel();
165 if ( (!barrelLayer) & (toPos != std::signbit(layer->
position().
z())) )
continue;
167 if (hitTree[il].
empty())
continue;
169 auto const & hits = *thirdHitMap[il];
171 auto & correction = corrections[il];
173 correction.init(line, point2, outSeq);
175 auto & predictionRZ = preds[il];
177 predictionRZ.initPropagator(&line);
178 Range rzRange = predictionRZ();
179 correction.correctRZRange(rzRange);
189 radius = predictionRZ.detRange();
191 radius =
Range(
max(rzRange.min(), predictionRZ.detSize().min()),
192 min(rzRange.max(), predictionRZ.detSize().max()) );
194 if (radius.empty())
continue;
198 auto rPhi1 = predictionRPhitmp(radius.max());
199 bool ok1 = !rPhi1.empty();
201 correction.correctRPhiRange(rPhi1);
202 rPhi1.first /= radius.max();
203 rPhi1.second /= radius.max();
205 auto rPhi2 = predictionRPhitmp(radius.min());
206 bool ok2 = !rPhi2.empty();
208 correction.correctRPhiRange(rPhi2);
209 rPhi2.first /= radius.min();
210 rPhi2.second /= radius.min();
215 rPhi1.second =
proxim(rPhi1.second,rPhi1.first);
217 rPhi2.first =
proxim(rPhi2.first,rPhi1.first);
218 rPhi2.second =
proxim(rPhi2.second,rPhi1.first);
219 phiRange = rPhi1.sum(rPhi2);
220 }
else phiRange=rPhi1;
223 rPhi2.second =
proxim(rPhi2.second,rPhi2.first);
233 float prmin=phiRange.min(), prmax=phiRange.max();
236 if (prmax-prmin>maxDelphi) {
237 auto prm = phiRange.mean();
238 prmin = prm - 0.5f*maxDelphi;
239 prmax = prm + 0.5f*maxDelphi;
244 Range regMax = predictionRZ.detRange();
245 Range regMin = predictionRZ(regMax.min()-regOffset);
246 regMax = predictionRZ(regMax.max()+regOffset);
247 correction.correctRZRange(regMin);
248 correction.correctRZRange(regMax);
249 if (regMax.min() < regMin.min()) {
swap(regMax, regMin);}
250 KDTreeBox phiZ(prmin, prmax, regMin.min()-nSigmaRZ*rzError[il], regMax.max()+nSigmaRZ*rzError[il]);
251 hitTree[il].search(phiZ, foundNodes);
256 rzRange.min()-regOffset-nSigmaRZ*rzError[il],
257 rzRange.max()+regOffset+nSigmaRZ*rzError[il]);
258 hitTree[il].search(phiZ, foundNodes);
265 for (
auto KDdata : foundNodes) {
269 edm::LogError(
"TooManyTriplets")<<
" number of triples exceeds maximum. no triplets produced.";
273 float p3_u = hits.u[KDdata];
274 float p3_v = hits.v[KDdata];
275 float p3_phi = hits.lphi[KDdata];
281 Range allowed = predictionRZ(p3_u);
282 correction.correctRZRange(allowed);
283 float vErr = nSigmaRZ *hits.dv[KDdata];
284 Range hitRange(p3_v-vErr, p3_v+vErr);
286 if (crossingRange.empty())
continue;
288 float ir = 1.f/hits.rv(KDdata);
289 float phiErr = nSigmaPhi * hits.drphi[KDdata]*ir;
291 for (
int icharge=-1; icharge <=1; icharge+=2) {
292 Range rangeRPhi = predictionRPhi(hits.rv(KDdata), icharge);
293 correction.correctRPhiRange(rangeRPhi);
294 if (
checkPhiInRange(p3_phi, rangeRPhi.first*ir-phiErr, rangeRPhi.second*ir+phiErr)) {
298 result.push_back( hittriplet );
300 LogDebug(
"RejectedTriplet") <<
"rejected triplet from comparitor ";
305 if (nook)
LogDebug(
"RejectedTriplet") <<
"rejected triplet from second phicheck " << p3_phi;
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
GlobalPoint const & origin() const
void initLayer(const DetLayer *layer)
PixelRecoRange< float > Range
const float extraHitRZtolerance
const unsigned int theMaxElement
std::unique_ptr< SeedComparitor > theComparitor
PixelTripletHLTGenerator(const edm::ParameterSet &cfg, edm::ConsumesCollector &iC)
T curvature(T InversePt, const edm::EventSetup &iSetup)
SeedingHitSet::ConstRecHitPointer Hit
BaseTrackerRecHit const * Hit
const bool useFixedPreFiltering
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
std::unique_ptr< HitPairGeneratorFromLayerPair > thePairGenerator
virtual const Surface::PositionType & position() const
Returns position of the surface.
float ptMin() const
minimal pt of interest
PixelRecoRange< T > intersection(const PixelRecoRange< T > &r) const
#define declareDynArray(T, n, x)
void initTolerance(float tolerance)
virtual unsigned int size() const
tuple size
Write out results.
const float extraHitRPhitolerance
virtual ~PixelTripletHLTGenerator()
T get(const Candidate &c)
T angle(T x1, T y1, T z1, T x2, T y2, T z2)