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 186 of file SeedingLayerSetsBuilder.cc.

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

Definition at line 190 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.

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

187  :
188  SeedingLayerSetsBuilder(cfg, iC)
189 {}
SeedingLayerSetsBuilder::~SeedingLayerSetsBuilder ( )

Definition at line 243 of file SeedingLayerSetsBuilder.cc.

243 {}

Member Function Documentation

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

Definition at line 360 of file SeedingLayerSetsBuilder.cc.

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

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

360  {
361  // We want to evaluate both in the first invocation (to properly
362  // initialize ESWatcher), and this way we avoid one branch compared
363  // to || (should be tiny effect)
364  return geometryWatcher_.check(es) | trhWatcher_.check(es);
365 }
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 369 of file SeedingLayerSetsBuilder.cc.

References i, eostools::move(), theLayers, theTTRHBuilders, and tmp.

Referenced by SeedingLayersEDProducer::produce().

370  {
371  indices.reserve(theLayers.size());
372  for(unsigned int i=0; i<theLayers.size(); ++i) {
373  // The index of the first hit of this layer
374  indices.push_back(hits.size());
375 
376  // Obtain and copy the hits
378  std::move(tmp.begin(), tmp.end(), std::back_inserter(hits));
379  }
380 }
int i
Definition: DBlmapReader.cc:9
std::vector< LayerSpec > theLayers
std::vector< HitPointer > Hits
Definition: SeedingLayer.h:28
std::vector< const TransientTrackingRecHitBuilder * > theTTRHBuilders
def move
Definition: eostools.py:508
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 245 of file SeedingLayerSetsBuilder.cc.

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

Referenced by SeedingLayerSetsBuilder().

246 {
248 
249  for (string::size_type iEnd=nameLayer.size(); iEnd > 0; --iEnd) {
250  string name = nameLayer.substr(0,iEnd);
251  if (cfg.exists(name)) return cfg.getParameter<edm::ParameterSet>(name);
252  }
253  edm::LogError("SeedingLayerSetsBuilder") <<"configuration for layer: "<<nameLayer<<" not found, job will probably crash!";
254  return result;
255 }
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 257 of file SeedingLayerSetsBuilder.cc.

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

Referenced by SeedingLayerSetsBuilder().

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

Definition at line 339 of file SeedingLayerSetsBuilder.cc.

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

Referenced by QuadrupletSeedMerger::mergeTriplets().

340 {
341  updateEventSetup(es);
342 
343  typedef std::vector<SeedingLayer> Set;
345 
346  for(size_t i=0, n=theLayerSetIndices.size(); i<n; i += theNumberOfLayersInSet) {
347  Set set;
348  for(size_t j=0; j<theNumberOfLayersInSet; ++j) {
349  const unsigned short layerIndex = theLayerSetIndices[i+j];
350  const LayerSpec& layer = theLayers[layerIndex];
351  const DetLayer *detLayer = theLayerDets[layerIndex];
352 
353  set.push_back( SeedingLayer( theLayerNames[layerIndex], layerIndex, detLayer, theTTRHBuilders[layerIndex], layer.extractor.get()));
354  }
355  result.push_back(set);
356  }
357  return result;
358 }
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 275 of file SeedingLayerSetsBuilder.cc.

References GeometricSearchTracker::barrelLayers(), edm::hlt::Exception, edm::EventSetup::get(), SeedingLayerSetsBuilder::LayerSpec::hitBuilder, i, SeedingLayerSetsBuilder::LayerSpec::idLayer, cmsHarvester::index, gen::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().

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