7 bool greaterByEnergy(
const std::pair<unsigned,double>&
a,
8 const std::pair<unsigned,double>&
b) {
9 return a.second > b.second;
16 std::vector<bool>& mask ) {
19 std::vector<std::pair<unsigned,double> > ordered_hits;
20 ordered_hits.reserve(input->size());
21 for(
unsigned i = 0;
i < input->size(); ++
i ) {
22 std::pair<unsigned,double> val = std::make_pair(
i,input->at(
i).energy());
23 auto pos = std::upper_bound(ordered_hits.begin(),ordered_hits.end(),
24 val, greaterByEnergy);
25 ordered_hits.insert(pos,val);
28 for(
const auto& idx_e : ordered_hits ) {
29 if( !mask[idx_e.first] )
continue;
30 const unsigned idx = idx_e.first;
32 int layer = rechit.
layer();
37 int ieta = theHcalDetId.
ieta();
38 int iphi = theHcalDetId.iphi();
39 int ihpd = 0, irbx = 0;
42 ihpd = ( ieta < 0 ? -iphi : iphi );
43 irbx = ( ieta < 0 ? -(iphi+5)/4 : (iphi+5)/4 );
46 ihpd = ( ieta < 0 ? -(iphi+1)/2-100 : (iphi+1)/2+100 );
47 irbx = ( ieta < 0 ? -(iphi+5)/4-20 : (iphi+5)/4+20 );
54 irbx = ( irbx < 0 ? -1 : 1 );
57 irbx = ( irbx < 0 ? -21 : 21 );
62 _hpds[ihpd].push_back(idx);
63 _rbxs[irbx].push_back(idx);
67 double totalEta = 0., totalEtaW = 0., totalPhi = 0., totalPhiW = 0.,
69 double totalEta2 = 1E-9, totalEta2W = 1E-9, totalPhi2 = 1E-9,
70 totalPhi2W = 1E-9, totalEnergy2 = 1E-9;
71 unsigned nSeeds = 0, nSeeds0 = 0;
72 std::unordered_map<int, std::vector<unsigned> > theHPDs;
73 std::unordered_multimap<double, unsigned> theEnergies;
74 for(
const auto& itrbx :
_rbxs ) {
75 if( (
std::abs(itrbx.first)<20 && itrbx.second.size() > 30 ) ||
76 (
std::abs(itrbx.first)>20 && itrbx.second.size() > 30 ) ) {
77 const std::vector<unsigned>&
rechits = itrbx.second;
80 totalEta = totalEtaW = totalPhi = totalPhiW = totalEnergy = 0.;
81 totalEta2 = totalEta2W = totalPhi2 = totalPhi2W = totalEnergy2 = 1
e-9;
82 nSeeds = nSeeds0 = rechits.size();
83 for(
unsigned jh = 0; jh < rechits.size(); ++jh ) {
90 if( neighbour->energy() > rechit.
energy() ) {
95 if( neighbour->energy() > 0.4 ) ++nN;
98 if ( isASeed && !nN ) --nSeeds0;
101 int iphi = theHcalDetId.
iphi();
102 switch( rechit.
layer() ) {
104 theHPDs[iphi].push_back(rechits[jh]);
107 theHPDs[(iphi-1)/2].push_back(rechits[jh]);
112 const double rhenergy = rechit.
energy();
113 const double rhphi = rechit.
position().phi();
114 const double rhphi2 = rhphi*rhphi;
115 const double rheta = rechit.
position().eta();
116 const double rheta2 = rheta*rheta;
117 theEnergies.emplace(rhenergy,rechits[jh]);
118 totalEnergy += rhenergy;
120 totalPhiW +=
std::abs(rhphi)*rhenergy;
122 totalEtaW += rheta*rhenergy;
123 totalEnergy2 += rhenergy*rhenergy;
125 totalPhi2W += rhphi2*rhenergy;
127 totalEta2W += rheta2*rhenergy;
129 totalPhi /= rechits.size();
130 totalEta /= rechits.size();
131 totalPhiW /= totalEnergy;
132 totalEtaW /= totalEnergy;
133 totalPhi2 /= rechits.size();
134 totalEta2 /= rechits.size();
135 totalPhi2W /= totalEnergy;
136 totalEta2W /= totalEnergy;
137 totalPhi2 =
std::sqrt(totalPhi2 - totalPhi*totalPhi);
138 totalEta2 =
std::sqrt(totalEta2 - totalEta*totalEta);
139 totalPhi2W =
std::sqrt(totalPhi2W - totalPhiW*totalPhi2);
140 totalEta2W =
std::sqrt(totalEta2W - totalEtaW*totalEtaW);
141 totalEnergy /= rechits.size();
142 totalEnergy2 /= rechits.size();
143 totalEnergy2 =
std::sqrt(totalEnergy2 - totalEnergy*totalEnergy);
146 for(
const auto& itHPD : theHPDs ) {
147 int hpdN = itHPD.first;
148 const std::vector<unsigned>& hpdHits = itHPD.second;
149 if( (
std::abs(hpdN) < 100 && hpdHits.size() > 14 ) ||
150 (
std::abs(hpdN) > 100 && hpdHits.size() > 14 ) ) ++nHPD15;
155 for(
const auto& itEn : theEnergies ) {
158 mask[itEn.second] =
false;
159 }
else if ( nn == 5 ) {
160 threshold = itEn.first*5;
161 mask[itEn.second] =
false;
163 if( itEn.first < threshold ) mask[itEn.second] =
false;
172 std::unordered_map<int,std::vector<unsigned> >::iterator neighbour1;
173 std::unordered_map<int,std::vector<unsigned> >::iterator neighbour2;
174 std::unordered_map<int,std::vector<unsigned> >::iterator neighbour0;
175 std::unordered_map<int,std::vector<unsigned> >::iterator neighbour3;
176 unsigned size1 = 0, size2 = 0;
177 for(
const auto& ithpd :
_hpds ) {
178 const std::vector<unsigned>&
rechits = ithpd.second;
182 for(
const unsigned rhidx : rechits ) {
184 const double e = rechit.
energy();
187 theEnergies.emplace(rechit.
energy(),rhidx);
189 totalEnergy /= rechits.size();
190 totalEnergy2 /= rechits.size();
191 totalEnergy2 =
std::sqrt(totalEnergy2 - totalEnergy*totalEnergy);
193 const int thehpd = ithpd.first;
196 neighbour1 = ( thehpd > 0 ? _hpds.find(72) : _hpds.find(-72) );
199 neighbour2 = ( thehpd > 0 ? _hpds.find(1) : _hpds.find(-1) );
202 neighbour1 = ( thehpd > 0 ? _hpds.find(136) : _hpds.find(-136) );
205 neighbour2 = ( thehpd > 0 ? _hpds.find(101) : _hpds.find(-101) );
208 neighbour1 = ( thehpd > 0 ? _hpds.find(thehpd-1) : _hpds.find(thehpd+1) );
209 neighbour2 = ( thehpd > 0 ? _hpds.find(thehpd+1) : _hpds.find(thehpd-1) );
212 if( neighbour1 != _hpds.end() ) {
213 const int nb1 = neighbour1->first;
216 neighbour0 = ( nb1 > 0 ? _hpds.find(72) : _hpds.find(-72) );
219 neighbour0 = ( nb1 > 0 ? _hpds.find(136) : _hpds.find(-136) );
222 neighbour0 = ( nb1 > 0 ? _hpds.find(nb1-1) : _hpds.find(nb1+1) );
226 neighbour0 = _hpds.end();
229 if( neighbour2 != _hpds.end() ) {
230 const int nb2 = neighbour2->first;
233 neighbour3 = ( nb2 > 0 ? _hpds.find(1) : _hpds.find(-1) );
236 neighbour3 = ( nb2 > 0 ? _hpds.find(101) : _hpds.find(-101) );
239 neighbour3 = ( nb2 > 0 ? _hpds.find(nb2+1) : _hpds.find(nb2-1) );
243 neighbour3 = _hpds.end();
246 size1 = neighbour1 != _hpds.end() ? neighbour1->second.size() : 0;
247 size2 = neighbour2 != _hpds.end() ? neighbour2->second.size() : 0;
249 if ( (
abs(neighbour1->first) > 100 && neighbour1->second.size() > 15 ) ||
250 (
abs(neighbour1->first) < 100 && neighbour1->second.size() > 12 ) )
251 size1 = neighbour0 != _hpds.end() ? neighbour0->second.size() : 0;
254 if ( (
abs(neighbour2->first) > 100 && neighbour2->second.size() > 15 ) ||
255 (
abs(neighbour2->first) < 100 && neighbour2->second.size() > 12 ) )
256 size2 = neighbour3 != _hpds.end() ? neighbour3->second.size() : 0;
258 if( (
std::abs(ithpd.first) > 100 && ithpd.second.size() > 15 ) ||
259 (
std::abs(ithpd.first) < 100 && ithpd.second.size() > 12 ) ) {
260 if( (
double)(size1+size2)/(
float)ithpd.second.size() < 1.0 ) {
263 for(
const auto& itEn : theEnergies ) {
265 mask[itEn.second] =
false;
266 }
else if ( nn == 5 ) {
267 threshold = itEn.first*2.5;
268 mask[itEn.second] =
false;
270 if( itEn.first < threshold ) mask[itEn.second] =
false;
const PFRecHitRefVector & neighbours4() const
unsigned detId() const
rechit detId
void clean(const edm::Handle< reco::PFRecHitCollection > &input, std::vector< bool > &mask)
static std::string const input
PFLayer::Layer layer() const
rechit layer
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)
std::unordered_map< int, std::vector< unsigned > > _hpds
std::unordered_map< int, std::vector< unsigned > > _rbxs
int iphi() const
get the cell iphi
const math::XYZPoint & position() const
rechit cell centre x, y, z
tuple idx
DEBUGGING if hasattr(process,"trackMonIterativeTracking2012"): print "trackMonIterativeTracking2012 D...
double energy() const
rechit energy