CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Classes | Public Types | Public Member Functions | Private Member Functions | Private Attributes
SeedingLayerSetsBuilder Class Reference

#include <SeedingLayerSetsBuilder.h>

Classes

struct  LayerSpec
 

Public Types

typedef unsigned short LayerSetIndex
 

Public Member Functions

bool check (const edm::EventSetup &es)
 
void hits (const edm::Event &ev, const edm::EventSetup &es, std::vector< unsigned int > &indices, ctfseeding::SeedingLayer::Hits &hits) const
 
const std::vector< const
DetLayer * > & 
layerDets () const
 
const std::vector< std::string > & layerNames () const
 
ctfseeding::SeedingLayerSets layers (const edm::EventSetup &es)
 
const std::vector
< LayerSetIndex > & 
layerSetIndices () const
 
unsigned short numberOfLayers () const
 
unsigned short numberOfLayersInSet () const
 
 SeedingLayerSetsBuilder ()
 
 SeedingLayerSetsBuilder (const edm::ParameterSet &cfg, edm::ConsumesCollector &iC)
 
 SeedingLayerSetsBuilder (const edm::ParameterSet &cfg, edm::ConsumesCollector &&iC)
 
void updateEventSetup (const edm::EventSetup &es)
 
 ~SeedingLayerSetsBuilder ()
 

Private Member Functions

edm::ParameterSet layerConfig (const std::string &nameLayer, const edm::ParameterSet &cfg) const
 
std::vector< std::vector
< std::string > > 
layerNamesInSets (const std::vector< std::string > &namesPSet)
 

Private Attributes

edm::ESWatcher
< TrackerRecoGeometryRecord
geometryWatcher_
 
std::vector< const DetLayer * > theLayerDets
 
std::vector< std::string > theLayerNames
 
std::vector< LayerSpectheLayers
 
std::vector< LayerSetIndextheLayerSetIndices
 
unsigned short theNumberOfLayersInSet
 
std::vector< const
TransientTrackingRecHitBuilder * > 
theTTRHBuilders
 
edm::ESWatcher
< TransientRecHitRecord
trhWatcher_
 

Detailed Description

Definition at line 20 of file SeedingLayerSetsBuilder.h.

Member Typedef Documentation

Definition at line 34 of file SeedingLayerSetsBuilder.h.

Constructor & Destructor Documentation

SeedingLayerSetsBuilder::SeedingLayerSetsBuilder ( )

Definition at line 184 of file SeedingLayerSetsBuilder.cc.

184 {}
SeedingLayerSetsBuilder::SeedingLayerSetsBuilder ( const edm::ParameterSet cfg,
edm::ConsumesCollector iC 
)

Definition at line 188 of file SeedingLayerSetsBuilder.cc.

References edm::hlt::Exception, spr::find(), newFWLiteAna::found, edm::ParameterSet::getParameter(), layerConfig(), layerNamesInSets(), bookConverter::max, AlCaHLTBitMon_QueryRunRegistry::string, theLayerDets, theLayerNames, theLayers, theLayerSetIndices, theNumberOfLayersInSet, and theTTRHBuilders.

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

185  :
186  SeedingLayerSetsBuilder(cfg, iC)
187 {}
SeedingLayerSetsBuilder::~SeedingLayerSetsBuilder ( )

Definition at line 241 of file SeedingLayerSetsBuilder.cc.

241 {}

Member Function Documentation

bool SeedingLayerSetsBuilder::check ( const edm::EventSetup es)

Definition at line 358 of file SeedingLayerSetsBuilder.cc.

References edm::ESWatcher< T >::check(), geometryWatcher_, and trhWatcher_.

Referenced by QuadrupletSeedMerger::mergeTriplets(), and SeedingLayersEDProducer::produce().

358  {
359  // We want to evaluate both in the first invocation (to properly
360  // initialize ESWatcher), and this way we avoid one branch compared
361  // to || (should be tiny effect)
362  return geometryWatcher_.check(es) | trhWatcher_.check(es);
363 }
edm::ESWatcher< TrackerRecoGeometryRecord > geometryWatcher_
edm::ESWatcher< TransientRecHitRecord > trhWatcher_
bool check(const edm::EventSetup &iSetup)
Definition: ESWatcher.h:57
void SeedingLayerSetsBuilder::hits ( const edm::Event ev,
const edm::EventSetup es,
std::vector< unsigned int > &  indices,
ctfseeding::SeedingLayer::Hits hits 
) const

