CMS 3D CMS Logo

SeedingLayerSetsHits.cc
Go to the documentation of this file.
4 
5 #include <algorithm>
6 #include <limits>
7 #include <sstream>
8 
10  const std::vector<LayerSetIndex> *layerSetIndices,
11  const std::vector<std::string> *layerNames,
12  const std::vector<const DetLayer *> *layerDets)
13  : nlayers_(nlayers), layerSetIndices_(layerSetIndices), layerNames_(layerNames), layerDets_(layerDets) {
14  layerHitIndices_.reserve(layerNames->size());
15 }
16 
17 void SeedingLayerSetsHits::shrink_to_fit() { rechits_.shrink_to_fit(); }
18 
20  if (layerIndex != layerHitIndices_.size()) {
21  throw cms::Exception("Assert")
22  << "SeedingLayerSetsHits::addHits() must be called in the order of the layers, got layer " << layerIndex
23  << " while was expecting " << layerHitIndices_.size();
24  }
25 
26  layerHitIndices_.push_back(rechits_.size());
27  std::move(hits.begin(), hits.end(), std::back_inserter(rechits_));
28 }
29 
31  HitIndex begin = layerHitIndices_[layerIndex];
32  ++layerIndex;
33  HitIndex end = layerIndex < layerHitIndices_.size() ? layerHitIndices_[layerIndex] : rechits_.size();
34 
35  Hits ret;
36  ret.reserve(end - begin);
37  std::transform(rechits_.begin() + begin, rechits_.begin() + end, std::back_inserter(ret), [](HitPointer const &p) {
38  return p.get();
39  });
40  return ret;
41 }
42 
44  std::stringstream ss;
45  ss << "SeedingLayerSetsHits with " << numberOfLayersInSet() << " layers in each LayerSets, LayerSets has " << size()
46  << " items\n";
47  for (LayerSetIndex iLayers = 0; iLayers < size(); ++iLayers) {
48  ss << " " << iLayers << ": ";
50  for (unsigned iLayer = 0; iLayer < layers.size(); ++iLayer) {
51  SeedingLayer layer = layers[iLayer];
52  ss << layer.name() << " (" << layer.index() << ", nhits " << layer.hits().size() << ") ";
53  }
54  ss << "\n";
55  }
56  LogDebug("SeedingLayerSetsHits") << ss.str();
57 }
const_iterator begin() const
void addHits(LayerIndex layerIndex, OwnedHits &&hits)
ret
prodAgent to be discontinued
unsigned short LayerSetIndex
unsigned short size() const
Get the number of SeedingLayerSets.
SeedingLayerSetsHits()=default
unsigned short numberOfLayersInSet() const
Get number of layers in each SeedingLayerSets.
std::vector< ConstRecHitPointer > Hits
const_iterator end() const
std::vector< HitIndex > layerHitIndices_
Hits hits(LayerIndex layerIndex) const
std::vector< HitPointer > OwnedHits
SeedingLayerSet operator[](LayerSetIndex index) const
Get the SeedingLayerSet at a given index.
def move(src, dest)
Definition: eostools.py:511
#define LogDebug(id)
unsigned transform(const HcalDetId &id, unsigned transformCode)