9 #include <unordered_map>
19 const std::vector<bool>& mask,
20 std::vector<bool>& seedable)
override;
25 const std::unordered_map<std::string, int>
_layerMap;
27 typedef std::tuple<std::vector<int>, std::vector<double>, std::vector<double> >
I3tuple;
44 _nNeighbours(conf.getParameter<int>(
"nNeighbours")),
53 {
"HCAL_BARREL2_RING1", 19},
58 for (
const auto&
pset : thresholds) {
61 std::vector<int> depths;
62 std::vector<double> thresh_E;
63 std::vector<double> thresh_pT;
64 std::vector<double> thresh_pT2;
67 depths =
pset.getParameter<std::vector<int> >(
"depths");
68 thresh_E =
pset.getParameter<std::vector<double> >(
"seedingThreshold");
69 thresh_pT =
pset.getParameter<std::vector<double> >(
"seedingThresholdPt");
70 if (thresh_E.size() != depths.size() || thresh_pT.size() != depths.size()) {
71 throw cms::Exception(
"InvalidGatheringThreshold") <<
"gatheringThresholds mismatch with the numbers of depths";
75 thresh_E.push_back(
pset.getParameter<
double>(
"seedingThreshold"));
76 thresh_pT.push_back(
pset.getParameter<
double>(
"seedingThresholdPt"));
79 for (
unsigned int i = 0;
i < thresh_pT.size(); ++
i) {
80 thresh_pT2.push_back(thresh_pT[
i] * thresh_pT[
i]);
85 throw cms::Exception(
"InvalidDetectorLayer") <<
"Detector layer : " << det <<
" is not in the list of recognized"
86 <<
" detector layers!";
95 const std::vector<bool>& mask,
96 std::vector<bool>& seedable) {
97 auto nhits = input->size();
102 auto cmp = [&](
int i,
int j) {
return energies[
i] < energies[
j]; };
103 std::priority_queue<int, DynArray<int>, decltype(cmp)> ordered_hits(cmp,
std::move(qst));
105 for (
unsigned i = 0; i <
nhits; ++
i) {
108 auto const& maybeseed = (*input)[
i];
109 energies[
i] = maybeseed.energy();
110 int seedlayer = (int)maybeseed.layer();
116 double thresholdE = 0.;
117 double thresholdPT2 = 0.;
119 for (
unsigned int j = 0; j < (std::get<2>(
thresholds)).size(); ++
j) {
129 if (maybeseed.energy() < thresholdE || maybeseed.pt2() < thresholdPT2)
133 ordered_hits.push(i);
136 while (!ordered_hits.empty()) {
137 auto idx = ordered_hits.top();
142 auto const& maybeseed = (*input)[idx];
146 myNeighbours = maybeseed.neighbours();
149 myNeighbours = _noNeighbours;
152 myNeighbours = maybeseed.neighbours4();
155 myNeighbours = maybeseed.neighbours8();
158 throw cms::Exception(
"InvalidConfiguration") <<
"LocalMaximumSeedFinder only accepts nNeighbors = {-1,0,4,8}";
160 seedable[idx] =
true;
161 for (
auto neighbour : myNeighbours) {
162 if (!mask[neighbour])
164 if (energies[neighbour] > energies[idx]) {
166 seedable[idx] =
false;
171 for (
auto neighbour : myNeighbours) {
176 int seedlayer = (int)maybeseed.layer();
184 auto const& nei = (*input)[neighbour];
185 if (maybeseed.depth() != nei.depth())
188 std::abs(maybeseed.positionREP().eta() - nei.positionREP().eta()) >
detacut)
193 usable[neighbour] =
false;
199 LogDebug(
"LocalMaximumSeedFinder") <<
" found " <<
std::count(seedable.begin(), seedable.end(),
true) <<
" seeds";
VParameterSet const & getParameterSetVector(std::string const &name) const
LocalMaximumSeedFinder & operator=(const LocalMaximumSeedFinder &)=delete
#define initDynArray(T, n, x, i)
void findSeeds(const edm::Handle< reco::PFRecHitCollection > &input, const std::vector< bool > &mask, std::vector< bool > &seedable) override
LocalMaximumSeedFinder(const edm::ParameterSet &conf)
static std::string const input
std::tuple< std::vector< int >, std::vector< double >, std::vector< double > > I3tuple
std::array< I3tuple, 35 > _thresholds
#define unInitDynArray(T, n, x)
Abs< T >::type abs(const T &t)
static constexpr int layerOffset
static constexpr double detacut
static constexpr double dphicut
#define DEFINE_EDM_PLUGIN(factory, type, name)
#define declareDynArray(T, n, x)
const std::unordered_map< std::string, int > _layerMap