Definition at line 367 of file SeedingLayerSetsBuilder.cc.

References i, theLayers, theTTRHBuilders, and tmp.

Referenced by SeedingLayersEDProducer::produce().

368  {
369  indices.reserve(theLayers.size());
370  for(unsigned int i=0; i<theLayers.size(); ++i) {
371  // The index of the first hit of this layer
372  indices.push_back(hits.size());
373 
374  // Obtain and copy the hits
376  std::move(tmp.begin(), tmp.end(), std::back_inserter(hits));
377  }
378 }
int i
Definition: DBlmapReader.cc:9
std::vector< LayerSpec > theLayers
std::vector< HitPointer > Hits
Definition: SeedingLayer.h:28
std::vector< const TransientTrackingRecHitBuilder * > theTTRHBuilders
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
void hits(const edm::Event &ev, const edm::EventSetup &es, std::vector< unsigned int > &indices, ctfseeding::SeedingLayer::Hits &hits) const
edm::ParameterSet SeedingLayerSetsBuilder::layerConfig ( const std::string &  nameLayer,
const edm::ParameterSet cfg 
) const
private

Definition at line 243 of file SeedingLayerSetsBuilder.cc.

References edm::ParameterSet::exists(), edm::ParameterSet::getParameter(), and query::result.

Referenced by SeedingLayerSetsBuilder().

244 {
246 
247  for (string::size_type iEnd=nameLayer.size(); iEnd > 0; --iEnd) {
248  string name = nameLayer.substr(0,iEnd);
249  if (cfg.exists(name)) return cfg.getParameter<edm::ParameterSet>(name);
250  }
251  edm::LogError("SeedingLayerSetsBuilder") <<"configuration for layer: "<<nameLayer<<" not found, job will probably crash!";
252  return result;
253 }
T getParameter(std::string const &) const
bool exists(std::string const &parameterName) const
checks if a parameter exists
uint16_t size_type
tuple result
Definition: query.py:137
const std::vector<const DetLayer *>& SeedingLayerSetsBuilder::layerDets ( ) const
inline

Definition at line 40 of file SeedingLayerSetsBuilder.h.

References theLayerDets.

Referenced by SeedingLayersEDProducer::produce().

40 { return theLayerDets; }
std::vector< const DetLayer * > theLayerDets
const std::vector<std::string>& SeedingLayerSetsBuilder::layerNames ( ) const
inline

Definition at line 39 of file SeedingLayerSetsBuilder.h.

References theLayerNames.

Referenced by SeedingLayersEDProducer::produce().

39 { return theLayerNames; }
std::vector< std::string > theLayerNames
vector< vector< string > > SeedingLayerSetsBuilder::layerNamesInSets ( const std::vector< std::string > &  namesPSet)
private

Definition at line 255 of file SeedingLayerSetsBuilder.cc.

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

Referenced by SeedingLayerSetsBuilder().

256 {
257  std::vector<std::vector<std::string> > result;
258  for (std::vector<std::string>::const_iterator is=namesPSet.begin(); is < namesPSet.end(); ++is) {
259  vector<std::string> layersInSet;
260  string line = *is;
261  string::size_type pos=0;
262  while (pos != string::npos ) {
263  pos=line.find("+");
264  string layer = line.substr(0,pos);
265  layersInSet.push_back(layer);
266  line=line.substr(pos+1,string::npos);
267  }
268  result.push_back(layersInSet);
269  }
270  return result;
271 }
uint16_t size_type
tuple result
Definition: query.py:137
SeedingLayerSets SeedingLayerSetsBuilder::layers ( const edm::EventSetup es)

Definition at line 337 of file SeedingLayerSetsBuilder.cc.

References SeedingLayerSetsBuilder::LayerSpec::extractor, i, j, n, query::result, theLayerDets, theLayerNames, theLayers, theLayerSetIndices, theNumberOfLayersInSet, theTTRHBuilders, and updateEventSetup().

Referenced by QuadrupletSeedMerger::mergeTriplets().

