test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
SeedFinderSelector.cc
Go to the documentation of this file.
2 
3 // framework
7 
8 // track reco
17 
18 // data formats
20 
22  : trackingRegion_(0)
23  , eventSetup_(0)
24  , measurementTracker_(0)
25  , measurementTrackerLabel_(cfg.getParameter<std::string>("measurementTracker"))
26 {
27  if(cfg.exists("pixelTripletGeneratorFactory"))
28  {
29  const edm::ParameterSet & tripletConfig = cfg.getParameter<edm::ParameterSet>("pixelTripletGeneratorFactory");
30  pixelTripletGenerator_.reset(HitTripletGeneratorFromPairAndLayersFactory::get()->create(tripletConfig.getParameter<std::string>("ComponentName"),tripletConfig,consumesCollector));
31  }
32 
33  if(cfg.exists("MultiHitGeneratorFactory"))
34  {
35  const edm::ParameterSet & tripletConfig = cfg.getParameter<edm::ParameterSet>("MultiHitGeneratorFactory");
36  multiHitGenerator_.reset(MultiHitGeneratorFromPairAndLayersFactory::get()->create(tripletConfig.getParameter<std::string>("ComponentName"),tripletConfig));
37  }
38 
40  {
41  throw cms::Exception("FastSimTracking") << "It is forbidden to specify both 'pixelTripletGeneratorFactory' and 'MultiHitGeneratorFactory' in configuration of SeedFinderSelection";
42  }
43 }
44 
45 
47 
49 {
50  eventSetup_ = &es;
51 
52  edm::ESHandle<MeasurementTracker> measurementTrackerHandle;
53  es.get<CkfComponentsRecord>().get(measurementTrackerLabel_, measurementTrackerHandle);
54  measurementTracker_ = &(*measurementTrackerHandle);
55 
57  {
58  multiHitGenerator_->initES(es);
59  }
60 }
61 
62 
63 bool SeedFinderSelector::pass(const std::vector<const FastTrackerRecHit *>& hits) const
64 {
66  {
67  throw cms::Exception("FastSimTracking") << "ERROR: event not initialized";
68  }
69  if(!trackingRegion_)
70  {
71  throw cms::Exception("FastSimTracking") << "ERROR: trackingRegion not set";
72  }
73 
74 
75  // check the inner 2 hits
76  if(hits.size() < 2)
77  {
78  throw cms::Exception("FastSimTracking") << "SeedFinderSelector::pass requires at least 2 hits";
79  }
80  const DetLayer * firstLayer = measurementTracker_->geometricSearchTracker()->detLayer(hits[0]->det()->geographicalId());
81  const DetLayer * secondLayer = measurementTracker_->geometricSearchTracker()->detLayer(hits[1]->det()->geographicalId());
82 
83  std::vector<BaseTrackerRecHit const *> firstHits(1,static_cast<const BaseTrackerRecHit*>(hits[0]));
84  std::vector<BaseTrackerRecHit const *> secondHits(1,static_cast<const BaseTrackerRecHit*>(hits[1]));
85 
86  const RecHitsSortedInPhi fhm(firstHits, trackingRegion_->origin(), firstLayer);
87  const RecHitsSortedInPhi shm(secondHits, trackingRegion_->origin(), secondLayer);
88 
89  HitDoublets result(fhm,shm);
90  HitPairGeneratorFromLayerPair::doublets(*trackingRegion_,*firstLayer,*secondLayer,fhm,shm,*eventSetup_,0,result);
91 
92  if(result.size()==0)
93  {
94  return false;
95  }
96 
97  // check the inner 3 hits
99  {
100  if(hits.size() < 3)
101  {
102  throw cms::Exception("FastSimTracking") << "For the given configuration, SeedFinderSelector::pass requires at least 3 hits";
103  }
104  const DetLayer * thirdLayer = measurementTracker_->geometricSearchTracker()->detLayer(hits[2]->det()->geographicalId());
105  std::vector<const DetLayer *> thirdLayerDetLayer(1,thirdLayer);
106  std::vector<BaseTrackerRecHit const *> thirdHits(1,static_cast<const BaseTrackerRecHit*>(hits[2]));
107  const RecHitsSortedInPhi thm(thirdHits,trackingRegion_->origin(), thirdLayer);
108  const RecHitsSortedInPhi * thmp =&thm;
109 
111  {
112  OrderedHitTriplets tripletresult;
113  pixelTripletGenerator_->hitTriplets(*trackingRegion_,tripletresult,*eventSetup_,result,&thmp,thirdLayerDetLayer,1);
114  return tripletresult.size()!=0;
115  }
116  else if(multiHitGenerator_)
117  {
118  OrderedMultiHits tripletresult;
119  multiHitGenerator_->hitTriplets(*trackingRegion_,tripletresult,*eventSetup_,result,&thmp,thirdLayerDetLayer,1);
120  return tripletresult.size()!=0;
121  }
122 
123  }
124  return true;
125 
126 }
T getParameter(std::string const &) const
bool pass(const std::vector< const FastTrackerRecHit * > &hits) const
tuple cfg
Definition: looper.py:293
const edm::EventSetup * eventSetup_
GlobalPoint const & origin() const
bool exists(std::string const &parameterName) const
checks if a parameter exists
bool ev
SeedFinderSelector(const edm::ParameterSet &cfg, edm::ConsumesCollector &&consumesCollector)
std::unique_ptr< HitTripletGeneratorFromPairAndLayers > pixelTripletGenerator_
tuple result
Definition: mps_fire.py:84
virtual unsigned int size() const
const TrackingRegion * trackingRegion_
const DetLayer * detLayer(const DetId &id) const
obsolete method. Use idToLayer() instead.
HitDoublets doublets(const TrackingRegion &reg, const edm::Event &ev, const edm::EventSetup &es, Layers layers)
const T & get() const
Definition: EventSetup.h:56
void initEvent(const edm::Event &ev, const edm::EventSetup &es)
const MeasurementTracker * measurementTracker_
virtual unsigned int size() const
const GeometricSearchTracker * geometricSearchTracker() const
const std::string measurementTrackerLabel_
T get(const Candidate &c)
Definition: component.h:55
std::unique_ptr< MultiHitGeneratorFromPairAndLayers > multiHitGenerator_