CMS 3D CMS Logo

List of all members | Classes | Public Types | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
SeedingLayerSetsBuilder Class Reference

#include <SeedingLayerSetsBuilder.h>

Classes

struct  LayerSpec
 

Public Types

using SeedingLayerId = std::tuple< GeomDetEnumerators::SubDetector, TrackerDetSide, int >
 

Public Member Functions

std::unique_ptr< SeedingLayerSetsHitshits (const edm::Event &ev, const edm::EventSetup &es)
 
std::vector< SeedingLayerIdlayers () const
 
const std::vector< SeedingLayerSetsHits::LayerSetIndex > & layerSetIndices () const
 
unsigned short numberOfLayers () const
 
unsigned short numberOfLayerSets () const
 
 SeedingLayerSetsBuilder ()=default
 
 SeedingLayerSetsBuilder (const edm::ParameterSet &cfg, edm::ConsumesCollector &iC)
 
 SeedingLayerSetsBuilder (const edm::ParameterSet &cfg, edm::ConsumesCollector &&iC)
 
SeedingLayerSetsLooper seedingLayerSetsLooper () const
 
 ~SeedingLayerSetsBuilder ()
 

Static Public Member Functions

static void fillDescriptions (edm::ParameterSetDescription &desc)
 
static std::vector< std::vector< std::string > > layerNamesInSets (const std::vector< std::string > &namesPSet)
 
static SeedingLayerId nameToEnumId (const std::string &name)
 

Private Member Functions

edm::ParameterSet layerConfig (const std::string &nameLayer, const edm::ParameterSet &cfg) const
 
void updateEventSetup (const edm::EventSetup &es)
 

Private Attributes

edm::ESWatcher< TrackerRecoGeometryRecordgeometryWatcher_
 
std::vector< const DetLayer * > theLayerDets
 
std::vector< std::string > theLayerNames
 
std::vector< LayerSpectheLayers
 
std::vector< SeedingLayerSetsHits::LayerSetIndextheLayerSetIndices
 
unsigned short theNumberOfLayersInSet
 
std::vector< const TransientTrackingRecHitBuilder * > theTTRHBuilders
 
edm::ESWatcher< TransientRecHitRecordtrhWatcher_
 

Detailed Description

Definition at line 24 of file SeedingLayerSetsBuilder.h.

Member Typedef Documentation

Definition at line 27 of file SeedingLayerSetsBuilder.h.

Constructor & Destructor Documentation

SeedingLayerSetsBuilder::SeedingLayerSetsBuilder ( )
default
SeedingLayerSetsBuilder::SeedingLayerSetsBuilder ( const edm::ParameterSet cfg,
edm::ConsumesCollector iC 
)

Definition at line 184 of file SeedingLayerSetsBuilder.cc.

References Exception, spr::find(), runEdmFileComparison::found, edm::ParameterSet::getParameter(), layerConfig(), layerNamesInSets(), SiStripPI::max, harvestTrackValidationPlots::str, AlCaHLTBitMon_QueryRunRegistry::string, theLayerDets, theLayerNames, theLayers, theLayerSetIndices, theNumberOfLayersInSet, and theTTRHBuilders.

