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

#include <GenericTripletGenerator.h>

Inheritance diagram for GenericTripletGenerator:
OrderedHitsGenerator

Public Member Functions

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

Private Member Functions

ctfseeding::SeedingLayerSets init (const edm::EventSetup &es)
 
std::pair< bool, float > qualityFilter (const OrderedHitTriplet &oht, const std::map< float, OrderedHitTriplet > &map, const ctfseeding::SeedingLayers &ls) const
 

Private Attributes

OrderedHitTriplets hitTriplets
 
SeedingLayerSetsBuilder theLsb
 

Additional Inherited Members

- Public Attributes inherited from OrderedHitsGenerator
unsigned int theMaxElement
 

Detailed Description

Definition at line 16 of file GenericTripletGenerator.h.

Constructor & Destructor Documentation

GenericTripletGenerator::GenericTripletGenerator ( const edm::ParameterSet conf)

Definition at line 11 of file GenericTripletGenerator.cc.

11  :
12  //conf_(conf),
13  theLsb(conf.getParameter<edm::ParameterSet>("LayerPSet")){
14  edm::LogInfo("CtfSpecialSeedGenerator|GenericTripletGenerator") << "Constructing GenericTripletGenerator";
15 }
T getParameter(std::string const &) const
SeedingLayerSetsBuilder theLsb
virtual GenericTripletGenerator::~GenericTripletGenerator ( )
inlinevirtual

Definition at line 19 of file GenericTripletGenerator.h.

19 {};

Member Function Documentation

void GenericTripletGenerator::clear ( void  )
inlinevirtual

Reimplemented from OrderedHitsGenerator.

Definition at line 23 of file GenericTripletGenerator.h.

References hitTriplets.

23 {hitTriplets.clear();}
SeedingLayerSets GenericTripletGenerator::init ( const edm::EventSetup es)
private

Definition at line 18 of file GenericTripletGenerator.cc.

References SeedingLayerSetsBuilder::layers(), and theLsb.

Referenced by run().

18  {
19  //edm::ParameterSet leyerPSet = conf_.getParameter<edm::ParameterSet>("LayerPSet");
20  //SeedingLayerSetsBuilder lsBuilder(leyerPSet);
21  SeedingLayerSets lss = theLsb.layers(es);
22  return lss;
23 }
SeedingLayerSetsBuilder theLsb
ctfseeding::SeedingLayerSets layers(const edm::EventSetup &es) const
std::vector< std::vector< SeedingLayer > > SeedingLayerSets
std::pair< bool, float > GenericTripletGenerator::qualityFilter ( const OrderedHitTriplet oht,
const std::map< float, OrderedHitTriplet > &  map,
const ctfseeding::SeedingLayers ls 
) const
private

Definition at line 77 of file GenericTripletGenerator.cc.

References alignCSCRings::e, OrderedHitTriplet::inner(), PV3DBase< T, PVType, FrameType >::mag(), mag(), OrderedHitTriplet::middle(), OrderedHitTriplet::outer(), PV3DBase< T, PVType, FrameType >::phi(), FastCircle::rho(), mathSSE::sqrt(), PV3DBase< T, PVType, FrameType >::x(), and PV3DBase< T, PVType, FrameType >::y().

Referenced by run().

