CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Types | Private Attributes
PixelTripletHLTGenerator Class Reference

#include <PixelTripletHLTGenerator.h>

Inheritance diagram for PixelTripletHLTGenerator:
HitTripletGeneratorFromPairAndLayers

Public Member Functions

virtual void hitTriplets (const TrackingRegion &region, OrderedHitTriplets &trs, const edm::Event &ev, const edm::EventSetup &es, SeedingLayerSetsHits::SeedingLayerSet pairLayers, const std::vector< SeedingLayerSetsHits::SeedingLayer > &thirdLayers) override
 
 PixelTripletHLTGenerator (const edm::ParameterSet &cfg, edm::ConsumesCollector &iC)
 
virtual ~PixelTripletHLTGenerator ()
 
- Public Member Functions inherited from HitTripletGeneratorFromPairAndLayers
 HitTripletGeneratorFromPairAndLayers (unsigned int maxElement=0)
 
 HitTripletGeneratorFromPairAndLayers (const edm::ParameterSet &pset)
 
void init (std::unique_ptr< HitPairGeneratorFromLayerPair > &&pairs, LayerCacheType *layerCache)
 
const
HitPairGeneratorFromLayerPair
pairGenerator () const
 
virtual ~HitTripletGeneratorFromPairAndLayers ()
 

Private Types

typedef
CombinedHitTripletGenerator::LayerCacheType 
LayerCacheType
 

Private Attributes

const float dphi
 
const float extraHitRPhitolerance
 
const float extraHitRZtolerance
 
std::unique_ptr< SeedComparitortheComparitor
 
const bool useBend
 
const bool useFixedPreFiltering
 
const bool useMScat
 

Additional Inherited Members

- Public Types inherited from HitTripletGeneratorFromPairAndLayers
typedef LayerHitMapCache LayerCacheType
 
- Protected Attributes inherited from HitTripletGeneratorFromPairAndLayers
LayerCacheTypetheLayerCache
 
const unsigned int theMaxElement
 
std::unique_ptr
< HitPairGeneratorFromLayerPair
thePairGenerator
 

Detailed Description

Definition at line 20 of file PixelTripletHLTGenerator.h.

Member Typedef Documentation

Definition at line 22 of file PixelTripletHLTGenerator.h.

Constructor & Destructor Documentation

PixelTripletHLTGenerator::PixelTripletHLTGenerator ( const edm::ParameterSet cfg,
edm::ConsumesCollector iC 
)

Definition at line 37 of file PixelTripletHLTGenerator.cc.

References beamerCreator::create(), reco::get(), edm::ParameterSet::getParameter(), AlCaHLTBitMon_QueryRunRegistry::string, and theComparitor.

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)
45 {
46  edm::ParameterSet comparitorPSet =
47  cfg.getParameter<edm::ParameterSet>("SeedComparitorPSet");
48  std::string comparitorName = comparitorPSet.getParameter<std::string>("ComponentName");
49  if(comparitorName != "none") {
50  theComparitor.reset( SeedComparitorFactory::get()->create( comparitorName, comparitorPSet, iC) );
51  }
52 }
T getParameter(std::string const &) const
std::unique_ptr< SeedComparitor > theComparitor
T get(const Candidate &c)
Definition: component.h:55
PixelTripletHLTGenerator::~PixelTripletHLTGenerator ( )
virtual

Definition at line 54 of file PixelTripletHLTGenerator.cc.

54 {}

Member Function Documentation

void PixelTripletHLTGenerator::hitTriplets ( const TrackingRegion region,
OrderedHitTriplets trs,
const edm::Event ev,
const edm::EventSetup es,
SeedingLayerSetsHits::SeedingLayerSet  pairLayers,
const std::vector< SeedingLayerSetsHits::SeedingLayer > &  thirdLayers 
)
overridevirtual

Implements HitTripletGeneratorFromPairAndLayers.

Definition at line 56 of file PixelTripletHLTGenerator.cc.

