11 #include <unordered_map> 21 const std::vector<bool>&
mask,
22 std::vector<bool>& seedable,
28 const std::unordered_map<std::string, int>
_layerMap;
30 typedef std::tuple<std::vector<int>, std::vector<double>, std::vector<double> >
I3tuple;
47 _nNeighbours(conf.getParameter<
int>(
"nNeighbours")),
56 {
"HCAL_BARREL2_RING1", 19},
60 const std::vector<edm::ParameterSet>&
thresholds = conf.getParameterSetVector(
"thresholdsByDetector");
64 std::vector<double> thresh_E;
65 std::vector<double> thresh_pT;
66 std::vector<double> thresh_pT2;
69 depths =
pset.getParameter<std::vector<int> >(
"depths");
70 thresh_E =
pset.getParameter<std::vector<double> >(
"seedingThreshold");
71 thresh_pT =
pset.getParameter<std::vector<double> >(
"seedingThresholdPt");
72 if (thresh_E.size() !=
depths.size() || thresh_pT.size() !=
depths.size()) {
73 throw cms::Exception(
"InvalidGatheringThreshold") <<
"gatheringThresholds mismatch with the numbers of depths";
77 thresh_E.push_back(
pset.getParameter<
double>(
"seedingThreshold"));
78 thresh_pT.push_back(
pset.getParameter<
double>(
"seedingThresholdPt"));
81 for (
unsigned int i = 0;
i < thresh_pT.size(); ++
i) {
82 thresh_pT2.push_back(thresh_pT[
i] * thresh_pT[
i]);
85 auto entry = _layerMap.find(det);
86 if (
entry == _layerMap.end()) {
87 throw cms::Exception(
"InvalidDetectorLayer") <<
"Detector layer : " << det <<
" is not in the list of recognized" 88 <<
" detector layers!";
91 _thresholds[
entry->second + layerOffset] = std::make_tuple(
depths, thresh_E, thresh_pT2);
97 const std::vector<bool>&
mask,
98 std::vector<bool>& seedable,
105 auto cmp = [&](
int i,
int j) {
return energies[
i] < energies[
j]; };
106 std::priority_queue<int, DynArray<int>, decltype(
cmp)> ordered_hits(
cmp,
std::move(qst));
108 for (
unsigned i = 0;
i <
nhits; ++
i) {
111 auto const& maybeseed = (*input)[
i];
112 energies[
i] = maybeseed.energy();
113 int seedlayer = (
int)maybeseed.layer();
119 double thresholdE = 0.;
120 double thresholdPT2 = 0.;
122 for (
unsigned int j = 0; j < (std::get<2>(
thresholds)).size(); ++
j) {
132 if (hcalCuts !=
nullptr) {
136 thresholdE =
item->seedThreshold();
140 if (maybeseed.energy() < thresholdE || maybeseed.pt2() < thresholdPT2)
144 ordered_hits.push(
i);
147 while (!ordered_hits.empty()) {
148 auto idx = ordered_hits.top();
153 auto const& maybeseed = (*input)[
idx];
157 myNeighbours = maybeseed.neighbours();
160 myNeighbours = _noNeighbours;
163 myNeighbours = maybeseed.neighbours4();
166 myNeighbours = maybeseed.neighbours8();
169 throw cms::Exception(
"InvalidConfiguration") <<
"LocalMaximumSeedFinder only accepts nNeighbors = {-1,0,4,8}";
171 seedable[
idx] =
true;
172 for (
auto neighbour : myNeighbours) {
173 if (!
mask[neighbour])
175 if (energies[neighbour] > energies[
idx]) {
177 seedable[
idx] =
false;
182 for (
auto neighbour : myNeighbours) {
187 int seedlayer = (
int)maybeseed.layer();
195 auto const& nei = (*input)[neighbour];
196 if (maybeseed.depth() != nei.depth())
199 std::abs(maybeseed.positionREP().eta() - nei.positionREP().eta()) >
detacut)
204 usable[neighbour] =
false;
210 LogDebug(
"LocalMaximumSeedFinder") <<
" found " <<
std::count(seedable.begin(), seedable.end(),
true) <<
" seeds";
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, const HcalPFCuts *) override
const Item * getValues(DetId fId, bool throwOnFail=true) const
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
constexpr uint32_t rawId() const
get the raw id
#define DEFINE_EDM_PLUGIN(factory, type, name)
#define declareDynArray(T, n, x)
const std::unordered_map< std::string, int > _layerMap