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

typedef unsigned short LayerSetIndex
 
using SeedingLayerId = std::tuple< GeomDetEnumerators::SubDetector, ctfseeding::SeedingLayer::Side, int >
 

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 ()
 

Static Public Member Functions

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
 

Private Attributes

edm::ESWatcher< TrackerRecoGeometryRecordgeometryWatcher_
 
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< TransientRecHitRecordtrhWatcher_
 

Detailed Description

Definition at line 20 of file SeedingLayerSetsBuilder.h.

Member Typedef Documentation

Definition at line 34 of file SeedingLayerSetsBuilder.h.

Definition at line 43 of file SeedingLayerSetsBuilder.h.

Constructor & Destructor Documentation

SeedingLayerSetsBuilder::SeedingLayerSetsBuilder ( )

Definition at line 182 of file SeedingLayerSetsBuilder.cc.

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

Definition at line 186 of file SeedingLayerSetsBuilder.cc.

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

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

183  :
184  SeedingLayerSetsBuilder(cfg, iC)
185 {}
SeedingLayerSetsBuilder::~SeedingLayerSetsBuilder ( )

Definition at line 239 of file SeedingLayerSetsBuilder.cc.

239 {}

Member Function Documentation

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

Definition at line 356 of file SeedingLayerSetsBuilder.cc.

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

Referenced by SeedingLayersEDProducer::produce().

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

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

Referenced by ntupleDataFormat._TrackingParticleMatchAdaptor::bestMatchingTrackingParticle(), and SeedingLayersEDProducer::produce().

366  {
367  indices.reserve(theLayers.size());
368  for(unsigned int i=0; i<theLayers.size(); ++i) {
369  // The index of the first hit of this layer
370  indices.push_back(hits.size());
371 
372  // Obtain and copy the hits
374  std::move(tmp.begin(), tmp.end(), std::back_inserter(hits));
375  }
376 }
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
def move(src, dest)
Definition: eostools.py:510
edm::ParameterSet SeedingLayerSetsBuilder::layerConfig ( const std::string &  nameLayer,
const edm::ParameterSet cfg 
) const
private

Definition at line 241 of file SeedingLayerSetsBuilder.cc.

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

Referenced by SeedingLayerSetsBuilder().

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

Definition at line 40 of file SeedingLayerSetsBuilder.h.

References ev, and hfClusterShapes_cfi::hits.

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.

Referenced by SeedingLayersEDProducer::produce().

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

Definition at line 253 of file SeedingLayerSetsBuilder.cc.

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

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

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

Definition at line 335 of file SeedingLayerSetsBuilder.cc.

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

336 {
337  updateEventSetup(es);
338 
339  typedef std::vector<SeedingLayer> Set;
341 
342  for(size_t i=0, n=theLayerSetIndices.size(); i<n; i += theNumberOfLayersInSet) {
343  Set set;
344  for(size_t j=0; j<theNumberOfLayersInSet; ++j) {
345  const unsigned short layerIndex = theLayerSetIndices[i+j];
346  const LayerSpec& layer = theLayers[layerIndex];
347  const DetLayer *detLayer = theLayerDets[layerIndex];
348 
349  set.push_back( SeedingLayer( theLayerNames[layerIndex], layerIndex, detLayer, theTTRHBuilders[layerIndex], layer.extractor.get()));
350  }
351  result.push_back(set);
352  }
353  return result;
354 }
std::vector< LayerSpec > theLayers
std::vector< std::string > theLayerNames
std::vector< const TransientTrackingRecHitBuilder * > theTTRHBuilders
void updateEventSetup(const edm::EventSetup &es)
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.

Referenced by SeedingLayersEDProducer::produce().

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

Definition at line 32 of file SeedingLayerSetsBuilder.cc.

References ctfseeding::SeedingLayer::Barrel, diffTreeTool::index, GeomDetEnumerators::invalidDet, ctfseeding::SeedingLayer::NegEndcap, GeomDetEnumerators::PixelBarrel, GeomDetEnumerators::PixelEndcap, ctfseeding::SeedingLayer::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) {
43  side = SeedingLayer::Barrel;
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 ) {
53  side = SeedingLayer::PosEndcap;
54  } else {
55  side = SeedingLayer::NegEndcap;
56  }
57  }
58  //
59  // TIB
60  //
61  else if ((index = name.find("TIB")) != string::npos) {
62  subdet = GeomDetEnumerators::TIB;
63  side = SeedingLayer::Barrel;
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 ) {
73  side = SeedingLayer::PosEndcap;
74  } else {
75  side = SeedingLayer::NegEndcap;
76  }
77  }
78  //
79  // TOB
80  //
81  else if ((index = name.find("TOB")) != string::npos) {
82  subdet = GeomDetEnumerators::TOB;
83  side = SeedingLayer::Barrel;
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 ) {
93  side = SeedingLayer::PosEndcap;
94  } else {
95  side = SeedingLayer::NegEndcap;
96  }
97  }
98  return std::make_tuple(subdet, side, idLayer);
99 }
unsigned short SeedingLayerSetsBuilder::numberOfLayers ( ) const
inline

Definition at line 38 of file SeedingLayerSetsBuilder.h.

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

Definition at line 35 of file SeedingLayerSetsBuilder.h.

Referenced by SeedingLayersEDProducer::produce().

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

Definition at line 271 of file SeedingLayerSetsBuilder.cc.

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

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

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

Referenced by check().

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

Definition at line 71 of file SeedingLayerSetsBuilder.h.

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

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

Definition at line 70 of file SeedingLayerSetsBuilder.h.

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

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

Definition at line 73 of file SeedingLayerSetsBuilder.h.

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

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

Definition at line 69 of file SeedingLayerSetsBuilder.h.

Referenced by layers(), and SeedingLayerSetsBuilder().

unsigned short SeedingLayerSetsBuilder::theNumberOfLayersInSet
private

Definition at line 68 of file SeedingLayerSetsBuilder.h.

Referenced by layers(), and SeedingLayerSetsBuilder().

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

Definition at line 72 of file SeedingLayerSetsBuilder.h.

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

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

Definition at line 51 of file SeedingLayerSetsBuilder.h.

Referenced by check().