ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/HbbAnalysis/src/TauDeltaRSelector.cc
Revision: 1.1
Committed: Thu Aug 6 07:36:35 2009 UTC (15 years, 9 months ago) by amagnan
Content type: text/plain
Branch: MAIN
CVS Tags: v01-00-00, beforeMETHacks, v00-05-03, v00-05-02, v00-05-01, v00-05-00, HbbAnaFor35X, v00-04-02, v00-04-01, v00-04-00, v00-03-00, v00-02-01, v00-02-00, HEAD
Log Message:
add selector for Hbb in etau

File Contents

# User Rev Content
1 amagnan 1.1 #include "DataFormats/Common/interface/Handle.h"
2     #include "DataFormats/Common/interface/ValueMap.h"
3     #include "DataFormats/Candidate/interface/Candidate.h"
4     #include "DataFormats/HepMCCandidate/interface/GenParticle.h"
5    
6     #include "DataFormats/PatCandidates/interface/Lepton.h"
7     #include "DataFormats/PatCandidates/interface/Muon.h"
8     #include "DataFormats/PatCandidates/interface/Electron.h"
9     #include "DataFormats/PatCandidates/interface/Tau.h"
10     #include "DataFormats/PatCandidates/interface/Jet.h"
11    
12     #include "UserCode/HbbAnalysis/interface/TauDeltaRSelector.hh"
13    
14    
15     TauDeltaRSelector::TauDeltaRSelector(const edm::ParameterSet & pset):
16     debug_(pset.getParameter<int>("DEBUG")),
17     tauLeptonIsolation_(pset.getParameter<double>("TauLeptonDeltaRCut")),
18     doElectron_(pset.getParameter<bool>("DoElectron")),
19     genParticleSrc_(pset.getParameter<edm::InputTag>("GenParticles")),
20     electronSrc_(pset.getParameter<edm::InputTag>("Electrons")),
21     muonSrc_(pset.getParameter<edm::InputTag>("Muons"))
22     {//constructor
23    
24    
25     }//constructor
26    
27     TauDeltaRSelector::~TauDeltaRSelector(){//destructor
28    
29     }//destructor
30    
31    
32    
33     void TauDeltaRSelector::select(edm::Handle<collection> & aTauCol,
34     edm::Event& aEvt,
35     const edm::EventSetup& aEvtSetup
36     )
37     {
38    
39     edm::Handle<std::vector<pat::Electron> > lElectronCollection;
40     edm::Handle<std::vector<pat::Muon> > lMuonCollection;
41    
42     if (doElectron_){
43     try {
44     aEvt.getByLabel(electronSrc_,lElectronCollection);
45     if (!lElectronCollection.isValid()){
46     edm::LogInfo("ERROR")<< "Error! Can't get electron by label. ";
47     }
48     if (debug_) std::cout << "** electroncollection = " << lElectronCollection->size() << " elements." << std::endl;
49     } catch(cms::Exception& e) {
50     std::cout << "AMM: Collection " << electronSrc_ << " not available! Exception : " << e.what() << ". " << std::endl;
51     }
52     }
53     else {
54     try {
55     aEvt.getByLabel(muonSrc_,lMuonCollection);
56     if (!lMuonCollection.isValid()){
57     edm::LogInfo("ERROR")<< "Error! Can't get muon by label. ";
58     }
59     if (debug_) std::cout << "** muoncollection = " << lMuonCollection->size() << " elements." << std::endl;
60     } catch(cms::Exception& e) {
61     std::cout << "AMM: Collection " << muonSrc_ << " not available! Exception : " << e.what() << ". " << std::endl;
62     }
63     }
64    
65     selected_.clear();
66    
67     for (std::vector<pat::Tau>::const_iterator iTau = aTauCol->begin();
68     iTau != aTauCol->end();
69     iTau++)
70     {
71     if (tauLeptonIsolation(*iTau,lElectronCollection,lMuonCollection)) {
72     selected_.push_back( & * iTau );
73     }
74     }
75    
76     }//select
77    
78    
79     bool TauDeltaRSelector::tauLeptonIsolation(const pat::Tau & aTau,
80     const edm::Handle<std::vector<pat::Electron> > & aColEle,
81     const edm::Handle<std::vector<pat::Muon> > & aColMu
82     )
83     {
84     double lDeltaR = 0;
85     if (doElectron_) lDeltaR = deltaRwithLepton<pat::Electron>(aTau,aColEle);
86     else lDeltaR = deltaRwithLepton<pat::Muon>(aTau,aColMu);
87    
88     //ask fabs so that if deltaR=-1 (if no lepton...) it returns true
89     if (fabs(lDeltaR) <= tauLeptonIsolation_) return false;
90     return true;
91     }
92    
93    
94    
95    
96    
97    
98    
99    
100    
101    
102    
103    
104    
105    
106    
107    
108    
109