79  {
80  //first check the radius
81  GlobalPoint innerpos = oht.inner()->globalPosition();
82  GlobalPoint middlepos = oht.middle()->globalPosition();
83  GlobalPoint outerpos = oht.outer()->globalPosition();
84  std::vector<const TrackingRecHit*> ohttrh;
85  ohttrh.push_back(&(*(oht.inner()))); ohttrh.push_back(&(*(oht.middle()))); ohttrh.push_back(&(*(oht.outer())));
86  std::vector<const TrackingRecHit*>::const_iterator ioht;
87  //now chech that the change in phi is reasonable. the limiting angular distance is the one in case
88  //one of the two points is a tangent point.
89  float limit_phi_distance1 = sqrt((middlepos.x()-outerpos.x())*(middlepos.x()-outerpos.x()) +
90  (middlepos.y()-outerpos.y())*(middlepos.y()-outerpos.y()))/middlepos.mag();//actually this is the tangent of the limiting angle
91  float limit_phi_distance2 = sqrt((middlepos.x()-innerpos.x())*(middlepos.x()-innerpos.x()) +
92  (middlepos.y()-innerpos.y())*(middlepos.y()-innerpos.y()))/innerpos.mag();
93  //if (fabs(tan(outerpos.phi()-middlepos.phi()))>limit_phi_distance1 ||
94  // fabs(tan(innerpos.phi()-middlepos.phi()))>limit_phi_distance2) {
95  if (fabs(outerpos.phi()-middlepos.phi())>fabs(atan(limit_phi_distance1)) ||
96  fabs(innerpos.phi()-middlepos.phi())>fabs(atan(limit_phi_distance2)) ) {
97  //std::cout << "rejected because phi" << std::endl;
98  return std::make_pair(false, 0.);
99  }
100  //should we add a control on the r-z plane too?
101  /*
102  //now check that there is no big change in the r-z projection
103  float dz1 = outerpos.z()-middlepos.z();
104  float dr1 = sqrt(outerpos.x()*outerpos.x()+outerpos.y()*outerpos.y())-
105  sqrt(middlepos.x()*middlepos.x()+middlepos.y()*middlepos.y());
106  float dz2 = middlepos.z()-innerpos.z();
107  float dr2 = sqrt(middlepos.x()*middlepos.x()+middlepos.y()*middlepos.y())-
108  sqrt(innerpos.x()*innerpos.x()+innerpos.y()*innerpos.y());
109  float tan1 = dz1/dr1;
110  float tan2 = dz2/dr2;
111  //how much should we allow? should we make it configurable?
112  if (fabs(tan1-tan2)/tan1>0.5){
113  //std::cout << "rejected because z" << std::endl;
114  return std::make_pair(false, 0.);
115  }
116  */
117  //now check the radius is not too small
118  FastCircle circle(innerpos, middlepos, outerpos);
119  if (circle.rho() < 200 && circle.rho() != 0) return std::make_pair(false, circle.rho()); //to small radius
120  //now check if at least 2 hits are shared with an existing triplet
121  //look for similar radii in the map
122  std::map<float, OrderedHitTriplet>::const_iterator lower_bound = map.lower_bound((1-0.01)*circle.rho());
123  std::map<float, OrderedHitTriplet>::const_iterator upper_bound = map.upper_bound((1+0.01)*circle.rho());
124  std::map<float, OrderedHitTriplet>::const_iterator iter;
125  for (iter = lower_bound; iter != upper_bound && iter->first <= upper_bound->first; iter++){
126  int shared=0;
127  std::vector<const TrackingRecHit*> curtrh;
128  curtrh.push_back(&*(iter->second.inner()));curtrh.push_back(&*(iter->second.middle()));curtrh.push_back(&*(iter->second.outer()));
129  std::vector<const TrackingRecHit*>::const_iterator curiter;
130  for (curiter = curtrh.begin(); curiter != curtrh.end(); curiter++){
131  for (ioht = ohttrh.begin(); ioht != ohttrh.end(); ioht++){
132  if ((*ioht)->geographicalId()==(*curiter)->geographicalId() &&
133  ((*ioht)->localPosition()-(*curiter)->localPosition()).mag()<1e-5) shared++;
134  }
135  }
136  if (shared>1) return std::make_pair(false, circle.rho());
137  }
138 
139  return std::make_pair(true,circle.rho());
140 }
const OuterRecHit & outer() const
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
Geom::Phi< T > phi() const
Definition: PV3DBase.h:69
T y() const
Definition: PV3DBase.h:63
const InnerRecHit & inner() const
const MiddleRecHit & middle() const
dictionary map
Definition: Association.py:205
T mag() const
Definition: PV3DBase.h:67
T sqrt(T t)
Definition: SSEVec.h:48
T x() const
Definition: PV3DBase.h:62
const OrderedSeedingHits & GenericTripletGenerator::run ( const TrackingRegion region,
const edm::Event ev,
const edm::EventSetup es 
)
virtual

Implements OrderedHitsGenerator.

Definition at line 26 of file GenericTripletGenerator.cc.

