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),
14  layerSetIndices_(layerSetIndices),
15  layerNames_(layerNames),
16  layerDets_(layerDets)
17 {
18  layerHitIndices_.reserve(layerNames->size());
19 }
20 
22  rechits_.shrink_to_fit();
23 }
24 
26  if(layerIndex != layerHitIndices_.size()) {
27  throw cms::Exception("Assert") << "SeedingLayerSetsHits::addHits() must be called in the order of the layers, got layer " << layerIndex << " while was expecting " << layerHitIndices_.size();
28  }
29 
30  layerHitIndices_.push_back(rechits_.size());
31  std::move(hits.begin(), hits.end(), std::back_inserter(rechits_));
32 }
33 
35  HitIndex begin = layerHitIndices_[layerIndex];
36  ++layerIndex;
37  HitIndex end = layerIndex < layerHitIndices_.size() ? layerHitIndices_[layerIndex] : rechits_.size();
38 
39  Hits ret;
40  ret.reserve(end-begin);
41  std::transform(rechits_.begin()+begin, rechits_.begin()+end, std::back_inserter(ret),[](HitPointer const &p){return p.get();});
42  return ret;
43 }
44 
45 
47  std::stringstream ss;
48  ss << "SeedingLayerSetsHits with " << numberOfLayersInSet() << " layers in each LayerSets, LayerSets has " << size() << " items\n";
49  for(LayerSetIndex iLayers=0; iLayers<size(); ++iLayers) {
50  ss << " " << iLayers << ": ";
52  for(unsigned iLayer=0; iLayer<layers.size(); ++iLayer) {
53  SeedingLayer layer = layers[iLayer];
54  ss << layer.name() << " (" << layer.index() << ", nhits " << layer.hits().size() << ") ";
55  }
56  ss << "\n";
57  }
58  LogDebug("SeedingLayerSetsHits") << ss.str();
59 }
#define LogDebug(id)
const_iterator end() const
LayerSetIndex size() const
Number of layers in this set.
unsigned short numberOfLayersInSet() const
Get number of layers in each SeedingLayerSets.
std::vector< LayerSetAndLayers > layers(const SeedingLayerSetsHits &sets)
Definition: LayerTriplets.cc:4
void addHits(LayerIndex layerIndex, OwnedHits &&hits)
unsigned short LayerSetIndex
const_iterator begin() const
SeedingLayerSetsHits()=default
Hits hits(LayerIndex layerIndex) const
SeedingLayerSet operator[](LayerSetIndex index) const
Get the SeedingLayerSet at a given index.
const std::string & name() const
std::vector< ConstRecHitPointer > Hits
std::vector< HitIndex > layerHitIndices_
std::vector< HitPointer > OwnedHits
unsigned short size() const
Get the number of SeedingLayerSets.
def move(src, dest)
Definition: eostools.py:511