6 #include <unordered_map>
27 const std::unordered_map<std::string, int>
_layerMap;
34 std::pair<double, double> dCrack(
double phi,
double eta) {
35 constexpr
double oneOverCrystalSize = 1.0 / 0.0175;
36 constexpr
double pi =
M_PI;
37 constexpr
double twopi = 2 *
pi;
40 constexpr
double cPhi[18] = {2.97025,
58 constexpr
double cEta[9] = {
59 0.0, 4.44747e-01, -4.44747e-01, 7.92824e-01, -7.92824e-01, 1.14090e+00, -1.14090e+00, 1.47464e+00, -1.47464e+00};
61 constexpr
double delta_cPhi = 0.00638;
66 if (phi >= -pi && phi <= pi) {
68 if (phi < cPhi[17] || phi >= cPhi[0]) {
89 for (
const double etaGap : cEta) {
92 defi *= oneOverCrystalSize;
93 deta *= oneOverCrystalSize;
94 return std::make_pair(defi, deta);
113 for (
const auto&
pset : thresholds) {
116 info._minS4S1_a =
pset.getParameter<
double>(
"minS4S1_a");
117 info._minS4S1_b =
pset.getParameter<
double>(
"minS4S1_b");
118 info._doubleSpikeS6S2 =
pset.getParameter<
double>(
"doubleSpikeS6S2");
119 info._eneThreshMod =
pset.getParameter<
double>(
"energyThresholdModifier");
120 info._fracThreshMod =
pset.getParameter<
double>(
"fractionThresholdModifier");
121 info._doubleSpikeThresh =
pset.getParameter<
double>(
"doubleSpikeThresh");
122 info._singleSpikeThresh =
pset.getParameter<
double>(
"singleSpikeThresh");
125 throw cms::Exception(
"InvalidDetectorLayer") <<
"Detector layer : " << det <<
" is not in the list of recognized"
126 <<
" detector layers!";
134 auto const& hits = *
input;
135 std::vector<unsigned> ordered_hits(hits.size());
136 for (
unsigned i = 0; i < hits.size(); ++
i)
138 std::sort(ordered_hits.begin(), ordered_hits.end(), [&](
unsigned i,
unsigned j) {
139 return hits[
i].energy() > hits[
j].energy();
142 for (
const auto& idx : ordered_hits) {
143 const unsigned i = idx;
147 int hitlayer = (int)rechit.
layer();
157 float compsumE = 0.0;
163 int heta = detid.
ieta();
164 int hphi = detid.
iphi();
171 int curphiL = hphi - predphi;
172 int curphiH = hphi + predphi;
180 std::pair<std::vector<int>, std::vector<int>> phietas({heta, heta + 1, heta - 1, heta, heta},
181 {hphi, hphi, hphi, curphiL, curphiH});
183 std::vector<uint32_t> rawDetIds;
184 for (
unsigned in = 0;
in < phietas.first.size();
in++) {
186 rawDetIds.push_back(tempID.
rawId());
189 for (
const auto& jdx : ordered_hits) {
190 const unsigned j = jdx;
192 for (
const auto& iID : rawDetIds)
193 if (iID == matchrechit.
detId())
194 compsumE += matchrechit.
energy();
199 const double rhenergy = rechit.
energy();
202 double surroundingEnergy = compsumE;
203 for (
auto k : neighbours4) {
206 auto const& neighbour = hits[
k];
207 const double sum = neighbour.energy();
208 surroundingEnergy += sum;
213 const double fraction1 = surroundingEnergy / rhenergy;
217 if (fraction1 < f1Cut) {
221 std::pair<double, double> dcr = dCrack(phi, eta);
231 double surroundingEnergyi = 0.0;
232 double enmax = -999.0;
233 unsigned int mostEnergeticNeighbour = 0;
235 for (
auto k : neighbours4i) {
238 auto const& neighbour = hits[
k];
239 const double nenergy = neighbour.energy();
240 surroundingEnergyi += nenergy;
241 if (nenergy > enmax) {
243 mostEnergeticNeighbour =
k;
248 double surroundingEnergyj = 0.0;
249 auto const& neighbours4j = hits[mostEnergeticNeighbour].neighbours4();
250 for (
auto k : neighbours4j) {
252 surroundingEnergyj += hits[
k].energy();
255 const double surroundingEnergyFraction =
256 (surroundingEnergyi + surroundingEnergyj) / (rechit.
energy() + hits[mostEnergeticNeighbour].energy()) - 1.;
261 std::pair<double, double> dcr = dCrack(phi, eta);
263 if (aeta < 5.0 && ((aeta < 2.85 && dcrmin > 1.0) ||
267 mask[mostEnergeticNeighbour] =
false;
float phi() const
momentum azimuthal angle
VParameterSet const & getParameterSetVector(std::string const &name) const
unsigned detId() const
rechit detId
double _doubleSpikeThresh
const std::unordered_map< std::string, int > _layerMap
constexpr uint32_t rawId() const
get the raw id
void clean(const edm::Handle< reco::PFRecHitCollection > &input, std::vector< bool > &mask) override
static std::string const input
PFLayer::Layer layer() const
rechit layer
double _singleSpikeThresh
SpikeAndDoubleSpikeCleaner(const edm::ParameterSet &conf, edm::ConsumesCollector &cc)
Particle flow rechit (rechit + geometry and topology information). See clustering algorithm in PFClus...
constexpr int iphi() const
get the cell iphi
Abs< T >::type abs(const T &t)
constexpr int ieta() const
get the cell ieta
float energy() const
rechit energy
std::pair< int, edm::FunctionWithDict > OK
std::unordered_map< int, spike_cleaning > _thresholds
SpikeAndDoubleSpikeCleaner & operator=(const SpikeAndDoubleSpikeCleaner &)=delete
#define DEFINE_EDM_PLUGIN(factory, type, name)
float eta() const
momentum pseudorapidity
Neighbours neighbours4() const
RhoEtaPhi const & positionREP() const