CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
GenericTripletGenerator Class Reference

#include <GenericTripletGenerator.h>

Inheritance diagram for GenericTripletGenerator:
OrderedHitsGenerator

Public Member Functions

void clear () override
 
 GenericTripletGenerator (const edm::ParameterSet &conf, edm::ConsumesCollector &iC)
 
const OrderedSeedingHitsrun (const TrackingRegion &region, const edm::Event &ev, const edm::EventSetup &es) override
 
 ~GenericTripletGenerator () override
 
- Public Member Functions inherited from OrderedHitsGenerator
 OrderedHitsGenerator ()
 
virtual ~OrderedHitsGenerator ()
 

Private Member Functions

std::pair< bool, float > qualityFilter (const OrderedHitTriplet &oht, const std::map< float, OrderedHitTriplet > &map, const SeedingLayerSetsHits::SeedingLayerSet &ls) const
 

Private Attributes

OrderedHitTriplets hitTriplets
 
edm::EDGetTokenT< SeedingLayerSetsHitstheSeedingLayerToken
 

Additional Inherited Members

- Public Attributes inherited from OrderedHitsGenerator
unsigned int theMaxElement
 

Detailed Description

Definition at line 15 of file GenericTripletGenerator.h.

Constructor & Destructor Documentation

◆ GenericTripletGenerator()

GenericTripletGenerator::GenericTripletGenerator ( const edm::ParameterSet conf,
edm::ConsumesCollector iC 
)

Definition at line 9 of file GenericTripletGenerator.cc.

11  edm::LogInfo("CtfSpecialSeedGenerator|GenericTripletGenerator") << "Constructing GenericTripletGenerator";
12 }

◆ ~GenericTripletGenerator()

GenericTripletGenerator::~GenericTripletGenerator ( )
inlineoverride

Definition at line 18 of file GenericTripletGenerator.h.

18 {};

Member Function Documentation

◆ clear()

void GenericTripletGenerator::clear ( void  )
inlineoverridevirtual

Reimplemented from OrderedHitsGenerator.

Definition at line 20 of file GenericTripletGenerator.h.

20 { hitTriplets.clear(); }

References hitTriplets.

◆ qualityFilter()

std::pair< bool, float > GenericTripletGenerator::qualityFilter ( const OrderedHitTriplet oht,
const std::map< float, OrderedHitTriplet > &  map,
const SeedingLayerSetsHits::SeedingLayerSet ls 
) const
private

Definition at line 62 of file GenericTripletGenerator.cc.

