ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/HbbAnalysis/interface/JetFlavour.hh
Revision: 1.1
Committed: Thu May 28 15:12:43 2009 UTC (15 years, 11 months ago) by amagnan
Content type: text/plain
Branch: MAIN
Log Message:
add JetFlavour class + selectors

File Contents

# User Rev Content
1 amagnan 1.1 #ifndef HbbAnalysis_JetFlavour_hh
2     #define HbbAnalysis_JetFlavour_hh
3    
4     #include <vector>
5     #include <string>
6     #include <cassert>
7    
8     #include "DataFormats/Common/interface/Handle.h"
9     #include "DataFormats/HepMCCandidate/interface/GenParticle.h"
10     #include "DataFormats/PatCandidates/interface/Jet.h"
11    
12     #include "FWCore/ServiceRegistry/interface/Service.h"
13     #include "PhysicsTools/UtilAlgos/interface/TFileService.h"
14    
15     #include "TH1F.h"
16     #include "TH2F.h"
17    
18    
19     namespace HbbAnalysis {//namespace
20    
21     class JetFlavour {
22    
23    
24     public:
25    
26     //to reset counters and initialise histograms
27     void Initialise(TFileDirectory & aDir, unsigned short aDebug, const unsigned int aFlavour);
28    
29     //find partons of given flavour: looking for quarks with
30     //more than one parent, and status 3
31     //written for Zbb/Zcc or QCD events. If W is found, return 0.
32     //Otherwise, return the number of partons found.
33     unsigned int fillPartons(const edm::Handle<reco::GenParticleCollection> & aGenParticles);
34    
35     inline const std::vector<unsigned int> & partons(){
36     return partons_;
37     }
38    
39     inline const unsigned int nPartons(){
40     assert (eid_.size() == partons_.size());
41     assert (muid_.size() == partons_.size());
42     assert (flav_.size() == partons_.size());
43     return partons_.size();
44     }
45    
46     inline const reco::GenParticle & parton(const edm::Handle<reco::GenParticleCollection> & aGenParticles,unsigned int aIndex){
47     assert(aIndex < partons_.size());
48     return (*aGenParticles).at(partons_.at(aIndex));
49     }
50    
51     inline const std::vector<unsigned int> & eids() {
52     assert (eid_.size() == partons_.size());
53     return eid_;
54     }
55    
56     inline const unsigned int nElectronDecays(){
57     assert (eid_.size() == partons_.size());
58     return eid_.size();
59     }
60    
61     inline const reco::GenParticle & stableElectron(const edm::Handle<reco::GenParticleCollection> & aGenParticles,unsigned int aIndex){
62     assert (eid_.size() == partons_.size());
63     assert(aIndex < eid_.size());
64     return (*aGenParticles).at(eid_.at(aIndex));
65     }
66    
67     inline const std::vector<unsigned int> & muids() {
68     assert (muid_.size() == partons_.size());
69     return muid_;
70     }
71    
72     inline const unsigned int nMuonDecays(){
73     assert (muid_.size() == partons_.size());
74     return muid_.size();
75     }
76    
77     inline const reco::GenParticle & stableMuon(const edm::Handle<reco::GenParticleCollection> & aGenParticles,unsigned int aIndex){
78     assert (muid_.size() == partons_.size());
79     assert(aIndex < muid_.size());
80     return (*aGenParticles).at(muid_.at(aIndex));
81     }
82    
83     inline const std::vector<unsigned int> & flavours() {
84     assert (flav_.size() == partons_.size());
85     return flav_;
86     }
87    
88     inline const unsigned int nFlavours(){
89     assert (flav_.size() == partons_.size());
90     return flav_.size();
91     }
92    
93     inline const unsigned int partonFlavour(unsigned int aIndex){
94     assert (flav_.size() == partons_.size());
95     assert(aIndex < flav_.size());
96     return flav_.at(aIndex);
97     }
98    
99    
100     std::pair<int,unsigned int> partonMatchingGenJet(const pat::Jet & aJet, const edm::Handle<reco::GenParticleCollection> & aGenParticles, double aDR);
101    
102     unsigned int leptonMatchingGenJet(const pat::Jet & aJet, const edm::Handle<reco::GenParticleCollection> & aGenParticles, double aDR);
103    
104     unsigned int partonMatchingRecoJet(const pat::Jet & aJet, const edm::Handle<reco::GenParticleCollection> & aGenParticles, double aDR);
105    
106     unsigned int leptonMatchingRecoJet(const pat::Jet & aJet, const edm::Handle<reco::GenParticleCollection> & aGenParticles, double aDR);
107    
108     bool compareParticles(const reco::Candidate * aMum, const reco::GenParticle & aP);
109    
110     void printParticle(const reco::GenParticle & aP) const;
111    
112     void printSummary();
113    
114     private:
115    
116     unsigned short debug_;
117    
118     //flavour of partons required: 3=u,d,s,g,
119     // 4=c, 5=b, 21=g, 45=b and/or c.
120     unsigned int flavour_;
121    
122     //vector of references to the initial partons of the hard-scattering
123     //found by looking for quarks with 2 parents and status 3
124     std::vector<unsigned int> partons_;
125    
126     //flavour:
127     //for b or c jets: 0=all, 1=had, 2=e, 3=mu
128     //for light-jet : 0=all, 2=u,d,s, 3=gluon
129     std::vector<unsigned int> flav_;
130    
131     //vector of references to the status 1 final lepton
132     std::vector<unsigned int> eid_;
133     std::vector<unsigned int> muid_;
134    
135     //counters to print event summary
136     unsigned int nTot_;
137     unsigned int nLight_;
138     unsigned int nGluon_;
139     unsigned int nCharm_;
140     unsigned int nBottom_;
141     unsigned int nTotal_;
142     unsigned int nHeavy_;
143     unsigned int nSemiHeavy_;
144    
145     unsigned int nZEvts_;
146     unsigned int nWEvts_;
147    
148     //control histograms
149     TH1F *p_nQuarks;
150     TH1F *p_nAntiQuarks;
151     TH1F *p_partonFlavour;
152    
153     TH1F *p_parentOfStableFlavour;
154     TH1F *p_stableFlavour;
155     TH1F *p_numberOfParentsOfStable;
156    
157    
158     };
159    
160     }//namespace
161    
162    
163     #endif //HbbAnalysis_JetFlavour_hh