forked from mflechl/ProductionFromNano
-
Notifications
You must be signed in to change notification settings - Fork 0
/
HMuTauhTreeFromNano.C
123 lines (92 loc) · 4.95 KB
/
HMuTauhTreeFromNano.C
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
#define HMuTauhTreeFromNano_cxx
#include "HMuTauhTreeFromNano.h"
#include <TH2.h>
#include <TStyle.h>
#include <TCanvas.h>
#include <TSystem.h>
#include <iostream>
#include <fstream>
/////////////////////////////////////////////////
/////////////////////////////////////////////////
bool HMuTauhTreeFromNano::pairSelection(unsigned int iPair)
{
///Baseline+post sync selection as on
///https://twiki.cern.ch/twiki/bin/viewauth/CMS/HiggsToTauTauWorking2016#Baseline_mu_tau_h
///Indices for multiplexed ID variables taken from LLRHiggsTauTau/NtupleProducer/plugins/
///HTauTauNtuplizer.cc, MuFiller.cc, TauFiller.cc, EleFiller.cc
debugWayPoint("[pairSelection] ------ Begin -------");
if(httPairs_.empty()) return false;
int pdgIdLeg1 = std::abs(httPairs_[iPair].getLeg1().getPDGid());
int pdgIdLeg2 = std::abs(httPairs_[iPair].getLeg2().getPDGid());
debugWayPoint("[pairSelection] pdgid of pair",{},{(int)pdgIdLeg1,(int)pdgIdLeg2});
unsigned int indexMuonLeg = -1;
if(pdgIdLeg1==13) indexMuonLeg = httPairs_[iPair].getIndexLeg1();
else if(pdgIdLeg2==13) indexMuonLeg = httPairs_[iPair].getIndexLeg2();
else return 0;
debugWayPoint("[pairSelection] Found Muon",{},{(int)indexMuonLeg});
unsigned int indexTauLeg = -1;
if(pdgIdLeg1==15) indexTauLeg = httPairs_[iPair].getIndexLeg1();
else if(pdgIdLeg2==15) indexTauLeg = httPairs_[iPair].getIndexLeg2();
else return 0;
debugWayPoint("[pairSelection] Found Tau",{},{(int)indexTauLeg});
TLorentzVector muonP4 = httLeptonCollection[indexMuonLeg].getP4();
TLorentzVector tauP4 = httLeptonCollection[indexTauLeg].getP4();
bool muonBaselineSelection = httLeptonCollection[indexMuonLeg].isBaseline();
debugWayPoint("[pairSelection] Muon",
{(double)muonP4.Pt(), (double)muonP4.Eta()},
{(int)muonBaselineSelection},
{"pt","eta","passCuts"});
bool tauBaselineSelection = httLeptonCollection[indexTauLeg].isSemiLepTau();
debugWayPoint("[pairSelection] Tau",
{(double)tauP4.Pt(), (double)tauP4.Eta()},
{(int)tauBaselineSelection},
{"pt","eta","passCuts"});
bool baselinePair = muonP4.DeltaR(tauP4) > 0.5;
debugWayPoint("[pairSelection] Overlap",{(double)muonP4.DeltaR(tauP4)}, {(int)baselinePair},{"DR","noOL"});
bool boolDiElectronVeto = false;
bool boolDiMuonVeto = diMuonVeto();
bool boolDiLeptonVeto = boolDiElectronVeto || boolDiMuonVeto;
bool boolAntiEle = ( (int)httLeptonCollection[indexTauLeg].getProperty(HTTEvent::usePropertyFor.at("tauIDDeepVSele") ) & 0x4) == 0x4; //Vloose AntiEle Id
bool boolAntiMu = ( (int)httLeptonCollection[indexTauLeg].getProperty(HTTEvent::usePropertyFor.at("tauIDDeepVSmu") ) & 0x8) == 0x8; //Tight AntiMu Id
bool boolAntiLeptonId = boolAntiEle && boolAntiMu;
bool boolExtraElectronVeto = thirdLeptonVeto(indexMuonLeg, indexTauLeg, 11);
bool boolExtraMuonVeto = thirdLeptonVeto(indexMuonLeg, indexTauLeg, 13);
bool boolThirdLeptonVeto = boolExtraMuonVeto || boolExtraElectronVeto;
httEvent->clearSelectionWord();
httEvent->setSelectionBit(SelectionBitsEnum::diMuonVeto,boolDiMuonVeto);
httEvent->setSelectionBit(SelectionBitsEnum::diElectronVeto, boolDiElectronVeto);
httEvent->setSelectionBit(SelectionBitsEnum::diLeptonVeto, boolDiLeptonVeto);
httEvent->setSelectionBit(SelectionBitsEnum::antiLeptonId, boolAntiLeptonId);
httEvent->setSelectionBit(SelectionBitsEnum::extraMuonVeto, boolExtraMuonVeto);
httEvent->setSelectionBit(SelectionBitsEnum::extraElectronVeto, boolExtraElectronVeto);
httEvent->setSelectionBit(SelectionBitsEnum::thirdLeptonVeto, boolThirdLeptonVeto);
return muonBaselineSelection && tauBaselineSelection && baselinePair
&& true;
}
bool HMuTauhTreeFromNano::diMuonVeto(){
std::vector<int> muonIndexes;
for(unsigned int iLepton=0;iLepton<httLeptonCollection.size();++iLepton)
{
if(std::abs(httLeptonCollection[iLepton].getPDGid())!=13) continue;
if(httLeptonCollection[iLepton].isDiLepton() ) muonIndexes.push_back(iLepton);
}
if(muonIndexes.size()<2) return false;
else{
for(auto &iMuon1 : muonIndexes)
{
for(auto &iMuon2 : muonIndexes)
{
if(iMuon1 == iMuon2) continue;
TLorentzVector muon1P4 = httLeptonCollection[iMuon1].getP4();
TLorentzVector muon2P4 = httLeptonCollection[iMuon2].getP4();
int muon1Charge = (int)httLeptonCollection[iMuon1].getProperty(PropertyEnum::charge);
int muon2Charge = (int)httLeptonCollection[iMuon2].getProperty(PropertyEnum::charge);
float deltaR = muon1P4.DeltaR(muon2P4);
if(muon2Charge*muon1Charge==-1 && deltaR>0.15) return true;
}
}
}
return false;
}
/////////////////////////////////////////////////
/////////////////////////////////////////////////