CMS 3D CMS Logo

List of all members | Public Member Functions | Private Types | Private Attributes | Static Private Attributes
LocalMaximumSeedFinder Class Referencefinal

#include <LocalMaximumSeedFinder.h>

Inheritance diagram for LocalMaximumSeedFinder:
SeedFinderBase

Public Member Functions

void findSeeds (const edm::Handle< reco::PFRecHitCollection > &input, const std::vector< bool > &mask, std::vector< bool > &seedable) override
 
 LocalMaximumSeedFinder (const edm::ParameterSet &conf)
 
 LocalMaximumSeedFinder (const LocalMaximumSeedFinder &)=delete
 
LocalMaximumSeedFinderoperator= (const LocalMaximumSeedFinder &)=delete
 
- Public Member Functions inherited from SeedFinderBase
const std::string & name () const
 
SeedFinderBaseoperator= (const SeedFinderBase &)=delete
 
 SeedFinderBase (const edm::ParameterSet &conf)
 
 SeedFinderBase (const SeedFinderBase &)=delete
 
virtual ~SeedFinderBase ()=default
 

Private Types

typedef std::tuple< std::vector< int >, std::vector< double >, std::vector< double > > I3tuple
 

Private Attributes

const std::unordered_map< std::string, int > _layerMap
 
const int _nNeighbours
 
std::array< I3tuple, 35 > _thresholds
 

Static Private Attributes

static constexpr int layerOffset = 15
 

Detailed Description

Definition at line 9 of file LocalMaximumSeedFinder.h.

Member Typedef Documentation

◆ I3tuple

typedef std::tuple<std::vector<int>, std::vector<double>, std::vector<double> > LocalMaximumSeedFinder::I3tuple
private

Definition at line 24 of file LocalMaximumSeedFinder.h.

Constructor & Destructor Documentation

◆ LocalMaximumSeedFinder() [1/2]

LocalMaximumSeedFinder::LocalMaximumSeedFinder ( const edm::ParameterSet conf)

Definition at line 13 of file LocalMaximumSeedFinder.cc.

14  : SeedFinderBase(conf),
15  _nNeighbours(conf.getParameter<int>("nNeighbours")),
16  _layerMap({{"PS2", (int)PFLayer::PS2},
17  {"PS1", (int)PFLayer::PS1},
18  {"ECAL_ENDCAP", (int)PFLayer::ECAL_ENDCAP},
19  {"ECAL_BARREL", (int)PFLayer::ECAL_BARREL},
20  {"NONE", (int)PFLayer::NONE},
21  {"HCAL_BARREL1", (int)PFLayer::HCAL_BARREL1},
22  {"HCAL_BARREL2_RING0", (int)PFLayer::HCAL_BARREL2},
23  // hack to deal with ring1 in HO
24  {"HCAL_BARREL2_RING1", 19},
25  {"HCAL_ENDCAP", (int)PFLayer::HCAL_ENDCAP},
26  {"HF_EM", (int)PFLayer::HF_EM},
27  {"HF_HAD", (int)PFLayer::HF_HAD}}) {
28  const std::vector<edm::ParameterSet>& thresholds = conf.getParameterSetVector("thresholdsByDetector");
29  for (const auto& pset : thresholds) {
30  const std::string& det = pset.getParameter<std::string>("detector");
31 
32  std::vector<int> depths;
33  std::vector<double> thresh_E;
34  std::vector<double> thresh_pT;
35  std::vector<double> thresh_pT2;
36 
37  if (det == std::string("HCAL_BARREL1") || det == std::string("HCAL_ENDCAP")) {
38  depths = pset.getParameter<std::vector<int> >("depths");
39  thresh_E = pset.getParameter<std::vector<double> >("seedingThreshold");
40  thresh_pT = pset.getParameter<std::vector<double> >("seedingThresholdPt");
41  if (thresh_E.size() != depths.size() || thresh_pT.size() != depths.size()) {
42  throw cms::Exception("InvalidGatheringThreshold") << "gatheringThresholds mismatch with the numbers of depths";
43  }
44  } else {
45  depths.push_back(0);
46  thresh_E.push_back(pset.getParameter<double>("seedingThreshold"));
47  thresh_pT.push_back(pset.getParameter<double>("seedingThresholdPt"));
48  }
49 
50  for (unsigned int i = 0; i < thresh_pT.size(); ++i) {
51  thresh_pT2.push_back(thresh_pT[i] * thresh_pT[i]);
52  }
53 
54  auto entry = _layerMap.find(det);
55  if (entry == _layerMap.end()) {
56  throw cms::Exception("InvalidDetectorLayer") << "Detector layer : " << det << " is not in the list of recognized"
57  << " detector layers!";
58  }
59 
60  _thresholds[entry->second + layerOffset] = std::make_tuple(depths, thresh_E, thresh_pT2);
61  }
62 }

