CMS 3D CMS Logo

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

#include <SeedFinderSelector.h>

Public Member Functions

void initEvent (const edm::Event &ev, const edm::EventSetup &es)
 
SeedingLayerSetsBuilder::SeedingLayerId Layer_tuple (const FastTrackerRecHit *hit) const
 
bool pass (const std::vector< const FastTrackerRecHit * > &hits) const
 
 SeedFinderSelector (const edm::ParameterSet &cfg, edm::ConsumesCollector &&consumesCollector)
 
void setTrackingRegion (const TrackingRegion *trackingRegion)
 
 ~SeedFinderSelector ()
 

Private Attributes

std::unique_ptr< CAHitQuadrupletGeneratorCAHitQuadGenerator_
 
std::unique_ptr< CAHitTripletGeneratorCAHitTriplGenerator_
 
const edm::EventSetupeventSetup_
 
std::vector< unsigned > layerPairs_
 
const MeasurementTrackermeasurementTracker_
 
const std::string measurementTrackerLabel_
 
std::unique_ptr< MultiHitGeneratorFromPairAndLayersmultiHitGenerator_
 
std::unique_ptr< HitTripletGeneratorFromPairAndLayerspixelTripletGenerator_
 
std::unique_ptr< SeedingLayerSetsHitsseedingLayer
 
std::vector< SeedingLayerSetsBuilder::SeedingLayerIdseedingLayerIds
 
std::unique_ptr< SeedingLayerSetsBuilderseedingLayers_
 
edm::ESHandle< TrackerTopologytrackerTopology
 
const TrackingRegiontrackingRegion_
 

Detailed Description

Definition at line 29 of file SeedFinderSelector.h.

Constructor & Destructor Documentation

SeedFinderSelector::SeedFinderSelector ( const edm::ParameterSet cfg,
edm::ConsumesCollector &&  consumesCollector 
)

Definition at line 24 of file SeedFinderSelector.cc.

References CAHitQuadGenerator_, CAHitTriplGenerator_, looper::cfg, beamerCreator::create(), Exception, edm::ParameterSet::exists(), reco::get(), edm::ParameterSet::getParameter(), layerPairs_, multiHitGenerator_, pixelTripletGenerator_, seedingLayers_, and AlCaHLTBitMon_QueryRunRegistry::string.