64  {
65  //first check the radius
66  GlobalPoint innerpos = oht.inner()->globalPosition();
67  GlobalPoint middlepos = oht.middle()->globalPosition();
68  GlobalPoint outerpos = oht.outer()->globalPosition();
69  std::vector<const TrackingRecHit*> ohttrh;
70  ohttrh.push_back(&(*(oht.inner())));
71  ohttrh.push_back(&(*(oht.middle())));
72  ohttrh.push_back(&(*(oht.outer())));
73  std::vector<const TrackingRecHit*>::const_iterator ioht;
74  //now chech that the change in phi is reasonable. the limiting angular distance is the one in case
75  //one of the two points is a tangent point.
76  float limit_phi_distance1 = sqrt((middlepos.x() - outerpos.x()) * (middlepos.x() - outerpos.x()) +
77  (middlepos.y() - outerpos.y()) * (middlepos.y() - outerpos.y())) /
78  middlepos.mag(); //actually this is the tangent of the limiting angle
79  float limit_phi_distance2 = sqrt((middlepos.x() - innerpos.x()) * (middlepos.x() - innerpos.x()) +
80  (middlepos.y() - innerpos.y()) * (middlepos.y() - innerpos.y())) /
81  innerpos.mag();
82  //if (fabs(tan(outerpos.phi()-middlepos.phi()))>limit_phi_distance1 ||
83  // fabs(tan(innerpos.phi()-middlepos.phi()))>limit_phi_distance2) {
84  if (fabs(outerpos.phi() - middlepos.phi()) > fabs(atan(limit_phi_distance1)) ||
85  fabs(innerpos.phi() - middlepos.phi()) > fabs(atan(limit_phi_distance2))) {
86  //std::cout << "rejected because phi" << std::endl;
87  return std::make_pair(false, 0.);
88  }
89  //should we add a control on the r-z plane too?
90  /*
91  //now check that there is no big change in the r-z projection
92  float dz1 = outerpos.z()-middlepos.z();
93  float dr1 = sqrt(outerpos.x()*outerpos.x()+outerpos.y()*outerpos.y())-
94  sqrt(middlepos.x()*middlepos.x()+middlepos.y()*middlepos.y());
95  float dz2 = middlepos.z()-innerpos.z();
96  float dr2 = sqrt(middlepos.x()*middlepos.x()+middlepos.y()*middlepos.y())-
97  sqrt(innerpos.x()*innerpos.x()+innerpos.y()*innerpos.y());
98  float tan1 = dz1/dr1;
99  float tan2 = dz2/dr2;
100  //how much should we allow? should we make it configurable?
101  if (fabs(tan1-tan2)/tan1>0.5){
102  //std::cout << "rejected because z" << std::endl;
103  return std::make_pair(false, 0.);
104  }
105  */
106  //now check the radius is not too small
107  FastCircle circle(innerpos, middlepos, outerpos);
108  if (circle.rho() < 200 && circle.rho() != 0)
109  return std::make_pair(false, circle.rho()); //to small radius
110  //now check if at least 2 hits are shared with an existing triplet
111  //look for similar radii in the map
112  std::map<float, OrderedHitTriplet>::const_iterator lower_bound = map.lower_bound((1 - 0.01) * circle.rho());
113  std::map<float, OrderedHitTriplet>::const_iterator upper_bound = map.upper_bound((1 + 0.01) * circle.rho());
114  std::map<float, OrderedHitTriplet>::const_iterator iter;
115  for (iter = lower_bound; iter != upper_bound && iter->first <= upper_bound->first; iter++) {
116  int shared = 0;
117  std::vector<const TrackingRecHit*> curtrh;
118  curtrh.push_back(&*(iter->second.inner()));
119  curtrh.push_back(&*(iter->second.middle()));
120  curtrh.push_back(&*(iter->second.outer()));
121  std::vector<const TrackingRecHit*>::const_iterator curiter;
122  for (curiter = curtrh.begin(); curiter != curtrh.end(); curiter++) {
123  for (ioht = ohttrh.begin(); ioht != ohttrh.end(); ioht++) {
124  if ((*ioht)->geographicalId() == (*curiter)->geographicalId() &&
125  ((*ioht)->localPosition() - (*curiter)->localPosition()).mag() < 1e-5)
126  shared++;
127  }
128  }
129  if (shared > 1)
130  return std::make_pair(false, circle.rho());
131  }
132 
133  return std::make_pair(true, circle.rho());
134 }

References MillePedeFileConverter_cfg::e, OrderedHitTriplet::inner(), cuda_std::lower_bound(), PV3DBase< T, PVType, FrameType >::mag(), mag(), genParticles_cff::map, OrderedHitTriplet::middle(), OrderedHitTriplet::outer(), PV3DBase< T, PVType, FrameType >::phi(), FastCircle::rho(), mathSSE::sqrt(), cuda_std::upper_bound(), PV3DBase< T, PVType, FrameType >::x(), and PV3DBase< T, PVType, FrameType >::y().

Referenced by run().

◆ run()

const OrderedSeedingHits & GenericTripletGenerator::run ( const TrackingRegion region,
const edm::Event ev,
const edm::EventSetup es 
)
overridevirtual

Implements OrderedHitsGenerator.

Definition at line 14 of file GenericTripletGenerator.cc.

16  {
17  hitTriplets.clear();
18  hitTriplets.reserve(0);
20  e.getByToken(theSeedingLayerToken, hlayers);
21  const SeedingLayerSetsHits& layers = *hlayers;
22  if (layers.numberOfLayersInSet() != 3)
23  throw cms::Exception("CtfSpecialSeedGenerator")
24  << "You are using " << layers.numberOfLayersInSet() << " layers in set instead of 3 ";
25  std::map<float, OrderedHitTriplet> radius_triplet_map;
27  auto innerHits = region.hits(es, ls[0]);
28  //std::cout << "innerHits.size()=" << innerHits.size() << std::endl;
29  auto middleHits = region.hits(es, ls[1]);
30  //std::cout << "middleHits.size()=" << middleHits.size() << std::endl;
31  auto outerHits = region.hits(es, ls[2]);
32  //std::cout << "outerHits.size()=" << outerHits.size() << std::endl;
33  //std::cout << "trying " << innerHits.size()*middleHits.size()*outerHits.size() << " combinations "<<std::endl;
34  for (auto iOuterHit = outerHits.begin(); iOuterHit != outerHits.end(); iOuterHit++) {
35  for (auto iMiddleHit = middleHits.begin(); iMiddleHit != middleHits.end(); iMiddleHit++) {
36  for (auto iInnerHit = innerHits.begin(); iInnerHit != innerHits.end(); iInnerHit++) {
37  //GlobalPoint innerpos = ls[0].hitBuilder()->build(&(**iInnerHit))->globalPosition();
38  //GlobalPoint middlepos = ls[1].hitBuilder()->build(&(**iMiddleHit))->globalPosition();
39  //GlobalPoint outerpos = ls[2].hitBuilder()->build(&(**iOuterHit))->globalPosition();
40  //FastCircle circle(innerpos,
41  // middlepos,
42  // outerpos);
43  //do a first check on the radius of curvature to reduce the combinatorics
44  OrderedHitTriplet oht(&(**iInnerHit), &(**iMiddleHit), &(**iOuterHit));
45  std::pair<bool, float> val_radius = qualityFilter(oht, radius_triplet_map, ls);
46  if (val_radius.first) {
47  //if (circle.rho() > 200 || circle.rho() == 0) { //0 radius means straight line
48  //hitTriplets.push_back(OrderedHitTriplet(*iInnerHit,
49  // *iMiddleHit,
50  // *iOuterHit));
51  hitTriplets.push_back(oht);
52  radius_triplet_map.insert(std::make_pair(val_radius.second, oht));
53  }
54  }
55  }
56  }
57  }
58  //std::cout << "ending with " << hitTriplets.size() << " triplets" << std::endl;
59  return hitTriplets;
60 }

