CMS 3D CMS Logo

List of all members | Classes | Public Member Functions | Private Attributes
MkFitHitIndexMap Class Reference

#include <MkFitHitIndexMap.h>

Classes

struct  ClusterToMkFitHit
 
struct  CMSSWHit
 
class  MkFitHit
 

Public Member Functions

size_t clusterIndex (MkFitHit hit) const
 Get CMSSW cluster index (currently used only for debugging) More...
 
const TrackingRecHithitPtr (MkFitHit hit) const
 Get CMSSW hit pointer. More...
 
void increaseLayerSize (int layer, size_t additionalSize)
 
void insert (edm::ProductID id, size_t clusterIndex, MkFitHit hit, const TrackingRecHit *hitPtr)
 
const MkFitHitmkFitHit (edm::ProductID id, size_t clusterIndex) const
 Get mkFit hit index and layer. More...
 
 MkFitHitIndexMap ()=default
 
void resizeByClusterIndex (edm::ProductID id, size_t clusterIndex)
 

Private Attributes

std::vector< ClusterToMkFitHitcmsswToMkFit_
 
std::vector< std::vector< CMSSWHit > > mkFitToCMSSW_
 

Detailed Description

This class provides mappings

Definition at line 15 of file MkFitHitIndexMap.h.

Constructor & Destructor Documentation

◆ MkFitHitIndexMap()

MkFitHitIndexMap::MkFitHitIndexMap ( )
default

Member Function Documentation

◆ clusterIndex()

size_t MkFitHitIndexMap::clusterIndex ( MkFitHit  hit) const
inline

Get CMSSW cluster index (currently used only for debugging)

Definition at line 64 of file MkFitHitIndexMap.h.

64 { return mkFitToCMSSW_.at(hit.layer()).at(hit.index()).clusterIndex; }

References mkFitToCMSSW_.

Referenced by MkFitOutputConverter::convertCandidates(), insert(), mkFitHit(), and resizeByClusterIndex().

◆ hitPtr()

const TrackingRecHit* MkFitHitIndexMap::hitPtr ( MkFitHit  hit) const
inline

Get CMSSW hit pointer.

Definition at line 61 of file MkFitHitIndexMap.h.

61 { return mkFitToCMSSW_.at(hit.layer()).at(hit.index()).ptr; }

References mkFitToCMSSW_.

Referenced by MkFitOutputConverter::convertCandidates(), and insert().

◆ increaseLayerSize()

void MkFitHitIndexMap::increaseLayerSize ( int  layer,
size_t  additionalSize 
)

Can be used to preallocate the internal vectors for mkFit->CMSSW mapping

Parameters
layerLayer index (in mkFit convention)
additionalSizeNumber of additional elements to make space for

Definition at line 26 of file MkFitHitIndexMap.cc.

26  {
27  if (layer >= static_cast<int>(mkFitToCMSSW_.size())) {
28  mkFitToCMSSW_.resize(layer + 1);
29  }
30  mkFitToCMSSW_[layer].resize(mkFitToCMSSW_[layer].size() + additionalSize);
31 }

References mkFitToCMSSW_, and findQualityFiles::size.

Referenced by MkFitInputConverter::convertHits().

◆ insert()

void MkFitHitIndexMap::insert ( edm::ProductID  id,
size_t  clusterIndex,
MkFitHit  hit,
const TrackingRecHit hitPtr 
)

Inserts a new hit in the mapping

Parameters
idProductID of the cluster collection
clusterIndexIndex of the cluster in the cluster collection
hitIndex and layer of the hit in the mkFit hit data structure
hitPtrPointer to the TrackingRecHit

Definition at line 33 of file MkFitHitIndexMap.cc.

33  {
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 }

References clusterIndex(), cmsswToMkFit_, newFWLiteAna::found, hitPtr(), and mkFitToCMSSW_.

Referenced by MkFitInputConverter::convertHits().

◆ mkFitHit()

const MkFitHitIndexMap::MkFitHit & MkFitHitIndexMap::mkFitHit ( edm::ProductID  id,
size_t  clusterIndex 
) const

Get mkFit hit index and layer.

Definition at line 51 of file MkFitHitIndexMap.cc.

51  {
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 }

References clusterIndex(), cmsswToMkFit_, Exception, JetChargeProducer_cfi::exp, newFWLiteAna::found, triggerObjects_cff::id, B2GTnPMonitor_cfi::item, and runTheMatrix::ret.

Referenced by MkFitInputConverter::convertSeeds().

◆ resizeByClusterIndex()

void MkFitHitIndexMap::resizeByClusterIndex ( edm::ProductID  id,
size_t  clusterIndex 
)

Can be used to preallocate the internal vectors for CMSSW->mkFit mapping

Definition at line 22 of file MkFitHitIndexMap.cc.

22  {
23  resizeByClusterIndexImpl(cmsswToMkFit_, id, clusterIndex);
24 }

References clusterIndex(), and cmsswToMkFit_.

Referenced by MkFitInputConverter::convertHits().

Member Data Documentation

◆ cmsswToMkFit_

std::vector<ClusterToMkFitHit> MkFitHitIndexMap::cmsswToMkFit_
private

Definition at line 82 of file MkFitHitIndexMap.h.

Referenced by insert(), mkFitHit(), and resizeByClusterIndex().

◆ mkFitToCMSSW_

std::vector<std::vector<CMSSWHit> > MkFitHitIndexMap::mkFitToCMSSW_
private

Definition at line 83 of file MkFitHitIndexMap.h.

Referenced by clusterIndex(), hitPtr(), increaseLayerSize(), and insert().

runTheMatrix.ret
ret
prodAgent to be discontinued
Definition: runTheMatrix.py:355
MkFitHitIndexMap::mkFitToCMSSW_
std::vector< std::vector< CMSSWHit > > mkFitToCMSSW_
Definition: MkFitHitIndexMap.h:83
MkFitHitIndexMap::clusterIndex
size_t clusterIndex(MkFitHit hit) const
Get CMSSW cluster index (currently used only for debugging)
Definition: MkFitHitIndexMap.h:64
newFWLiteAna.found
found
Definition: newFWLiteAna.py:118
MkFitHitIndexMap::hitPtr
const TrackingRecHit * hitPtr(MkFitHit hit) const
Get CMSSW hit pointer.
Definition: MkFitHitIndexMap.h:61
MkFitHitIndexMap::cmsswToMkFit_
std::vector< ClusterToMkFitHit > cmsswToMkFit_
Definition: MkFitHitIndexMap.h:82
B2GTnPMonitor_cfi.item
item
Definition: B2GTnPMonitor_cfi.py:147
triggerObjects_cff.id
id
Definition: triggerObjects_cff.py:31
Exception
Definition: hltDiff.cc:246
JetChargeProducer_cfi.exp
exp
Definition: JetChargeProducer_cfi.py:6
hit
Definition: SiStripHitEffFromCalibTree.cc:88
findQualityFiles.size
size
Write out results.
Definition: findQualityFiles.py:443