25  : trackingRegion_(nullptr)
26  , eventSetup_(nullptr)
27  , measurementTracker_(nullptr)
28  , measurementTrackerLabel_(cfg.getParameter<std::string>("measurementTracker"))
29 {
30  if(cfg.exists("pixelTripletGeneratorFactory"))
31  {
32  const edm::ParameterSet & tripletConfig = cfg.getParameter<edm::ParameterSet>("pixelTripletGeneratorFactory");
33  pixelTripletGenerator_.reset(HitTripletGeneratorFromPairAndLayersFactory::get()->create(tripletConfig.getParameter<std::string>("ComponentName"),tripletConfig,consumesCollector));
34  }
35 
36  if(cfg.exists("MultiHitGeneratorFactory"))
37  {
38  const edm::ParameterSet & tripletConfig = cfg.getParameter<edm::ParameterSet>("MultiHitGeneratorFactory");
39  multiHitGenerator_.reset(MultiHitGeneratorFromPairAndLayersFactory::get()->create(tripletConfig.getParameter<std::string>("ComponentName"),tripletConfig));
40  }
41 
42  if(cfg.exists("CAHitTripletGeneratorFactory"))
43  {
44  const edm::ParameterSet & tripletConfig = cfg.getParameter<edm::ParameterSet>("CAHitTripletGeneratorFactory");
45  CAHitTriplGenerator_ = std::make_unique<CAHitTripletGenerator>(tripletConfig,consumesCollector);
46  seedingLayers_ = std::make_unique<SeedingLayerSetsBuilder>(cfg, consumesCollector, edm::InputTag("fastTrackerRecHits")); //calling the new FastSim specific constructor to make SeedingLayerSetsHits pointer for triplet iterations
47  layerPairs_ = cfg.getParameter<std::vector<unsigned>>("layerPairs"); //allowed layer pairs for CA triplets
48  }
49 
50  if(cfg.exists("CAHitQuadrupletGeneratorFactory"))
51  {
52  const edm::ParameterSet & quadrupletConfig = cfg.getParameter<edm::ParameterSet>("CAHitQuadrupletGeneratorFactory");
53  CAHitQuadGenerator_ = std::make_unique<CAHitQuadrupletGenerator>(quadrupletConfig, consumesCollector);
54  seedingLayers_ = std::make_unique<SeedingLayerSetsBuilder>(cfg, consumesCollector, edm::InputTag("fastTrackerRecHits")); //calling the new FastSim specific constructor to make SeedingLayerSetsHits pointer for quadruplet iterations
55  layerPairs_ = cfg.getParameter<std::vector<unsigned>>("layerPairs"); //allowed layer pairs for CA quadruplets
56  }
57 
59  {
60  throw cms::Exception("FastSimTracking") << "It is forbidden to specify together 'pixelTripletGeneratorFactory', 'CAHitTripletGeneratorFactory' and 'MultiHitGeneratorFactory' in configuration of SeedFinderSelection";
61  }
63  {
64  throw cms::Exception("FastSimTracking") << "It is forbidden to specify 'CAHitQuadrupletGeneratorFactory' together with 'pixelTripletGeneratorFactory', 'CAHitTripletGeneratorFactory' or 'MultiHitGeneratorFactory' in configuration of SeedFinderSelection";
65  }
66 }
T getParameter(std::string const &) const
std::unique_ptr< CAHitQuadrupletGenerator > CAHitQuadGenerator_
const edm::EventSetup * eventSetup_
def create(alignables, pedeDump, additionalData, outputFile, config)
bool exists(std::string const &parameterName) const
checks if a parameter exists
std::unique_ptr< HitTripletGeneratorFromPairAndLayers > pixelTripletGenerator_
std::vector< unsigned > layerPairs_
const TrackingRegion * trackingRegion_
std::unique_ptr< SeedingLayerSetsBuilder > seedingLayers_
const MeasurementTracker * measurementTracker_
const std::string measurementTrackerLabel_
std::unique_ptr< CAHitTripletGenerator > CAHitTriplGenerator_
T get(const Candidate &c)
Definition: component.h:55
std::unique_ptr< MultiHitGeneratorFromPairAndLayers > multiHitGenerator_
SeedFinderSelector::~SeedFinderSelector ( )

Definition at line 69 of file SeedFinderSelector.cc.

69 {;}

Member Function Documentation

void SeedFinderSelector::initEvent ( const edm::Event ev,
const edm::EventSetup es 
)

Definition at line 71 of file SeedFinderSelector.cc.

References CAHitQuadGenerator_, CAHitTriplGenerator_, eventSetup_, edm::EventSetup::get(), measurementTracker_, measurementTrackerLabel_, multiHitGenerator_, seedingLayer, seedingLayerIds, seedingLayers_, and trackerTopology.

72 {
73  eventSetup_ = &es;
74 
75  edm::ESHandle<MeasurementTracker> measurementTrackerHandle;
76  es.get<CkfComponentsRecord>().get(measurementTrackerLabel_, measurementTrackerHandle);
78  measurementTracker_ = &(*measurementTrackerHandle);
79 
81  {
82  multiHitGenerator_->initES(es);
83  }
84 
85  //for CA triplet iterations
87  seedingLayer = seedingLayers_->makeSeedingLayerSetsHitsforFastSim(ev, es);
88  seedingLayerIds = seedingLayers_->layers();
89  CAHitTriplGenerator_->initEvent(ev,es);
90  }
91  //for CA quadruplet iterations
93  seedingLayer = seedingLayers_->makeSeedingLayerSetsHitsforFastSim(ev, es);
94  seedingLayerIds = seedingLayers_->layers();
95  CAHitQuadGenerator_->initEvent(ev,es);
96  }
97 }
std::unique_ptr< CAHitQuadrupletGenerator > CAHitQuadGenerator_
const edm::EventSetup * eventSetup_
std::unique_ptr< SeedingLayerSetsHits > seedingLayer
std::vector< SeedingLayerSetsBuilder::SeedingLayerId > seedingLayerIds
edm::ESHandle< TrackerTopology > trackerTopology
std::unique_ptr< SeedingLayerSetsBuilder > seedingLayers_
T get() const
Definition: EventSetup.h:63
const MeasurementTracker * measurementTracker_
const std::string measurementTrackerLabel_
std::unique_ptr< CAHitTripletGenerator > CAHitTriplGenerator_
std::unique_ptr< MultiHitGeneratorFromPairAndLayers > multiHitGenerator_
SeedingLayerSetsBuilder::SeedingLayerId SeedFinderSelector::Layer_tuple ( const FastTrackerRecHit hit) const

