5 bool greaterByEnergy(
const std::pair<unsigned,double>&
a,
6 const std::pair<unsigned,double>&
b) {
7 return a.second > b.second;
9 std::pair<double,double> dCrack(
double phi,
double eta) {
10 constexpr double oneOverCrystalSize=1.0/0.0175;
15 constexpr double cPhi[18] = {2.97025, 2.621184149601134, 2.272118299202268,
16 1.9230524488034024, 1.5739865984045365,
17 1.2249207480056705, 0.8758548976068048,
18 0.5267890472079388, 0.1777231968090729,
19 -0.17134265358979306, -0.520408503988659,
20 -0.8694743543875245, -1.2185402047863905,
21 -1.5676060551852569, -1.9166719055841224,
22 -2.265737755982988, -2.6148036063818543,
25 4.44747e-01, -4.44747e-01,
26 7.92824e-01, -7.92824e-01,
27 1.14090e+00, -1.14090e+00,
28 1.47464e+00, -1.47464e+00};
33 if( eta < 0 ) phi+=delta_cPhi;
34 if( phi >= -pi && phi <= pi ) {
36 if( phi < cPhi[17] || phi >= cPhi[0] ) {
37 if( phi < 0 ) phi += 2*
pi;
56 for(
const double etaGap : cEta ) {
59 defi *= oneOverCrystalSize;
60 deta *= oneOverCrystalSize;
61 return std::make_pair(defi,deta);
80 const std::vector<edm::ParameterSet>& thresholds =
82 for(
const auto& pset : thresholds ) {
85 info._minS4S1_a = pset.getParameter<
double>(
"minS4S1_a");
86 info._minS4S1_b = pset.getParameter<
double>(
"minS4S1_b");
87 info._doubleSpikeS6S2 = pset.getParameter<
double>(
"doubleSpikeS6S2");
88 info._eneThreshMod = pset.getParameter<
double>(
"energyThresholdModifier");
90 pset.getParameter<
double>(
"fractionThresholdModifier");
91 info._doubleSpikeThresh = pset.getParameter<
double>(
"doubleSpikeThresh");
92 info._singleSpikeThresh = pset.getParameter<
double>(
"singleSpikeThresh");
96 <<
"Detector layer : " << det <<
" is not in the list of recognized"
97 <<
" detector layers!";
106 std::vector<bool>& mask ) {
108 std::vector<std::pair<unsigned,double> > ordered_hits;
109 for(
unsigned i = 0; i < input->size(); ++
i ) {
110 std::pair<unsigned,double> val = std::make_pair(i,input->at(i).energy());
111 auto pos = std::upper_bound(ordered_hits.begin(),ordered_hits.end(),
112 val, greaterByEnergy);
113 ordered_hits.insert(pos,val);
116 for(
const auto& idx_e : ordered_hits ) {
117 const unsigned i = idx_e.first;
118 if( !mask[i] )
continue;
120 int hitlayer = (int)rechit.
layer();
127 const double rhenergy = rechit.
energy();
130 double surroundingEnergy = rechit.
energy();
131 double neighbourEnergy = 0.0;
132 double layerEnergy = 0.0;
134 if( !mask[neighbour.key()] )
continue;
135 const double sum = neighbour->energy();
136 surroundingEnergy += sum;
137 neighbourEnergy += sum;
138 layerEnergy += neighbour->energy();
143 const double fraction1 = surroundingEnergy/rhenergy;
148 if( fraction1 < f1Cut ) {
152 std::pair<double,double> dcr = dCrack(phi,eta);
157 ( (aeta < 2.85 && dcrmin > 1.0) ||
166 double surroundingEnergyi = 0.0;
167 double enmax = -999.0;
171 if( !mask[neighbour.key()] )
continue;
172 const double nenergy = neighbour->energy();
173 surroundingEnergyi += nenergy;
174 if( nenergy > enmax ) {
176 mostEnergeticNeighbour = neighbour;
181 double surroundingEnergyj = 0.0;
183 mostEnergeticNeighbour->neighbours4();
186 surroundingEnergyj += neighbour->energy();
189 const double surroundingEnergyFraction =
190 (surroundingEnergyi+surroundingEnergyj) /
191 (rechit.
energy()+mostEnergeticNeighbour->energy()) - 1.;
196 std::pair<double,double> dcr = dCrack(phi,eta);
201 ( (aeta < 2.85 && dcrmin > 1.0) ||
206 mask[mostEnergeticNeighbour.
key()] =
false;
VParameterSet const & getParameterSetVector(std::string const &name) const
SpikeAndDoubleSpikeCleaner(const edm::ParameterSet &conf)
void clean(const edm::Handle< reco::PFRecHitCollection > &input, std::vector< bool > &mask)
const PFRecHitRefVector & neighbours4() const
double _doubleSpikeThresh
key_type key() const
Accessor for product key.
static std::string const input
PFLayer::Layer layer() const
rechit layer
double _singleSpikeThresh
Particle flow rechit (rechit + geometry and topology information). See clustering algorithm in PFClus...
Abs< T >::type abs(const T &t)
std::pair< int, edm::FunctionWithDict > OK
std::unordered_map< int, spike_cleaning > _thresholds
double energy() const
rechit energy
const REPPoint & positionREP() const
const std::unordered_map< std::string, int > _layerMap