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 Member Functions | Private Attributes
PixelTripletHLTGenerator Class Reference

#include <PixelTripletHLTGenerator.h>

Inheritance diagram for PixelTripletHLTGenerator:
HitTripletGeneratorFromPairAndLayers HitTripletGenerator OrderedHitsGenerator

Public Member Functions

virtual void hitTriplets (const TrackingRegion &region, OrderedHitTriplets &trs, const edm::Event &ev, const edm::EventSetup &es)
 
void init (const HitPairGenerator &pairs, LayerCacheType *layerCache) override
 
const HitPairGeneratorpairGenerator () const
 
 PixelTripletHLTGenerator (const edm::ParameterSet &cfg, edm::ConsumesCollector &iC)
 
void setSeedingLayers (SeedingLayerSetsHits::SeedingLayerSet pairLayers, std::vector< SeedingLayerSetsHits::SeedingLayer > thirdLayers) override
 
virtual ~PixelTripletHLTGenerator ()
 
- Public Member Functions inherited from HitTripletGeneratorFromPairAndLayers
virtual ~HitTripletGeneratorFromPairAndLayers ()
 
- Public Member Functions inherited from HitTripletGenerator
virtual void clear ()
 
 HitTripletGenerator (unsigned int size=500)
 
virtual void hitTriplets (const TrackingRegion &reg, OrderedHitTriplets &prs, const edm::EventSetup &es)
 
virtual const OrderedHitTripletsrun (const TrackingRegion &region, const edm::Event &ev, const edm::EventSetup &es)
 
virtual ~HitTripletGenerator ()
 
- Public Member Functions inherited from OrderedHitsGenerator
 OrderedHitsGenerator ()
 
virtual ~OrderedHitsGenerator ()
 

Private Types

typedef
CombinedHitTripletGenerator::LayerCacheType 
LayerCacheType
 

Private Member Functions

bool checkPhiInRange (float phi, float phi1, float phi2) const
 
std::pair< float, float > mergePhiRanges (const std::pair< float, float > &r1, const std::pair< float, float > &r2) const
 

Private Attributes

float dphi
 
float extraHitRPhitolerance
 
float extraHitRZtolerance
 
std::unique_ptr< SeedComparitortheComparitor
 
LayerCacheTypetheLayerCache
 
std::vector
< SeedingLayerSetsHits::SeedingLayer
theLayers
 
HitPairGeneratorthePairGenerator
 
bool useBend
 
bool useFixedPreFiltering
 
bool useMScat
 

Additional Inherited Members

- Public Types inherited from HitTripletGeneratorFromPairAndLayers
typedef LayerHitMapCache LayerCacheType
 
- Public Attributes inherited from OrderedHitsGenerator
unsigned int theMaxElement
 

Detailed Description

Definition at line 22 of file PixelTripletHLTGenerator.h.

Member Typedef Documentation

Definition at line 24 of file PixelTripletHLTGenerator.h.

Constructor & Destructor Documentation

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

Definition at line 32 of file PixelTripletHLTGenerator.cc.

References SurfaceDeformationFactory::create(), dphi, reco::get(), edm::ParameterSet::getParameter(), AlCaHLTBitMon_QueryRunRegistry::string, theComparitor, OrderedHitsGenerator::theMaxElement, and useFixedPreFiltering.

33  : thePairGenerator(0),
34  theLayerCache(0),
35  useFixedPreFiltering(cfg.getParameter<bool>("useFixedPreFiltering")),
36  extraHitRZtolerance(cfg.getParameter<double>("extraHitRZtolerance")),
37  extraHitRPhitolerance(cfg.getParameter<double>("extraHitRPhitolerance")),
38  useMScat(cfg.getParameter<bool>("useMultScattering")),
39  useBend(cfg.getParameter<bool>("useBending"))
40 {
41  theMaxElement=cfg.getParameter<unsigned int>("maxElement");
42  dphi = (useFixedPreFiltering) ? cfg.getParameter<double>("phiPreFiltering") : 0;
43 
44  edm::ParameterSet comparitorPSet =
45  cfg.getParameter<edm::ParameterSet>("SeedComparitorPSet");
46  std::string comparitorName = comparitorPSet.getParameter<std::string>("ComponentName");
47  if(comparitorName != "none") {
48  theComparitor.reset( SeedComparitorFactory::get()->create( comparitorName, comparitorPSet, iC) );
49  }
50 }
T getParameter(std::string const &) const
std::unique_ptr< SeedComparitor > theComparitor
SurfaceDeformation * create(int type, const std::vector< double > &params)
T get(const Candidate &c)
Definition: component.h:55
PixelTripletHLTGenerator::~PixelTripletHLTGenerator ( )
virtual

