1 |
|
#include "VHbbAnalysis/HbbAnalyzer/interface/HbbCandidateFinder.h" |
2 |
|
|
3 |
+ |
struct CompareJetPt { |
4 |
+ |
bool operator()( const VHbbEvent::SimpleJet& j1, const VHbbEvent::SimpleJet& j2 ) const { |
5 |
+ |
return j1.fourMomentum.Pt() > j2.fourMomentum.Pt(); |
6 |
+ |
} |
7 |
+ |
}; |
8 |
|
|
9 |
+ |
struct CompareBTag { |
10 |
+ |
bool operator()(const VHbbEvent::SimpleJet& j1, const VHbbEvent::SimpleJet& j2 ) const { |
11 |
+ |
return j1.csv > j2.csv; |
12 |
+ |
} |
13 |
+ |
}; |
14 |
|
|
15 |
< |
|
6 |
< |
HbbCandidateFinder::HbbCandidateFinder(const edm::ParameterSet& iConfig): vhbbevent_(iConfig.getParameter<edm::InputTag>("VHbbEventLabel")) { |
15 |
> |
HbbCandidateFinder::HbbCandidateFinder(const edm::ParameterSet& iConfig): vhbbevent_(iConfig.getParameter<edm::InputTag>("VHbbEventLabel")), verbose_ (iConfig.getParameter<bool>("verbose")), jetPtThreshold(iConfig.getParameter<double>("jetPtThreshold")){ |
16 |
|
produces<std::vector<VHbbCandidate > >(); |
17 |
|
} |
18 |
|
|
31 |
|
std::auto_ptr<std::vector<VHbbCandidate> > vHbbCandidates( new std::vector<VHbbCandidate> ); |
32 |
|
|
33 |
|
edm::Handle<VHbbEvent> vHbbEvent; |
34 |
< |
iEvent.getByLabel(vhbbevent_, vHbbEvent); |
34 |
> |
// iEvent.getByLabel(vhbbevent_, vHbbEvent); |
35 |
> |
iEvent.getByType(vHbbEvent); |
36 |
|
|
37 |
|
|
38 |
|
// |
42 |
|
// hbbCandidateFinderAlgo(vHbbCandidates, vHbbEvent-> result()); |
43 |
|
// do nothing for a test |
44 |
|
|
45 |
< |
run(vHbbEvent.product(), vHbbCandidates); |
45 |
> |
run(vHbbEvent.product(),vHbbCandidates); |
46 |
> |
|
47 |
|
|
48 |
+ |
if (verbose_) |
49 |
+ |
std::cout <<" Pushing VHbb candidates: "<<vHbbCandidates->size()<<std::endl; |
50 |
|
|
51 |
|
iEvent.put(vHbbCandidates); |
52 |
|
|
56 |
|
// |
57 |
|
// first find the jets |
58 |
|
// |
46 |
– |
std::pair<int,int> jets = findDiJets(event->simpleJets2); |
47 |
– |
|
48 |
– |
if (jets.first<0 || jets.second<0) return ; |
59 |
|
|
60 |
+ |
VHbbEvent::SimpleJet j1,j2; |
61 |
+ |
std::vector<VHbbEvent::SimpleJet> addJets; |
62 |
+ |
bool foundJets = findDiJets(event->simpleJets2,j1,j2,addJets) ; |
63 |
+ |
|
64 |
+ |
if (verbose_){ |
65 |
+ |
std::cout <<" Found Dijets: "<<foundJets<< " Additional: "<<addJets.size()<< std::endl; |
66 |
+ |
} |
67 |
+ |
|
68 |
+ |
if (foundJets == false) return; |
69 |
|
// |
70 |
|
// search for a dilepton - just |
71 |
|
// |
72 |
< |
int ele = findDiElectron(event->diElectronInfo); |
73 |
< |
int mu = findDiMuon(event->diMuonInfo); |
74 |
< |
|
75 |
< |
if (ele<0 && mu < 0 ) return; |
72 |
> |
std::vector<VHbbEvent::MuonInfo> mu; |
73 |
> |
findMuons(event->muInfo,mu); |
74 |
> |
std::vector<VHbbEvent::ElectronInfo> ele; |
75 |
> |
findElectrons(event->eleInfo,ele); |
76 |
> |
|
77 |
> |
if (verbose_){ |
78 |
> |
std::cout <<" Electrons: "<< ele.size()<<std::endl; |
79 |
> |
std::cout <<" Muons : "<< mu.size()<<std::endl; |
80 |
> |
} |
81 |
> |
if (ele.size()<1 && mu.size() < 1 ) return; |
82 |
|
|
83 |
|
// |
84 |
|
// fill! |
85 |
|
// |
86 |
< |
VHbbCandidate temp; |
87 |
< |
temp.H.jets.push_back(event->simpleJets2[jets.first]); |
88 |
< |
temp.H.jets.push_back(event->simpleJets2[jets.second]); |
89 |
< |
temp.H.fourMomentum = (event->simpleJets2[jets.first]).fourMomentum+(event->simpleJets2[jets.second]).fourMomentum; |
90 |
< |
if (mu>-1){ |
91 |
< |
temp.V.muons.push_back((event->diMuonInfo[mu]).daughter1); |
92 |
< |
temp.V.muons.push_back((event->diMuonInfo[mu]).daughter2); |
93 |
< |
temp.V.fourMomentum = (temp.V.muons[0]).fourMomentum+(temp.V.muons[1]).fourMomentum; |
94 |
< |
}else{ |
95 |
< |
temp.V.electrons.push_back((event->diElectronInfo[ele]).daughter1); |
96 |
< |
temp.V.electrons.push_back((event->diElectronInfo[ele]).daughter2); |
97 |
< |
temp.V.fourMomentum = (temp.V.electrons[0]).fourMomentum+(temp.V.electrons[1]).fourMomentum; |
86 |
> |
VHbbCandidate tempMu; |
87 |
> |
VHbbCandidate tempE; |
88 |
> |
tempMu.H.jets.push_back(j1); |
89 |
> |
tempMu.H.jets.push_back(j2); |
90 |
> |
tempMu.H.fourMomentum = (j1).fourMomentum+(j2).fourMomentum; |
91 |
> |
tempMu.additionalJets = addJets; |
92 |
> |
tempE = tempMu; |
93 |
> |
TLorentzVector pMu,pE; |
94 |
> |
|
95 |
> |
if (mu.size()){ |
96 |
> |
for (std::vector<VHbbEvent::MuonInfo>::iterator it = mu.begin(); it !=mu.end(); ++it){ |
97 |
> |
tempMu.V.muons.push_back(*it); |
98 |
> |
} |
99 |
> |
} |
100 |
> |
if (ele.size()){ |
101 |
> |
for (std::vector<VHbbEvent::ElectronInfo>::iterator it = ele.begin(); it !=ele.end(); ++it){ |
102 |
> |
tempE.V.electrons.push_back(*it); |
103 |
> |
} |
104 |
|
} |
105 |
|
|
106 |
< |
candidates->push_back(temp); |
107 |
< |
|
106 |
> |
if (tempMu.V.muons.size()){ |
107 |
> |
candidates->push_back(tempMu); |
108 |
> |
} |
109 |
> |
if (tempE.V.electrons.size()){ |
110 |
> |
candidates->push_back(tempE); |
111 |
> |
} |
112 |
|
} |
113 |
|
|
114 |
< |
std::pair <int, int> HbbCandidateFinder::findDiJets (const std::vector<VHbbEvent::SimpleJet>& jets){ |
114 |
> |
bool HbbCandidateFinder::findDiJets (const std::vector<VHbbEvent::SimpleJet>& jets, VHbbEvent::SimpleJet& j1, VHbbEvent::SimpleJet& j2,std::vector<VHbbEvent::SimpleJet>& addJets){ |
115 |
|
|
116 |
< |
// |
117 |
< |
// select jets |
118 |
< |
// |
119 |
< |
// |
120 |
< |
|
121 |
< |
unsigned int maxJets = jets.size(); |
122 |
< |
int i1(-99),i2(-99); |
123 |
< |
float btag_max(-100); |
124 |
< |
// |
125 |
< |
// do the combinatorics |
126 |
< |
|
127 |
< |
if (maxJets<2) return pair<int,int>(-1,-1); |
128 |
< |
|
129 |
< |
for (unsigned int j1=0; j1<maxJets-1; j1++) { |
130 |
< |
for (unsigned int j2=j1+1; j2<maxJets; j2++) { |
131 |
< |
float j1_btag = (jets)[j1].csv; |
132 |
< |
float j2_btag = (jets)[j2].csv; |
133 |
< |
|
134 |
< |
if (j1_btag<=0.0 || j2_btag<=0.0) continue; |
135 |
< |
|
136 |
< |
if ((jets)[j1].fourMomentum.Pt()< 30. || |
137 |
< |
(jets)[j2].fourMomentum.Pt()< 30.) continue; |
138 |
< |
|
139 |
< |
if (j1_btag+j2_btag>btag_max) { |
140 |
< |
btag_max = j1_btag+j2_btag; |
141 |
< |
i1 = j1; |
142 |
< |
i2 = j2; |
143 |
< |
} |
116 |
> |
std::vector<VHbbEvent::SimpleJet> tempJets; |
117 |
> |
|
118 |
> |
for (unsigned int i=0 ; i< jets.size(); ++i){ |
119 |
> |
if (jets[i].fourMomentum.Pt()> jetPtThreshold) |
120 |
> |
tempJets.push_back(jets[i]); |
121 |
> |
} |
122 |
> |
|
123 |
> |
CompareBTag bTagComparator; |
124 |
> |
|
125 |
> |
if (tempJets.size()<2) return false; |
126 |
> |
|
127 |
> |
std::sort(tempJets.begin(), tempJets.end(), bTagComparator); |
128 |
> |
|
129 |
> |
j1 = tempJets[0]; |
130 |
> |
j2 = tempJets[1]; |
131 |
> |
// |
132 |
> |
// additional jets |
133 |
> |
// |
134 |
> |
if (tempJets.size()>2){ |
135 |
> |
for (unsigned int i=2 ; i< tempJets.size(); ++i){ |
136 |
> |
addJets.push_back(tempJets[i]); |
137 |
> |
} |
138 |
> |
} |
139 |
> |
CompareJetPt ptComparator; |
140 |
> |
|
141 |
> |
std::sort(addJets.begin(), addJets.end(), ptComparator); |
142 |
> |
return true; |
143 |
> |
} |
144 |
> |
|
145 |
> |
void HbbCandidateFinder::findMuons(const std::vector<VHbbEvent::MuonInfo>& muons, std::vector<VHbbEvent::MuonInfo>& out){ |
146 |
> |
/* Use: |
147 |
> |
For both W -> mu nu and Z -> mu mu, we adopt the standard VBTF muon selection described in VbtfWmunuBaselineSelection. The explicit cuts are reproduced here: |
148 |
> |
|
149 |
> |
We use RECO Muons that are both Global and Tracker |
150 |
> |
chi2/ndof < 10 for the global muon fit |
151 |
> |
The track associated to the muon must have |
152 |
> |
>= 1 pixel hits |
153 |
> |
>= 10 pixel + strip hits |
154 |
> |
>= 1 valid hit in the muon chambers |
155 |
> |
>= 2 muon stations |
156 |
> |
|dxy| < 0.2 |
157 |
> |
|eta| < 2.4 |
158 |
> |
Relative combined isolation (R) is required to be < 0.15 |
159 |
> |
R = [Sum pT(trks) + Et(ECAL) + Et(HCAL)] / pT(mu) computed in a cone of radius 0.3 in eta-phi |
160 |
> |
pT(mu) > 20 GeV |
161 |
> |
*/ |
162 |
> |
for (std::vector<VHbbEvent::MuonInfo>::const_iterator it = muons.begin(); it!= muons.end(); ++it){ |
163 |
> |
if ( |
164 |
> |
(*it).nPixelHits>= 1 && |
165 |
> |
(*it).nHits +(*it).nPixelHits >= 10 && |
166 |
> |
// |
167 |
> |
// sta muon not saved???? |
168 |
> |
(*it).ipDb<.2 && |
169 |
> |
((*it).hIso+(*it).eIso+(*it).tIso)/(*it).fourMomentum.Pt()<.15 && |
170 |
> |
(*it).fourMomentum.Eta()<2.4 && |
171 |
> |
(*it).fourMomentum.Pt()>20) { |
172 |
> |
out.push_back(*it); |
173 |
|
} |
174 |
|
} |
111 |
– |
if (i1>=0 && i2>=0) return pair<int,int>(i1,i2); |
112 |
– |
else return pair<int,int>(-1,-1); |
175 |
|
} |
176 |
|
|
115 |
– |
int HbbCandidateFinder::findDiMuon (const std::vector<VHbbEvent::DiMuonInfo>& dimu){ |
116 |
– |
int res = -99; |
117 |
– |
if (dimu.size()>0) res= 1; |
118 |
– |
return res; |
177 |
|
|
178 |
+ |
void HbbCandidateFinder::findElectrons(const std::vector<VHbbEvent::ElectronInfo>& electrons, std::vector<VHbbEvent::ElectronInfo>& out){ |
179 |
+ |
/* |
180 |
+ |
We adopt the standard cut-based selection from VBTF described in detail here. |
181 |
+ |
|
182 |
+ |
Z -> ee |
183 |
+ |
gsf electrons |
184 |
+ |
VBTF WP95 |
185 |
+ |
|eta|<2.5, excluding the gap 1.44 < |eta| < 1.57 |
186 |
+ |
pT(e) > 20 |
187 |
+ |
|
188 |
+ |
W -> e nu |
189 |
+ |
gsf electrons |
190 |
+ |
VBTF WP80 |
191 |
+ |
|eta|<2.5, excluding the gap 1.44 < |eta| < 1.57 |
192 |
+ |
pT(e) > 30 |
193 |
+ |
*/ |
194 |
+ |
|
195 |
+ |
for (std::vector<VHbbEvent::ElectronInfo>::const_iterator it = electrons.begin(); it!= electrons.end(); ++it){ |
196 |
+ |
if ( |
197 |
+ |
// fake |
198 |
+ |
// (*it).id95> && |
199 |
+ |
std::abs((*it).fourMomentum.Eta()) < 2.5 && |
200 |
+ |
!( std::abs((*it).fourMomentum.Eta()) < 1.57 && std::abs((*it).fourMomentum.Eta()) > 1.44) && |
201 |
+ |
(*it).fourMomentum.Pt()>30 |
202 |
+ |
){ |
203 |
+ |
out.push_back(*it); |
204 |
+ |
} |
205 |
+ |
} |
206 |
|
} |
121 |
– |
int HbbCandidateFinder::findDiElectron (const std::vector<VHbbEvent::DiElectronInfo>& die){ |
122 |
– |
int res = -99; |
123 |
– |
if (die.size()>0) res= 1; |
124 |
– |
return res; |
125 |
– |
} |
126 |
– |
|
207 |
|
|
208 |
|
|
209 |
|
//define this as a plug-in |