185 {
186  std::vector<std::string> namesPset = cfg.getParameter<std::vector<std::string> >("layerList");
187  std::vector<std::vector<std::string> > layerNamesInSets = this->layerNamesInSets(namesPset);
188 
189  // debug printout of layers
190  typedef std::vector<std::string>::const_iterator IS;
191  typedef std::vector<std::vector<std::string> >::const_iterator IT;
192  std::ostringstream str;
193  // The following should not be set to cout
194 // for (IT it = layerNamesInSets.begin(); it != layerNamesInSets.end(); it++) {
195 // str << "SET: ";
196 // for (IS is = it->begin(); is != it->end(); is++) str << *is <<" ";
197 // str << std::endl;
198 // }
199 // std::cout << str.str() << std::endl;
200  if(layerNamesInSets.empty())
202  else
203  theNumberOfLayersInSet = layerNamesInSets[0].size();
204 
205 
206  for (IT it = layerNamesInSets.begin(); it != layerNamesInSets.end(); it++) {
207  if(it->size() != theNumberOfLayersInSet)
208  throw cms::Exception("Configuration") << "Assuming all SeedingLayerSets to have same number of layers. LayerSet " << (it-layerNamesInSets.begin()) << " has " << it->size() << " while 0th has " << theNumberOfLayersInSet;
209  for(const std::string& layerName: *it) {
210  auto found = std::find(theLayerNames.begin(), theLayerNames.end(), layerName);
211  unsigned short layerIndex = 0;
212  if(found != theLayerNames.end()) {
213  layerIndex = found-theLayerNames.begin();
214  }
215  else {
217  throw cms::Exception("Assert") << "Too many layers in " << __FILE__ << ":" << __LINE__ << ", we may have to enlarge the index type from unsigned short to unsigned int";
218  }
219 
220  layerIndex = theLayers.size();
221  theLayers.emplace_back(theLayerNames.size(), layerName, layerConfig(layerName, cfg), iC);
222  theLayerNames.push_back(layerName);
223  }
224  theLayerSetIndices.push_back(layerIndex);
225  }
226  }
227  theLayerDets.resize(theLayers.size());
228  theTTRHBuilders.resize(theLayers.size());
229 
230  // debug printout
231  // The following should not be set to cout
232  //for(const LayerSpec& layer: theLayers) {
233  // std::cout << layer.print(theLayerNames) << std::endl;
234  //}
235 }
T getParameter(std::string const &) const
std::vector< LayerSpec > theLayers
std::vector< std::string > theLayerNames
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:20
std::vector< const TransientTrackingRecHitBuilder * > theTTRHBuilders
std::vector< SeedingLayerSetsHits::LayerSetIndex > theLayerSetIndices
std::vector< LinkConnSpec >::const_iterator IT
edm::ParameterSet layerConfig(const std::string &nameLayer, const edm::ParameterSet &cfg) const
std::vector< const DetLayer * > theLayerDets
static std::vector< std::vector< std::string > > layerNamesInSets(const std::vector< std::string > &namesPSet)
SeedingLayerSetsBuilder::SeedingLayerSetsBuilder ( const edm::ParameterSet cfg,
edm::ConsumesCollector &&  iC 
)

Definition at line 181 of file SeedingLayerSetsBuilder.cc.

181  :
182  SeedingLayerSetsBuilder(cfg, iC)
183 {}
SeedingLayerSetsBuilder()=default
SeedingLayerSetsBuilder::~SeedingLayerSetsBuilder ( )

Definition at line 237 of file SeedingLayerSetsBuilder.cc.

237 {}

Member Function Documentation

void SeedingLayerSetsBuilder::fillDescriptions ( edm::ParameterSetDescription desc)
static

Definition at line 239 of file SeedingLayerSetsBuilder.cc.

References edm::ParameterSetDescription::add(), relativeConstraints::empty, and edm::ParameterSetDescription::setAllowAnything().

Referenced by SeedingLayersEDProducer::fillDescriptions(), and PixelInactiveAreaTrackingRegionsSeedingLayersProducer::fillDescriptions().

