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)
 
std::string Layer_name (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::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, 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  CAHitTriplGenerator_->initEvent(ev,es);
89  }
90  //for CA quadruplet iterations
92  seedingLayer = seedingLayers_->makeSeedingLayerSetsHitsforFastSim(ev, es);
93  CAHitQuadGenerator_->initEvent(ev,es);
94  }
95 }
std::unique_ptr< CAHitQuadrupletGenerator > CAHitQuadGenerator_
const edm::EventSetup * eventSetup_
std::unique_ptr< SeedingLayerSetsHits > seedingLayer
edm::ESHandle< TrackerTopology > trackerTopology
const T & get() const
Definition: EventSetup.h:55
std::unique_ptr< SeedingLayerSetsBuilder > seedingLayers_
const MeasurementTracker * measurementTracker_
const std::string measurementTrackerLabel_
std::unique_ptr< CAHitTripletGenerator > CAHitTriplGenerator_
std::unique_ptr< MultiHitGeneratorFromPairAndLayers > multiHitGenerator_
std::string SeedFinderSelector::Layer_name ( const FastTrackerRecHit hit) const

Definition at line 276 of file SeedFinderSelector.cc.

References TrackingRecHit::det(), GeomDet::geographicalId(), dataset::name, PixelSubdetector::PixelBarrel, PixelSubdetector::PixelEndcap, edm::ESHandle< T >::product(), TrackerTopology::pxbLayer(), TrackerTopology::pxfDisk(), TrackerTopology::pxfSide(), AlCaHLTBitMon_QueryRunRegistry::string, and trackerTopology.

Referenced by pass().

277 {
278  std::string name="UNKWN";
279  const TrackerTopology* const tTopo = trackerTopology.product();
280  int idLayer = 0;
281  if( (hit->det()->geographicalId()).subdetId() == PixelSubdetector::PixelBarrel){
282  idLayer = tTopo->pxbLayer(hit->det()->geographicalId());
283  name = "BPix"+std::to_string(idLayer);
284  }
285  else if ((hit->det()->geographicalId()).subdetId() == PixelSubdetector::PixelEndcap){
286  idLayer = tTopo->pxfDisk(hit->det()->geographicalId());
287  if(tTopo->pxfSide(hit->det()->geographicalId())==1)
288  name = "FPix"+std::to_string(idLayer)+"_neg";
289  else
290  name = "FPix"+std::to_string(idLayer)+"_pos";
291  }
292  return name;
293 }
unsigned int pxfDisk(const DetId &id) const
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 98 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_name(), layerPairs_, LayerTriplets::layers(), eostools::ls(), measurementTracker_, eostools::move(), multiHitGenerator_, dataset::name, TrackingRegion::origin(), AlCaHLTBitMon_ParallelJobs::p, pixelTripletGenerator_, IntermediateHitDoublets::regionSize(), mps_fire::result, seedingLayer, AlCaHLTBitMon_QueryRunRegistry::string, and trackingRegion_.

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

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::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_name().

const TrackingRegion* SeedFinderSelector::trackingRegion_
private

Definition at line 49 of file SeedFinderSelector.h.

Referenced by pass().