References PFLayer::ECAL_BARREL, PFLayer::ECAL_ENDCAP, PFLayer::HCAL_BARREL1, PFLayer::HCAL_BARREL2, PFLayer::HCAL_ENDCAP, PFLayer::HF_EM, PFLayer::HF_HAD, createfilelist::int, PFLayer::NONE, PFLayer::PS1, and PFLayer::PS2.

◆ LocalMaximumSeedFinder() [2/2]

LocalMaximumSeedFinder::LocalMaximumSeedFinder ( const LocalMaximumSeedFinder )
delete

Member Function Documentation

◆ findSeeds()

void LocalMaximumSeedFinder::findSeeds ( const edm::Handle< reco::PFRecHitCollection > &  input,
const std::vector< bool > &  mask,
std::vector< bool > &  seedable 
)
overridevirtual

Implements SeedFinderBase.

Definition at line 65 of file LocalMaximumSeedFinder.cc.

67  {
68  auto nhits = input->size();
69  initDynArray(bool, nhits, usable, true);
70  //need to run over energy sorted rechits
71  declareDynArray(float, nhits, energies);
72  unInitDynArray(int, nhits, qst); // queue storage
73  auto cmp = [&](int i, int j) { return energies[i] < energies[j]; };
74  std::priority_queue<int, DynArray<int>, decltype(cmp)> ordered_hits(cmp, std::move(qst));
75 
76  for (unsigned i = 0; i < nhits; ++i) {
77  if (!mask[i])
78  continue; // cannot seed masked objects
79  auto const& maybeseed = (*input)[i];
80  energies[i] = maybeseed.energy();
81  int seedlayer = (int)maybeseed.layer();
82  if (seedlayer == PFLayer::HCAL_BARREL2 && std::abs(maybeseed.positionREP().eta()) > 0.34) {
83  seedlayer = 19;
84  }
85  auto const& thresholds = _thresholds[seedlayer + layerOffset];
86 
87  double thresholdE = 0.;
88  double thresholdPT2 = 0.;
89 
90  for (unsigned int j = 0; j < (std::get<2>(thresholds)).size(); ++j) {
91  int depth = std::get<0>(thresholds)[j];
92  if ((seedlayer == PFLayer::HCAL_BARREL1 && maybeseed.depth() == depth) ||
93  (seedlayer == PFLayer::HCAL_ENDCAP && maybeseed.depth() == depth) ||
94  (seedlayer != PFLayer::HCAL_BARREL1 && seedlayer != PFLayer::HCAL_ENDCAP)) {
95  thresholdE = std::get<1>(thresholds)[j];
96  thresholdPT2 = std::get<2>(thresholds)[j];
97  }
98  }
99 
100  if (maybeseed.energy() < thresholdE || maybeseed.pt2() < thresholdPT2)
101  usable[i] = false;
102  if (!usable[i])
103  continue;
104  ordered_hits.push(i);
105  }
106 
107  while (!ordered_hits.empty()) {
108  auto idx = ordered_hits.top();
109  ordered_hits.pop();
110  if (!usable[idx])
111  continue;
112  //get the neighbours of this seed
113  auto const& maybeseed = (*input)[idx];
114  reco::PFRecHit::Neighbours myNeighbours;
115  switch (_nNeighbours) {
116  case -1:
117  myNeighbours = maybeseed.neighbours();
118  break;
119  case 0: // for HF clustering
120  myNeighbours = _noNeighbours;
121  break;
122  case 4:
123  myNeighbours = maybeseed.neighbours4();
124  break;
125  case 8:
126  myNeighbours = maybeseed.neighbours8();
127  break;
128  default:
129  throw cms::Exception("InvalidConfiguration") << "LocalMaximumSeedFinder only accepts nNeighbors = {-1,0,4,8}";
130  }
131  seedable[idx] = true;
132  for (auto neighbour : myNeighbours) {
133  if (!mask[neighbour])
134  continue;
135  if (energies[neighbour] > energies[idx]) {
136  // std::cout << "how this can be?" << std::endl;
137  seedable[idx] = false;
138  break;
139  }
140  }
141  if (seedable[idx]) {
142  for (auto neighbour : myNeighbours) {
143  usable[neighbour] = false;
144  }
145  }
146  }
147 
148  LogDebug("LocalMaximumSeedFinder") << " found " << std::count(seedable.begin(), seedable.end(), true) << " seeds";
149 }