239  {
241  empty.setAllowAnything(); // for now accept any parameter in the PSets, consider improving later
242 
243  desc.add<std::vector<std::string> >("layerList", {});
244  desc.add<edm::ParameterSetDescription>("BPix", empty);
245  desc.add<edm::ParameterSetDescription>("FPix", empty);
246  desc.add<edm::ParameterSetDescription>("TIB", empty);
247  desc.add<edm::ParameterSetDescription>("TID", empty);
248  desc.add<edm::ParameterSetDescription>("TOB", empty);
249  desc.add<edm::ParameterSetDescription>("TEC", empty);
250  desc.add<edm::ParameterSetDescription>("MTIB", empty);
251  desc.add<edm::ParameterSetDescription>("MTID", empty);
252  desc.add<edm::ParameterSetDescription>("MTOB", empty);
253  desc.add<edm::ParameterSetDescription>("MTEC", empty);
254 }
void setAllowAnything()
allow any parameter label/value pairs
ParameterDescriptionBase * add(U const &iLabel, T const &value)
std::unique_ptr< SeedingLayerSetsHits > SeedingLayerSetsBuilder::hits ( const edm::Event ev,
const edm::EventSetup es 
)

Definition at line 364 of file SeedingLayerSetsBuilder.cc.

References theLayerDets, theLayerNames, theLayers, theLayerSetIndices, theNumberOfLayersInSet, theTTRHBuilders, and updateEventSetup().

Referenced by SeedingLayersEDProducer::produce(), and PixelInactiveAreaTrackingRegionsSeedingLayersProducer::produce().

364  {
365  updateEventSetup(es);
366 
367  auto ret = std::make_unique<SeedingLayerSetsHits>(theNumberOfLayersInSet,
369  &theLayerNames,
370  &theLayerDets);
371 
372  for(auto& layer: theLayers) {
373  ret->addHits(layer.nameIndex, layer.extractor->hits((const TkTransientTrackingRecHitBuilder &)(*theTTRHBuilders[layer.nameIndex]), ev, es));
374  }
375  ret->shrink_to_fit();
376  return ret;
377 }
std::vector< LayerSpec > theLayers
std::vector< std::string > theLayerNames
std::vector< const TransientTrackingRecHitBuilder * > theTTRHBuilders
void updateEventSetup(const edm::EventSetup &es)
std::vector< SeedingLayerSetsHits::LayerSetIndex > theLayerSetIndices
std::vector< const DetLayer * > theLayerDets
edm::ParameterSet SeedingLayerSetsBuilder::layerConfig ( const std::string &  nameLayer,
const edm::ParameterSet cfg 
) const
private

Definition at line 256 of file SeedingLayerSetsBuilder.cc.

References edm::ParameterSet::exists(), edm::ParameterSet::getParameter(), dataset::name, and mps_fire::result.

Referenced by SeedingLayerSetsBuilder().

257 {
259 
260  for (string::size_type iEnd=nameLayer.size(); iEnd > 0; --iEnd) {
261  string name = nameLayer.substr(0,iEnd);
262  if (cfg.exists(name)) return cfg.getParameter<edm::ParameterSet>(name);
263  }
264  edm::LogError("SeedingLayerSetsBuilder") <<"configuration for layer: "<<nameLayer<<" not found, job will probably crash!";
265  return result;
266 }
T getParameter(std::string const &) const
bool exists(std::string const &parameterName) const
checks if a parameter exists
uint16_t size_type
vector< vector< string > > SeedingLayerSetsBuilder::layerNamesInSets ( const std::vector< std::string > &  namesPSet)
static

Definition at line 268 of file SeedingLayerSetsBuilder.cc.

References geometryCSVtoXML::line, and mps_fire::result.

Referenced by MTVHistoProducerAlgoForTracker::MTVHistoProducerAlgoForTracker(), and SeedingLayerSetsBuilder().

269 {
270  std::vector<std::vector<std::string> > result;
271  for (std::vector<std::string>::const_iterator is=namesPSet.begin(); is < namesPSet.end(); ++is) {
272  vector<std::string> layersInSet;
273  string line = *is;
275  while (pos != string::npos ) {
276  pos=line.find("+");
277  string layer = line.substr(0,pos);
278  layersInSet.push_back(layer);
279  line=line.substr(pos+1,string::npos);
280  }
281  result.push_back(layersInSet);
282  }
283  return result;
284 }
uint16_t size_type
std::vector< SeedingLayerSetsBuilder::SeedingLayerId > SeedingLayerSetsBuilder::layers ( ) const

