CMS 3D CMS Logo

List of all members | Classes | Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | Private Member Functions | Private Attributes
CAHitQuadrupletGenerator Class Reference

#include <CAHitQuadrupletGenerator.h>

Inheritance diagram for CAHitQuadrupletGenerator:
HitQuadrupletGenerator OrderedHitsGenerator

Classes

class  QuantityDependsPt
 
class  QuantityDependsPtEval
 

Public Types

typedef LayerHitMapCache LayerCacheType
 
typedef OrderedHitSeeds ResultType
 

Public Member Functions

 CAHitQuadrupletGenerator (const edm::ParameterSet &cfg, edm::ConsumesCollector &&iC, bool needSeedingLayerSetsHits=true)
 
 CAHitQuadrupletGenerator (const edm::ParameterSet &cfg, edm::ConsumesCollector &iC, bool needSeedingLayerSetsHits=true)
 
void hitNtuplets (const IntermediateHitDoublets &regionDoublets, std::vector< OrderedHitSeeds > &result, const edm::EventSetup &es, const SeedingLayerSetsHits &layers)
 
virtual void hitQuadruplets (const TrackingRegion &reg, OrderedHitSeeds &quadruplets, const edm::Event &ev, const edm::EventSetup &es)
 from base class More...
 
void initEvent (const edm::Event &ev, const edm::EventSetup &es)
 
virtual ~CAHitQuadrupletGenerator ()
 
- Public Member Functions inherited from HitQuadrupletGenerator
virtual void clear () final
 
 HitQuadrupletGenerator (unsigned int size=500)
 
virtual const OrderedHitSeedsrun (const TrackingRegion &region, const edm::Event &ev, const edm::EventSetup &es) final
 
virtual ~HitQuadrupletGenerator ()
 
- Public Member Functions inherited from OrderedHitsGenerator
 OrderedHitsGenerator ()
 
virtual ~OrderedHitsGenerator ()
 

Static Public Member Functions

static void fillDescriptions (edm::ParameterSetDescription &desc)
 
static const char * fillDescriptionsLabel ()
 

Static Public Attributes

static unsigned int minLayers = 4
 

Private Member Functions

void hitQuadruplets (const TrackingRegion &reg, OrderedHitSeeds &result, std::vector< const HitDoublets * > &hitDoublets, const CAGraph &g, const edm::EventSetup &es)
 

Private Attributes

const float caHardPtCut = 0.f
 
const bool caOnlyOneLastHitPerLayerFilter = false
 
const float caPhiCut = 0.1f
 
const float caThetaCut = 0.00125f
 
const float extraHitRPhitolerance
 
const bool fitFastCircle
 
const bool fitFastCircleChi2Cut
 
const QuantityDependsPt maxChi2
 
std::unique_ptr< SeedComparitortheComparitor
 
LayerCacheType theLayerCache
 
edm::EDGetTokenT< SeedingLayerSetsHitstheSeedingLayerToken
 
const bool useBendingCorrection
 

Additional Inherited Members

- Public Attributes inherited from OrderedHitsGenerator
unsigned int theMaxElement
 

Detailed Description

Definition at line 32 of file CAHitQuadrupletGenerator.h.

Member Typedef Documentation

Definition at line 34 of file CAHitQuadrupletGenerator.h.

Definition at line 37 of file CAHitQuadrupletGenerator.h.

Constructor & Destructor Documentation

CAHitQuadrupletGenerator::CAHitQuadrupletGenerator ( const edm::ParameterSet cfg,
edm::ConsumesCollector &&  iC,
bool  needSeedingLayerSetsHits = true 
)
inline

Definition at line 41 of file CAHitQuadrupletGenerator.h.

References CAHitQuadrupletGenerator_cfi::CAHitQuadrupletGenerator, and looper::cfg.

41 : CAHitQuadrupletGenerator(cfg, iC, needSeedingLayerSetsHits) {}
CAHitQuadrupletGenerator(const edm::ParameterSet &cfg, edm::ConsumesCollector &&iC, bool needSeedingLayerSetsHits=true)
CAHitQuadrupletGenerator::CAHitQuadrupletGenerator ( const edm::ParameterSet cfg,
edm::ConsumesCollector iC,
bool  needSeedingLayerSetsHits = true 
)

Definition at line 46 of file CAHitQuadrupletGenerator.cc.

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

