ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/auterman/PhysicsTools/LeptonIsolation/interface/CalIsolationAlgo.h
Revision: 1.1
Committed: Tue May 15 17:44:50 2007 UTC (17 years, 11 months ago) by auterman
Content type: text/plain
Branch: MAIN
Branch point for: tex, PatCrossCleaner, Demo, SusyScan, scripts, LeptonIsolation
Log Message:
Initial revision

File Contents

# User Rev Content
1 auterman 1.1 #include <algorithm>
2     #include <vector>
3    
4     #include "FWCore/Framework/interface/EDProducer.h"
5     #include "FWCore/ParameterSet/interface/ParameterSetfwd.h"
6     #include "FWCore/ParameterSet/interface/ParameterSet.h"
7     #include "PhysicsTools/Utilities/interface/Math.h"
8     #include "DataFormats/TrackReco/interface/Track.h"
9    
10     #include "FWCore/Framework/interface/EventSetup.h"
11     #include "FWCore/Framework/interface/Event.h"
12     #include "FWCore/Framework/interface/ESHandle.h"
13     #include "DataFormats/Common/interface/Handle.h"
14     #include <TObjArray.h>
15     #include "DataFormats/GeometryVector/interface/GlobalPoint.h"
16     #include "DataFormats/GeometryVector/interface/GlobalVector.h"
17    
18     #include "PhysicsTools/LeptonIsolation/interface/PropagateToCal.h"
19    
20     template <typename T1, typename C2>
21     class CalIsolationAlgo {
22     public:
23     typedef double value_type;
24     CalIsolationAlgo( const edm::ParameterSet & );
25     ~CalIsolationAlgo();
26     double operator()(const T1 &, const C2 &, const edm::EventSetup &) const;
27     double operator()(const reco::Track&, const C2 &, const edm::EventSetup &) const;
28    
29     private:
30     double dRMin_, dRMax_, dzMax_;
31     bool do_propagation_;
32     PropagateToCal SrcAtCal;
33     };
34    
35     template <typename T1, typename C2>
36     CalIsolationAlgo<T1,C2>::CalIsolationAlgo( const edm::ParameterSet & cfg ) :
37     dRMin_( cfg.template getParameter<double>( "dRMin" ) ),
38     dRMax_( cfg.template getParameter<double>( "dRMax" ) ),
39     do_propagation_( cfg.template getParameter<bool>( "PropagateToCal" ) ),
40     SrcAtCal(cfg)///class to propagate particles from the vertex to the calorimeter
41     {
42     }
43    
44     template <typename T1, typename C2>
45     CalIsolationAlgo<T1,C2>::~CalIsolationAlgo() {
46     }
47    
48     template <typename T1, typename C2> double CalIsolationAlgo<T1,C2>::
49     operator()(const T1 & cand, const C2 & elements, const edm::EventSetup &iSetup) const {
50     const GlobalPoint Vertex(cand.vx(), cand.vy(), cand.vz());//@@check if this is [cm]!
51     GlobalVector Cand(cand.pt(), cand.eta(), cand.phi());
52     if (do_propagation_ && cand.charge()!=0)
53     SrcAtCal.propagate(Vertex, Cand, cand.charge(), iSetup);
54    
55     double etSum = 0;
56     for( typename C2::const_iterator elem = elements.begin();
57     elem != elements.end(); ++elem ) {
58     double dR = deltaR( elem->eta(), elem->phi(),
59     (double)Cand.eta(), (double)Cand.phi() );
60     if ( dR < dRMax_ && dR > dRMin_ ) {
61     etSum += elem->et();
62     }
63     }
64     return etSum;
65     }
66    
67     ///specialized template operator () for tracks; since this source already has defined
68     ///outer eta and phi. This is the track's end point in the tracker, this should be close
69     ///the tracks entry into the calorimeter.
70     template <typename T1, typename C2> double CalIsolationAlgo<T1,C2>::
71     operator()(const reco::Track & cand, const C2 & elements, const edm::EventSetup &iSetup) const {
72     double etSum = 0;
73     for( typename C2::const_iterator elem = elements.begin();
74     elem != elements.end(); ++elem ) {
75     double dR = deltaR( elem->eta(), elem->phi(),
76     cand.outerEta(), cand.outerPhi() );
77     if ( dR < dRMax_ && dR > dRMin_ ) {
78     etSum += elem->et();
79     }
80     }
81     return etSum;
82     }