338 {
339  updateEventSetup(es);
340 
341  typedef std::vector<SeedingLayer> Set;
343 
344  for(size_t i=0, n=theLayerSetIndices.size(); i<n; i += theNumberOfLayersInSet) {
345  Set set;
346  for(size_t j=0; j<theNumberOfLayersInSet; ++j) {
347  const unsigned short layerIndex = theLayerSetIndices[i+j];
348  const LayerSpec& layer = theLayers[layerIndex];
349  const DetLayer *detLayer = theLayerDets[layerIndex];
350 
351  set.push_back( SeedingLayer( theLayerNames[layerIndex], layerIndex, detLayer, theTTRHBuilders[layerIndex], layer.extractor.get()));
352  }
353  result.push_back(set);
354  }
355  return result;
356 }
int i
Definition: DBlmapReader.cc:9
std::vector< LayerSpec > theLayers
std::vector< std::string > theLayerNames
std::vector< const TransientTrackingRecHitBuilder * > theTTRHBuilders
void updateEventSetup(const edm::EventSetup &es)
tuple result
Definition: query.py:137
int j
Definition: DBlmapReader.cc:9
std::vector< LayerSetIndex > theLayerSetIndices
std::vector< const DetLayer * > theLayerDets
std::vector< std::vector< SeedingLayer > > SeedingLayerSets
const std::vector<LayerSetIndex>& SeedingLayerSetsBuilder::layerSetIndices ( ) const
inline

Definition at line 36 of file SeedingLayerSetsBuilder.h.

References theLayerSetIndices.

Referenced by SeedingLayersEDProducer::produce().

36 { return theLayerSetIndices; }
std::vector< LayerSetIndex > theLayerSetIndices
unsigned short SeedingLayerSetsBuilder::numberOfLayers ( ) const
inline

Definition at line 38 of file SeedingLayerSetsBuilder.h.

References theLayers.

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

Definition at line 35 of file SeedingLayerSetsBuilder.h.

References theNumberOfLayersInSet.

Referenced by SeedingLayersEDProducer::produce().

35 { return theNumberOfLayersInSet; }
void SeedingLayerSetsBuilder::updateEventSetup ( const edm::EventSetup es)

Definition at line 273 of file SeedingLayerSetsBuilder.cc.

References GeometricSearchTracker::barrelLayers(), edm::hlt::Exception, edm::EventSetup::get(), SeedingLayerSetsBuilder::LayerSpec::hitBuilder, i, SeedingLayerSetsBuilder::LayerSpec::idLayer, cmsHarvester::index, n, SeedingLayerSetsBuilder::LayerSpec::nameIndex, GeometricSearchTracker::negForwardLayers(), GeometricSearchTracker::negTecLayers(), GeometricSearchTracker::negTidLayers(), GeomDetEnumerators::PixelBarrel, GeomDetEnumerators::PixelEndcap, GeometricSearchTracker::posForwardLayers(), GeometricSearchTracker::posTecLayers(), GeometricSearchTracker::posTidLayers(), edm::ESHandle< class >::product(), SeedingLayerSetsBuilder::LayerSpec::side, SeedingLayerSetsBuilder::LayerSpec::subdet, GeomDetEnumerators::TEC, theLayerDets, theLayerNames, theLayers, theTTRHBuilders, GeomDetEnumerators::TIB, GeometricSearchTracker::tibLayers(), GeomDetEnumerators::TID, GeomDetEnumerators::TOB, GeometricSearchTracker::tobLayers(), and patCandidatesForDimuonsSequences_cff::tracker.

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