46  :
47 extraHitRPhitolerance(cfg.getParameter<double>("extraHitRPhitolerance")), //extra window in ThirdHitPredictionFromCircle range (divide by R to get phi)
48 maxChi2(cfg.getParameter<edm::ParameterSet>("maxChi2")),
49 fitFastCircle(cfg.getParameter<bool>("fitFastCircle")),
50 fitFastCircleChi2Cut(cfg.getParameter<bool>("fitFastCircleChi2Cut")),
51 useBendingCorrection(cfg.getParameter<bool>("useBendingCorrection")),
52 caThetaCut(cfg.getParameter<double>("CAThetaCut")),
53 caPhiCut(cfg.getParameter<double>("CAPhiCut")),
54 caHardPtCut(cfg.getParameter<double>("CAHardPtCut")),
55 caOnlyOneLastHitPerLayerFilter(cfg.getParameter<bool>("CAOnlyOneLastHitPerLayerFilter"))
56 {
57  if(needSeedingLayerSetsHits)
59 
60  if (cfg.exists("SeedComparitorPSet"))
61  {
62  edm::ParameterSet comparitorPSet =
63  cfg.getParameter<edm::ParameterSet>("SeedComparitorPSet");
64  std::string comparitorName = comparitorPSet.getParameter<std::string>("ComponentName");
65  if (comparitorName != "none")
66  {
67  theComparitor.reset(SeedComparitorFactory::get()->create(comparitorName, comparitorPSet, iC));
68  }
69  }
70 }
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
T getParameter(std::string const &) const
def create(alignables, pedeDump, additionalData, outputFile, config)
bool exists(std::string const &parameterName) const
checks if a parameter exists
std::unique_ptr< SeedComparitor > theComparitor
const QuantityDependsPt maxChi2
edm::EDGetTokenT< SeedingLayerSetsHits > theSeedingLayerToken
T get(const Candidate &c)
Definition: component.h:55
CAHitQuadrupletGenerator::~CAHitQuadrupletGenerator ( )
virtual

Definition at line 72 of file CAHitQuadrupletGenerator.cc.

73 {
74 }

Member Function Documentation

void CAHitQuadrupletGenerator::fillDescriptions ( edm::ParameterSetDescription desc)
static

Definition at line 76 of file CAHitQuadrupletGenerator.cc.

References edm::ParameterSetDescription::add(), and AlCaHLTBitMon_QueryRunRegistry::string.

76  {
77  desc.add<double>("extraHitRPhitolerance", 0.1);
78  desc.add<bool>("fitFastCircle", false);
79  desc.add<bool>("fitFastCircleChi2Cut", false);
80  desc.add<bool>("useBendingCorrection", false);
81  desc.add<double>("CAThetaCut", 0.00125);
82  desc.add<double>("CAPhiCut", 10);
83  desc.add<double>("CAHardPtCut", 0);
84  desc.add<bool>("CAOnlyOneLastHitPerLayerFilter",false);
85  edm::ParameterSetDescription descMaxChi2;
86  descMaxChi2.add<double>("pt1", 0.2);
87  descMaxChi2.add<double>("pt2", 1.5);
88  descMaxChi2.add<double>("value1", 500);
89  descMaxChi2.add<double>("value2", 50);
90  descMaxChi2.add<bool>("enabled", true);
91  desc.add<edm::ParameterSetDescription>("maxChi2", descMaxChi2);
92 
93  edm::ParameterSetDescription descComparitor;
94  descComparitor.add<std::string>("ComponentName", "none");
95  descComparitor.setAllowAnything(); // until we have moved SeedComparitor too to EDProducers
96  desc.add<edm::ParameterSetDescription>("SeedComparitorPSet", descComparitor);
97 }
ParameterDescriptionBase * add(U const &iLabel, T const &value)
static const char* CAHitQuadrupletGenerator::fillDescriptionsLabel ( )
inlinestatic

Definition at line 47 of file CAHitQuadrupletGenerator.h.

References ev, g, LayerTriplets::layers(), and mps_fire::result.

47 { return "caHitQuadruplet"; }
void CAHitQuadrupletGenerator::hitNtuplets ( const IntermediateHitDoublets regionDoublets,
std::vector< OrderedHitSeeds > &  result,
const edm::EventSetup es,
const SeedingLayerSetsHits layers 
)

Definition at line 237 of file CAHitQuadrupletGenerator.cc.

