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 
33 void MkFitHitIndexMap::insert(edm::ProductID id, size_t clusterIndex, MkFitHit hit, const TrackingRecHit* hitPtr) {
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 }
runTheMatrix.ret
ret
prodAgent to be discontinued
Definition: runTheMatrix.py:373
MkFitHitIndexMap::mkFitToCMSSW_
std::vector< std::vector< CMSSWHit > > mkFitToCMSSW_
Definition: MkFitHitIndexMap.h:83
MkFitHitIndexMap::CMSSWHit
Definition: MkFitHitIndexMap.h:75
MkFitHitIndexMap::clusterIndex
size_t clusterIndex(MkFitHit hit) const
Get CMSSW cluster index (currently used only for debugging)
Definition: MkFitHitIndexMap.h:64
MkFitHitIndexMap::resizeByClusterIndex
void resizeByClusterIndex(edm::ProductID id, size_t clusterIndex)
Definition: MkFitHitIndexMap.cc:22
newFWLiteAna.found
found
Definition: newFWLiteAna.py:118
MkFitHitIndexMap::hitPtr
const TrackingRecHit * hitPtr(MkFitHit hit) const
Get CMSSW hit pointer.
Definition: MkFitHitIndexMap.h:61
MkFitHitIndexMap::increaseLayerSize
void increaseLayerSize(int layer, size_t additionalSize)
Definition: MkFitHitIndexMap.cc:26
MkFitHitIndexMap::mkFitHit
const MkFitHit & mkFitHit(edm::ProductID id, size_t clusterIndex) const
Get mkFit hit index and layer.
Definition: MkFitHitIndexMap.cc:51
MkFitHitIndexMap::insert
void insert(edm::ProductID id, size_t clusterIndex, MkFitHit hit, const TrackingRecHit *hitPtr)
Definition: MkFitHitIndexMap.cc:33
MkFitHitIndexMap::cmsswToMkFit_
std::vector< ClusterToMkFitHit > cmsswToMkFit_
Definition: MkFitHitIndexMap.h:82
B2GTnPMonitor_cfi.item
item
Definition: B2GTnPMonitor_cfi.py:147
TrackingRecHit
Definition: TrackingRecHit.h:21
triggerObjects_cff.id
id
Definition: triggerObjects_cff.py:31
T
long double T
Definition: Basic3DVectorLD.h:48
MkFitHitIndexMap.h
Exception
Definition: hltDiff.cc:246
Exception.h
MkFitHitIndexMap::MkFitHit
Definition: MkFitHitIndexMap.h:19
JetChargeProducer_cfi.exp
exp
Definition: JetChargeProducer_cfi.py:6
edm::ProductID
Definition: ProductID.h:27
hit
Definition: SiStripHitEffFromCalibTree.cc:88
findQualityFiles.size
size
Write out results.
Definition: findQualityFiles.py:443