Definition at line 52 of file PixelTripletHLTGenerator.cc.

References thePairGenerator.

52  {
53  delete thePairGenerator;
54 }

Member Function Documentation

bool PixelTripletHLTGenerator::checkPhiInRange ( float  phi,
float  phi1,
float  phi2 
) const
private

Definition at line 309 of file PixelTripletHLTGenerator.cc.

References Geom::ftwoPi().

Referenced by hitTriplets().

310 {
311  while (phi > phi2) phi -= Geom::ftwoPi();
312  while (phi < phi1) phi += Geom::ftwoPi();
313  return ( (phi1 <= phi) && (phi <= phi2) );
314 }
float ftwoPi()
Definition: Pi.h:36
Definition: DDAxes.h:10
void PixelTripletHLTGenerator::hitTriplets ( const TrackingRegion region,
OrderedHitTriplets trs,
const edm::Event ev,
const edm::EventSetup es 
)
virtual

Implements HitTripletGenerator.

Definition at line 69 of file PixelTripletHLTGenerator.cc.

References angle(), KDTreeLinkerAlgo< DATA >::build(), checkPhiInRange(), constexpr, PixelRecoUtilities::curvature(), HitDoublets::detLayer(), HitPairGenerator::doublets(), dphi, relativeConstraints::empty, extraHitRPhitolerance, extraHitRZtolerance, f, Geom::fpi(), Geom::ftwoPi(), i, ThirdHitRZPredictionBase::initLayer(), ThirdHitRZPrediction< Propagator >::initPropagator(), ThirdHitRZPredictionBase::initTolerance(), HitDoublets::inner, PixelRecoRange< T >::intersection(), DetLayer::isBarrel(), geometryCSVtoXML::line, LogDebug, max(), mergePhiRanges(), bookConverter::min, nSigmaPhi, nSigmaRZ, TrackingRegion::origin(), TrackingRegion::originRBound(), HitDoublets::outer, PV3DBase< T, PVType, FrameType >::perp(), TrackingRegion::ptMin(), CosmicsPD_Skims::radius, KDTreeLinkerAlgo< DATA >::search(), DetLayer::seqNum(), OrderedHitTriplets::size(), findQualityFiles::size, swap(), theComparitor, theLayers, OrderedHitsGenerator::theMaxElement, thePairGenerator, useBend, useFixedPreFiltering, useMScat, findQualityFiles::v, PV3DBase< T, PVType, FrameType >::x(), and PV3DBase< T, PVType, FrameType >::y().