References edm::hlt::Exception, TrackingRegion::hits(), hitTriplets, init(), python.rootplot.utilities::ls(), and qualityFilter().

28  {
29  hitTriplets.clear();
30  hitTriplets.reserve(0);
31  SeedingLayerSets lss = init(es);
32  SeedingLayerSets::const_iterator iLss;
33  std::map<float, OrderedHitTriplet> radius_triplet_map;
34  for (iLss = lss.begin(); iLss != lss.end(); iLss++){
35  SeedingLayers ls = *iLss;
36  if (ls.size() != 3){
37  throw cms::Exception("CtfSpecialSeedGenerator") << "You are using " << ls.size() <<" layers in set instead of 3 ";
38  }
39  std::vector<SeedingHit> innerHits = region.hits(e, es, &ls[0]);
40  //std::cout << "innerHits.size()=" << innerHits.size() << std::endl;
41  std::vector<SeedingHit> middleHits = region.hits(e, es, &ls[1]);
42  //std::cout << "middleHits.size()=" << middleHits.size() << std::endl;
43  std::vector<SeedingHit> outerHits = region.hits(e, es, &ls[2]);
44  //std::cout << "outerHits.size()=" << outerHits.size() << std::endl;
45  //std::cout << "trying " << innerHits.size()*middleHits.size()*outerHits.size() << " combinations "<<std::endl;
46  std::vector<SeedingHit>::const_iterator iOuterHit;
47  for (iOuterHit = outerHits.begin(); iOuterHit != outerHits.end(); iOuterHit++){
48  std::vector<SeedingHit>::const_iterator iMiddleHit;
49  for (iMiddleHit = middleHits.begin(); iMiddleHit != middleHits.end(); iMiddleHit++){
50  std::vector<SeedingHit>::const_iterator iInnerHit;
51  for (iInnerHit = innerHits.begin(); iInnerHit != innerHits.end(); iInnerHit++){
52  //GlobalPoint innerpos = ls[0].hitBuilder()->build(&(**iInnerHit))->globalPosition();
53  //GlobalPoint middlepos = ls[1].hitBuilder()->build(&(**iMiddleHit))->globalPosition();
54  //GlobalPoint outerpos = ls[2].hitBuilder()->build(&(**iOuterHit))->globalPosition();
55  //FastCircle circle(innerpos,
56  // middlepos,
57  // outerpos);
58  //do a first check on the radius of curvature to reduce the combinatorics
59  OrderedHitTriplet oht(*iInnerHit,*iMiddleHit,*iOuterHit);
60  std::pair<bool,float> val_radius = qualityFilter(oht,radius_triplet_map,ls);
61  if (val_radius.first){
62  //if (circle.rho() > 200 || circle.rho() == 0) { //0 radius means straight line
63  //hitTriplets.push_back(OrderedHitTriplet(*iInnerHit,
64  // *iMiddleHit,
65  // *iOuterHit));
66  hitTriplets.push_back(oht);
67  radius_triplet_map.insert(std::make_pair(val_radius.second,oht));
68  }
69  }
70  }
71  }
72  }
73  //std::cout << "ending with " << hitTriplets.size() << " triplets" << std::endl;
74  return hitTriplets;
75 }
virtual Hits hits(const edm::Event &ev, const edm::EventSetup &es, const ctfseeding::SeedingLayer *layer) const =0
get hits from layer compatible with region constraints
std::pair< bool, float > qualityFilter(const OrderedHitTriplet &oht, const std::map< float, OrderedHitTriplet > &map, const ctfseeding::SeedingLayers &ls) const
ctfseeding::SeedingLayerSets init(const edm::EventSetup &es)
std::vector< SeedingLayer > SeedingLayers
std::vector< std::vector< SeedingLayer > > SeedingLayerSets

Member Data Documentation

OrderedHitTriplets GenericTripletGenerator::hitTriplets
private

Definition at line 31 of file GenericTripletGenerator.h.

Referenced by clear(), and run().

SeedingLayerSetsBuilder GenericTripletGenerator::theLsb
private

Definition at line 30 of file GenericTripletGenerator.h.

Referenced by init().