Definition at line 355 of file SeedingLayerSetsBuilder.cc.

References numberOfLayers(), and theLayers.

355  {
356  std::vector<SeedingLayerId> ret;
357  ret.reserve(numberOfLayers());
358  for(const auto& layer: theLayers) {
359  ret.emplace_back(layer.subdet, layer.side, layer.idLayer);
360  }
361  return ret;
362 }
std::vector< LayerSpec > theLayers
unsigned short numberOfLayers() const
const std::vector<SeedingLayerSetsHits::LayerSetIndex>& SeedingLayerSetsBuilder::layerSetIndices ( ) const
inline

Definition at line 41 of file SeedingLayerSetsBuilder.h.

References looper::cfg, ev, hfClusterShapes_cfi::hits, dataset::name, and AlCaHLTBitMon_QueryRunRegistry::string.

41 { return theLayerSetIndices; }
std::vector< SeedingLayerSetsHits::LayerSetIndex > theLayerSetIndices
SeedingLayerSetsBuilder::SeedingLayerId SeedingLayerSetsBuilder::nameToEnumId ( const std::string &  name)
static

Definition at line 32 of file SeedingLayerSetsBuilder.cc.

References Barrel, GeomDetEnumerators::invalidDet, NegEndcap, GeomDetEnumerators::PixelBarrel, GeomDetEnumerators::PixelEndcap, PosEndcap, GeomDetEnumerators::TEC, GeomDetEnumerators::TIB, GeomDetEnumerators::TID, and GeomDetEnumerators::TOB.

Referenced by SeedingLayerSetsBuilder::LayerSpec::LayerSpec(), and MTVHistoProducerAlgoForTracker::MTVHistoProducerAlgoForTracker().

32  {
35  int idLayer = 0;
36 
37  size_t index;
38  //
39  // BPIX
40  //
41  if ((index = name.find("BPix")) != string::npos) {
44  idLayer = atoi(name.substr(index+4,1).c_str());
45  }
46  //
47  // FPIX
48  //
49  else if ((index = name.find("FPix")) != string::npos) {
51  idLayer = atoi(name.substr(index+4).c_str());
52  if ( name.find("pos") != string::npos ) {
54  } else {
56  }
57  }
58  //
59  // TIB
60  //
61  else if ((index = name.find("TIB")) != string::npos) {
62  subdet = GeomDetEnumerators::TIB;
64  idLayer = atoi(name.substr(index+3,1).c_str());
65  }
66  //
67  // TID
68  //
69  else if ((index = name.find("TID")) != string::npos) {
70  subdet = GeomDetEnumerators::TID;
71  idLayer = atoi(name.substr(index+3,1).c_str());
72  if ( name.find("pos") != string::npos ) {
74  } else {
76  }
77  }
78  //
79  // TOB
80  //
81  else if ((index = name.find("TOB")) != string::npos) {
82  subdet = GeomDetEnumerators::TOB;
84  idLayer = atoi(name.substr(index+3,1).c_str());
85  }
86  //
87  // TEC
88  //
89  else if ((index = name.find("TEC")) != string::npos) {
90  subdet = GeomDetEnumerators::TEC;
91  idLayer = atoi(name.substr(index+3,1).c_str());
92  if ( name.find("pos") != string::npos ) {
94  } else {
96  }
97  }
98  return std::make_tuple(subdet, side, idLayer);
99 }
TrackerDetSide
Definition: TrackerDetSide.h:4
unsigned short SeedingLayerSetsBuilder::numberOfLayers ( ) const
inline

Definition at line 36 of file SeedingLayerSetsBuilder.h.

Referenced by layers().

36 { return theLayers.size(); }
std::vector< LayerSpec > theLayers
unsigned short SeedingLayerSetsBuilder::numberOfLayerSets ( ) const
inline

