1 |
#include "../interface/Selection.h"
|
2 |
|
3 |
//____CONSTRUCTORS______________________________________________________//
|
4 |
|
5 |
Selection::Selection() {
|
6 |
setJetCuts();
|
7 |
setMuonCuts();
|
8 |
setDiMuonCuts();
|
9 |
setElectronCuts();
|
10 |
setLooseMuonCuts();
|
11 |
setLooseElectronCuts();
|
12 |
setPlainElectronCuts();
|
13 |
}
|
14 |
|
15 |
Selection::Selection(const std::vector<TRootJet*>& jets_, const std::vector<TRootMuon*>& muons_, const std::vector<TRootMET*>& mets_){
|
16 |
setJetCuts();
|
17 |
setMuonCuts();
|
18 |
setDiMuonCuts();
|
19 |
setElectronCuts();
|
20 |
setLooseMuonCuts();
|
21 |
setLooseElectronCuts();
|
22 |
setPlainElectronCuts();
|
23 |
for(unsigned int i=0;i<jets_.size();i++) jets.push_back(jets_[i]);
|
24 |
for(unsigned int i=0;i<muons_.size();i++) muons.push_back(muons_[i]);
|
25 |
for(unsigned int i=0;i<mets_.size();i++) mets.push_back(mets_[i]);
|
26 |
}
|
27 |
|
28 |
Selection::Selection(const std::vector<TRootJet*>& jets_, const std::vector<TRootMuon*>& muons_, const std::vector<TRootElectron*>& electrons_, const std::vector<TRootMET*>& mets_){
|
29 |
setJetCuts();
|
30 |
setMuonCuts();
|
31 |
setDiMuonCuts();
|
32 |
setElectronCuts();
|
33 |
setLooseMuonCuts();
|
34 |
setLooseElectronCuts();
|
35 |
setPlainElectronCuts();
|
36 |
for(unsigned int i=0;i<jets_.size();i++) jets.push_back(jets_[i]);
|
37 |
for(unsigned int i=0;i<muons_.size();i++) muons.push_back(muons_[i]);
|
38 |
for(unsigned int i=0;i<electrons_.size();i++) electrons.push_back(electrons_[i]);
|
39 |
for(unsigned int i=0;i<mets_.size();i++) mets.push_back(mets_[i]);
|
40 |
}
|
41 |
|
42 |
Selection::Selection(const Selection& s) {
|
43 |
// copy the objects
|
44 |
jets = s.jets;
|
45 |
electrons = s.electrons;
|
46 |
muons = s.muons;
|
47 |
mets = s.mets;
|
48 |
// copy the cutvalues
|
49 |
setJetCuts(s.JetPtThreshold_,s.JetEtaThreshold_,s.JetEMFThreshold_,s.n90HitsThreshold_,s.fHPDThreshold_,s.DRJetElectron_,s.DRJetMuon_);
|
50 |
setMuonCuts(s.MuonPtThreshold_,s.MuonEtaThreshold_,s.MuonRelIso_,s.MuonNofValidHits_,s.Muond0Cut_,s.MuonDRJetsCut_,s.MuonNMatches_,s.MuonDistVzPVz_,s.MuonNPixelLayersWithMeasurement_);
|
51 |
setDiMuonCuts(s.MuonPtThreshold_,s.MuonEtaThreshold_,s.MuonRelIso_,s.MuonNofValidHits_,s.Muond0Cut_,s.MuonDRJetsCut_);
|
52 |
setLooseMuonCuts(s.JetPtThreshold_,s.JetEtaThreshold_,s.MuonRelIso_);
|
53 |
setElectronCuts(s.ElectronEtThreshold_,s.ElectronEtaThreshold_,s.ElectronRelIso_,s.Electrond0Cut_,s.ElectronDistVzPVz_);
|
54 |
setLooseElectronCuts(s.ElectronEtThreshold_,s.ElectronEtaThreshold_,s.ElectronRelIso_);
|
55 |
setPlainElectronCuts(s.ElectronEtThreshold_,s.ElectronEtaThreshold_);
|
56 |
}
|
57 |
|
58 |
//______________________________________________________________________//
|
59 |
|
60 |
//____DESTRUCTOR________________________________________________________//
|
61 |
|
62 |
Selection::~Selection() {
|
63 |
jets.clear();
|
64 |
electrons.clear();
|
65 |
muons.clear();
|
66 |
mets.clear();
|
67 |
}
|
68 |
|
69 |
//______________________________________________________________________//
|
70 |
|
71 |
|
72 |
//____CUT INITIALISATION________________________________________________//
|
73 |
|
74 |
void Selection::setJetCuts(float Pt, float Eta, float EMF, float n90Hits, float fHPD, float dRJetElectron, float dRJetMuon) {
|
75 |
JetPtThreshold_ = Pt;
|
76 |
JetEtaThreshold_ = Eta;
|
77 |
JetEMFThreshold_ = EMF;
|
78 |
n90HitsThreshold_ = n90Hits;
|
79 |
fHPDThreshold_ = fHPD;
|
80 |
DRJetElectron_ = dRJetElectron;
|
81 |
DRJetMuon_ = dRJetMuon; // only used for PFlow without PF2PAT
|
82 |
}
|
83 |
|
84 |
void Selection::setJetCuts() {
|
85 |
setJetCuts(15.,2.4,0.01,1.,0.98,0.3,0.1); // refSelV4 values
|
86 |
}
|
87 |
|
88 |
void Selection::setElectronCuts(float Et, float Eta, float RelIso, float d0, float DistVzPVz) {
|
89 |
ElectronEtThreshold_ = Et;
|
90 |
ElectronEtaThreshold_ = Eta;
|
91 |
ElectronRelIso_ = RelIso;
|
92 |
Electrond0Cut_ = d0;
|
93 |
ElectronDistVzPVz_ = DistVzPVz;
|
94 |
|
95 |
// setup VBTF cuts (DO NOT TOUCH)
|
96 |
cutsVBTFWP70["sigmaIEtaIEta_B"]=0.01;
|
97 |
cutsVBTFWP70["deltaPhi_B"]=0.03;
|
98 |
cutsVBTFWP70["deltaETA_B"]=0.004;
|
99 |
cutsVBTFWP70["HoverE_B"]=0.025;
|
100 |
cutsVBTFWP70["sigmaIEtaIEta_E"]=0.03;
|
101 |
cutsVBTFWP70["deltaPhi_E"]=0.02;
|
102 |
cutsVBTFWP70["deltaETA_E"]=0.005;
|
103 |
cutsVBTFWP70["HoverE_E"]=0.025;
|
104 |
|
105 |
}
|
106 |
|
107 |
void Selection::setElectronCuts() {
|
108 |
setElectronCuts(20,2.4,0.1,0.02,1);
|
109 |
}
|
110 |
|
111 |
void Selection::setLooseElectronCuts(float Et, float Eta, float RelIso) {
|
112 |
ElectronLooseEtThreshold_ = Et;
|
113 |
ElectronLooseEtaThreshold_ = Eta;
|
114 |
ElectronLooseRelIso_ = RelIso;
|
115 |
|
116 |
// setup VBTF cuts (DO NOT TOUCH)
|
117 |
cutsVBTFWP95["sigmaIEtaIEta_B"]=0.01;
|
118 |
cutsVBTFWP95["deltaPhi_B"]=0.8;
|
119 |
cutsVBTFWP95["deltaETA_B"]=0.007;
|
120 |
cutsVBTFWP95["HoverE_B"]=0.15;
|
121 |
cutsVBTFWP95["sigmaIEtaIEta_E"]=0.03;
|
122 |
cutsVBTFWP95["deltaPhi_E"]=0.7;
|
123 |
cutsVBTFWP95["deltaETA_E"]=0.01;
|
124 |
cutsVBTFWP95["HoverE_E"]=0.07;
|
125 |
}
|
126 |
|
127 |
void Selection::setLooseElectronCuts() {
|
128 |
setLooseElectronCuts(15,2.5,0.2); // refSelV4 (mu) values
|
129 |
}
|
130 |
|
131 |
void Selection::setPlainElectronCuts(float Et, float Eta) {
|
132 |
ElectronLooseEtThreshold_ = Et;
|
133 |
ElectronLooseEtaThreshold_ = Eta;
|
134 |
}
|
135 |
|
136 |
void Selection::setPlainElectronCuts() {
|
137 |
setPlainElectronCuts(10,2.5);
|
138 |
}
|
139 |
|
140 |
void Selection::setMuonCuts(float Pt, float Eta, float RelIso, int NValidHits, float d0, float DRJets, int NMatches, float DistVzPVz, int NPixelLayersWithMeas) {
|
141 |
MuonPtThreshold_ = Pt;
|
142 |
MuonEtaThreshold_ = Eta;
|
143 |
MuonRelIso_ = RelIso;
|
144 |
MuonNofValidHits_ = NValidHits;
|
145 |
Muond0Cut_ = d0;
|
146 |
MuonDRJetsCut_ = DRJets;
|
147 |
MuonNMatches_ = NMatches;
|
148 |
MuonDistVzPVz_ = DistVzPVz;
|
149 |
MuonNPixelLayersWithMeasurement_ = NPixelLayersWithMeas;
|
150 |
}
|
151 |
|
152 |
void Selection::setMuonCuts() {
|
153 |
setMuonCuts(20,2.4,0.05,10,0.02,0.3,1,1,1); // refSelV4 values
|
154 |
}
|
155 |
|
156 |
void Selection::setDiMuonCuts(float Pt, float Eta, float RelIso, int NValidHits, float d0, float DRJets) {
|
157 |
MuonPtThreshold_ = Pt;
|
158 |
MuonEtaThreshold_ = Eta;
|
159 |
MuonRelIso_ = RelIso;
|
160 |
MuonNofValidHits_ = NValidHits;
|
161 |
Muond0Cut_ = d0;
|
162 |
MuonDRJetsCut_ = DRJets;
|
163 |
}
|
164 |
|
165 |
void Selection::setDiMuonCuts() {
|
166 |
setDiMuonCuts(20,2.4,0.15,10,0.02,0.3); // refSelV4 values
|
167 |
}
|
168 |
|
169 |
void Selection::setLooseMuonCuts(float Pt, float Eta, float RelIso) {
|
170 |
MuonLoosePtThreshold_ = Pt;
|
171 |
MuonLooseEtaThreshold_ = Eta;
|
172 |
MuonLooseRelIso_ = RelIso;
|
173 |
}
|
174 |
|
175 |
void Selection::setLooseMuonCuts() {
|
176 |
setLooseMuonCuts(10,2.5,0.2); // refSelV4 (mu+el) values
|
177 |
}
|
178 |
|
179 |
//______________________________________________________________________//
|
180 |
|
181 |
//__EXTRA METHODS_______________________________________________________//
|
182 |
|
183 |
bool passVBTFID(TRootElectron* el, std::map<std::string,float> cuts) {
|
184 |
|
185 |
//try the cuts manually
|
186 |
bool passvbtf = false;
|
187 |
|
188 |
float sigmaiEtaiEta = el->sigmaIEtaIEta();
|
189 |
float deltaPhi = el->deltaPhiIn();
|
190 |
float deltaETA = el->deltaEtaIn();
|
191 |
float HoverE = el->hadronicOverEm();
|
192 |
|
193 |
if (fabs(el->superClusterEta()) < 1.4442)
|
194 |
if (sigmaiEtaiEta < cuts["sigmaIEtaIEta_B"])
|
195 |
if (fabs(deltaPhi) < cuts["deltaPhi_B"])
|
196 |
if (fabs(deltaETA) < cuts["deltaETA_B"])
|
197 |
if (HoverE < cuts["HoverE_B"])
|
198 |
passvbtf=true;
|
199 |
|
200 |
if (fabs(el->superClusterEta()) > 1.5660)
|
201 |
if (sigmaiEtaiEta < cuts["sigmaIEtaIEta_E"])
|
202 |
if (fabs(deltaPhi) < cuts["deltaPhi_E"])
|
203 |
if (fabs(deltaETA) < cuts["deltaETA_E"])
|
204 |
if (HoverE < cuts["HoverE_E"])
|
205 |
passvbtf=true;
|
206 |
|
207 |
return passvbtf;
|
208 |
|
209 |
}
|
210 |
|
211 |
//______________________________________________________________________//
|
212 |
|
213 |
//____SELECTION GETTERS_________________________________________________//
|
214 |
|
215 |
// ______________JETS_________________________________________________//
|
216 |
|
217 |
std::vector<TRootJet*> Selection::GetSelectedJets(float PtThr, float EtaThr, bool applyJetID) const{
|
218 |
std::vector<TRootJet*> selectedJets;
|
219 |
|
220 |
for(unsigned int i=0;i<jets.size();i++){
|
221 |
|
222 |
TRootJet* init_jet = (TRootJet*) jets[i];
|
223 |
|
224 |
if (init_jet->jetType() == 1) { // CaloJets
|
225 |
|
226 |
const TRootCaloJet* CaloJet = static_cast<const TRootCaloJet*>(init_jet);
|
227 |
|
228 |
if(fabs(CaloJet->Eta())<EtaThr && CaloJet->Pt()>PtThr) {
|
229 |
|
230 |
if( applyJetID ) {
|
231 |
if ( CaloJet->ecalEnergyFraction() > JetEMFThreshold_) {
|
232 |
if (CaloJet->fHPD() < fHPDThreshold_ ) {
|
233 |
if (CaloJet->n90Hits()> n90HitsThreshold_ ) {
|
234 |
selectedJets.push_back(init_jet);
|
235 |
}
|
236 |
}
|
237 |
}
|
238 |
}
|
239 |
else selectedJets.push_back(init_jet);
|
240 |
|
241 |
}
|
242 |
}
|
243 |
|
244 |
else if (init_jet->jetType() == 2) { // PFJets
|
245 |
|
246 |
const TRootPFJet* PFJet = static_cast<const TRootPFJet*>(init_jet);
|
247 |
|
248 |
if(fabs(PFJet->Eta())<JetEtaThreshold_ && PFJet->Pt()>JetPtThreshold_)
|
249 |
if ( applyJetID ) {
|
250 |
if (PFJet->nConstituents() > 1 )
|
251 |
if (PFJet->chargedEmEnergyFraction() < 0.99 )
|
252 |
if (PFJet->neutralHadronEnergyFraction() < 0.99 )
|
253 |
if (PFJet->neutralEmEnergyFraction() < 0.99 )
|
254 |
if (fabs(PFJet->Eta()) >= 2.4 || PFJet->chargedHadronEnergyFraction() > 0)
|
255 |
if (fabs(PFJet->Eta()) >= 2.4 || PFJet->chargedMultiplicity() > 0)
|
256 |
selectedJets.push_back(init_jet);
|
257 |
} else selectedJets.push_back(init_jet);
|
258 |
}
|
259 |
|
260 |
else if (init_jet->jetType() == 3) { // JPTJets
|
261 |
|
262 |
const TRootJPTJet* JPTJet = static_cast<const TRootJPTJet*>(init_jet);
|
263 |
|
264 |
if(fabs(JPTJet->Eta())<JetEtaThreshold_ && JPTJet->Pt()>JetPtThreshold_)
|
265 |
if( applyJetID ) {
|
266 |
if ( JPTJet->ecalEnergyFraction() > JetEMFThreshold_) {
|
267 |
if (JPTJet->fHPD() < fHPDThreshold_ ) {
|
268 |
if (JPTJet->n90Hits()> n90HitsThreshold_ ) {
|
269 |
selectedJets.push_back(init_jet);
|
270 |
}
|
271 |
}
|
272 |
}
|
273 |
}
|
274 |
else selectedJets.push_back(init_jet);
|
275 |
}
|
276 |
}
|
277 |
std::sort(selectedJets.begin(),selectedJets.end(),HighestPt());
|
278 |
return selectedJets;
|
279 |
}
|
280 |
|
281 |
std::vector<TRootJet*> Selection::GetSelectedJets(float PtThr, float EtaThr, vector<TLorentzVector*> lepton, float dRLeptonJet, bool applyJetID) const {
|
282 |
std::vector<TRootJet*> init_jets = GetSelectedJets(PtThr,EtaThr,applyJetID);
|
283 |
std::vector<TRootJet*> selectedJets;
|
284 |
for (unsigned int i=0; i<init_jets.size(); i++) {
|
285 |
float minDrElJet = 9999999999.;
|
286 |
for (unsigned int j=0; j<lepton.size(); j++) {
|
287 |
TLorentzVector* l = (TLorentzVector*) lepton[j];
|
288 |
float dr = l->DeltaR(*init_jets[i]);
|
289 |
if ( dr < minDrElJet ) minDrElJet = dr;
|
290 |
}
|
291 |
|
292 |
if (minDrElJet >= dRLeptonJet)
|
293 |
selectedJets.push_back(init_jets[i]);
|
294 |
}
|
295 |
std::sort(selectedJets.begin(),selectedJets.end(),HighestPt());
|
296 |
return selectedJets;
|
297 |
}
|
298 |
|
299 |
std::vector<TRootJet*> Selection::GetSelectedJets(float PtThr, float EtaThr, vector<TRootMuon*> muons, float dRLeptonJet, bool applyJetID) const {
|
300 |
std::vector<TLorentzVector*> leptons;
|
301 |
for (unsigned int i=0; i<muons.size(); i++)
|
302 |
leptons.push_back((TLorentzVector*)muons[i]);
|
303 |
return GetSelectedJets(JetPtThreshold_,JetEtaThreshold_,leptons,DRJetMuon_,applyJetID);
|
304 |
}
|
305 |
|
306 |
std::vector<TRootJet*> Selection::GetSelectedJets(float PtThr, float EtaThr, vector<TRootElectron*> electrons, float dRLeptonJet, bool applyJetID) const {
|
307 |
std::vector<TLorentzVector*> leptons;
|
308 |
for (unsigned int i=0; i<electrons.size(); i++)
|
309 |
leptons.push_back((TLorentzVector*)electrons[i]);
|
310 |
return GetSelectedJets(JetPtThreshold_,JetEtaThreshold_,leptons,DRJetElectron_,applyJetID);
|
311 |
}
|
312 |
|
313 |
std::vector<TRootJet*> Selection::GetSelectedJets(vector<TRootMuon*> muons, bool applyJetID) const {
|
314 |
std::vector<TLorentzVector*> leptons;
|
315 |
for (unsigned int i=0; i<muons.size(); i++)
|
316 |
leptons.push_back((TLorentzVector*)muons[i]);
|
317 |
return GetSelectedJets(JetPtThreshold_,JetEtaThreshold_,leptons,DRJetMuon_,applyJetID);
|
318 |
}
|
319 |
|
320 |
std::vector<TRootJet*> Selection::GetSelectedJets(vector<TRootElectron*> electrons, bool applyJetID) const {
|
321 |
std::vector<TLorentzVector*> leptons;
|
322 |
for (unsigned int i=0; i<electrons.size(); i++)
|
323 |
leptons.push_back((TLorentzVector*)electrons[i]);
|
324 |
return GetSelectedJets(JetPtThreshold_,JetEtaThreshold_,leptons,DRJetElectron_,applyJetID);
|
325 |
}
|
326 |
|
327 |
|
328 |
std::vector<TRootJet*> Selection::GetSelectedJets(bool applyJetID) const{
|
329 |
return GetSelectedJets(JetPtThreshold_,JetEtaThreshold_,applyJetID);
|
330 |
}
|
331 |
|
332 |
std::vector<TRootJet*> Selection::GetSelectedBJets(const std::vector<TRootJet*>& seljets, int& btagAlgo, float& btagCut) const{
|
333 |
std::vector<TRootJet*> bjets;
|
334 |
Float_t btagDisc = 0;
|
335 |
for(unsigned int i = 0; i<seljets.size(); i++) {
|
336 |
if( btagAlgo == 0) btagDisc = seljets[i]->btag_trackCountingHighEffBJetTags();
|
337 |
else if(btagAlgo == 1) btagDisc = seljets[i]->btag_trackCountingHighPurBJetTags();
|
338 |
else if(btagAlgo == 2) btagDisc = seljets[i]->btag_jetProbabilityBJetTags();
|
339 |
else if(btagAlgo == 3) btagDisc = seljets[i]->btag_jetBProbabilityBJetTags();
|
340 |
else if(btagAlgo == 4) btagDisc = seljets[i]->btag_simpleSecondaryVertexHighEffBJetTags();
|
341 |
else if(btagAlgo == 5) btagDisc = seljets[i]->btag_simpleSecondaryVertexHighPurBJetTags();
|
342 |
else if(btagAlgo == 6) btagDisc = seljets[i]->btag_combinedSecondaryVertexBJetTags();
|
343 |
else btagDisc = -999999;
|
344 |
if(btagDisc>btagCut) bjets.push_back(seljets[i]);
|
345 |
}
|
346 |
return bjets;
|
347 |
}
|
348 |
|
349 |
// ______________MUONS________________________________________________//
|
350 |
|
351 |
std::vector<TRootMuon*> Selection::GetSelectedMuons(float PtThr, float EtaThr,float MuonRelIso) const{
|
352 |
std::vector<TRootMuon*> selectedMuons;
|
353 |
for(unsigned int i=0;i<muons.size();i++){
|
354 |
if(muons[i]->isGlobalMuon() && muons[i]->isTrackerMuon() && muons[i]->idGlobalMuonPromptTight()
|
355 |
&& muons[i]->Pt()>PtThr
|
356 |
&& fabs(muons[i]->Eta())<EtaThr
|
357 |
&& muons[i]->relativeIso03() < MuonRelIso
|
358 |
&& fabs(muons[i]->d0()) <Muond0Cut_
|
359 |
&& muons[i]->nofValidHits()>MuonNofValidHits_
|
360 |
&& muons[i]->nofMatches()>MuonNMatches_
|
361 |
&& muons[i]->nofPixelLayersWithMeasurement() >= MuonNPixelLayersWithMeasurement_
|
362 |
) {
|
363 |
|
364 |
selectedMuons.push_back(muons[i]);
|
365 |
}
|
366 |
}
|
367 |
std::sort(selectedMuons.begin(),selectedMuons.end(),HighestPt());
|
368 |
return selectedMuons;
|
369 |
}
|
370 |
|
371 |
std::vector<TRootMuon*> Selection::GetSelectedMuons() const{
|
372 |
return GetSelectedMuons(MuonPtThreshold_,MuonEtaThreshold_,MuonRelIso_);
|
373 |
}
|
374 |
|
375 |
std::vector<TRootMuon*> Selection::GetSelectedMuons(float PtThr, float EtaThr,float MuonRelIso, vector<TRootJet*> selJets) const{
|
376 |
std::vector<TRootMuon*> selectedMuons;
|
377 |
std::vector<TRootMuon*> init_muons=GetSelectedMuons(PtThr,EtaThr,MuonRelIso);
|
378 |
for(unsigned int i=0;i<init_muons.size();i++){
|
379 |
float mindRMuJet = 999999.;
|
380 |
TRootJet* jet;
|
381 |
for(unsigned int j=0;j<selJets.size();j++) {
|
382 |
jet = selJets.at(j);
|
383 |
float dRMuJet = init_muons[i]->DeltaR(*jet);
|
384 |
if(dRMuJet < mindRMuJet) mindRMuJet = dRMuJet;
|
385 |
}
|
386 |
if(mindRMuJet > MuonDRJetsCut_){
|
387 |
selectedMuons.push_back(init_muons[i]);
|
388 |
}
|
389 |
}
|
390 |
std::sort(selectedMuons.begin(),selectedMuons.end(),HighestPt());
|
391 |
return selectedMuons;
|
392 |
}
|
393 |
|
394 |
std::vector<TRootMuon*> Selection::GetSelectedMuons(float PtThr, float EtaThr, float MuonRelIso, TRootVertex* vertex, vector<TRootJet*> selJets) const {
|
395 |
std::vector<TRootMuon*> selectedMuons;
|
396 |
std::vector<TRootMuon*> init_muons=GetSelectedMuons(PtThr,EtaThr,MuonRelIso,selJets);
|
397 |
for(unsigned int i=0;i<init_muons.size();i++){
|
398 |
TRootMuon* mu = (TRootMuon*) init_muons[i];
|
399 |
if ( fabs(mu->vz() - vertex->Z()) < MuonDistVzPVz_) {
|
400 |
selectedMuons.push_back(init_muons[i]);
|
401 |
}
|
402 |
}
|
403 |
std::sort(selectedMuons.begin(),selectedMuons.end(),HighestPt());
|
404 |
return selectedMuons;
|
405 |
}
|
406 |
|
407 |
std::vector<TRootMuon*> Selection::GetSelectedMuons(TRootVertex* vertex) const {
|
408 |
std::vector<TRootJet*> empty;
|
409 |
return GetSelectedMuons(MuonPtThreshold_,MuonEtaThreshold_,MuonRelIso_,vertex,empty);
|
410 |
}
|
411 |
|
412 |
std::vector<TRootMuon*> Selection::GetSelectedMuons(TRootVertex* vertex, vector<TRootJet*> selJets) const {
|
413 |
return GetSelectedMuons(MuonPtThreshold_,MuonEtaThreshold_,MuonRelIso_,vertex,selJets);
|
414 |
}
|
415 |
|
416 |
std::vector<TRootMuon*> Selection::GetSelectedDiMuons(float PtThr, float EtaThr,float MuonRelIso) const{
|
417 |
std::vector<TRootMuon*> selectedMuons;
|
418 |
for(unsigned int i=0;i<muons.size();i++){
|
419 |
if(muons[i]->isGlobalMuon() && muons[i]->isTrackerMuon() && muons[i]->idGlobalMuonPromptTight()
|
420 |
&& muons[i]->Pt()>PtThr
|
421 |
&& fabs(muons[i]->Eta())<EtaThr
|
422 |
&& muons[i]->relativeIso03() < MuonRelIso
|
423 |
&& fabs(muons[i]->d0()) <Muond0Cut_
|
424 |
&& muons[i]->nofValidHits()>MuonNofValidHits_
|
425 |
) {
|
426 |
|
427 |
selectedMuons.push_back(muons[i]);
|
428 |
}
|
429 |
}
|
430 |
std::sort(selectedMuons.begin(),selectedMuons.end(),HighestPt());
|
431 |
return selectedMuons;
|
432 |
}
|
433 |
|
434 |
std::vector<TRootMuon*> Selection::GetSelectedDiMuons() const{
|
435 |
return GetSelectedDiMuons(MuonPtThreshold_,MuonEtaThreshold_,MuonRelIso_);
|
436 |
}
|
437 |
|
438 |
std::vector<TRootMuon*> Selection::GetSelectedDiMuons(float PtThr, float EtaThr,float MuonRelIso, vector<TRootJet*> selJets) const{
|
439 |
std::vector<TRootMuon*> selectedMuons;
|
440 |
std::vector<TRootMuon*> init_muons=GetSelectedDiMuons(PtThr,EtaThr,MuonRelIso);
|
441 |
for(unsigned int i=0;i<init_muons.size();i++){
|
442 |
float mindRMuJet = 999999.;
|
443 |
TRootJet* jet;
|
444 |
for(unsigned int j=0;j<selJets.size();j++) {
|
445 |
jet = selJets.at(j);
|
446 |
float dRMuJet = init_muons[i]->DeltaR(*jet);
|
447 |
if(dRMuJet < mindRMuJet) mindRMuJet = dRMuJet;
|
448 |
}
|
449 |
if(mindRMuJet > MuonDRJetsCut_){
|
450 |
selectedMuons.push_back(init_muons[i]);
|
451 |
}
|
452 |
}
|
453 |
std::sort(selectedMuons.begin(),selectedMuons.end(),HighestPt());
|
454 |
return selectedMuons;
|
455 |
}
|
456 |
|
457 |
|
458 |
|
459 |
std::vector<TRootMuon*> Selection::GetSelectedLooseMuons(float PtThr, float EtaThr,float MuonRelIso) const{
|
460 |
std::vector<TRootMuon*> selectedMuons;
|
461 |
for(unsigned int i=0;i<muons.size();i++){
|
462 |
if(muons[i]->isGlobalMuon() && fabs(muons[i]->Eta())<EtaThr && muons[i]->Pt()>PtThr && muons[i]->relativeIso03() < MuonRelIso ) {
|
463 |
|
464 |
selectedMuons.push_back(muons[i]);
|
465 |
}
|
466 |
}
|
467 |
std::sort(selectedMuons.begin(),selectedMuons.end(),HighestPt());
|
468 |
return selectedMuons;
|
469 |
}
|
470 |
|
471 |
std::vector<TRootMuon*> Selection::GetSelectedLooseMuons() const{
|
472 |
return GetSelectedLooseMuons(MuonLoosePtThreshold_, MuonLooseEtaThreshold_, MuonLooseRelIso_);
|
473 |
}
|
474 |
|
475 |
std::vector<TRootMuon*> Selection::GetSelectedMuonsNoID(float PtThr, float EtaThr,float MuonRelIso) const{
|
476 |
std::vector<TRootMuon*> selectedMuons;
|
477 |
for(unsigned int i=0;i<muons.size();i++){
|
478 |
if(fabs(muons[i]->Eta())<EtaThr && muons[i]->Pt()>PtThr && muons[i]->relativeIso03() < MuonRelIso){
|
479 |
selectedMuons.push_back(muons[i]);
|
480 |
}
|
481 |
}
|
482 |
std::sort(selectedMuons.begin(),selectedMuons.end(),HighestPt());
|
483 |
return selectedMuons;
|
484 |
}
|
485 |
|
486 |
std::vector<TRootMuon*> Selection::GetSelectedMuonsInvIso(float PtThr, float EtaThr,float MuonRelIso) const{
|
487 |
std::vector<TRootMuon*> init_muons = GetSelectedMuons(PtThr,EtaThr,9999.);
|
488 |
std::vector<TRootMuon*> selectedMuons;
|
489 |
for(unsigned int i=0;i<init_muons.size();i++){
|
490 |
//Compute isolation
|
491 |
if(init_muons[i]->relativeIso03() > MuonRelIso )
|
492 |
selectedMuons.push_back(init_muons[i]);
|
493 |
}
|
494 |
std::sort(selectedMuons.begin(),selectedMuons.end(),HighestPt());
|
495 |
return selectedMuons;
|
496 |
}
|
497 |
|
498 |
std::vector<TRootMuon*> Selection::GetSelectedMuonsInvIso(float PtThr, float EtaThr,float MuonRelIso, vector<TRootJet*> selJets) const{
|
499 |
std::vector<TRootMuon*> init_muons = GetSelectedMuonsInvIso(PtThr,EtaThr,MuonRelIso);
|
500 |
std::vector<TRootMuon*> selectedMuons;
|
501 |
for(unsigned int i=0;i<init_muons.size();i++){
|
502 |
float mindRMuJet = 999.;
|
503 |
for(unsigned int j=0;j<selJets.size();j++) {
|
504 |
float dRMuJet = init_muons[i]->DeltaR(*selJets.at(j));
|
505 |
if(dRMuJet < mindRMuJet) mindRMuJet = dRMuJet;
|
506 |
}
|
507 |
if(mindRMuJet> MuonDRJetsCut_){
|
508 |
selectedMuons.push_back(muons[i]);
|
509 |
}
|
510 |
}
|
511 |
std::sort(selectedMuons.begin(),selectedMuons.end(),HighestPt());
|
512 |
return selectedMuons;
|
513 |
}
|
514 |
|
515 |
std::vector<TRootMuon*> Selection::GetSelectedMuonsNonIso(float PtThr, float EtaThr, vector<TRootJet*> selJets) const{
|
516 |
return GetSelectedMuons(PtThr,EtaThr,9999.,selJets);
|
517 |
}
|
518 |
|
519 |
std::vector<TRootMuon*> Selection::GetSelectedMuonsNonIso() const{
|
520 |
return GetSelectedMuons(MuonPtThreshold_,MuonEtaThreshold_,9999.);
|
521 |
}
|
522 |
|
523 |
std::vector<TRootMuon*> Selection::GetSelectedMuonsIsoRange(float PtThr, float EtaThr,float MuonRelIsoMin, float MuonRelIsoMax, vector<TRootJet*> selJets) const{
|
524 |
std::vector<TRootMuon*> init_muons = GetSelectedMuons(PtThr,EtaThr,9999.,selJets);
|
525 |
std::vector<TRootMuon*> selectedMuons;
|
526 |
for(unsigned int i=0;i<init_muons.size();i++){
|
527 |
//Compute isolation
|
528 |
if( MuonRelIsoMin < init_muons[i]->relativeIso03() && init_muons[i]->relativeIso03() < MuonRelIsoMax )
|
529 |
selectedMuons.push_back(muons[i]);
|
530 |
}
|
531 |
std::sort(selectedMuons.begin(),selectedMuons.end(),HighestPt());
|
532 |
return selectedMuons;
|
533 |
}
|
534 |
|
535 |
// ______________ELECTRONS____________________________________________//
|
536 |
|
537 |
std::vector<TRootElectron*> Selection::GetSelectedElectrons(float EtThr, float EtaThr, float ElectronRelIso) const {
|
538 |
std::vector<TRootElectron*> selectedElectrons;
|
539 |
//cout << ElectronRelIso << endl;
|
540 |
for(unsigned int i=0;i<electrons.size();i++){
|
541 |
TRootElectron* el = (TRootElectron*) electrons[i];
|
542 |
//Compute isolation
|
543 |
float RelIso = (el->caloIso(3)+el->trackerIso(3)) / el->Et();
|
544 |
|
545 |
//try the cuts manually
|
546 |
bool passvbtf = passVBTFID(el,cutsVBTFWP70);
|
547 |
|
548 |
// supercluster eta cut -> EB-EE transition region
|
549 |
if(el->Et() > EtThr && fabs(el->Eta())< EtaThr)
|
550 |
if ( fabs(el->superClusterEta()) > 1.5660 || fabs(el->superClusterEta()) < 1.4442 )
|
551 |
if ( fabs(el->d0()) < Electrond0Cut_ )
|
552 |
if ( RelIso < ElectronRelIso )
|
553 |
if (passvbtf)
|
554 |
if((fabs(el->Dist()) >= 0.02 || fabs(el->DCot()) >= 0.02) && el->missingHits() == 0)
|
555 |
|
556 |
selectedElectrons.push_back(electrons[i]);
|
557 |
}
|
558 |
std::sort(selectedElectrons.begin(),selectedElectrons.end(),HighestPt());
|
559 |
return selectedElectrons;
|
560 |
}
|
561 |
|
562 |
std::vector<TRootElectron*> Selection::GetSelectedElectrons() const{
|
563 |
return GetSelectedElectrons(ElectronEtThreshold_, ElectronEtaThreshold_, ElectronRelIso_);
|
564 |
}
|
565 |
|
566 |
std::vector<TRootElectron*> Selection::GetSelectedElectrons(TRootVertex* vertex) const{
|
567 |
return GetSelectedElectrons(ElectronEtThreshold_, ElectronEtaThreshold_, ElectronRelIso_,vertex);
|
568 |
}
|
569 |
|
570 |
std::vector<TRootElectron*> Selection::GetSelectedElectrons(float EtThr, float EtaThr, float ElectronRelIso, TRootVertex* vertex) const {
|
571 |
std::vector<TRootElectron*> init_electrons = GetSelectedElectrons(EtThr,EtaThr,ElectronRelIso);
|
572 |
std::vector<TRootElectron*> selectedElectrons;
|
573 |
for(unsigned int i=0;i<init_electrons.size();i++){
|
574 |
TRootElectron* el = (TRootElectron*) init_electrons[i];
|
575 |
if ( fabs(el->vz() - vertex->Z()) < ElectronDistVzPVz_) {
|
576 |
selectedElectrons.push_back(init_electrons[i]);
|
577 |
}
|
578 |
}
|
579 |
|
580 |
std::sort(selectedElectrons.begin(),selectedElectrons.end(),HighestPt());
|
581 |
return selectedElectrons;
|
582 |
}
|
583 |
|
584 |
std::vector<TRootElectron*> Selection::GetSelectedLooseElectrons(float EtThr, float EtaThr, float ElectronRelIso, bool vbtfid) const {
|
585 |
std::vector<TRootElectron*> selectedElectrons;
|
586 |
for(unsigned int i=0;i<electrons.size();i++){
|
587 |
TRootElectron* el = (TRootElectron*) electrons[i];
|
588 |
//Compute isolation
|
589 |
float RelIso = (el->caloIso(3)+el->trackerIso(3)) / el->Et();
|
590 |
|
591 |
//try the cuts manually
|
592 |
bool passvbtf = passVBTFID(el,cutsVBTFWP95);
|
593 |
|
594 |
if(el->Et() > EtThr && fabs(el->Eta()) < EtaThr && RelIso < ElectronRelIso)
|
595 |
if ( !vbtfid || ( vbtfid && fabs(el->superClusterEta()) > 1.5660 || fabs(el->superClusterEta()) < 1.4442 ) )
|
596 |
if (!vbtfid || (vbtfid && passvbtf))
|
597 |
selectedElectrons.push_back(electrons[i]);
|
598 |
}
|
599 |
std::sort(selectedElectrons.begin(),selectedElectrons.end(),HighestPt());
|
600 |
return selectedElectrons;
|
601 |
}
|
602 |
|
603 |
std::vector<TRootElectron*> Selection::GetSelectedLooseElectrons(bool vbtfid) const {
|
604 |
return GetSelectedLooseElectrons(ElectronLooseEtThreshold_, ElectronLooseEtaThreshold_, ElectronLooseRelIso_,vbtfid);
|
605 |
}
|
606 |
|
607 |
|
608 |
std::vector<TRootElectron*> Selection::GetSelectedPlainElectrons(float EtThr, float EtaThr) const {
|
609 |
std::vector<TRootElectron*> selectedPlainElectrons;
|
610 |
for(unsigned int i=0;i<electrons.size();i++){
|
611 |
TRootElectron* el = (TRootElectron*) electrons[i];
|
612 |
//Compute isolation
|
613 |
|
614 |
|
615 |
if(el->Et() > EtThr && fabs(el->Eta()) < EtaThr)
|
616 |
|
617 |
selectedPlainElectrons.push_back(electrons[i]);
|
618 |
}
|
619 |
std::sort(selectedPlainElectrons.begin(),selectedPlainElectrons.end(),HighestPt());
|
620 |
return selectedPlainElectrons;
|
621 |
}
|
622 |
|
623 |
//____________IS SELECTED_______________________________________________//
|
624 |
|
625 |
bool Selection::isPVSelected(const std::vector<TRootVertex*>& vertex, int NdofCut, float Zcut, float RhoCut){
|
626 |
if(vertex.size()==0) return false;
|
627 |
float Rho = sqrt(vertex[0]->x()*vertex[0]->x()+vertex[0]->y()*vertex[0]->y());
|
628 |
if(!vertex[0]->isFake() && vertex[0]->ndof()>NdofCut && abs(vertex[0]->z())<Zcut && Rho<RhoCut) return true;
|
629 |
return false;
|
630 |
}
|
631 |
|
632 |
bool Selection::isSelected(unsigned int Njets, bool Veto2ndLepton) const{
|
633 |
if(Veto2ndLepton){
|
634 |
if(GetSelectedMuons().size()==1 && GetSelectedElectrons().size()==0 && GetSelectedJets().size()>= Njets) return true;
|
635 |
}
|
636 |
else{
|
637 |
if(GetSelectedMuons().size()>0 && GetSelectedJets().size()>= Njets) return true;
|
638 |
}
|
639 |
return false;
|
640 |
}
|
641 |
|
642 |
bool Selection::isSelected(float JetPtThr, unsigned int Njets, bool Veto2ndLepton) const{
|
643 |
if(Veto2ndLepton){
|
644 |
if(GetSelectedMuons().size()==1 && GetSelectedElectrons().size()==0 && GetSelectedJets(JetPtThr, JetEtaThreshold_, JetEMFThreshold_).size()>= Njets) return true;
|
645 |
}
|
646 |
else{
|
647 |
if(GetSelectedMuons().size()>0 && GetSelectedJets(JetPtThr, JetEtaThreshold_, JetEMFThreshold_).size()>= Njets) return true;
|
648 |
}
|
649 |
return false;
|
650 |
}
|
651 |
|
652 |
bool Selection::isSelected(float PtThrJets, float EtaThrJets, float PtThrMuons, float EtaThrMuons, float MuonRelIso, float PtThrElectrons, float EtaThrElectrons, float ElectronRelIso, unsigned int Njets, bool Veto2ndLepton) const{
|
653 |
if(Veto2ndLepton){
|
654 |
if(GetSelectedMuons(PtThrMuons, EtaThrMuons, MuonRelIso, GetSelectedJets(PtThrJets, EtaThrJets, Njets)).size()==1 && GetSelectedElectrons(PtThrElectrons, EtaThrElectrons, ElectronRelIso).size()==0 && GetSelectedJets(PtThrJets, EtaThrJets, Njets).size()>=Njets) return true;
|
655 |
}
|
656 |
else{
|
657 |
if(GetSelectedMuons(PtThrMuons, EtaThrMuons, MuonRelIso, GetSelectedJets(PtThrJets, EtaThrJets, Njets)).size()>0 && GetSelectedJets(PtThrJets, EtaThrJets, Njets).size()>=Njets) return true;
|
658 |
}
|
659 |
return false;
|
660 |
}
|
661 |
|
662 |
//______________________________________________________________________//
|