References funct::abs(), EnergyCorrector::c, caHardPtCut, caOnlyOneLastHitPerLayerFilter, caPhiCut, caThetaCut, HiEvtPlane_cfi::chi2, FastCircleFit::chi2(), RZLine::chi2(), ThirdHitPredictionFromCircle::curvature(), PixelRecoUtilities::curvature(), GlobalErrorBase< T, ErrorWeightType >::czz(), relativeConstraints::error, CAHitQuadrupletGenerator::QuantityDependsPt::evaluator(), extraHitRPhitolerance, fitFastCircle, fitFastCircleChi2Cut, runEdmFileComparison::found, g, edm::EventSetup::get(), i, hcalTTPDigis_cfi::id, SeedingLayerSetsHits::SeedingLayer::index(), diffTreeTool::index, SurfaceOrientation::inner, IntermediateHitDoublets::LayerPairHitDoublets::innerLayerIndex(), PixelRecoUtilities::inversePt(), gedGsfElectrons_cfi::isBarrel, edm::isNotFinite(), TrackerTopology::layer(), geometryCSVtoXML::line, hpstanc_transforms::max, maxChi2, TrackingRegion::origin(), SurfaceOrientation::outer, IntermediateHitDoublets::LayerPairHitDoublets::outerLayerIndex(), PixelSubdetector::PixelBarrel, point, edm::ESHandle< T >::product(), EnergyCorrector::pt, GlobalErrorBase< T, ErrorWeightType >::rerr(), TrackerTopology::side(), funct::sqr(), mathSSE::sqrt(), GeomDetEnumerators::subDetId, theComparitor, useBendingCorrection, CAHitQuadrupletGenerator::QuantityDependsPtEval::value(), x, PV3DBase< T, PVType, FrameType >::x(), y, PV3DBase< T, PVType, FrameType >::y(), and PV3DBase< T, PVType, FrameType >::z().