73 {
74 
75  if (theComparitor) theComparitor->init(ev, es);
76 
77  auto const & doublets = thePairGenerator->doublets(region,ev,es);
78 
79  if (doublets.empty()) return;
80 
81  auto outSeq = doublets.detLayer(HitDoublets::outer)->seqNum();
82 
83 
84  // std::cout << "pairs " << doublets.size() << std::endl;
85 
86  float regOffset = region.origin().perp(); //try to take account of non-centrality (?)
87  int size = theLayers.size();
88 
90 
91  const RecHitsSortedInPhi * thirdHitMap[size];
93 
94  using NodeInfo = KDTreeNodeInfo<unsigned int>;
95  std::vector<NodeInfo > layerTree; // re-used throughout
96  std::vector<unsigned int> foundNodes; // re-used thoughout
97  foundNodes.reserve(100);
98 
100  float rzError[size]; //save maximum errors
101  float maxphi = Geom::ftwoPi(), minphi = -maxphi; // increase to cater for any range
102 
103  // fill the prediction vector
104  for (int il=0; il!=size; ++il) {
105  thirdHitMap[il] = &(*theLayerCache)(theLayers[il], region, ev, es);
106  auto const & hits = *thirdHitMap[il];
107  ThirdHitRZPrediction<PixelRecoLineRZ> & pred = preds[il];
108  pred.initLayer(theLayers[il].detLayer());
110 
111  layerTree.clear();
112  float minv=999999.0, maxv= -999999.0; // Initialise to extreme values in case no hits
113  float maxErr=0.0f;
114  for (unsigned int i=0; i!=hits.size(); ++i) {
115  auto angle = hits.phi(i);
116  auto v = hits.gv(i);
117  //use (phi,r) for endcaps rather than (phi,z)
118  minv = std::min(minv,v); maxv = std::max(maxv,v);
119  float myerr = hits.dv[i];
120  maxErr = std::max(maxErr,myerr);
121  layerTree.emplace_back(i, angle, v); // save it
122  if (angle < 0) // wrap all points in phi
123  { layerTree.emplace_back(i, angle+Geom::ftwoPi(), v);}
124  else
125  { layerTree.emplace_back(i, angle-Geom::ftwoPi(), v);}
126  }
127  KDTreeBox phiZ(minphi, maxphi, minv-0.01f, maxv+0.01f); // declare our bounds
128  //add fudge factors in case only one hit and also for floating-point inaccuracy
129  hitTree[il].build(layerTree, phiZ); // make KDtree
130  rzError[il] = maxErr; //save error
131  // std::cout << "layer " << theLayers[il].detLayer()->seqNum() << " " << layerTree.size() << std::endl;
132  }
133 
134  float imppar = region.originRBound();
135  float imppartmp = region.originRBound()+region.origin().perp();
136  float curv = PixelRecoUtilities::curvature(1.f/region.ptMin(), es);
137 
138  for (std::size_t ip =0; ip!=doublets.size(); ip++) {
139  auto xi = doublets.x(ip,HitDoublets::inner);
140  auto yi = doublets.y(ip,HitDoublets::inner);
141  auto zi = doublets.z(ip,HitDoublets::inner);
142  auto rvi = doublets.rv(ip,HitDoublets::inner);
143  auto xo = doublets.x(ip,HitDoublets::outer);
144  auto yo = doublets.y(ip,HitDoublets::outer);
145  auto zo = doublets.z(ip,HitDoublets::outer);
146  auto rvo = doublets.rv(ip,HitDoublets::outer);
147 
148  PixelRecoPointRZ point1(rvi, zi);
149  PixelRecoPointRZ point2(rvo, zo);
150  PixelRecoLineRZ line(point1, point2);
151  ThirdHitPredictionFromInvParabola predictionRPhi(xi-region.origin().x(),yi-region.origin().y(),
152  xo-region.origin().x(),yo-region.origin().y(),
153  imppar,curv,extraHitRPhitolerance);
154 
155  ThirdHitPredictionFromInvParabola predictionRPhitmp(xi,yi,xo,yo,imppartmp,curv,extraHitRPhitolerance);
156 
157  // printf("++Constr %f %f %f %f %f %f %f\n",xi,yi,xo,yo,imppartmp,curv,extraHitRPhitolerance);
158 
159  // std::cout << ip << ": " << point1.r() << ","<< point1.z() << " "
160  // << point2.r() << ","<< point2.z() <<std::endl;
161 
162  for (int il=0; il!=size; ++il) {
163  if (hitTree[il].empty()) continue; // Don't bother if no hits
164 
165  auto const & hits = *thirdHitMap[il];
166 
167  const DetLayer * layer = theLayers[il].detLayer();
168  auto barrelLayer = layer->isBarrel();
169 
170  ThirdHitCorrection correction(es, region.ptMin(), layer, line, point2, outSeq, useMScat, useBend);
171 
172  ThirdHitRZPrediction<PixelRecoLineRZ> & predictionRZ = preds[il];
173 
174  predictionRZ.initPropagator(&line);
175  Range rzRange = predictionRZ();
176  correction.correctRZRange(rzRange);
177 
178  Range phiRange;
179  if (useFixedPreFiltering) {
180  float phi0 = doublets.phi(ip,HitDoublets::outer);
181  phiRange = Range(phi0-dphi,phi0+dphi);
182  }
183  else {
184  Range radius;
185  if (barrelLayer) {
186  radius = predictionRZ.detRange();
187  } else {
188  radius = Range(max(rzRange.min(), predictionRZ.detSize().min()),
189  min(rzRange.max(), predictionRZ.detSize().max()) );
190  }
191  if (radius.empty()) continue;
192 
193  // std::cout << "++R " << radius.min() << " " << radius.max() << std::endl;
194 
195  /*
196  Range rPhi1m = predictionRPhitmp(radius.max(), -1);
197  Range rPhi1p = predictionRPhitmp(radius.max(), 1);
198  Range rPhi2m = predictionRPhitmp(radius.min(), -1);
199  Range rPhi2p = predictionRPhitmp(radius.min(), 1);
200  Range rPhi1 = rPhi1m.sum(rPhi1p);
201  Range rPhi2 = rPhi2m.sum(rPhi2p);
202 
203 
204  auto rPhi1N = predictionRPhitmp(radius.max());
205  auto rPhi2N = predictionRPhitmp(radius.min());
206 
207  std::cout << "VI "
208  << rPhi1N.first <<'/'<< rPhi1.first << ' '
209  << rPhi1N.second <<'/'<< rPhi1.second << ' '
210  << rPhi2N.first <<'/'<< rPhi2.first << ' '
211  << rPhi2N.second <<'/'<< rPhi2.second
212  << std::endl;
213 
214  */
215 
216  auto rPhi1 = predictionRPhitmp(radius.max());
217  auto rPhi2 = predictionRPhitmp(radius.min());
218 
219 
220  correction.correctRPhiRange(rPhi1);
221  correction.correctRPhiRange(rPhi2);
222  rPhi1.first /= radius.max();
223  rPhi1.second /= radius.max();
224  rPhi2.first /= radius.min();
225  rPhi2.second /= radius.min();
226  phiRange = mergePhiRanges(rPhi1,rPhi2);
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  if ((prmax-prmin) > Geom::ftwoPi())
235  { prmax=Geom::fpi(); prmin = -Geom::fpi();}
236  else
237  { while (prmax>maxphi) { prmin -= Geom::ftwoPi(); prmax -= Geom::ftwoPi();}
238  while (prmin<minphi) { prmin += Geom::ftwoPi(); prmax += Geom::ftwoPi();}
239  // This needs range -twoPi to +twoPi to work
240  }
241  if (barrelLayer)
242  {
243  Range regMax = predictionRZ.detRange();
244  Range regMin = predictionRZ(regMax.min()-regOffset);
245  regMax = predictionRZ(regMax.max()+regOffset);
246  correction.correctRZRange(regMin);
247  correction.correctRZRange(regMax);
248  if (regMax.min() < regMin.min()) { swap(regMax, regMin);}
249  KDTreeBox phiZ(prmin, prmax, regMin.min()-nSigmaRZ*rzError[il], regMax.max()+nSigmaRZ*rzError[il]);
250  hitTree[il].search(phiZ, foundNodes);
251  }
252  else
253  {
254  KDTreeBox phiZ(prmin, prmax,
255  rzRange.min()-regOffset-nSigmaRZ*rzError[il],
256  rzRange.max()+regOffset+nSigmaRZ*rzError[il]);
257  hitTree[il].search(phiZ, foundNodes);
258  }
259 
260  // std::cout << ip << ": " << theLayers[il].detLayer()->seqNum() << " " << foundNodes.size() << " " << prmin << " " << prmax << std::endl;
261 
262 
263  // int kk=0;
264  for (auto KDdata : foundNodes) {
265 
266  if (theMaxElement!=0 && result.size() >= theMaxElement){
267  result.clear();
268  edm::LogError("TooManyTriplets")<<" number of triples exceeds maximum. no triplets produced.";
269  return;
270  }
271 
272  float p3_u = hits.u[KDdata];
273  float p3_v = hits.v[KDdata];
274  float p3_phi = hits.lphi[KDdata];
275 
276  //if ((kk++)%100==0)
277  //std::cout << kk << ": " << p3_u << " " << p3_v << " " << p3_phi << std::endl;
278 
279 
280  Range allowed = predictionRZ(p3_u);
281  correction.correctRZRange(allowed);
282  float vErr = nSigmaRZ *hits.dv[KDdata];
283  Range hitRange(p3_v-vErr, p3_v+vErr);
284  Range crossingRange = allowed.intersection(hitRange);
285  if (crossingRange.empty()) continue;
286 
287  float ir = 1.f/hits.rv(KDdata);
288  float phiErr = nSigmaPhi * hits.drphi[KDdata]*ir;
289  for (int icharge=-1; icharge <=1; icharge+=2) {
290  Range rangeRPhi = predictionRPhi(hits.rv(KDdata), icharge);
291  correction.correctRPhiRange(rangeRPhi);
292  if (checkPhiInRange(p3_phi, rangeRPhi.first*ir-phiErr, rangeRPhi.second*ir+phiErr)) {
293  // insert here check with comparitor
294  OrderedHitTriplet hittriplet( doublets.hit(ip,HitDoublets::inner), doublets.hit(ip,HitDoublets::outer), hits.theHits[KDdata].hit());
295  if (!theComparitor || theComparitor->compatible(hittriplet,region) ) {
296  result.push_back( hittriplet );
297  } else {
298  LogDebug("RejectedTriplet") << "rejected triplet from comparitor ";
299  }
300  break;
301  }
302  }
303  }
304  }
305  }
306  // std::cout << "triplets " << result.size() << std::endl;
307 }
#define LogDebug(id)
std::vector< SeedingLayerSetsHits::SeedingLayer > theLayers
void swap(ora::Record &rh, ora::Record &lh)
Definition: Record.h:70
int i
Definition: DBlmapReader.cc:9
void build(std::vector< KDTreeNodeInfo > &eltList, const KDTreeBox &region)
void initPropagator(const Propagator *propagator)
T perp() const
Definition: PV3DBase.h:72
GlobalPoint const & origin() const
void initLayer(const DetLayer *layer)
float fpi()
Definition: Pi.h:35
void search(const KDTreeBox &searchBox, std::vector< KDTreeNodeInfo > &resRecHitList)
std::pair< float, float > mergePhiRanges(const std::pair< float, float > &r1, const std::pair< float, float > &r2) const
std::unique_ptr< SeedComparitor > theComparitor
int seqNum() const
Definition: DetLayer.h:36
T curvature(T InversePt, const edm::EventSetup &iSetup)
const T & max(const T &a, const T &b)
constexpr double nSigmaRZ
tuple result
Definition: query.py:137
double f[11][100]
virtual HitDoublets doublets(const TrackingRegion &reg, const edm::Event &ev, const edm::EventSetup &es)
constexpr double nSigmaPhi
SeedingHitSet::ConstRecHitPointer Hit
BaseTrackerRecHit const * Hit
bool isBarrel() const
Definition: DetLayer.h:32
PixelRecoRange< float > Range
PixelRecoRange< T > intersection(const PixelRecoRange< T > &r) const
bool checkPhiInRange(float phi, float phi1, float phi2) const
void initTolerance(float tolerance)
DetLayer const * detLayer(layer l) const
tuple size
Write out results.
#define constexpr
float ftwoPi()
Definition: Pi.h:36
T angle(T x1, T y1, T z1, T x2, T y2, T z2)
Definition: angle.h:11
void PixelTripletHLTGenerator::init ( const HitPairGenerator pairs,
LayerCacheType layerCache 
)
overridevirtual

Implements HitTripletGeneratorFromPairAndLayers.

Definition at line 56 of file PixelTripletHLTGenerator.cc.

References HitPairGenerator::clone(), theLayerCache, and thePairGenerator.

58 {
59  thePairGenerator = pairs.clone();
60  theLayerCache = layerCache;
61 }
virtual HitPairGenerator * clone() const =0
std::pair< float, float > PixelTripletHLTGenerator::mergePhiRanges ( const std::pair< float, float > &  r1,
const std::pair< float, float > &  r2 
) const
private

Definition at line 316 of file PixelTripletHLTGenerator.cc.

References Geom::fpi(), Geom::ftwoPi(), max(), and bookConverter::min.

Referenced by hitTriplets().

318 { float r2_min=r2.first;
319  float r2_max=r2.second;
320  while (r1.first-r2_min > Geom::fpi()) { r2_min += Geom::ftwoPi(); r2_max += Geom::ftwoPi();}
321  while (r1.first-r2_min < -Geom::fpi()) { r2_min -= Geom::ftwoPi(); r2_max -= Geom::ftwoPi(); }
322 
323  return std::make_pair(min(r1.first,r2_min),max(r1.second,r2_max));
324 }
float fpi()
Definition: Pi.h:35
const T & max(const T &a, const T &b)
float ftwoPi()
Definition: Pi.h:36
const HitPairGenerator& PixelTripletHLTGenerator::pairGenerator ( ) const
inline

Definition at line 39 of file PixelTripletHLTGenerator.h.

References thePairGenerator.

39 { return *thePairGenerator; }
void PixelTripletHLTGenerator::setSeedingLayers ( SeedingLayerSetsHits::SeedingLayerSet  pairLayers,
std::vector< SeedingLayerSetsHits::SeedingLayer thirdLayers 
)
overridevirtual

Implements HitTripletGeneratorFromPairAndLayers.

Definition at line 63 of file PixelTripletHLTGenerator.cc.

References HitPairGenerator::setSeedingLayers(), theLayers, and thePairGenerator.

64  {
66  theLayers = thirdLayers;
67 }
std::vector< SeedingLayerSetsHits::SeedingLayer > theLayers
virtual void setSeedingLayers(SeedingLayerSetsHits::SeedingLayerSet layers)=0

Member Data Documentation

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().

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

Definition at line 57 of file PixelTripletHLTGenerator.h.

Referenced by hitTriplets(), and PixelTripletHLTGenerator().

LayerCacheType* PixelTripletHLTGenerator::theLayerCache
private

Definition at line 49 of file PixelTripletHLTGenerator.h.

Referenced by init().

std::vector<SeedingLayerSetsHits::SeedingLayer> PixelTripletHLTGenerator::theLayers
private

Definition at line 48 of file PixelTripletHLTGenerator.h.

Referenced by hitTriplets(), and setSeedingLayers().

HitPairGenerator* PixelTripletHLTGenerator::thePairGenerator
private
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().