References angle(), checkPhiInRange(), constexpr, PixelRecoUtilities::curvature(), declareDynArray, dphi, relativeConstraints::empty, ev, extraHitRPhitolerance, extraHitRZtolerance, f, Geom::ftwoPi(), i, ThirdHitRZPredictionBase::initLayer(), ThirdHitRZPredictionBase::initTolerance(), HitDoublets::inner, PixelRecoRange< T >::intersection(), DetLayer::isBarrel(), geometryCSVtoXML::line, LogDebug, M_PI, bookConverter::max, min(), normalizedPhi(), nSigmaPhi, nSigmaRZ, TrackingRegion::origin(), TrackingRegion::originRBound(), HitDoublets::outer, PV3DBase< T, PVType, FrameType >::perp(), GeometricSearchDet::position(), proxim(), TrackingRegion::ptMin(), CosmicsPD_Skims::radius, HLT_25ns10e33_v2_cff::region, OrderedHitTriplets::size(), findQualityFiles::size, swap(), theComparitor, HitTripletGeneratorFromPairAndLayers::theMaxElement, HitTripletGeneratorFromPairAndLayers::thePairGenerator, useBend, useFixedPreFiltering, useMScat, findQualityFiles::v, PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), and PV3DBase< T, PVType, FrameType >::z().

