ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/HbbAnalysis/src/JetDeltaRSelector.cc
Revision: 1.2
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
Changes since 1.1: +2 -2 lines
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/JetDeltaRSelector.hh"
13    
14    
15     JetDeltaRSelector::JetDeltaRSelector(const edm::ParameterSet & pset):
16     debug_(pset.getParameter<int>("DEBUG")),
17     jetLeptonIsolation_(pset.getParameter<double>("JetLeptonDeltaRCut")),
18     genParticleSrc_(pset.getParameter<edm::InputTag>("GenParticles")),
19     electronSrc_(pset.getParameter<edm::InputTag>("Electrons")),
20     muonSrc_(pset.getParameter<edm::InputTag>("Muons")),
21     tauSrc_(pset.getParameter<edm::InputTag>("Taus"))
22     {//constructor
23    
24    
25     }//constructor
26    
27     JetDeltaRSelector::~JetDeltaRSelector(){//destructor
28    
29     }//destructor
30    
31    
32     void JetDeltaRSelector::select(edm::Handle<collection> & aJetCol,
33     edm::Event& aEvt,
34     const edm::EventSetup& aEvtSetup
35     )
36     {
37    
38     edm::Handle<std::vector<pat::Electron> > lElectronCollection;
39    
40     try {
41     aEvt.getByLabel(electronSrc_,lElectronCollection);
42     if (!lElectronCollection.isValid()){
43     edm::LogInfo("ERROR")<< "Error! Can't get electron by label. ";
44     }
45     if (debug_) std::cout << "** electroncollection = " << lElectronCollection->size() << " elements." << std::endl;
46     } catch(cms::Exception& e) {
47     std::cout << "AMM: Collection " << electronSrc_ << " not available! Exception : " << e.what() << ". " << std::endl;
48     }
49    
50     edm::Handle<std::vector<pat::Muon> > lMuonCollection;
51     try {
52     aEvt.getByLabel(muonSrc_,lMuonCollection);
53     if (!lMuonCollection.isValid()){
54     edm::LogInfo("ERROR")<< "Error! Can't get muon by label. ";
55     }
56     if (debug_) std::cout << "** muoncollection = " << lMuonCollection->size() << " elements." << std::endl;
57     } catch(cms::Exception& e) {
58     std::cout << "AMM: Collection " << muonSrc_ << " not available! Exception : " << e.what() << ". " << std::endl;
59     }
60    
61     edm::Handle<std::vector<pat::Tau> > lTauCollection;
62     try {
63     aEvt.getByLabel(tauSrc_,lTauCollection);
64     if (!lTauCollection.isValid()){
65     edm::LogInfo("ERROR")<< "Error! Can't get Tau by label. ";
66     }
67     if (debug_) std::cout << "** Taucollection = " << lTauCollection->size() << " elements." << std::endl;
68     } catch(cms::Exception& e) {
69     std::cout << "AMM: Collection " << tauSrc_ << " not available! Exception : " << e.what() << ". " << std::endl;
70     }
71    
72    
73     selected_.clear();
74    
75     for (std::vector<pat::Jet>::const_iterator iJet = aJetCol->begin();
76     iJet != aJetCol->end();
77     iJet++)
78     {
79     if (jetLeptonIsolation(*iJet,lElectronCollection,lMuonCollection,lTauCollection)) {
80     selected_.push_back( & * iJet );
81     }
82     }
83    
84     }//select
85    
86    
87 amagnan 1.2
88    
89 amagnan 1.1 bool JetDeltaRSelector::jetLeptonIsolation(const pat::Jet & aJet,
90     const edm::Handle<std::vector<pat::Electron> > & aColEle,
91     const edm::Handle<std::vector<pat::Muon> > & aColMu,
92     const edm::Handle<std::vector<pat::Tau> > & aColTau
93     )
94     {
95     double lDeltaRele = deltaRwithLepton<pat::Electron>(aJet,aColEle);
96     double lDeltaRmu = deltaRwithLepton<pat::Muon>(aJet,aColMu);
97     double lDeltaRtau = deltaRwithLepton<pat::Tau>(aJet,aColTau);
98    
99     //ask fabs so that if deltaR=-1 (if no lepton...) it returns true
100     if (fabs(lDeltaRele) <= jetLeptonIsolation_ || fabs(lDeltaRmu) <= jetLeptonIsolation_ || fabs(lDeltaRtau) <= jetLeptonIsolation_) return false;
101     return true;
102     }
103    
104    
105    
106    
107    
108    
109    
110    
111    
112    
113    
114    
115    
116    
117    
118