240  {
241  CAGraph g;
242 
243  std::vector<const HitDoublets *> hitDoublets;
244 
245  auto layerPairEqual = [](const IntermediateHitDoublets::LayerPairHitDoublets& pair,
248  return pair.innerLayerIndex() == inner && pair.outerLayerIndex() == outer;
249  };
251  es.get<TrackerTopologyRcd>().get(tTopoHand);
252  const TrackerTopology *tTopo=tTopoHand.product();
253 
254  const int numberOfHitsInNtuplet = 4;
255  std::vector<CACell::CAntuplet> foundQuadruplets;
256 
257 
258 
259  int index =0;
260  for(const auto& regionLayerPairs: regionDoublets) {
261 
262  const TrackingRegion& region = regionLayerPairs.region();
263  hitDoublets.clear();
264  foundQuadruplets.clear();
265  if (index == 0){
266  createGraphStructure(layers, g);
267  }
268  else{
269  clearGraphStructure(layers, g);
270  }
271 
272  fillGraph(layers, g, hitDoublets,
273  [&](const SeedingLayerSetsHits::SeedingLayer& inner,
275  std::vector<const HitDoublets *>& hitDoublets) {
276  using namespace std::placeholders;
277  auto found = std::find_if(regionLayerPairs.begin(), regionLayerPairs.end(),
278  std::bind(layerPairEqual, _1, inner.index(), outer.index()));
279  if(found != regionLayerPairs.end()) {
280  hitDoublets.emplace_back(&(found->doublets()));
281  return true;
282  }
283  return false;
284  });
285 
286  CellularAutomaton ca(g);
287 
288  ca.createAndConnectCells(hitDoublets, region, caThetaCut,
290 
291  ca.evolve(numberOfHitsInNtuplet);
292 
293  ca.findNtuplets(foundQuadruplets, numberOfHitsInNtuplet);
294 
295 
296  const QuantityDependsPtEval maxChi2Eval = maxChi2.evaluator(es);
297 
298  // re-used thoughout
299  std::array<float, 4> bc_r;
300  std::array<float, 4> bc_z;
301  std::array<float, 4> bc_errZ2;
302  std::array<GlobalPoint, 4> gps;
303  std::array<GlobalError, 4> ges;
304  std::array<bool, 4> barrels;
305  bool hasAlreadyPushedACandidate = false;
306  float selectedChi2 = std::numeric_limits<float>::max();
307  unsigned int previousfourthLayerId = 0;
308  std::array<unsigned int, 2> previousCellIds ={{0,0}};
309  unsigned int previousSideId = 0;
310  int previousSubDetId = 0;
311 
312  unsigned int numberOfFoundQuadruplets = foundQuadruplets.size();
313 
314  // Loop over quadruplets
315  for (unsigned int quadId = 0; quadId < numberOfFoundQuadruplets; ++quadId)
316  {
317 
318  auto isBarrel = [](const unsigned id) -> bool
319  {
320  return id == PixelSubdetector::PixelBarrel;
321  };
322  for(unsigned int i = 0; i< 3; ++i)
323  {
324  auto const& ahit = foundQuadruplets[quadId][i]->getInnerHit();
325  gps[i] = ahit->globalPosition();
326  ges[i] = ahit->globalPositionError();
327  barrels[i] = isBarrel(ahit->geographicalId().subdetId());
328  }
329 
330  auto const& ahit = foundQuadruplets[quadId][2]->getOuterHit();
331  gps[3] = ahit->globalPosition();
332  ges[3] = ahit->globalPositionError();
333  barrels[3] = isBarrel(ahit->geographicalId().subdetId());
335  {
336  const auto fourthLayerId = tTopo->layer(ahit->geographicalId());
337  const auto sideId = tTopo->side(ahit->geographicalId());
338  const auto subDetId = ahit->geographicalId().subdetId();
339  const auto isTheSameTriplet = (quadId != 0) && (foundQuadruplets[quadId][0]->getCellId() == previousCellIds[0]) && (foundQuadruplets[quadId][1]->getCellId() == previousCellIds[1]);
340  const auto isTheSameFourthLayer = (quadId != 0) && (fourthLayerId == previousfourthLayerId) && (subDetId == previousSubDetId) && (sideId == previousSideId);
341 
342  previousCellIds = {{foundQuadruplets[quadId][0]->getCellId(), foundQuadruplets[quadId][1]->getCellId()}};
343  previousfourthLayerId = fourthLayerId;
344 
345 
346  if(!(isTheSameTriplet && isTheSameFourthLayer ))
347  {
348  selectedChi2 = std::numeric_limits<float>::max();
349  hasAlreadyPushedACandidate = false;
350  }
351 
352  }
353  // TODO:
354  // - 'line' is not used for anything
355  // - if we decide to always do the circle fit for 4 hits, we don't
356  // need ThirdHitPredictionFromCircle for the curvature; then we
357  // could remove extraHitRPhitolerance configuration parameter
358  PixelRecoLineRZ line(gps[0], gps[2]);
359  ThirdHitPredictionFromCircle predictionRPhi(gps[0], gps[2], extraHitRPhitolerance);
360  const float curvature = predictionRPhi.curvature(ThirdHitPredictionFromCircle::Vector2D(gps[1].x(), gps[1].y()));
361  const float abscurv = std::abs(curvature);
362  const float thisMaxChi2 = maxChi2Eval.value(abscurv);
363  if (theComparitor)
364  {
365  SeedingHitSet tmpTriplet(foundQuadruplets[quadId][0]->getInnerHit(), foundQuadruplets[quadId][2]->getInnerHit(), foundQuadruplets[quadId][2]->getOuterHit());
366 
367 
368  if (!theComparitor->compatible(tmpTriplet) )
369  {
370  continue;
371  }
372  }
373 
374  float chi2 = std::numeric_limits<float>::quiet_NaN();
375  // TODO: Do we have any use case to not use bending correction?
377  {
378  // Following PixelFitterByConformalMappingAndLine
379  const float simpleCot = ( gps.back().z() - gps.front().z() ) / (gps.back().perp() - gps.front().perp() );
380  const float pt = 1.f / PixelRecoUtilities::inversePt(abscurv, es);
381  for (int i=0; i < 4; ++i)
382  {
383  const GlobalPoint & point = gps[i];
384  const GlobalError & error = ges[i];
385  bc_r[i] = sqrt( sqr(point.x() - region.origin().x()) + sqr(point.y() - region.origin().y()) );
386  bc_r[i] += pixelrecoutilities::LongitudinalBendingCorrection(pt, es)(bc_r[i]);
387  bc_z[i] = point.z() - region.origin().z();
388  bc_errZ2[i] = (barrels[i]) ? error.czz() : error.rerr(point)*sqr(simpleCot);
389  }
390  RZLine rzLine(bc_r, bc_z, bc_errZ2, RZLine::ErrZ2_tag());
391  chi2 = rzLine.chi2();
392  }
393  else
394  {
395  RZLine rzLine(gps, ges, barrels);
396  chi2 = rzLine.chi2();
397  }
398  if (edm::isNotFinite(chi2) || chi2 > thisMaxChi2)
399  {
400  continue;
401  }
402  // TODO: Do we have any use case to not use circle fit? Maybe
403  // HLT where low-pT inefficiency is not a problem?
404  if (fitFastCircle)
405  {
406  FastCircleFit c(gps, ges);
407  chi2 += c.chi2();
408  if (edm::isNotFinite(chi2)) continue;
409  if (fitFastCircleChi2Cut && chi2 > thisMaxChi2) continue;
410  }
412  {
413  if (chi2 < selectedChi2)
414  {
415  selectedChi2 = chi2;
416  if(hasAlreadyPushedACandidate)
417  {
418  result[index].pop_back();
419  }
420  result[index].emplace_back(foundQuadruplets[quadId][0]->getInnerHit(), foundQuadruplets[quadId][1]->getInnerHit(),foundQuadruplets[quadId][2]->getInnerHit(), foundQuadruplets[quadId][2]->getOuterHit());
421  hasAlreadyPushedACandidate = true;
422  }
423  }
424  else
425  {
426  result[index].emplace_back(foundQuadruplets[quadId][0]->getInnerHit(), foundQuadruplets[quadId][1]->getInnerHit(), foundQuadruplets[quadId][2]->getInnerHit(), foundQuadruplets[quadId][2]->getOuterHit());
427  }
428  }
429  index++;
430  }
431 
432 }
int i
Definition: DBlmapReader.cc:9
GlobalPoint const & origin() const
unsigned int side(const DetId &id) const
T y() const
Definition: PV3DBase.h:63
std::unique_ptr< SeedComparitor > theComparitor
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e g
Definition: Activities.doc:4
T inversePt(T curvature, const edm::EventSetup &iSetup)
bool isNotFinite(T x)
Definition: isFinite.h:10
T curvature(T InversePt, const edm::EventSetup &iSetup)
SeedingLayerSetsHits::LayerIndex innerLayerIndex() const
T sqrt(T t)
Definition: SSEVec.h:18
T z() const
Definition: PV3DBase.h:64
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
Definition: RZLine.h:12
const QuantityDependsPt maxChi2
T rerr(const GlobalPoint &aPoint) const
const T & get() const
Definition: EventSetup.h:56
unsigned int layer(const DetId &id) const
SeedingLayerSetsHits::LayerIndex outerLayerIndex() const
Square< F >::type sqr(const F &f)
Definition: Square.h:13
QuantityDependsPtEval evaluator(const edm::EventSetup &es) const
unsigned int subDetId[20]
T x() const
Definition: PV3DBase.h:62
T const * product() const
Definition: ESHandle.h:86
*vegas h *****************************************************used in the default bin number in original ***version of VEGAS is ***a higher bin number might help to derive a more precise ***grade subtle point
Definition: invegas.h:5
void CAHitQuadrupletGenerator::hitQuadruplets ( const TrackingRegion reg,
OrderedHitSeeds quadruplets,
const edm::Event ev,
const edm::EventSetup es 
)
virtual

from base class

Implements HitQuadrupletGenerator.

Definition at line 198 of file CAHitQuadrupletGenerator.cc.

References LayerHitMapCache::clear(), HitPairGeneratorFromLayerPair::doublets(), MillePedeFileConverter_cfg::e, g, edm::Event::getByToken(), SurfaceOrientation::inner, LayerTriplets::layers(), SeedingLayerSetsHits::numberOfLayersInSet(), SurfaceOrientation::outer, theComparitor, theLayerCache, and theSeedingLayerToken.

201 {
203  ev.getByToken(theSeedingLayerToken, hlayers);
204  const SeedingLayerSetsHits& layers = *hlayers;
205  if (layers.numberOfLayersInSet() != 4)
206  throw cms::Exception("Configuration")
207  << "CAHitQuadrupletsGenerator expects SeedingLayerSetsHits::numberOfLayersInSet() to be 4, got "
208  << layers.numberOfLayersInSet();
209 
210  CAGraph g;
211 
212  std::vector<HitDoublets> hitDoublets;
213 
214 
215  HitPairGeneratorFromLayerPair thePairGenerator(0, 1, &theLayerCache);
216 
217  createGraphStructure(layers, g);
218  fillGraph(layers, g, hitDoublets,
221  std::vector<HitDoublets>& hitDoublets) {
222  hitDoublets.emplace_back(thePairGenerator.doublets(region, ev, es, inner, outer));
223  return true;
224  });
225 
226  if (theComparitor)
227  theComparitor->init(ev, es);
228 
229  std::vector<const HitDoublets *> hitDoubletsPtr;
230  hitDoubletsPtr.reserve(hitDoublets.size());
231  for(const auto& e: hitDoublets)
232  hitDoubletsPtr.emplace_back(&e);
233 
234  hitQuadruplets(region, result, hitDoubletsPtr, g, es);
236 }
unsigned short numberOfLayersInSet() const
Get number of layers in each SeedingLayerSets.
std::vector< LayerSetAndLayers > layers(const SeedingLayerSetsHits &sets)
Definition: LayerTriplets.cc:4
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:457
std::unique_ptr< SeedComparitor > theComparitor
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e g
Definition: Activities.doc:4
virtual void hitQuadruplets(const TrackingRegion &reg, OrderedHitSeeds &quadruplets, const edm::Event &ev, const edm::EventSetup &es)
from base class
edm::EDGetTokenT< SeedingLayerSetsHits > theSeedingLayerToken
void CAHitQuadrupletGenerator::hitQuadruplets ( const TrackingRegion reg,
OrderedHitSeeds result,
std::vector< const HitDoublets * > &  hitDoublets,
const CAGraph g,
const edm::EventSetup es 
)
private