References _nNeighbours, _thresholds, funct::abs(), fileCollector::cmp, KineDebug3::count(), declareDynArray, LEDCalibrationChannels::depth, Exception, PFLayer::HCAL_BARREL1, PFLayer::HCAL_BARREL2, PFLayer::HCAL_ENDCAP, mps_fire::i, training_settings::idx, initDynArray, input, createfilelist::int, dqmiolumiharvest::j, layerOffset, LogDebug, eostools::move(), nhits, findQualityFiles::size, particleFlowZeroSuppressionECAL_cff::thresholds, and unInitDynArray.

◆ operator=()

LocalMaximumSeedFinder& LocalMaximumSeedFinder::operator= ( const LocalMaximumSeedFinder )
delete

Member Data Documentation

◆ _layerMap

const std::unordered_map<std::string, int> LocalMaximumSeedFinder::_layerMap
private

Definition at line 22 of file LocalMaximumSeedFinder.h.

◆ _nNeighbours

const int LocalMaximumSeedFinder::_nNeighbours
private

Definition at line 20 of file LocalMaximumSeedFinder.h.

Referenced by findSeeds().

◆ _thresholds

std::array<I3tuple, 35> LocalMaximumSeedFinder::_thresholds
private

Definition at line 26 of file LocalMaximumSeedFinder.h.

Referenced by findSeeds().

◆ layerOffset

constexpr int LocalMaximumSeedFinder::layerOffset = 15
staticconstexprprivate

Definition at line 27 of file LocalMaximumSeedFinder.h.

Referenced by findSeeds().

SeedFinderBase::SeedFinderBase
SeedFinderBase(const edm::ParameterSet &conf)
Definition: SeedFinderBase.h:11
mps_fire.i
i
Definition: mps_fire.py:355
input
static const std::string input
Definition: EdmProvDump.cc:48
LocalMaximumSeedFinder::layerOffset
static constexpr int layerOffset
Definition: LocalMaximumSeedFinder.h:27
particleFlowZeroSuppressionECAL_cff.thresholds
thresholds
Definition: particleFlowZeroSuppressionECAL_cff.py:31
mps_splice.entry
entry
Definition: mps_splice.py:68
PFLayer::HCAL_ENDCAP
Definition: PFLayer.h:37
initDynArray
#define initDynArray(T, n, x, i)
Definition: DynArray.h:94
training_settings.idx
idx
Definition: training_settings.py:16
PFLayer::ECAL_BARREL
Definition: PFLayer.h:33
PFLayer::PS1
Definition: PFLayer.h:31
PFLayer::HCAL_BARREL2
Definition: PFLayer.h:36
PFLayer::HF_EM
Definition: PFLayer.h:38
LocalMaximumSeedFinder::_layerMap
const std::unordered_map< std::string, int > _layerMap
Definition: LocalMaximumSeedFinder.h:22
PFLayer::HCAL_BARREL1
Definition: PFLayer.h:35
customizeHLTforCMSSW.depths
depths
Definition: customizeHLTforCMSSW.py:31
declareDynArray
#define declareDynArray(T, n, x)
Definition: DynArray.h:91
PFLayer::NONE
Definition: PFLayer.h:34
nhits
Definition: HIMultiTrackSelector.h:42
LEDCalibrationChannels.depth
depth
Definition: LEDCalibrationChannels.py:65
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
PFLayer::HF_HAD
Definition: PFLayer.h:39
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:670
KineDebug3::count
void count()
Definition: KinematicConstrainedVertexUpdatorT.h:21
LocalMaximumSeedFinder::_nNeighbours
const int _nNeighbours
Definition: LocalMaximumSeedFinder.h:20
createfilelist.int
int
Definition: createfilelist.py:10
reco::PFRecHit::Neighbours
Definition: PFRecHit.h:39
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
eostools.move
def move(src, dest)
Definition: eostools.py:511
fileCollector.cmp
cmp
Definition: fileCollector.py:125
Exception
Definition: hltDiff.cc:246
edm::ParameterSet::getParameterSetVector
VParameterSet const & getParameterSetVector(std::string const &name) const
Definition: ParameterSet.cc:2153
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
PFLayer::ECAL_ENDCAP
Definition: PFLayer.h:32
PFLayer::PS2
Definition: PFLayer.h:30
unInitDynArray
#define unInitDynArray(T, n, x)
Definition: DynArray.h:88
LocalMaximumSeedFinder::_thresholds
std::array< I3tuple, 35 > _thresholds
Definition: LocalMaximumSeedFinder.h:26
muonDTDigis_cfi.pset
pset
Definition: muonDTDigis_cfi.py:27
findQualityFiles.size
size
Write out results.
Definition: findQualityFiles.py:443