Definition at line 37 of file SeedingLayerSetsBuilder.h.

References LayerTriplets::layers().

std::vector< SeedingLayerSetsHits::LayerSetIndex > theLayerSetIndices
SeedingLayerSetsLooper SeedingLayerSetsBuilder::seedingLayerSetsLooper ( ) const
inline

Definition at line 39 of file SeedingLayerSetsBuilder.h.

void SeedingLayerSetsBuilder::updateEventSetup ( const edm::EventSetup es)
private

Definition at line 286 of file SeedingLayerSetsBuilder.cc.

References GeometricSearchTracker::barrelLayers(), edm::ESWatcher< T >::check(), Exception, geometryWatcher_, edm::EventSetup::get(), GeometricSearchTracker::negForwardLayers(), GeometricSearchTracker::negTecLayers(), GeometricSearchTracker::negTidLayers(), GeomDetEnumerators::PixelBarrel, GeomDetEnumerators::PixelEndcap, PosEndcap, GeometricSearchTracker::posForwardLayers(), GeometricSearchTracker::posTecLayers(), GeometricSearchTracker::posTidLayers(), edm::ESHandle< T >::product(), GeomDetEnumerators::TEC, theLayerDets, theLayerNames, theLayers, theTTRHBuilders, GeomDetEnumerators::TIB, GeometricSearchTracker::tibLayers(), GeomDetEnumerators::TID, GeomDetEnumerators::TOB, GeometricSearchTracker::tobLayers(), mixOne_simraw_on_sim_cfi::tracker, and trhWatcher_.

Referenced by hits().

286  {
287  // We want to evaluate both in the first invocation (to properly
288  // initialize ESWatcher), and this way we avoid one branch compared
289  // to || (should be tiny effect)
290  if(! (geometryWatcher_.check(es) | trhWatcher_.check(es)) )
291  return;
292 
294  es.get<TrackerRecoGeometryRecord>().get( htracker );
295  const GeometricSearchTracker& tracker = *htracker;
296 
297  const std::vector<BarrelDetLayer const*>& bpx = tracker.barrelLayers();
298  const std::vector<BarrelDetLayer const*>& tib = tracker.tibLayers();
299  const std::vector<BarrelDetLayer const*>& tob = tracker.tobLayers();
300 
301  const std::vector<ForwardDetLayer const*>& fpx_pos = tracker.posForwardLayers();
302  const std::vector<ForwardDetLayer const*>& tid_pos = tracker.posTidLayers();
303  const std::vector<ForwardDetLayer const*>& tec_pos = tracker.posTecLayers();
304 
305  const std::vector<ForwardDetLayer const*>& fpx_neg = tracker.negForwardLayers();
306  const std::vector<ForwardDetLayer const*>& tid_neg = tracker.negTidLayers();
307  const std::vector<ForwardDetLayer const*>& tec_neg = tracker.negTecLayers();
308 
309  for(const auto& layer: theLayers) {
310  const DetLayer * detLayer = nullptr;
311  int index = layer.idLayer-1;
312 
313  if (layer.subdet == GeomDetEnumerators::PixelBarrel) {
314  detLayer = bpx[index];
315  }
316  else if (layer.subdet == GeomDetEnumerators::PixelEndcap) {
317  if (layer.side == TrackerDetSide::PosEndcap) {
318  detLayer = fpx_pos[index];
319  } else {
320  detLayer = fpx_neg[index];
321  }
322  }
323  else if (layer.subdet == GeomDetEnumerators::TIB) {
324  detLayer = tib[index];
325  }
326  else if (layer.subdet == GeomDetEnumerators::TID) {
327  if (layer.side == TrackerDetSide::PosEndcap) {
328  detLayer = tid_pos[index];
329  } else {
330  detLayer = tid_neg[index];
331  }
332  }
333  else if (layer.subdet == GeomDetEnumerators::TOB) {
334  detLayer = tob[index];
335  }
336  else if (layer.subdet == GeomDetEnumerators::TEC) {
337  if (layer.side == TrackerDetSide::PosEndcap) {
338  detLayer = tec_pos[index];
339  } else {
340  detLayer = tec_neg[index];
341  }
342  }
343  else {
344  throw cms::Exception("Configuration") << "Did not find DetLayer for layer " << theLayerNames[layer.nameIndex];
345  }
346 
348  es.get<TransientRecHitRecord>().get(layer.hitBuilder, builder);
349 
350  theLayerDets[layer.nameIndex] = detLayer;
351  theTTRHBuilders[layer.nameIndex] = builder.product();
352  }
353 }
std::vector< ForwardDetLayer const * > const & posForwardLayers() const
std::vector< LayerSpec > theLayers
edm::ESWatcher< TrackerRecoGeometryRecord > geometryWatcher_
std::vector< std::string > theLayerNames
std::vector< BarrelDetLayer const * > const & tobLayers() const
std::vector< const TransientTrackingRecHitBuilder * > theTTRHBuilders
std::vector< ForwardDetLayer const * > const & negForwardLayers() const
edm::ESWatcher< TransientRecHitRecord > trhWatcher_
std::vector< BarrelDetLayer const * > const & tibLayers() const
std::vector< ForwardDetLayer const * > const & posTecLayers() const
const T & get() const
Definition: EventSetup.h:59
std::vector< ForwardDetLayer const * > const & negTidLayers() const
bool check(const edm::EventSetup &iSetup)
Definition: ESWatcher.h:57
std::vector< ForwardDetLayer const * > const & posTidLayers() const
std::vector< ForwardDetLayer const * > const & negTecLayers() const
T const * product() const
Definition: ESHandle.h:86
std::vector< const DetLayer * > theLayerDets
std::vector< BarrelDetLayer const * > const & barrelLayers() const