Definition at line 434 of file CAHitQuadrupletGenerator.cc.

References funct::abs(), EnergyCorrector::c, caHardPtCut, caOnlyOneLastHitPerLayerFilter, caPhiCut, caThetaCut, HiEvtPlane_cfi::chi2, FastCircleFit::chi2(), RZLine::chi2(), CellularAutomaton::createAndConnectCells(), ThirdHitPredictionFromCircle::curvature(), PixelRecoUtilities::curvature(), GlobalErrorBase< T, ErrorWeightType >::czz(), relativeConstraints::error, CAHitQuadrupletGenerator::QuantityDependsPt::evaluator(), CellularAutomaton::evolve(), extraHitRPhitolerance, CellularAutomaton::findNtuplets(), fitFastCircle, fitFastCircleChi2Cut, edm::EventSetup::get(), i, hcalTTPDigis_cfi::id, PixelRecoUtilities::inversePt(), gedGsfElectrons_cfi::isBarrel, edm::isNotFinite(), TrackerTopology::layer(), geometryCSVtoXML::line, hpstanc_transforms::max, maxChi2, TrackingRegion::origin(), PixelSubdetector::PixelBarrel, point, edm::ESHandle< T >::product(), EnergyCorrector::pt, GlobalErrorBase< T, ErrorWeightType >::rerr(), TrackerTopology::side(), funct::sqr(), mathSSE::sqrt(), GeomDetEnumerators::subDetId, theComparitor, useBendingCorrection, CAHitQuadrupletGenerator::QuantityDependsPtEval::value(), x, PV3DBase< T, PVType, FrameType >::x(), y, PV3DBase< T, PVType, FrameType >::y(), and PV3DBase< T, PVType, FrameType >::z().

