ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/auterman/PhysicsTools/LeptonIsolation/interface/CalIsolationAlgo.h
Revision: 1.2
Committed: Wed May 16 09:47:03 2007 UTC (17 years, 11 months ago) by auterman
Content type: text/plain
Branch: MAIN
CVS Tags: HEAD
Changes since 1.1: +3 -18 lines
Log Message:
*** empty log message ***

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    
28     private:
29     double dRMin_, dRMax_, dzMax_;
30     bool do_propagation_;
31     PropagateToCal SrcAtCal;
32     };
33    
34     template <typename T1, typename C2>
35     CalIsolationAlgo<T1,C2>::CalIsolationAlgo( const edm::ParameterSet & cfg ) :
36     dRMin_( cfg.template getParameter<double>( "dRMin" ) ),
37     dRMax_( cfg.template getParameter<double>( "dRMax" ) ),
38     do_propagation_( cfg.template getParameter<bool>( "PropagateToCal" ) ),
39     SrcAtCal(cfg)///class to propagate particles from the vertex to the calorimeter
40     {
41     }
42    
43     template <typename T1, typename C2>
44     CalIsolationAlgo<T1,C2>::~CalIsolationAlgo() {
45     }
46    
47     template <typename T1, typename C2> double CalIsolationAlgo<T1,C2>::
48     operator()(const T1 & cand, const C2 & elements, const edm::EventSetup &iSetup) const {
49     const GlobalPoint Vertex(cand.vx(), cand.vy(), cand.vz());//@@check if this is [cm]!
50     GlobalVector Cand(cand.pt(), cand.eta(), cand.phi());
51 auterman 1.2
52     ///Extrapolate charged particles from their vertex to the point of entry into the
53     ///calorimeter, if this is requested in the cfg file.
54 auterman 1.1 if (do_propagation_ && cand.charge()!=0)
55     SrcAtCal.propagate(Vertex, Cand, cand.charge(), iSetup);
56    
57     double etSum = 0;
58     for( typename C2::const_iterator elem = elements.begin();
59     elem != elements.end(); ++elem ) {
60     double dR = deltaR( elem->eta(), elem->phi(),
61     (double)Cand.eta(), (double)Cand.phi() );
62     if ( dR < dRMax_ && dR > dRMin_ ) {
63     etSum += elem->et();
64     }
65     }
66     return etSum;
67     }