Member Data Documentation

edm::ESWatcher<TrackerRecoGeometryRecord> SeedingLayerSetsBuilder::geometryWatcher_
private

Definition at line 52 of file SeedingLayerSetsBuilder.h.

Referenced by updateEventSetup().

std::vector<const DetLayer *> SeedingLayerSetsBuilder::theLayerDets
private

Definition at line 77 of file SeedingLayerSetsBuilder.h.

Referenced by hits(), SeedingLayerSetsBuilder(), and updateEventSetup().

std::vector<std::string> SeedingLayerSetsBuilder::theLayerNames
private

Definition at line 76 of file SeedingLayerSetsBuilder.h.

Referenced by hits(), SeedingLayerSetsBuilder(), and updateEventSetup().

std::vector<LayerSpec> SeedingLayerSetsBuilder::theLayers
private

Definition at line 79 of file SeedingLayerSetsBuilder.h.

Referenced by hits(), layers(), SeedingLayerSetsBuilder(), and updateEventSetup().

std::vector<SeedingLayerSetsHits::LayerSetIndex> SeedingLayerSetsBuilder::theLayerSetIndices
private

Definition at line 75 of file SeedingLayerSetsBuilder.h.

Referenced by hits(), and SeedingLayerSetsBuilder().

unsigned short SeedingLayerSetsBuilder::theNumberOfLayersInSet
private

Definition at line 74 of file SeedingLayerSetsBuilder.h.

Referenced by hits(), and SeedingLayerSetsBuilder().

std::vector<const TransientTrackingRecHitBuilder *> SeedingLayerSetsBuilder::theTTRHBuilders
private

Definition at line 78 of file SeedingLayerSetsBuilder.h.

Referenced by hits(), SeedingLayerSetsBuilder(), and updateEventSetup().

edm::ESWatcher<TransientRecHitRecord> SeedingLayerSetsBuilder::trhWatcher_
private

Definition at line 53 of file SeedingLayerSetsBuilder.h.

Referenced by updateEventSetup().