Definition at line 278 of file SeedFinderSelector.cc.

References Barrel, TrackingRecHit::det(), GeomDet::geographicalId(), GeomDetEnumerators::invalidDet, NegEndcap, GeomDetEnumerators::PixelBarrel, PixelSubdetector::PixelBarrel, GeomDetEnumerators::PixelEndcap, PixelSubdetector::PixelEndcap, PosEndcap, edm::ESHandle< T >::product(), TrackerTopology::pxbLayer(), TrackerTopology::pxfDisk(), TrackerTopology::pxfSide(), and trackerTopology.

Referenced by pass().

279 {
280  const TrackerTopology* const tTopo = trackerTopology.product();
283  int idLayer = 0;
284 
285  if( (hit->det()->geographicalId()).subdetId() == PixelSubdetector::PixelBarrel){
287  side = TrackerDetSide::Barrel;
288  idLayer = tTopo->pxbLayer(hit->det()->geographicalId());
289  }
290  else if ((hit->det()->geographicalId()).subdetId() == PixelSubdetector::PixelEndcap){
292  idLayer = tTopo->pxfDisk(hit->det()->geographicalId());
293  if(tTopo->pxfSide(hit->det()->geographicalId())==1){
295  }
296  else{
298  }
299  }
300  return std::make_tuple(subdet, side, idLayer);
301 }
unsigned int pxfDisk(const DetId &id) const
TrackerDetSide
Definition: TrackerDetSide.h:4
const GeomDet * det() const
DetId geographicalId() const
The label of this GeomDet.
Definition: GeomDet.h:79
edm::ESHandle< TrackerTopology > trackerTopology
unsigned int pxbLayer(const DetId &id) const
unsigned int pxfSide(const DetId &id) const
T const * product() const
Definition: ESHandle.h:86
bool SeedFinderSelector::pass ( const std::vector< const FastTrackerRecHit * > &  hits) const

Definition at line 100 of file SeedFinderSelector.cc.

References IntermediateHitDoublets::beginRegion(), CAHitQuadGenerator_, CAHitTriplGenerator_, GeometricSearchTracker::detLayer(), HitPairGeneratorFromLayerPair::doublets(), eventSetup_, Exception, objects.autophobj::filler, runEdmFileComparison::found, MeasurementTracker::geometricSearchTracker(), mps_fire::i, Layer_tuple(), layerPairs_, LayerTriplets::layers(), eostools::ls(), measurementTracker_, eostools::move(), multiHitGenerator_, TrackingRegion::origin(), AlCaHLTBitMon_ParallelJobs::p, pixelTripletGenerator_, IntermediateHitDoublets::regionSize(), mps_fire::result, seedingLayer, seedingLayerIds, and trackingRegion_.

