105 std::vector<unsigned > ordered_hits(
hits.size());
106 for(
unsigned i = 0;
i <
hits.size(); ++
i ) ordered_hits[
i]=
i;
107 std::sort(ordered_hits.begin(),ordered_hits.end(),[&](
unsigned i,
unsigned j) {
return hits[
i].energy()>
hits[j].energy();});
109 for(
const auto&
idx : ordered_hits ) {
110 const unsigned i =
idx;
111 if( !
mask[i] )
continue;
119 if( rechit.
energy() < clean._singleSpikeThresh )
continue;
123 float compsumE = 0.0;
128 int heta = detid.
ieta();
129 int hphi = detid.
iphi();
135 int curphiL = hphi-predphi;
136 int curphiH = hphi+predphi;
139 while (curphiL<0) curphiL+=72;
140 while (curphiH>72) curphiH-=72;
142 std::pair<std::vector<int>, std::vector<int>> phietas({heta,heta+1,heta-1,heta,heta},{hphi,hphi,hphi,curphiL,curphiH});
144 std::vector<uint32_t> rawDetIds;
145 for(
unsigned in=0;
in<phietas.first.size();
in++) {
147 rawDetIds.push_back(tempID.rawId());
150 for(
const auto& jdx : ordered_hits ) {
151 const unsigned j = jdx;
153 for(
const auto& iID : rawDetIds )
if (iID==matchrechit.
detId())compsumE+=matchrechit.
energy();
158 const double rhenergy = rechit.
energy();
161 double surroundingEnergy = compsumE;
162 for(
auto k : neighbours4 ) {
163 if( !
mask[
k] )
continue;
164 auto const & neighbour =
hits[
k];
165 const double sum = neighbour.energy();
166 surroundingEnergy += sum;
171 const double fraction1 = surroundingEnergy/rhenergy;
174 const double f1Cut = ( clean._minS4S1_a*std::log10(rechit.
energy()) +
176 if( fraction1 < f1Cut ) {
180 std::pair<double,double> dcr = dCrack(phi,eta);
185 ( (aeta < 2.85 && dcrmin > 1.0) ||
186 (rhenergy > clean._eneThreshMod*clean._singleSpikeThresh &&
187 fraction1 < f1Cut/clean._fracThreshMod ) ) ) {
192 if(
mask[i] && rhenergy > clean._doubleSpikeThresh ) {
194 double surroundingEnergyi = 0.0;
195 double enmax = -999.0;
196 unsigned int mostEnergeticNeighbour=0;
198 for(
auto k : neighbours4i ) {
199 if( !
mask[k] )
continue;
200 auto const & neighbour =
hits[
k];
201 const double nenergy = neighbour.energy();
202 surroundingEnergyi += nenergy;
203 if( nenergy > enmax ) {
205 mostEnergeticNeighbour =
k;
210 double surroundingEnergyj = 0.0;
211 auto const & neighbours4j =
212 hits[mostEnergeticNeighbour].neighbours4();
213 for(
auto k : neighbours4j ) {
215 surroundingEnergyj +=
hits[
k].energy();
218 const double surroundingEnergyFraction =
219 (surroundingEnergyi+surroundingEnergyj) /
220 (rechit.
energy()+
hits[mostEnergeticNeighbour].energy()) - 1.;
221 if ( surroundingEnergyFraction < clean._doubleSpikeS6S2 ) {
225 std::pair<double,double> dcr = dCrack(phi,eta);
230 ( (aeta < 2.85 && dcrmin > 1.0) ||
231 (rhenergy > clean._eneThreshMod*clean._doubleSpikeThresh &&
232 surroundingEnergyFraction < clean._doubleSpikeS6S2/clean._fracThreshMod )
235 mask[mostEnergeticNeighbour] =
false;
float phi() const
momentum azimuthal angle
unsigned detId() const
rechit detId
void clean(const edm::Handle< reco::PFRecHitCollection > &input, std::vector< bool > &mask) override
static std::string const input
PFLayer::Layer layer() const
rechit layer
U second(std::pair< T, U > const &p)
Particle flow rechit (rechit + geometry and topology information). See clustering algorithm in PFClus...
int ieta() const
get the cell ieta
Abs< T >::type abs(const T &t)
float energy() const
rechit energy
int iphi() const
get the cell iphi
std::unordered_map< int, spike_cleaning > _thresholds
float eta() const
momentum pseudorapidity
Neighbours neighbours4() const
RhoEtaPhi const & positionREP() const