#include <PixelTripletHLTGenerator.h>
Definition at line 23 of file PixelTripletHLTGenerator.h.
typedef CombinedHitTripletGenerator::LayerCacheType PixelTripletHLTGenerator::LayerCacheType [private] |
Reimplemented from HitTripletGeneratorFromPairAndLayers.
Definition at line 25 of file PixelTripletHLTGenerator.h.
PixelTripletHLTGenerator::PixelTripletHLTGenerator | ( | const edm::ParameterSet & | cfg | ) |
Definition at line 32 of file PixelTripletHLTGenerator.cc.
References dphi, reco::get(), edm::ParameterSet::getParameter(), AlCaHLTBitMon_QueryRunRegistry::string, theComparitor, OrderedHitsGenerator::theMaxElement, and useFixedPreFiltering.
: thePairGenerator(0), theLayerCache(0), useFixedPreFiltering(cfg.getParameter<bool>("useFixedPreFiltering")), extraHitRZtolerance(cfg.getParameter<double>("extraHitRZtolerance")), extraHitRPhitolerance(cfg.getParameter<double>("extraHitRPhitolerance")), useMScat(cfg.getParameter<bool>("useMultScattering")), useBend(cfg.getParameter<bool>("useBending")) { theMaxElement=cfg.getParameter<unsigned int>("maxElement"); dphi = (useFixedPreFiltering) ? cfg.getParameter<double>("phiPreFiltering") : 0; edm::ParameterSet comparitorPSet = cfg.getParameter<edm::ParameterSet>("SeedComparitorPSet"); std::string comparitorName = comparitorPSet.getParameter<std::string>("ComponentName"); theComparitor = (comparitorName == "none") ? 0 : SeedComparitorFactory::get()->create( comparitorName, comparitorPSet); }
PixelTripletHLTGenerator::~PixelTripletHLTGenerator | ( | ) | [virtual] |
Definition at line 51 of file PixelTripletHLTGenerator.cc.
References theComparitor, and thePairGenerator.
{ delete thePairGenerator; delete theComparitor; }
bool PixelTripletHLTGenerator::checkPhiInRange | ( | float | phi, |
float | phi1, | ||
float | phi2 | ||
) | const [private] |
Definition at line 284 of file PixelTripletHLTGenerator.cc.
References Geom::ftwoPi().
Referenced by hitTriplets().
{ while (phi > phi2) phi -= Geom::ftwoPi(); while (phi < phi1) phi += Geom::ftwoPi(); return ( (phi1 <= phi) && (phi <= phi2) ); }
void PixelTripletHLTGenerator::hitTriplets | ( | const TrackingRegion & | region, |
OrderedHitTriplets & | trs, | ||
const edm::Event & | ev, | ||
const edm::EventSetup & | es | ||
) | [virtual] |
Implements HitTripletGenerator.
Definition at line 65 of file PixelTripletHLTGenerator.cc.
References angle(), KDTreeLinkerAlgo< DATA >::build(), checkPhiInRange(), SeedComparitor::compatible(), constexpr, PixelRecoUtilities::curvature(), HitDoublets::detLayer(), HitPairGenerator::doublets(), dphi, relativeConstraints::empty, extraHitRPhitolerance, extraHitRZtolerance, f, Geom::fpi(), Geom::ftwoPi(), i, SeedComparitor::init(), ThirdHitRZPredictionBase::initLayer(), ThirdHitRZPrediction< Propagator >::initPropagator(), ThirdHitRZPredictionBase::initTolerance(), HitDoublets::inner, PixelRecoRange< T >::intersection(), DetLayer::isBarrel(), geometryCSVtoXML::line, LogDebug, max(), PixelRecoRange< T >::max(), mergePhiRanges(), min, nSigmaPhi, nSigmaRZ, TrackingRegion::origin(), TrackingRegion::originRBound(), HitDoublets::outer, PV3DBase< T, PVType, FrameType >::perp(), TrackingRegion::ptMin(), CosmicsPD_Skims::radius, KDTreeLinkerAlgo< DATA >::search(), DetLayer::seqNum(), findQualityFiles::size, OrderedHitTriplets::size(), mathSSE::sqrt(), PixelRecoRange< T >::sum(), swap(), theComparitor, theLayers, OrderedHitsGenerator::theMaxElement, thePairGenerator, useBend, useFixedPreFiltering, useMScat, findQualityFiles::v, PV3DBase< T, PVType, FrameType >::x(), and PV3DBase< T, PVType, FrameType >::y().
{ if (theComparitor) theComparitor->init(es); auto const & doublets = thePairGenerator->doublets(region,ev,es); if (doublets.empty()) return; auto outSeq = doublets.detLayer(HitDoublets::outer)->seqNum(); // std::cout << "pairs " << doublets.size() << std::endl; float regOffset = region.origin().perp(); //try to take account of non-centrality (?) int size = theLayers.size(); ThirdHitRZPrediction<PixelRecoLineRZ> preds[size]; const RecHitsSortedInPhi * thirdHitMap[size]; typedef RecHitsSortedInPhi::Hit Hit; using NodeInfo = KDTreeNodeInfo<unsigned int>; std::vector<NodeInfo > layerTree; // re-used throughout KDTreeLinkerAlgo<unsigned int> hitTree[size]; float rzError[size]; //save maximum errors float maxphi = Geom::ftwoPi(), minphi = -maxphi; // increase to cater for any range // fill the prediction vector for (int il=0; il!=size; ++il) { thirdHitMap[il] = &(*theLayerCache)(&theLayers[il], region, ev, es); auto const & hits = *thirdHitMap[il]; ThirdHitRZPrediction<PixelRecoLineRZ> & pred = preds[il]; pred.initLayer(theLayers[il].detLayer()); pred.initTolerance(extraHitRZtolerance); layerTree.clear(); float minv=999999.0, maxv= -999999.0; // Initialise to extreme values in case no hits float maxErr=0.0f; for (unsigned int i=0; i!=hits.size(); ++i) { auto angle = hits.phi(i); auto v = hits.gv(i); //use (phi,r) for endcaps rather than (phi,z) minv = std::min(minv,v); maxv = std::max(maxv,v); float myerr = hits.dv[i]; maxErr = std::max(maxErr,myerr); layerTree.emplace_back(i, angle, v); // save it if (angle < 0) // wrap all points in phi { layerTree.emplace_back(i, angle+Geom::ftwoPi(), v);} else { layerTree.emplace_back(i, angle-Geom::ftwoPi(), v);} } KDTreeBox phiZ(minphi, maxphi, minv-0.01f, maxv+0.01f); // declare our bounds //add fudge factors in case only one hit and also for floating-point inaccuracy hitTree[il].build(layerTree, phiZ); // make KDtree rzError[il] = maxErr; //save error // std::cout << "layer " << theLayers[il].detLayer()->seqNum() << " " << layerTree.size() << std::endl; } float imppar = region.originRBound(); float imppartmp = region.originRBound()+region.origin().perp(); float curv = PixelRecoUtilities::curvature(1.f/region.ptMin(), es); for (std::size_t ip =0; ip!=doublets.size(); ip++) { auto xi = doublets.x(ip,HitDoublets::inner); auto yi = doublets.y(ip,HitDoublets::inner); auto zi = doublets.z(ip,HitDoublets::inner); auto rvi = doublets.rv(ip,HitDoublets::inner); auto xo = doublets.x(ip,HitDoublets::outer); auto yo = doublets.y(ip,HitDoublets::outer); auto zo = doublets.z(ip,HitDoublets::outer); auto rvo = doublets.rv(ip,HitDoublets::outer); PixelRecoPointRZ point1(rvi, zi); PixelRecoPointRZ point2(rvo, zo); PixelRecoLineRZ line(point1, point2); ThirdHitPredictionFromInvParabola predictionRPhi(xi-region.origin().x(),yi-region.origin().y(), xo-region.origin().x(),yo-region.origin().y(), imppar,curv,extraHitRPhitolerance); ThirdHitPredictionFromInvParabola predictionRPhitmp(xi,yi,xo,yo,imppartmp,curv,extraHitRPhitolerance); // printf("++Constr %f %f %f %f %f %f %f\n",xi,yi,xo,yo,imppartmp,curv,extraHitRPhitolerance); // std::cout << ip << ": " << point1.r() << ","<< point1.z() << " " // << point2.r() << ","<< point2.z() <<std::endl; for (int il=0; il!=size; ++il) { if (hitTree[il].empty()) continue; // Don't bother if no hits auto const & hits = *thirdHitMap[il]; const DetLayer * layer = theLayers[il].detLayer(); auto barrelLayer = layer->isBarrel(); ThirdHitCorrection correction(es, region.ptMin(), layer, line, point2, outSeq, useMScat, useBend); ThirdHitRZPrediction<PixelRecoLineRZ> & predictionRZ = preds[il]; predictionRZ.initPropagator(&line); Range rzRange = predictionRZ(); correction.correctRZRange(rzRange); Range phiRange; if (useFixedPreFiltering) { float phi0 = doublets.phi(ip,HitDoublets::outer); phiRange = Range(phi0-dphi,phi0+dphi); } else { Range radius; if (barrelLayer) { radius = predictionRZ.detRange(); } else { radius = Range(max(rzRange.min(), predictionRZ.detSize().min()), min(rzRange.max(), predictionRZ.detSize().max()) ); } if (radius.empty()) continue; // std::cout << "++R " << radius.min() << " " << radius.max() << std::endl; Range rPhi1m = predictionRPhitmp(radius.max(), -1); Range rPhi1p = predictionRPhitmp(radius.max(), 1); Range rPhi2m = predictionRPhitmp(radius.min(), -1); Range rPhi2p = predictionRPhitmp(radius.min(), 1); Range rPhi1 = rPhi1m.sum(rPhi1p); Range rPhi2 = rPhi2m.sum(rPhi2p); correction.correctRPhiRange(rPhi1); correction.correctRPhiRange(rPhi2); rPhi1.first /= radius.max(); rPhi1.second /= radius.max(); rPhi2.first /= radius.min(); rPhi2.second /= radius.min(); phiRange = mergePhiRanges(rPhi1,rPhi2); } constexpr float nSigmaRZ = std::sqrt(12.f); // ...and continue as before constexpr float nSigmaPhi = 3.f; layerTree.clear(); // Now recover hits in bounding box... float prmin=phiRange.min(), prmax=phiRange.max(); if ((prmax-prmin) > Geom::ftwoPi()) { prmax=Geom::fpi(); prmin = -Geom::fpi();} else { while (prmax>maxphi) { prmin -= Geom::ftwoPi(); prmax -= Geom::ftwoPi();} while (prmin<minphi) { prmin += Geom::ftwoPi(); prmax += Geom::ftwoPi();} // This needs range -twoPi to +twoPi to work } if (barrelLayer) { Range regMax = predictionRZ.detRange(); Range regMin = predictionRZ(regMax.min()-regOffset); regMax = predictionRZ(regMax.max()+regOffset); correction.correctRZRange(regMin); correction.correctRZRange(regMax); if (regMax.min() < regMin.min()) { swap(regMax, regMin);} KDTreeBox phiZ(prmin, prmax, regMin.min()-nSigmaRZ*rzError[il], regMax.max()+nSigmaRZ*rzError[il]); hitTree[il].search(phiZ, layerTree); } else { KDTreeBox phiZ(prmin, prmax, rzRange.min()-regOffset-nSigmaRZ*rzError[il], rzRange.max()+regOffset+nSigmaRZ*rzError[il]); hitTree[il].search(phiZ, layerTree); } // std::cout << ip << ": " << theLayers[il].detLayer()->seqNum() << " " << layerTree.size() << " " << prmin << " " << prmax << std::endl; // int kk=0; for (auto const & ih : layerTree) { if (theMaxElement!=0 && result.size() >= theMaxElement){ result.clear(); edm::LogError("TooManyTriplets")<<" number of triples exceeds maximum. no triplets produced."; return; } auto KDdata = ih.data; float p3_u = hits.u[KDdata]; float p3_v = hits.v[KDdata]; float p3_phi = hits.lphi[KDdata]; //if ((kk++)%100==0) //std::cout << kk << ": " << p3_u << " " << p3_v << " " << p3_phi << std::endl; Range allowed = predictionRZ(p3_u); correction.correctRZRange(allowed); float vErr = nSigmaRZ *hits.dv[KDdata]; Range hitRange(p3_v-vErr, p3_v+vErr); Range crossingRange = allowed.intersection(hitRange); if (crossingRange.empty()) continue; float ir = 1.f/hits.rv(KDdata); float phiErr = nSigmaPhi * hits.drphi[KDdata]*ir; for (int icharge=-1; icharge <=1; icharge+=2) { Range rangeRPhi = predictionRPhi(hits.rv(KDdata), icharge); correction.correctRPhiRange(rangeRPhi); if (checkPhiInRange(p3_phi, rangeRPhi.first*ir-phiErr, rangeRPhi.second*ir+phiErr)) { // insert here check with comparitor OrderedHitTriplet hittriplet( doublets.hit(ip,HitDoublets::inner), doublets.hit(ip,HitDoublets::outer), hits.theHits[KDdata].hit()); if (!theComparitor || theComparitor->compatible(hittriplet,region) ) { result.push_back( hittriplet ); } else { LogDebug("RejectedTriplet") << "rejected triplet from comparitor "; } break; } } } } } // std::cout << "triplets " << result.size() << std::endl; }
void PixelTripletHLTGenerator::init | ( | const HitPairGenerator & | pairs, |
const std::vector< ctfseeding::SeedingLayer > & | layers, | ||
LayerCacheType * | layerCache | ||
) | [virtual] |
Implements HitTripletGeneratorFromPairAndLayers.
Definition at line 56 of file PixelTripletHLTGenerator.cc.
References HitPairGenerator::clone(), theLayerCache, theLayers, and thePairGenerator.
{ thePairGenerator = pairs.clone(); theLayers = layers; theLayerCache = layerCache; }
std::pair< float, float > PixelTripletHLTGenerator::mergePhiRanges | ( | const std::pair< float, float > & | r1, |
const std::pair< float, float > & | r2 | ||
) | const [private] |
Definition at line 291 of file PixelTripletHLTGenerator.cc.
References Geom::fpi(), Geom::ftwoPi(), max(), and min.
Referenced by hitTriplets().
{ float r2_min=r2.first; float r2_max=r2.second; while (r1.first-r2_min > Geom::fpi()) { r2_min += Geom::ftwoPi(); r2_max += Geom::ftwoPi();} while (r1.first-r2_min < -Geom::fpi()) { r2_min -= Geom::ftwoPi(); r2_max -= Geom::ftwoPi(); } return std::make_pair(min(r1.first,r2_min),max(r1.second,r2_max)); }
const HitPairGenerator& PixelTripletHLTGenerator::pairGenerator | ( | ) | const [inline] |
Definition at line 38 of file PixelTripletHLTGenerator.h.
References thePairGenerator.
{ return *thePairGenerator; }
const std::vector<ctfseeding::SeedingLayer>& PixelTripletHLTGenerator::thirdLayers | ( | ) | const [inline] |
Definition at line 39 of file PixelTripletHLTGenerator.h.
References theLayers.
{ return theLayers; }
float PixelTripletHLTGenerator::dphi [private] |
Definition at line 56 of file PixelTripletHLTGenerator.h.
Referenced by hitTriplets(), and PixelTripletHLTGenerator().
float PixelTripletHLTGenerator::extraHitRPhitolerance [private] |
Definition at line 53 of file PixelTripletHLTGenerator.h.
Referenced by hitTriplets().
float PixelTripletHLTGenerator::extraHitRZtolerance [private] |
Definition at line 52 of file PixelTripletHLTGenerator.h.
Referenced by hitTriplets().
Definition at line 57 of file PixelTripletHLTGenerator.h.
Referenced by hitTriplets(), PixelTripletHLTGenerator(), and ~PixelTripletHLTGenerator().
Definition at line 49 of file PixelTripletHLTGenerator.h.
Referenced by init().
std::vector<ctfseeding::SeedingLayer> PixelTripletHLTGenerator::theLayers [private] |
Definition at line 48 of file PixelTripletHLTGenerator.h.
Referenced by hitTriplets(), init(), and thirdLayers().
Definition at line 47 of file PixelTripletHLTGenerator.h.
Referenced by hitTriplets(), init(), pairGenerator(), and ~PixelTripletHLTGenerator().
bool PixelTripletHLTGenerator::useBend [private] |
Definition at line 55 of file PixelTripletHLTGenerator.h.
Referenced by hitTriplets().
bool PixelTripletHLTGenerator::useFixedPreFiltering [private] |
Definition at line 51 of file PixelTripletHLTGenerator.h.
Referenced by hitTriplets(), and PixelTripletHLTGenerator().
bool PixelTripletHLTGenerator::useMScat [private] |
Definition at line 54 of file PixelTripletHLTGenerator.h.
Referenced by hitTriplets().