62 {
63 
64  if (theComparitor) theComparitor->init(ev, es);
65 
66  auto const & doublets = thePairGenerator->doublets(region,ev,es, pairLayers);
67 
68  if (doublets.empty()) return;
69 
70  auto outSeq = doublets.detLayer(HitDoublets::outer)->seqNum();
71 
72 
73  // std::cout << "pairs " << doublets.size() << std::endl;
74 
75  float regOffset = region.origin().perp(); //try to take account of non-centrality (?)
76  int size = thirdLayers.size();
77 
79  declareDynArray(ThirdHitCorrection, size, corrections);
80 
81  const RecHitsSortedInPhi * thirdHitMap[size];
83 
84  using NodeInfo = KDTreeNodeInfo<unsigned int>;
85  std::vector<NodeInfo > layerTree; // re-used throughout
86  std::vector<unsigned int> foundNodes; // re-used thoughout
87  foundNodes.reserve(100);
88 
90  float rzError[size]; //save maximum errors
91 
92 
93  const float maxDelphi = region.ptMin() < 0.3f ? float(M_PI)/4.f : float(M_PI)/8.f; // FIXME move to config??
94  const float maxphi = M_PI+maxDelphi, minphi = -maxphi; // increase to cater for any range
95  const float safePhi = M_PI-maxDelphi; // sideband
96 
97 
98  // fill the prediction vector
99  for (int il=0; il<size; ++il) {
100  thirdHitMap[il] = &(*theLayerCache)(thirdLayers[il], region, ev, es);
101  auto const & hits = *thirdHitMap[il];
102  ThirdHitRZPrediction<PixelRecoLineRZ> & pred = preds[il];
103  pred.initLayer(thirdLayers[il].detLayer());
105 
106  corrections[il].init(es, region.ptMin(), *doublets.detLayer(HitDoublets::inner), *doublets.detLayer(HitDoublets::outer),
107  *thirdLayers[il].detLayer(), useMScat, useBend);
108 
109  layerTree.clear();
110  float minv=999999.0f, maxv= -minv; // Initialise to extreme values in case no hits
111  float maxErr=0.0f;
112  for (unsigned int i=0; i!=hits.size(); ++i) {
113  auto angle = hits.phi(i);
114  auto v = hits.gv(i);
115  //use (phi,r) for endcaps rather than (phi,z)
116  minv = std::min(minv,v); maxv = std::max(maxv,v);
117  float myerr = hits.dv[i];
118  maxErr = std::max(maxErr,myerr);
119  layerTree.emplace_back(i, angle, v); // save it
120  // populate side-bands
121  if (angle>safePhi) layerTree.emplace_back(i, angle-Geom::ftwoPi(), v);
122  else if (angle<-safePhi) layerTree.emplace_back(i, angle+Geom::ftwoPi(), v);
123  }
124  KDTreeBox phiZ(minphi, maxphi, minv-0.01f, maxv+0.01f); // declare our bounds
125  //add fudge factors in case only one hit and also for floating-point inaccuracy
126  hitTree[il].build(layerTree, phiZ); // make KDtree
127  rzError[il] = maxErr; //save error
128  // std::cout << "layer " << thirdLayers[il].detLayer()->seqNum() << " " << layerTree.size() << std::endl;
129  }
130 
131  float imppar = region.originRBound();
132  float imppartmp = region.originRBound()+region.origin().perp();
133  float curv = PixelRecoUtilities::curvature(1.f/region.ptMin(), es);
134 
135  for (std::size_t ip =0; ip!=doublets.size(); ip++) {
136  auto xi = doublets.x(ip,HitDoublets::inner);
137  auto yi = doublets.y(ip,HitDoublets::inner);
138  auto zi = doublets.z(ip,HitDoublets::inner);
139  auto rvi = doublets.rv(ip,HitDoublets::inner);
140  auto xo = doublets.x(ip,HitDoublets::outer);
141  auto yo = doublets.y(ip,HitDoublets::outer);
142  auto zo = doublets.z(ip,HitDoublets::outer);
143  auto rvo = doublets.rv(ip,HitDoublets::outer);
144 
145  auto toPos = std::signbit(zo-zi);
146 
147  PixelRecoPointRZ point1(rvi, zi);
148  PixelRecoPointRZ point2(rvo, zo);
149  PixelRecoLineRZ line(point1, point2);
150  ThirdHitPredictionFromInvParabola predictionRPhi(xi-region.origin().x(),yi-region.origin().y(),
151  xo-region.origin().x(),yo-region.origin().y(),
152  imppar,curv,extraHitRPhitolerance);
153 
154  ThirdHitPredictionFromInvParabola predictionRPhitmp(xi,yi,xo,yo,imppartmp,curv,extraHitRPhitolerance);
155 
156  // printf("++Constr %f %f %f %f %f %f %f\n",xi,yi,xo,yo,imppartmp,curv,extraHitRPhitolerance);
157 
158  // std::cout << ip << ": " << point1.r() << ","<< point1.z() << " "
159  // << point2.r() << ","<< point2.z() <<std::endl;
160 
161  for (int il=0; il!=size; ++il) {
162  const DetLayer * layer = thirdLayers[il].detLayer();
163  auto barrelLayer = layer->isBarrel();
164 
165  if ( (!barrelLayer) & (toPos != std::signbit(layer->position().z())) ) continue;
166 
167  if (hitTree[il].empty()) continue; // Don't bother if no hits
168 
169  auto const & hits = *thirdHitMap[il];
170 
171  auto & correction = corrections[il];
172 
173  correction.init(line, point2, outSeq);
174 
175  auto & predictionRZ = preds[il];
176 
177  predictionRZ.initPropagator(&line);
178  Range rzRange = predictionRZ();
179  correction.correctRZRange(rzRange);
180 
181  Range phiRange;
182  if (useFixedPreFiltering) {
183  float phi0 = doublets.phi(ip,HitDoublets::outer);
184  phiRange = Range(phi0-dphi,phi0+dphi);
185  }
186  else {
187  Range radius;
188  if (barrelLayer) {
189  radius = predictionRZ.detRange();
190  } else {
191  radius = Range(max(rzRange.min(), predictionRZ.detSize().min()),
192  min(rzRange.max(), predictionRZ.detSize().max()) );
193  }
194  if (radius.empty()) continue;
195 
196  // std::cout << "++R " << radius.min() << " " << radius.max() << std::endl;
197 
198  auto rPhi1 = predictionRPhitmp(radius.max());
199  bool ok1 = !rPhi1.empty();
200  if (ok1) {
201  correction.correctRPhiRange(rPhi1);
202  rPhi1.first /= radius.max();
203  rPhi1.second /= radius.max();
204  }
205  auto rPhi2 = predictionRPhitmp(radius.min());
206  bool ok2 = !rPhi2.empty();
207  if (ok2) {
208  correction.correctRPhiRange(rPhi2);
209  rPhi2.first /= radius.min();
210  rPhi2.second /= radius.min();
211  }
212 
213  if (ok1) {
214  rPhi1.first = normalizedPhi(rPhi1.first);
215  rPhi1.second = proxim(rPhi1.second,rPhi1.first);
216  if(ok2) {
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;
221  } else if(ok2) {
222  rPhi2.first = normalizedPhi(rPhi2.first);
223  rPhi2.second = proxim(rPhi2.second,rPhi2.first);
224  phiRange=rPhi2;
225  } else continue;
226 
227  }
228 
229  constexpr float nSigmaRZ = 3.46410161514f; // std::sqrt(12.f); // ...and continue as before
230  constexpr float nSigmaPhi = 3.f;
231 
232  foundNodes.clear(); // Now recover hits in bounding box...
233  float prmin=phiRange.min(), prmax=phiRange.max();
234 
235 
236  if (prmax-prmin>maxDelphi) {
237  auto prm = phiRange.mean();
238  prmin = prm - 0.5f*maxDelphi;
239  prmax = prm + 0.5f*maxDelphi;
240  }
241 
242  if (barrelLayer)
243  {
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);
252  }
253  else
254  {
255  KDTreeBox phiZ(prmin, prmax,
256  rzRange.min()-regOffset-nSigmaRZ*rzError[il],
257  rzRange.max()+regOffset+nSigmaRZ*rzError[il]);
258  hitTree[il].search(phiZ, foundNodes);
259  }
260 
261  // std::cout << ip << ": " << thirdLayers[il].detLayer()->seqNum() << " " << foundNodes.size() << " " << prmin << " " << prmax << std::endl;
262 
263 
264  // int kk=0;
265  for (auto KDdata : foundNodes) {
266 
267  if (theMaxElement!=0 && result.size() >= theMaxElement){
268  result.clear();
269  edm::LogError("TooManyTriplets")<<" number of triples exceeds maximum. no triplets produced.";
270  return;
271  }
272 
273  float p3_u = hits.u[KDdata];
274  float p3_v = hits.v[KDdata];
275  float p3_phi = hits.lphi[KDdata];
276 
277  //if ((kk++)%100==0)
278  //std::cout << kk << ": " << p3_u << " " << p3_v << " " << p3_phi << std::endl;
279 
280 
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);
285  Range crossingRange = allowed.intersection(hitRange);
286  if (crossingRange.empty()) continue;
287 
288  float ir = 1.f/hits.rv(KDdata);
289  float phiErr = nSigmaPhi * hits.drphi[KDdata]*ir;
290  bool nook=true;
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)) {
295  // insert here check with comparitor
296  OrderedHitTriplet hittriplet( doublets.hit(ip,HitDoublets::inner), doublets.hit(ip,HitDoublets::outer), hits.theHits[KDdata].hit());
297  if (!theComparitor || theComparitor->compatible(hittriplet,region) ) {
298  result.push_back( hittriplet );
299  } else {
300  LogDebug("RejectedTriplet") << "rejected triplet from comparitor ";
301  }
302  nook=false; break;
303  }
304  }
305  if (nook) LogDebug("RejectedTriplet") << "rejected triplet from second phicheck " << p3_phi;
306  }
307  }
308  }
309  // std::cout << "triplets " << result.size() << std::endl;
310 }
#define LogDebug(id)
void swap(ora::Record &rh, ora::Record &lh)
Definition: Record.h:70
int i
Definition: DBlmapReader.cc:9
T perp() const
Definition: PV3DBase.h:72
GlobalPoint const & origin() const
constexpr float ftwoPi()
Definition: Pi.h:36
void initLayer(const DetLayer *layer)
PixelRecoRange< float > Range
bool ev
#define constexpr
std::unique_ptr< SeedComparitor > theComparitor
tuple result
Definition: mps_fire.py:84
T curvature(T InversePt, const edm::EventSetup &iSetup)
T z() const
Definition: PV3DBase.h:64
double f[11][100]
T min(T a, T b)
Definition: MathUtil.h:58
SeedingHitSet::ConstRecHitPointer Hit
BaseTrackerRecHit const * Hit
#define M_PI
bool isBarrel() const
Definition: DetLayer.h:32
std::unique_ptr< HitPairGeneratorFromLayerPair > thePairGenerator
T proxim(T b, T a)
Definition: normalizedPhi.h:13
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
bool checkPhiInRange(T phi, T phi1, T phi2)
Definition: normalizedPhi.h:21
#define declareDynArray(T, n, x)
Definition: DynArray.h:58
void initTolerance(float tolerance)
tuple size
Write out results.
T normalizedPhi(T phi)
Definition: normalizedPhi.h:8
T angle(T x1, T y1, T z1, T x2, T y2, T z2)
Definition: angle.h:11

Member Data Documentation

const float PixelTripletHLTGenerator::dphi
private

Definition at line 40 of file PixelTripletHLTGenerator.h.

Referenced by hitTriplets().

const float PixelTripletHLTGenerator::extraHitRPhitolerance
private

Definition at line 37 of file PixelTripletHLTGenerator.h.

Referenced by hitTriplets().

const float PixelTripletHLTGenerator::extraHitRZtolerance
private

Definition at line 36 of file PixelTripletHLTGenerator.h.

Referenced by hitTriplets().

std::unique_ptr<SeedComparitor> PixelTripletHLTGenerator::theComparitor
private

Definition at line 41 of file PixelTripletHLTGenerator.h.

Referenced by hitTriplets(), and PixelTripletHLTGenerator().

const bool PixelTripletHLTGenerator::useBend
private

Definition at line 39 of file PixelTripletHLTGenerator.h.

Referenced by hitTriplets().

const bool PixelTripletHLTGenerator::useFixedPreFiltering
private

Definition at line 35 of file PixelTripletHLTGenerator.h.

Referenced by hitTriplets().

const bool PixelTripletHLTGenerator::useMScat
private

Definition at line 38 of file PixelTripletHLTGenerator.h.

Referenced by hitTriplets().