101 {
103  {
104  throw cms::Exception("FastSimTracking") << "ERROR: event not initialized";
105  }
106  if(!trackingRegion_)
107  {
108  throw cms::Exception("FastSimTracking") << "ERROR: trackingRegion not set";
109  }
110 
111 
112  // check the inner 2 hits
113  if(hits.size() < 2)
114  {
115  throw cms::Exception("FastSimTracking") << "SeedFinderSelector::pass requires at least 2 hits";
116  }
117  const DetLayer * firstLayer = measurementTracker_->geometricSearchTracker()->detLayer(hits[0]->det()->geographicalId());
118  const DetLayer * secondLayer = measurementTracker_->geometricSearchTracker()->detLayer(hits[1]->det()->geographicalId());
119 
120  std::vector<BaseTrackerRecHit const *> firstHits{hits[0]};
121  std::vector<BaseTrackerRecHit const *> secondHits{hits[1]};
122 
123  const RecHitsSortedInPhi fhm(firstHits, trackingRegion_->origin(), firstLayer);
124  const RecHitsSortedInPhi shm(secondHits, trackingRegion_->origin(), secondLayer);
125 
126  HitDoublets result(fhm,shm);
127  HitPairGeneratorFromLayerPair::doublets(*trackingRegion_,*firstLayer,*secondLayer,fhm,shm,*eventSetup_,0,result);
128 
129  if(result.empty())
130  {
131  return false;
132  }
133 
134  // check the inner 3 hits
136  {
137  if(hits.size() < 3)
138  {
139  throw cms::Exception("FastSimTracking") << "For the given configuration, SeedFinderSelector::pass requires at least 3 hits";
140  }
141  const DetLayer * thirdLayer = measurementTracker_->geometricSearchTracker()->detLayer(hits[2]->det()->geographicalId());
142  std::vector<const DetLayer *> thirdLayerDetLayer(1,thirdLayer);
143  std::vector<BaseTrackerRecHit const *> thirdHits{hits[2]};
144  const RecHitsSortedInPhi thm(thirdHits,trackingRegion_->origin(), thirdLayer);
145  const RecHitsSortedInPhi * thmp =&thm;
146 
148  {
149  OrderedHitTriplets tripletresult;
150  pixelTripletGenerator_->hitTriplets(*trackingRegion_,tripletresult,*eventSetup_,result,&thmp,thirdLayerDetLayer,1);
151  return !tripletresult.empty();
152  }
153  else if(multiHitGenerator_)
154  {
155  OrderedMultiHits tripletresult;
156  multiHitGenerator_->hitTriplets(*trackingRegion_,tripletresult,*eventSetup_,result,&thmp,thirdLayerDetLayer,1);
157  return !tripletresult.empty();
158  }
159  //new for Phase1
160  else if(CAHitTriplGenerator_)
161  {
162  if(!seedingLayer)
163  throw cms::Exception("FastSimTracking") << "ERROR: SeedingLayers pointer not set for CATripletGenerator";
164 
166  //constructing IntermediateHitDoublets to be passed onto CAHitTripletGenerator::hitNtuplets()
167  IntermediateHitDoublets ihd(&layers);
168  const TrackingRegion& tr_ = *trackingRegion_;
169  auto filler = ihd.beginRegion(&tr_);
170 
171  //Forming doublets for CA triplets from the allowed layer pair combinations:(0,1),(1,2)
172  std::array<SeedingLayerSetsBuilder::SeedingLayerId,2> hitPair;
173  for(int i=0; i<2; i++){
175  hitPair[0] = Layer_tuple(hits[i]);
176  hitPair[1] = Layer_tuple(hits[i+1]);
177 
178  bool found;
180  found = false;
181  for(const auto p : layerPairs_){
182  pairCandidate = ls.slice(p,p+2);
183  if(hitPair[0] == seedingLayerIds[pairCandidate[0].index()] && hitPair[1] == seedingLayerIds[pairCandidate[1].index()]){
184  found = true;
185  break;
186  }
187  }
188  if(found)
189  break;
190  }
191  assert(found == true);
192  const DetLayer * fLayer = measurementTracker_->geometricSearchTracker()->detLayer(hits[i]->det()->geographicalId());
193  const DetLayer * sLayer = measurementTracker_->geometricSearchTracker()->detLayer(hits[i+1]->det()->geographicalId());
194  std::vector<BaseTrackerRecHit const *> fHits{hits[i]};
195  std::vector<BaseTrackerRecHit const *> sHits{hits[i+1]};
196 
197  //Important: doublets to be added to the cache
198  auto& layerCache = filler.layerHitMapCache();
199  const RecHitsSortedInPhi& firsthm = *layerCache.add(pairCandidate[0], std::make_unique<RecHitsSortedInPhi>(fHits, trackingRegion_->origin(),fLayer));
200  const RecHitsSortedInPhi& secondhm = *layerCache.add(pairCandidate[1], std::make_unique<RecHitsSortedInPhi>(sHits, trackingRegion_->origin(),sLayer));
201  HitDoublets res(firsthm,secondhm);
202  HitPairGeneratorFromLayerPair::doublets(*trackingRegion_,*fLayer,*sLayer,firsthm,secondhm,*eventSetup_,0,res);
203  filler.addDoublets(pairCandidate, std::move(res)); //fill the formed doublet
204  }
205  std::vector<OrderedHitSeeds> tripletresult;
206  tripletresult.resize(ihd.regionSize());
207  for(auto& ntuplet : tripletresult)
208  ntuplet.reserve(3);
209  CAHitTriplGenerator_->hitNtuplets(ihd,tripletresult,*eventSetup_,*seedingLayer); //calling the function from the class, modifies tripletresult
210  return !tripletresult.empty();
211  }
212  }
213  //new for Phase1
215  {
216  if(hits.size() < 4)
217  {
218  throw cms::Exception("FastSimTracking") << "For the given configuration, SeedFinderSelector::pass requires at least 4 hits";
219  }
220 
221  if(!seedingLayer)
222  throw cms::Exception("FastSimTracking") << "ERROR: SeedingLayers pointer not set for CAHitQuadrupletGenerator";
223 
225  //constructing IntermediateHitDoublets to be passed onto CAHitQuadrupletGenerator::hitNtuplets()
226  IntermediateHitDoublets ihd(&layers);
227  const TrackingRegion& tr_ = *trackingRegion_;
228  auto filler = ihd.beginRegion(&tr_);
229 
230  //Forming doublets for CA quadruplets from the allowed layer pair combinations:(0,1),(1,2),(2,3)
231  std::array<SeedingLayerSetsBuilder::SeedingLayerId,2> hitPair;
232  for(int i=0; i<3; i++){
234  hitPair[0] = Layer_tuple(hits[i]);
235  hitPair[1] = Layer_tuple(hits[i+1]);
236 
237  bool found;
238  for(SeedingLayerSetsHits::SeedingLayerSet ls : *seedingLayer){
239  found = false;
240  for(const auto p : layerPairs_){
241  pairCandidate = ls.slice(p,p+2);
242  if(hitPair[0] == seedingLayerIds[pairCandidate[0].index()] && hitPair[1] == seedingLayerIds[pairCandidate[1].index()]){
243  found = true;
244  break;
245  }
246  }
247  if(found)
248  break;
249  }
250  assert(found == true);
251  const DetLayer * fLayer = measurementTracker_->geometricSearchTracker()->detLayer(hits[i]->det()->geographicalId());
252  const DetLayer * sLayer = measurementTracker_->geometricSearchTracker()->detLayer(hits[i+1]->det()->geographicalId());
253  std::vector<BaseTrackerRecHit const *> fHits{hits[i]};
254  std::vector<BaseTrackerRecHit const *> sHits{hits[i+1]};
255 
256  //Important: doublets to be added to the cache
257  auto& layerCache = filler.layerHitMapCache();
258  const RecHitsSortedInPhi& firsthm = *layerCache.add(pairCandidate[0], std::make_unique<RecHitsSortedInPhi>(fHits, trackingRegion_->origin(), fLayer));
259  const RecHitsSortedInPhi& secondhm = *layerCache.add(pairCandidate[1], std::make_unique<RecHitsSortedInPhi>(sHits, trackingRegion_->origin(), sLayer));
260  HitDoublets res(firsthm,secondhm);
261  HitPairGeneratorFromLayerPair::doublets(*trackingRegion_,*fLayer,*sLayer,firsthm,secondhm,*eventSetup_,0,res);
262  filler.addDoublets(pairCandidate, std::move(res)); //fill the formed doublet
263  }
264 
265  std::vector<OrderedHitSeeds> quadrupletresult;
266  quadrupletresult.resize(ihd.regionSize());
267  for(auto& ntuplet : quadrupletresult)
268  ntuplet.reserve(4);
269  CAHitQuadGenerator_->hitNtuplets(ihd,quadrupletresult,*eventSetup_,*seedingLayer); //calling the function from the class, modifies quadrupletresult
270  return !quadrupletresult.empty();
271  }
272 
273  return true;
274 
275 }
std::vector< LayerSetAndLayers > layers(const SeedingLayerSetsHits &sets)
Definition: LayerTriplets.cc:4
std::unique_ptr< CAHitQuadrupletGenerator > CAHitQuadGenerator_
const edm::EventSetup * eventSetup_
GlobalPoint const & origin() const
std::unique_ptr< SeedingLayerSetsHits > seedingLayer
std::unique_ptr< HitTripletGeneratorFromPairAndLayers > pixelTripletGenerator_
Definition: Electron.h:6
std::vector< SeedingLayerSetsBuilder::SeedingLayerId > seedingLayerIds
SeedingLayerSetsBuilder::SeedingLayerId Layer_tuple(const FastTrackerRecHit *hit) const
std::vector< unsigned > layerPairs_
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)
def ls(path, rec=False)
Definition: eostools.py:348
const MeasurementTracker * measurementTracker_
const GeometricSearchTracker * geometricSearchTracker() const
std::unique_ptr< CAHitTripletGenerator > CAHitTriplGenerator_
def move(src, dest)
Definition: eostools.py:510
std::unique_ptr< MultiHitGeneratorFromPairAndLayers > multiHitGenerator_
void SeedFinderSelector::setTrackingRegion ( const TrackingRegion trackingRegion)
inline

