CMS 3D CMS Logo

MkFitHitIndexMap.cc
Go to the documentation of this file.
2 
4 
5 #include <algorithm>
6 
7 namespace {
8  template <typename T>
9  auto resizeByClusterIndexImpl(T& cmsswToMkFit, edm::ProductID id, size_t clusterIndex) -> typename T::iterator {
10  auto found =
11  std::find_if(cmsswToMkFit.begin(), cmsswToMkFit.end(), [&](const auto& item) { return item.productID == id; });
12  if (found == cmsswToMkFit.end()) {
13  found = cmsswToMkFit.emplace(cmsswToMkFit.end(), id);
14  }
15  if (found->mkFitHits.size() <= clusterIndex) {
16  found->mkFitHits.resize(clusterIndex + 1);
17  }
18  return found;
19  }
20 } // namespace
21 
23  resizeByClusterIndexImpl(cmsswToMkFit_, id, clusterIndex);
24 }
25 
26 void MkFitHitIndexMap::increaseLayerSize(int layer, size_t additionalSize) {
27  if (layer >= static_cast<int>(mkFitToCMSSW_.size())) {
28  mkFitToCMSSW_.resize(layer + 1);
29  }
30  mkFitToCMSSW_[layer].resize(mkFitToCMSSW_[layer].size() + additionalSize);
31 }
32 
34  // mapping CMSSW->mkfit
35  auto found = resizeByClusterIndexImpl(cmsswToMkFit_, id, clusterIndex);
36  found->mkFitHits[clusterIndex] = hit;
37 
38  // mapping mkfit->CMSSW
39  // when client calls increaseLayerSize() the two checks below are
40  // redundant, but better to keep them
41  if (hit.layer() >= static_cast<int>(mkFitToCMSSW_.size())) {
42  mkFitToCMSSW_.resize(hit.layer() + 1);
43  }
44  auto& layer = mkFitToCMSSW_[hit.layer()];
45  if (hit.index() >= static_cast<int>(layer.size())) {
46  layer.resize(hit.index() + 1);
47  }
48  layer[hit.index()] = CMSSWHit(hitPtr, clusterIndex);
49 }
50 
52  auto found =
53  std::find_if(cmsswToMkFit_.begin(), cmsswToMkFit_.end(), [&](const auto& item) { return item.productID == id; });
54  if (found == cmsswToMkFit_.end()) {
55  auto exp = cms::Exception("Assert");
56  exp << "Encountered a seed with a hit having productID " << id
57  << " which is not any of the input hit collections: ";
58  for (const auto& elem : cmsswToMkFit_) {
59  exp << elem.productID << " ";
60  }
61  throw exp;
62  }
63  const MkFitHit& ret = found->mkFitHits.at(clusterIndex);
64  if (ret.index() < 0) {
65  throw cms::Exception("Assert") << "No hit index for cluster " << clusterIndex << " of collection " << id;
66  }
67  return ret;
68 }
size
Write out results.
void increaseLayerSize(int layer, size_t additionalSize)
ret
prodAgent to be discontinued
std::vector< ClusterToMkFitHit > cmsswToMkFit_
void insert(edm::ProductID id, size_t clusterIndex, MkFitHit hit, const TrackingRecHit *hitPtr)
const MkFitHit & mkFitHit(edm::ProductID id, size_t clusterIndex) const
Get mkFit hit index and layer.
size_t clusterIndex(MkFitHit hit) const
Get CMSSW cluster index (currently used only for debugging)
std::vector< std::vector< CMSSWHit > > mkFitToCMSSW_
def elem(elemtype, innerHTML='', html_class='', kwargs)
Definition: HTMLExport.py:19
void resizeByClusterIndex(edm::ProductID id, size_t clusterIndex)
const TrackingRecHit * hitPtr(MkFitHit hit) const
Get CMSSW hit pointer.
long double T