1 |
auterman |
1.1 |
#include "FWCore/Framework/interface/EDProducer.h"
|
2 |
|
|
#include "FWCore/ParameterSet/interface/ParameterSetfwd.h"
|
3 |
|
|
#include "FWCore/ParameterSet/interface/ParameterSet.h"
|
4 |
|
|
#include <algorithm>
|
5 |
|
|
#include "PhysicsTools/Utilities/interface/Math.h"
|
6 |
|
|
|
7 |
|
|
template <typename T1, typename C2>
|
8 |
|
|
class PtIsolationAlgo {
|
9 |
|
|
public:
|
10 |
|
|
typedef double value_type;
|
11 |
|
|
PtIsolationAlgo( const edm::ParameterSet & );
|
12 |
|
|
~PtIsolationAlgo();
|
13 |
|
|
double operator()(const T1 &, const C2 &, const edm::EventSetup &) const;
|
14 |
|
|
|
15 |
|
|
private:
|
16 |
|
|
double dRMin_, dRMax_, dzMax_;
|
17 |
|
|
};
|
18 |
|
|
|
19 |
|
|
template <typename T1, typename C2>
|
20 |
|
|
PtIsolationAlgo<T1,C2>::PtIsolationAlgo( const edm::ParameterSet & cfg ) :
|
21 |
|
|
dRMin_( cfg.template getParameter<double>( "dRMin" ) ),
|
22 |
|
|
dRMax_( cfg.template getParameter<double>( "dRMax" ) ),
|
23 |
|
|
dzMax_( cfg.template getParameter<double>( "dzMax" ) ) {
|
24 |
|
|
}
|
25 |
|
|
|
26 |
|
|
template <typename T1, typename C2>
|
27 |
|
|
PtIsolationAlgo<T1,C2>::~PtIsolationAlgo() {
|
28 |
|
|
}
|
29 |
|
|
|
30 |
|
|
template <typename T1, typename C2>
|
31 |
|
|
double PtIsolationAlgo<T1,C2>::operator()(const T1 & cand, const C2 & elements, const edm::EventSetup &) const {
|
32 |
|
|
double ptSum = 0;
|
33 |
|
|
for( typename C2::const_iterator elem = elements.begin(); elem != elements.end(); ++ elem ) {
|
34 |
|
|
double dz = fabs( elem->vz() - cand.vz() );
|
35 |
|
|
//double dR = deltaR( elem->p4(), cand.p4() );
|
36 |
|
|
double dR = deltaR( elem->eta(), elem->phi(), cand.eta(), cand.phi() );
|
37 |
|
|
if ( dz < dzMax_ && dR < dRMax_ && dR > dRMin_ ) {
|
38 |
|
|
ptSum += elem->pt();
|
39 |
|
|
}
|
40 |
|
|
}
|
41 |
|
|
|
42 |
|
|
return ptSum;
|
43 |
|
|
}
|