Definition at line 39 of file SeedFinderSelector.h.

References hfClusterShapes_cfi::hits.

39 {trackingRegion_ = trackingRegion;}
const TrackingRegion * trackingRegion_

Member Data Documentation

std::unique_ptr<CAHitQuadrupletGenerator> SeedFinderSelector::CAHitQuadGenerator_
private

Definition at line 54 of file SeedFinderSelector.h.

Referenced by initEvent(), pass(), and SeedFinderSelector().

std::unique_ptr<CAHitTripletGenerator> SeedFinderSelector::CAHitTriplGenerator_
private

Definition at line 53 of file SeedFinderSelector.h.

Referenced by initEvent(), pass(), and SeedFinderSelector().

const edm::EventSetup* SeedFinderSelector::eventSetup_
private

Definition at line 50 of file SeedFinderSelector.h.

Referenced by initEvent(), and pass().

std::vector<unsigned> SeedFinderSelector::layerPairs_
private

Definition at line 57 of file SeedFinderSelector.h.

Referenced by pass(), and SeedFinderSelector().

const MeasurementTracker* SeedFinderSelector::measurementTracker_
private

Definition at line 51 of file SeedFinderSelector.h.

Referenced by initEvent(), and pass().

const std::string SeedFinderSelector::measurementTrackerLabel_
private