References MillePedeFileConverter_cfg::e, hitTriplets, hgcalTopologyTester_cfi::layers, eostools::ls(), qualityFilter(), HLT_2018_cff::region, and theSeedingLayerToken.

Member Data Documentation

◆ hitTriplets

OrderedHitTriplets GenericTripletGenerator::hitTriplets
private

Definition at line 27 of file GenericTripletGenerator.h.

Referenced by clear(), and run().

◆ theSeedingLayerToken

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

Definition at line 26 of file GenericTripletGenerator.h.

Referenced by run().

eostools.ls
def ls(path, rec=False)
Definition: eostools.py:349
PV3DBase::x
T x() const
Definition: PV3DBase.h:59
GenericTripletGenerator::theSeedingLayerToken
edm::EDGetTokenT< SeedingLayerSetsHits > theSeedingLayerToken
Definition: GenericTripletGenerator.h:26
edm::LogInfo
Definition: MessageLogger.h:254
SeedingLayerSetsHits
Definition: SeedingLayerSetsHits.h:18
edm::Handle
Definition: AssociativeIterator.h:50
cuda_std::upper_bound
__host__ constexpr __device__ RandomIt upper_bound(RandomIt first, RandomIt last, const T &value, Compare comp={})
Definition: cudastdAlgorithm.h:45
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
edm::ConsumesCollector::consumes
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
Definition: ConsumesCollector.h:49
Point3DBase< float, GlobalTag >
OrderedHitTriplet::middle
MiddleRecHit middle() const
Definition: OrderedHitTriplet.h:20
cuda_std::lower_bound
__host__ constexpr __device__ RandomIt lower_bound(RandomIt first, RandomIt last, const T &value, Compare comp={})
Definition: cudastdAlgorithm.h:27
OrderedHitTriplet::outer
OuterRecHit outer() const
Definition: OrderedHitTriplet.h:21
GenericTripletGenerator::qualityFilter
std::pair< bool, float > qualityFilter(const OrderedHitTriplet &oht, const std::map< float, OrderedHitTriplet > &map, const SeedingLayerSetsHits::SeedingLayerSet &ls) const
Definition: GenericTripletGenerator.cc:62
PV3DBase::y
T y() const
Definition: PV3DBase.h:60
FastCircle
Definition: FastCircle.h:33
PV3DBase::mag
T mag() const
Definition: PV3DBase.h:64
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
mag
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
Definition: Basic3DVectorLD.h:127
OrderedHitTriplet::inner
InnerRecHit inner() const
Definition: OrderedHitTriplet.h:19
SeedingLayerSetsHits::SeedingLayerSet
Definition: SeedingLayerSetsHits.h:65
HLT_2018_cff.region
region
Definition: HLT_2018_cff.py:81479
OrderedHitTriplet
Definition: OrderedHitTriplet.h:11
cms::Exception
Definition: Exception.h:70
genParticles_cff.map
map
Definition: genParticles_cff.py:11
GenericTripletGenerator::hitTriplets
OrderedHitTriplets hitTriplets
Definition: GenericTripletGenerator.h:27
edm::InputTag
Definition: InputTag.h:15
hgcalTopologyTester_cfi.layers
layers
Definition: hgcalTopologyTester_cfi.py:8
PV3DBase::phi
Geom::Phi< T > phi() const
Definition: PV3DBase.h:66
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37