35 using namespace ctfseeding;
40 useFixedPreFiltering(cfg.getParameter<bool>(
"useFixedPreFiltering")),
41 extraHitRZtolerance(cfg.getParameter<double>(
"extraHitRZtolerance")),
42 extraHitRPhitolerance(cfg.getParameter<double>(
"extraHitRPhitolerance")),
43 useMScat(cfg.getParameter<bool>(
"useMultScattering")),
44 useBend(cfg.getParameter<bool>(
"useBending")),
45 dphi(useFixedPreFiltering ? cfg.getParameter<double>(
"phiPreFiltering") : 0)
50 if(comparitorName !=
"none") {
59 desc.
add<
double>(
"extraHitRPhitolerance", 0.032);
60 desc.
add<
double>(
"extraHitRZtolerance", 0.037);
61 desc.
add<
bool>(
"useMultScattering",
true);
62 desc.
add<
bool>(
"useBending",
true);
63 desc.
add<
bool>(
"useFixedPreFiltering",
false);
64 desc.
add<
double>(
"phiPreFiltering", 0.3);
77 const std::vector<SeedingLayerSetsHits::SeedingLayer>& thirdLayers)
79 auto const & doublets =
thePairGenerator->doublets(region,ev,es, pairLayers);
80 if (doublets.empty())
return;
89 const std::vector<SeedingLayerSetsHits::SeedingLayer>& thirdLayers,
90 std::vector<int> *tripletLastLayerIndex,
94 int size = thirdLayers.size();
96 vector<const DetLayer *> thirdLayerDetLayer(size,0);
97 for (
int il=0; il<
size; ++il)
99 thirdHitMap[il] = &layerCache(thirdLayers[il], region, es);
100 thirdLayerDetLayer[il] = thirdLayers[il].detLayer();
102 hitTriplets(region, result, es, doublets, thirdHitMap, thirdLayerDetLayer, size, tripletLastLayerIndex);
111 const std::vector<const DetLayer *> & thirdLayerDetLayer,
112 const int nThirdLayers)
114 hitTriplets(region, result, es, doublets, thirdHitMap, thirdLayerDetLayer, nThirdLayers,
nullptr);
121 const std::vector<const DetLayer *> & thirdLayerDetLayer,
122 const int nThirdLayers,
123 std::vector<int> *tripletLastLayerIndex) {
134 std::vector<NodeInfo > layerTree;
135 std::vector<unsigned int> foundNodes;
136 foundNodes.reserve(100);
139 float rzError[nThirdLayers];
141 const float maxDelphi = region.
ptMin() < 0.3f ? float(
M_PI)/4.f : float(
M_PI)/8.f;
142 const float maxphi =
M_PI+maxDelphi, minphi = -maxphi;
143 const float safePhi =
M_PI-maxDelphi;
146 for (
int il=0; il<nThirdLayers; ++il) {
147 auto const & hits = *thirdHitMap[il];
156 float minv=999999.0f, maxv= -minv;
158 for (
unsigned int i=0;
i!=hits.size(); ++
i) {
163 float myerr = hits.dv[
i];
165 layerTree.emplace_back(
i,
angle,
v);
170 KDTreeBox phiZ(minphi, maxphi, minv-0.01
f, maxv+0.01
f);
172 hitTree[il].build(layerTree, phiZ);
173 rzError[il] = maxErr;
181 for (std::size_t ip =0; ip!=doublets.
size(); ip++) {
191 auto toPos = std::signbit(zo-zi);
207 for (
int il=0; il!=nThirdLayers; ++il) {
208 const DetLayer * layer = thirdLayerDetLayer[il];
209 auto barrelLayer = layer->
isBarrel();
211 if ( (!barrelLayer) & (toPos != std::signbit(layer->
position().
z())) )
continue;
213 if (hitTree[il].
empty())
continue;
215 auto const & hits = *thirdHitMap[il];
217 auto & correction = corrections[il];
219 correction.init(line, point2, outSeq);
221 auto & predictionRZ = preds[il];
223 predictionRZ.initPropagator(&line);
224 Range rzRange = predictionRZ();
225 correction.correctRZRange(rzRange);
235 radius = predictionRZ.detRange();
237 radius =
Range(
max(rzRange.min(), predictionRZ.detSize().min()),
238 min(rzRange.max(), predictionRZ.detSize().max()) );
240 if (radius.empty())
continue;
244 auto rPhi1 = predictionRPhitmp(radius.max());
245 bool ok1 = !rPhi1.empty();
247 correction.correctRPhiRange(rPhi1);
248 rPhi1.first /= radius.max();
249 rPhi1.second /= radius.max();
251 auto rPhi2 = predictionRPhitmp(radius.min());
252 bool ok2 = !rPhi2.empty();
254 correction.correctRPhiRange(rPhi2);
255 rPhi2.first /= radius.min();
256 rPhi2.second /= radius.min();
261 rPhi1.second =
proxim(rPhi1.second,rPhi1.first);
263 rPhi2.first =
proxim(rPhi2.first,rPhi1.first);
264 rPhi2.second =
proxim(rPhi2.second,rPhi1.first);
265 phiRange = rPhi1.sum(rPhi2);
266 }
else phiRange=rPhi1;
269 rPhi2.second =
proxim(rPhi2.second,rPhi2.first);
279 float prmin=phiRange.min(), prmax=phiRange.max();
282 if (prmax-prmin>maxDelphi) {
283 auto prm = phiRange.mean();
284 prmin = prm - 0.5f*maxDelphi;
285 prmax = prm + 0.5f*maxDelphi;
290 Range regMax = predictionRZ.detRange();
291 Range regMin = predictionRZ(regMax.min()-regOffset);
292 regMax = predictionRZ(regMax.max()+regOffset);
293 correction.correctRZRange(regMin);
294 correction.correctRZRange(regMax);
295 if (regMax.min() < regMin.min()) {
swap(regMax, regMin);}
296 KDTreeBox phiZ(prmin, prmax, regMin.min()-nSigmaRZ*rzError[il], regMax.max()+nSigmaRZ*rzError[il]);
297 hitTree[il].search(phiZ, foundNodes);
302 rzRange.min()-regOffset-nSigmaRZ*rzError[il],
303 rzRange.max()+regOffset+nSigmaRZ*rzError[il]);
304 hitTree[il].search(phiZ, foundNodes);
311 for (
auto KDdata : foundNodes) {
315 edm::LogError(
"TooManyTriplets")<<
" number of triples exceeds maximum. no triplets produced.";
319 float p3_u = hits.u[KDdata];
320 float p3_v = hits.v[KDdata];
321 float p3_phi = hits.lphi[KDdata];
327 Range allowed = predictionRZ(p3_u);
328 correction.correctRZRange(allowed);
329 float vErr = nSigmaRZ *hits.dv[KDdata];
330 Range hitRange(p3_v-vErr, p3_v+vErr);
332 if (crossingRange.empty())
continue;
334 float ir = 1.f/hits.rv(KDdata);
337 float phiErr = nSigmaPhi * hits.drphi[KDdata]*ir;
338 phiErr =
std::min(maxPhiErr, phiErr);
340 for (
int icharge=-1; icharge <=1; icharge+=2) {
341 Range rangeRPhi = predictionRPhi(hits.rv(KDdata), icharge);
342 if(rangeRPhi.first>rangeRPhi.second)
continue;
343 correction.correctRPhiRange(rangeRPhi);
344 if (
checkPhiInRange(p3_phi, rangeRPhi.first*ir-phiErr, rangeRPhi.second*ir+phiErr,maxPhiErr)) {
348 result.push_back( hittriplet );
350 if(tripletLastLayerIndex) tripletLastLayerIndex->push_back(il);
352 LogDebug(
"RejectedTriplet") <<
"rejected triplet from comparitor ";
357 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)
void setAllowAnything()
allow any parameter label/value pairs
float x(int i, layer l) const
const float extraHitRZtolerance
const unsigned int theMaxElement
std::unique_ptr< SeedComparitor > theComparitor
float z(int i, layer l) const
T curvature(T InversePt, const edm::EventSetup &iSetup)
PixelRecoRange< float > Range
static void fillDescriptions(edm::ParameterSetDescription &desc)
static void fillDescriptions(edm::ParameterSetDescription &desc)
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
PixelTripletHLTGenerator(const edm::ParameterSet &cfg, edm::ConsumesCollector &&iC)
LayerCacheType * theLayerCache
float y(int i, layer l) const
ParameterDescriptionBase * add(U const &iLabel, T const &value)
SeedingHitSet::ConstRecHitPointer Hit
BaseTrackerRecHit const * Hit
const bool useFixedPreFiltering
float phi(int i, layer l) const
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
PixelRecoRange< T > intersection(const PixelRecoRange< T > &r) const
#define declareDynArray(T, n, x)
void initTolerance(float tolerance)
virtual unsigned int size() const
DetLayer const * detLayer(layer l) const
float rv(int i, layer l) 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)