Definition at line 52 of file SeedFinderSelector.h.

Referenced by initEvent().

std::unique_ptr<MultiHitGeneratorFromPairAndLayers> SeedFinderSelector::multiHitGenerator_
private

Definition at line 48 of file SeedFinderSelector.h.

Referenced by initEvent(), pass(), and SeedFinderSelector().

std::unique_ptr<HitTripletGeneratorFromPairAndLayers> SeedFinderSelector::pixelTripletGenerator_
private

Definition at line 47 of file SeedFinderSelector.h.

Referenced by pass(), and SeedFinderSelector().

std::unique_ptr<SeedingLayerSetsHits> SeedFinderSelector::seedingLayer
private

Definition at line 56 of file SeedFinderSelector.h.

Referenced by initEvent(), and pass().

std::vector<SeedingLayerSetsBuilder::SeedingLayerId> SeedFinderSelector::seedingLayerIds
private

Definition at line 59 of file SeedFinderSelector.h.

Referenced by initEvent(), and pass().

std::unique_ptr<SeedingLayerSetsBuilder> SeedFinderSelector::seedingLayers_
private

Definition at line 55 of file SeedFinderSelector.h.

Referenced by initEvent(), and SeedFinderSelector().

edm::ESHandle<TrackerTopology> SeedFinderSelector::trackerTopology
private

Definition at line 58 of file SeedFinderSelector.h.

Referenced by initEvent(), and Layer_tuple().

const TrackingRegion* SeedFinderSelector::trackingRegion_
private

Definition at line 49 of file SeedFinderSelector.h.

Referenced by pass().