6 #include <unordered_map> 18 std::unordered_map<int, std::vector<unsigned> >
_hpds,
_rbxs;
24 bool greaterByEnergy(
const std::pair<unsigned, double>&
a,
const std::pair<unsigned, double>&
b) {
25 return a.second >
b.second;
33 std::vector<std::pair<unsigned, double> > ordered_hits;
34 ordered_hits.reserve(
input->size());
35 for (
unsigned i = 0;
i <
input->size(); ++
i) {
36 std::pair<unsigned, double>
val = std::make_pair(
i,
input->at(
i).energy());
38 ordered_hits.insert(
pos,
val);
41 for (
const auto& idx_e : ordered_hits) {
42 if (!
mask[idx_e.first])
44 const unsigned idx = idx_e.first;
51 int ieta = theHcalDetId.ieta();
52 int iphi = theHcalDetId.iphi();
53 int ihpd = 0, irbx = 0;
60 ihpd = (
ieta < 0 ? -(
iphi + 1) / 2 - 100 : (
iphi + 1) / 2 + 100);
61 irbx = (
ieta < 0 ? -(
iphi + 5) / 4 - 20 : (
iphi + 5) / 4 + 20);
68 irbx = (irbx < 0 ? -1 : 1);
71 irbx = (irbx < 0 ? -21 : 21);
81 std::unordered_map<int, std::vector<unsigned> > theHPDs;
82 std::unordered_multimap<double, unsigned> theEnergies;
83 for (
const auto& itrbx :
_rbxs) {
84 if ((
std::abs(itrbx.first) < 20 && itrbx.second.size() > 30) ||
85 (
std::abs(itrbx.first) > 20 && itrbx.second.size() > 30)) {
86 const std::vector<unsigned>&
rechits = itrbx.second;
90 for (
unsigned jh = 0; jh <
rechits.size(); ++jh) {
96 for (
auto k : neighbours4) {
97 auto const& neighbour = (*input)[
k];
98 if (neighbour.energy() > rechit.
energy()) {
103 if (neighbour.energy() > 0.4)
111 int iphi = theHcalDetId.iphi();
112 switch (rechit.
layer()) {
122 const double rhenergy = rechit.
energy();
123 theEnergies.emplace(rhenergy,
rechits[jh]);
127 for (
const auto& itHPD : theHPDs) {
128 int hpdN = itHPD.first;
129 const std::vector<unsigned>& hpdHits = itHPD.second;
130 if ((
std::abs(hpdN) < 100 && hpdHits.size() > 14) || (
std::abs(hpdN) > 100 && hpdHits.size() > 14))
136 for (
const auto& itEn : theEnergies) {
139 mask[itEn.second] =
false;
140 }
else if (
nn == 5) {
142 mask[itEn.second] =
false;
145 mask[itEn.second] =
false;
154 std::unordered_map<int, std::vector<unsigned> >::iterator neighbour1;
155 std::unordered_map<int, std::vector<unsigned> >::iterator neighbour2;
156 std::unordered_map<int, std::vector<unsigned> >::iterator neighbour0;
157 std::unordered_map<int, std::vector<unsigned> >::iterator neighbour3;
158 unsigned size1 = 0, size2 = 0;
159 for (
const auto& ithpd :
_hpds) {
160 const std::vector<unsigned>&
rechits = ithpd.second;
162 for (
const unsigned rhidx :
rechits) {
164 theEnergies.emplace(rechit.
energy(), rhidx);
167 const int thehpd = ithpd.first;
170 neighbour1 = (thehpd > 0 ?
_hpds.find(72) :
_hpds.find(-72));
173 neighbour2 = (thehpd > 0 ?
_hpds.find(1) :
_hpds.find(-1));
176 neighbour1 = (thehpd > 0 ?
_hpds.find(136) :
_hpds.find(-136));
179 neighbour2 = (thehpd > 0 ?
_hpds.find(101) :
_hpds.find(-101));
182 neighbour1 = (thehpd > 0 ?
_hpds.find(thehpd - 1) :
_hpds.find(thehpd + 1));
183 neighbour2 = (thehpd > 0 ?
_hpds.find(thehpd + 1) :
_hpds.find(thehpd - 1));
186 if (neighbour1 !=
_hpds.end()) {
187 const int nb1 = neighbour1->first;
190 neighbour0 = (nb1 > 0 ?
_hpds.find(72) :
_hpds.find(-72));
193 neighbour0 = (nb1 > 0 ?
_hpds.find(136) :
_hpds.find(-136));
196 neighbour0 = (nb1 > 0 ?
_hpds.find(nb1 - 1) :
_hpds.find(nb1 + 1));
200 neighbour0 =
_hpds.end();
203 if (neighbour2 !=
_hpds.end()) {
204 const int nb2 = neighbour2->first;
207 neighbour3 = (nb2 > 0 ?
_hpds.find(1) :
_hpds.find(-1));
210 neighbour3 = (nb2 > 0 ?
_hpds.find(101) :
_hpds.find(-101));
213 neighbour3 = (nb2 > 0 ?
_hpds.find(nb2 + 1) :
_hpds.find(nb2 - 1));
217 neighbour3 =
_hpds.end();
220 size1 = neighbour1 !=
_hpds.end() ? neighbour1->second.size() : 0;
221 size2 = neighbour2 !=
_hpds.end() ? neighbour2->second.size() : 0;
223 if ((
abs(neighbour1->first) > 100 && neighbour1->second.size() > 15) ||
224 (
abs(neighbour1->first) < 100 && neighbour1->second.size() > 12))
225 size1 = neighbour0 !=
_hpds.end() ? neighbour0->second.size() : 0;
228 if ((
abs(neighbour2->first) > 100 && neighbour2->second.size() > 15) ||
229 (
abs(neighbour2->first) < 100 && neighbour2->second.size() > 12))
230 size2 = neighbour3 !=
_hpds.end() ? neighbour3->second.size() : 0;
232 if ((
std::abs(ithpd.first) > 100 && ithpd.second.size() > 15) ||
233 (
std::abs(ithpd.first) < 100 && ithpd.second.size() > 12)) {
234 if ((
double)(size1 + size2) / (
float)ithpd.second.size() < 1.0) {
237 for (
const auto& itEn : theEnergies) {
239 mask[itEn.second] =
false;
240 }
else if (
nn == 5) {
242 mask[itEn.second] =
false;
245 mask[itEn.second] =
false;
std::unordered_map< int, std::vector< unsigned > > _rbxs
Neighbours neighbours4() const
uint32_t cc[maxCellsPerHit]
PFLayer::Layer layer() const
rechit layer
RBXAndHPDCleaner(const edm::ParameterSet &conf, edm::ConsumesCollector &cc)
static std::string const input
unsigned detId() const
rechit detId
Particle flow rechit (rechit + geometry and topology information). See clustering algorithm in PFClus...
Abs< T >::type abs(const T &t)
RBXAndHPDCleaner & operator=(const RBXAndHPDCleaner &)=delete
std::unordered_map< int, std::vector< unsigned > > _hpds
deadvectors [0] push_back({0.0175431, 0.538005, 6.80997, 13.29})
float energy() const
rechit energy
#define DEFINE_EDM_PLUGIN(factory, type, name)
void clean(const edm::Handle< reco::PFRecHitCollection > &input, std::vector< bool > &mask) override