437  {
438  //Retrieve tracker topology from geometry
440  es.get<TrackerTopologyRcd>().get(tTopoHand);
441  const TrackerTopology *tTopo=tTopoHand.product();
442 
443  const int numberOfHitsInNtuplet = 4;
444  std::vector<CACell::CAntuplet> foundQuadruplets;
445 
446  CellularAutomaton ca(g);
447 
448  ca.createAndConnectCells(hitDoublets, region, caThetaCut,
450 
451  ca.evolve(numberOfHitsInNtuplet);
452 
453  ca.findNtuplets(foundQuadruplets, numberOfHitsInNtuplet);
454 
455 
456  const QuantityDependsPtEval maxChi2Eval = maxChi2.evaluator(es);
457 
458  // re-used thoughout
459  std::array<float, 4> bc_r;
460  std::array<float, 4> bc_z;
461  std::array<float, 4> bc_errZ2;
462  std::array<GlobalPoint, 4> gps;
463  std::array<GlobalError, 4> ges;
464  std::array<bool, 4> barrels;
465  bool hasAlreadyPushedACandidate = false;
466  float selectedChi2 = std::numeric_limits<float>::max();
467  unsigned int previousfourthLayerId = 0;
468  std::array<unsigned int, 2> previousCellIds ={{0,0}};
469  unsigned int previousSideId = 0;
470  int previousSubDetId = 0;
471 
472  unsigned int numberOfFoundQuadruplets = foundQuadruplets.size();
473 
474  // Loop over quadruplets
475  for (unsigned int quadId = 0; quadId < numberOfFoundQuadruplets; ++quadId)
476  {
477 
478  auto isBarrel = [](const unsigned id) -> bool
479  {
480  return id == PixelSubdetector::PixelBarrel;
481  };
482  for(unsigned int i = 0; i< 3; ++i)
483  {
484  auto const& ahit = foundQuadruplets[quadId][i]->getInnerHit();
485  gps[i] = ahit->globalPosition();
486  ges[i] = ahit->globalPositionError();
487  barrels[i] = isBarrel(ahit->geographicalId().subdetId());
488  }
489 
490  auto const& ahit = foundQuadruplets[quadId][2]->getOuterHit();
491  gps[3] = ahit->globalPosition();
492  ges[3] = ahit->globalPositionError();
493  barrels[3] = isBarrel(ahit->geographicalId().subdetId());
494 
496  {
497  const auto fourthLayerId = tTopo->layer(ahit->geographicalId());
498  const auto sideId = tTopo->side(ahit->geographicalId());
499  const auto subDetId = ahit->geographicalId().subdetId();
500  const auto isTheSameTriplet = (quadId != 0) && (foundQuadruplets[quadId][0]->getCellId() == previousCellIds[0]) && (foundQuadruplets[quadId][1]->getCellId() == previousCellIds[1]);
501  const auto isTheSameFourthLayer = (quadId != 0) && (fourthLayerId == previousfourthLayerId) && (subDetId == previousSubDetId) && (sideId == previousSideId);
502 
503  previousCellIds = {{foundQuadruplets[quadId][0]->getCellId(), foundQuadruplets[quadId][1]->getCellId()}};
504  previousfourthLayerId = fourthLayerId;
505 
506 
507  if(!(isTheSameTriplet && isTheSameFourthLayer ))
508  {
509  selectedChi2 = std::numeric_limits<float>::max();
510  hasAlreadyPushedACandidate = false;
511  }
512 
513  }
514 
515 
516  // TODO:
517  // - 'line' is not used for anything
518  // - if we decide to always do the circle fit for 4 hits, we don't
519  // need ThirdHitPredictionFromCircle for the curvature; then we
520  // could remove extraHitRPhitolerance configuration parameter
521  PixelRecoLineRZ line(gps[0], gps[2]);
522  ThirdHitPredictionFromCircle predictionRPhi(gps[0], gps[2], extraHitRPhitolerance);
523  const float curvature = predictionRPhi.curvature(ThirdHitPredictionFromCircle::Vector2D(gps[1].x(), gps[1].y()));
524  const float abscurv = std::abs(curvature);
525  const float thisMaxChi2 = maxChi2Eval.value(abscurv);
526 
527  if (theComparitor)
528  {
529  SeedingHitSet tmpTriplet(foundQuadruplets[quadId][0]->getInnerHit(), foundQuadruplets[quadId][2]->getInnerHit(), foundQuadruplets[quadId][2]->getOuterHit());
530 
531 
532  if (!theComparitor->compatible(tmpTriplet) )
533  {
534  continue;
535  }
536  }
537 
538  float chi2 = std::numeric_limits<float>::quiet_NaN();
539  // TODO: Do we have any use case to not use bending correction?
541  {
542  // Following PixelFitterByConformalMappingAndLine
543  const float simpleCot = ( gps.back().z() - gps.front().z() ) / (gps.back().perp() - gps.front().perp() );
544  const float pt = 1.f / PixelRecoUtilities::inversePt(abscurv, es);
545  for (int i=0; i < 4; ++i)
546  {
547  const GlobalPoint & point = gps[i];
548  const GlobalError & error = ges[i];
549  bc_r[i] = sqrt( sqr(point.x() - region.origin().x()) + sqr(point.y() - region.origin().y()) );
550  bc_r[i] += pixelrecoutilities::LongitudinalBendingCorrection(pt, es)(bc_r[i]);
551  bc_z[i] = point.z() - region.origin().z();
552  bc_errZ2[i] = (barrels[i]) ? error.czz() : error.rerr(point)*sqr(simpleCot);
553  }
554  RZLine rzLine(bc_r, bc_z, bc_errZ2, RZLine::ErrZ2_tag());
555  chi2 = rzLine.chi2();
556  }
557  else
558  {
559  RZLine rzLine(gps, ges, barrels);
560  chi2 = rzLine.chi2();
561  }
562  if (edm::isNotFinite(chi2) || chi2 > thisMaxChi2)
563  {
564  continue;
565 
566  }
567  // TODO: Do we have any use case to not use circle fit? Maybe
568  // HLT where low-pT inefficiency is not a problem?
569  if (fitFastCircle)
570  {
571  FastCircleFit c(gps, ges);
572  chi2 += c.chi2();
573  if (edm::isNotFinite(chi2))
574  continue;
575  if (fitFastCircleChi2Cut && chi2 > thisMaxChi2)
576  continue;
577  }
578 
580  {
581  if (chi2 < selectedChi2)
582  {
583  selectedChi2 = chi2;
584 
585  if(hasAlreadyPushedACandidate)
586  {
587  result.pop_back();
588 
589  }
590  result.emplace_back(foundQuadruplets[quadId][0]->getInnerHit(), foundQuadruplets[quadId][1]->getInnerHit(),
591  foundQuadruplets[quadId][2]->getInnerHit(), foundQuadruplets[quadId][2]->getOuterHit());
592  hasAlreadyPushedACandidate = true;
593 
594  }
595  }
596  else
597  {
598 
599  result.emplace_back(foundQuadruplets[quadId][0]->getInnerHit(), foundQuadruplets[quadId][1]->getInnerHit(), foundQuadruplets[quadId][2]->getInnerHit(), foundQuadruplets[quadId][2]->getOuterHit());
600  }
601 
602  }
603 
604 }
int i
Definition: DBlmapReader.cc:9
unsigned int side(const DetId &id) const
T y() const
Definition: PV3DBase.h:63
std::unique_ptr< SeedComparitor > theComparitor
T inversePt(T curvature, const edm::EventSetup &iSetup)
bool isNotFinite(T x)
Definition: isFinite.h:10
T curvature(T InversePt, const edm::EventSetup &iSetup)
T sqrt(T t)
Definition: SSEVec.h:18
T z() const
Definition: PV3DBase.h:64
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
Definition: RZLine.h:12
const QuantityDependsPt maxChi2
T rerr(const GlobalPoint &aPoint) const
const T & get() const
Definition: EventSetup.h:56
unsigned int layer(const DetId &id) const
Square< F >::type sqr(const F &f)
Definition: Square.h:13
QuantityDependsPtEval evaluator(const edm::EventSetup &es) const
unsigned int subDetId[20]
T x() const
Definition: PV3DBase.h:62
T const * product() const
Definition: ESHandle.h:86
*vegas h *****************************************************used in the default bin number in original ***version of VEGAS is ***a higher bin number might help to derive a more precise ***grade subtle point
Definition: invegas.h:5
void CAHitQuadrupletGenerator::initEvent ( const edm::Event ev,
const edm::EventSetup es 
)

Member Data Documentation

const float CAHitQuadrupletGenerator::caHardPtCut = 0.f
private

Definition at line 148 of file CAHitQuadrupletGenerator.h.

Referenced by hitNtuplets(), and hitQuadruplets().

const bool CAHitQuadrupletGenerator::caOnlyOneLastHitPerLayerFilter = false
private

Definition at line 149 of file CAHitQuadrupletGenerator.h.

Referenced by hitNtuplets(), and hitQuadruplets().

const float CAHitQuadrupletGenerator::caPhiCut = 0.1f
private

Definition at line 147 of file CAHitQuadrupletGenerator.h.

Referenced by hitNtuplets(), and hitQuadruplets().

const float CAHitQuadrupletGenerator::caThetaCut = 0.00125f
private

Definition at line 146 of file CAHitQuadrupletGenerator.h.

Referenced by hitNtuplets(), and hitQuadruplets().

const float CAHitQuadrupletGenerator::extraHitRPhitolerance
private

Definition at line 139 of file CAHitQuadrupletGenerator.h.

Referenced by hitNtuplets(), and hitQuadruplets().

const bool CAHitQuadrupletGenerator::fitFastCircle
private

Definition at line 142 of file CAHitQuadrupletGenerator.h.

Referenced by hitNtuplets(), and hitQuadruplets().

const bool CAHitQuadrupletGenerator::fitFastCircleChi2Cut
private

Definition at line 143 of file CAHitQuadrupletGenerator.h.

Referenced by hitNtuplets(), and hitQuadruplets().

const QuantityDependsPt CAHitQuadrupletGenerator::maxChi2
private

Definition at line 141 of file CAHitQuadrupletGenerator.h.

Referenced by hitNtuplets(), and hitQuadruplets().

unsigned int CAHitQuadrupletGenerator::minLayers = 4
static

Definition at line 36 of file CAHitQuadrupletGenerator.h.

std::unique_ptr<SeedComparitor> CAHitQuadrupletGenerator::theComparitor
private
LayerCacheType CAHitQuadrupletGenerator::theLayerCache
private

Definition at line 71 of file CAHitQuadrupletGenerator.h.

Referenced by hitQuadruplets().

edm::EDGetTokenT<SeedingLayerSetsHits> CAHitQuadrupletGenerator::theSeedingLayerToken
private

Definition at line 69 of file CAHitQuadrupletGenerator.h.

Referenced by CAHitQuadrupletGenerator(), and hitQuadruplets().

const bool CAHitQuadrupletGenerator::useBendingCorrection
private

Definition at line 144 of file CAHitQuadrupletGenerator.h.

Referenced by hitNtuplets(), and hitQuadruplets().