273  {
275  es.get<TrackerRecoGeometryRecord>().get( htracker );
276  const GeometricSearchTracker& tracker = *htracker;
277 
278  const std::vector<BarrelDetLayer const*>& bpx = tracker.barrelLayers();
279  const std::vector<BarrelDetLayer const*>& tib = tracker.tibLayers();
280  const std::vector<BarrelDetLayer const*>& tob = tracker.tobLayers();
281 
282  const std::vector<ForwardDetLayer const*>& fpx_pos = tracker.posForwardLayers();
283  const std::vector<ForwardDetLayer const*>& tid_pos = tracker.posTidLayers();
284  const std::vector<ForwardDetLayer const*>& tec_pos = tracker.posTecLayers();
285 
286  const std::vector<ForwardDetLayer const*>& fpx_neg = tracker.negForwardLayers();
287  const std::vector<ForwardDetLayer const*>& tid_neg = tracker.negTidLayers();
288  const std::vector<ForwardDetLayer const*>& tec_neg = tracker.negTecLayers();
289 
290  for(size_t i=0, n=theLayers.size(); i<n; ++i) {
291  const LayerSpec& layer = theLayers[i];
292  const DetLayer * detLayer = nullptr;
293  int index = layer.idLayer-1;
294 
295  if (layer.subdet == GeomDetEnumerators::PixelBarrel) {
296  detLayer = bpx[index];
297  }
298  else if (layer.subdet == GeomDetEnumerators::PixelEndcap) {
299  if (layer.side == SeedingLayer::PosEndcap) {
300  detLayer = fpx_pos[index];
301  } else {
302  detLayer = fpx_neg[index];
303  }
304  }
305  else if (layer.subdet == GeomDetEnumerators::TIB) {
306  detLayer = tib[index];
307  }
308  else if (layer.subdet == GeomDetEnumerators::TID) {
309  if (layer.side == SeedingLayer::PosEndcap) {
310  detLayer = tid_pos[index];
311  } else {
312  detLayer = tid_neg[index];
313  }
314  }
315  else if (layer.subdet == GeomDetEnumerators::TOB) {
316  detLayer = tob[index];
317  }
318  else if (layer.subdet == GeomDetEnumerators::TEC) {
319  if (layer.side == SeedingLayer::PosEndcap) {
320  detLayer = tec_pos[index];
321  } else {
322  detLayer = tec_neg[index];
323  }
324  }
325  else {
326  throw cms::Exception("Configuration") << "Did not find DetLayer for layer " << theLayerNames[layer.nameIndex];
327  }
328 
330  es.get<TransientRecHitRecord>().get(layer.hitBuilder, builder);
331 
332  theLayerDets[i] = detLayer;
333  theTTRHBuilders[i] = builder.product();
334  }
335 }
int i
Definition: DBlmapReader.cc:9
std::vector< ForwardDetLayer const * > const & posForwardLayers() const
std::vector< LayerSpec > theLayers
std::vector< std::string > theLayerNames
std::vector< BarrelDetLayer const * > const & tobLayers() const
std::vector< const TransientTrackingRecHitBuilder * > theTTRHBuilders
std::vector< ForwardDetLayer const * > const & negForwardLayers() const
std::vector< BarrelDetLayer const * > const & tibLayers() const
std::vector< ForwardDetLayer const * > const & posTecLayers() const
const T & get() const
Definition: EventSetup.h:55
T const * product() const
Definition: ESHandle.h:86
std::vector< ForwardDetLayer const * > const & negTidLayers() const
std::vector< ForwardDetLayer const * > const & posTidLayers() const
std::vector< ForwardDetLayer const * > const & negTecLayers() const
std::vector< const DetLayer * > theLayerDets
std::vector< BarrelDetLayer const * > const & barrelLayers() const

Member Data Documentation

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

Definition at line 48 of file SeedingLayerSetsBuilder.h.

Referenced by check().

std::vector<const DetLayer *> SeedingLayerSetsBuilder::theLayerDets
private
std::vector<std::string> SeedingLayerSetsBuilder::theLayerNames
private
std::vector<LayerSpec> SeedingLayerSetsBuilder::theLayers
private
std::vector<LayerSetIndex> SeedingLayerSetsBuilder::theLayerSetIndices
private

Definition at line 67 of file SeedingLayerSetsBuilder.h.

Referenced by layers(), layerSetIndices(), and SeedingLayerSetsBuilder().

unsigned short SeedingLayerSetsBuilder::theNumberOfLayersInSet
private

Definition at line 66 of file SeedingLayerSetsBuilder.h.

Referenced by layers(), numberOfLayersInSet(), and SeedingLayerSetsBuilder().

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

Definition at line 70 of file SeedingLayerSetsBuilder.h.

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

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

Definition at line 49 of file SeedingLayerSetsBuilder.h.

Referenced by check().