1 |
< |
#include "Selection.h" |
2 |
< |
#include "PassHLT.h" |
3 |
< |
|
4 |
< |
#include "SiMVAElectronSelection.h" |
5 |
< |
|
6 |
< |
#include "HZZCiCElectronSelection.h" |
7 |
< |
#include "HZZLikelihoodElectronSelection.h" |
8 |
< |
#include "HZZBDTElectronSelection.h" |
9 |
< |
#include "RunLumiRangeMap.h" |
1 |
> |
#include "SelectionStatus.h" |
2 |
> |
#include "EventData.h" |
3 |
> |
#include "SimpleLepton.h" |
4 |
|
#include "EfficiencyWeightsInterface.h" |
5 |
|
|
6 |
< |
RunLumiRangeMap rlrm; |
7 |
< |
TH1D * hpu; |
8 |
< |
|
6 |
> |
#include "ElectronSelection.h" |
7 |
> |
#include "MuonSelection.h" |
8 |
> |
#include "IsolationSelection.h" |
9 |
> |
//#include "PassHLT.h" |
10 |
> |
#include "Selection.h" |
11 |
|
|
12 |
< |
// #include "TH2D.h" |
13 |
< |
// extern TH2D * h_mu_eff_idiso_2011a; |
18 |
< |
// extern TH2D * h_mu_eff_idiso_s11; |
19 |
< |
// extern TH2D * h_mu_effdata_trigger_doublemu7_2011a; |
20 |
< |
// extern TH2D * h_mu_effdata_trigger_doublemu13_8_leading_2011a; |
21 |
< |
// extern TH2D * h_mu_effdata_trigger_doublemu13_8_trailing_2011a; |
22 |
< |
|
23 |
< |
// unsigned getGenChannel(mithep::TGenInfo * ginfo) { |
24 |
< |
// int gchannel=-1; |
25 |
< |
// if( abs(ginfo->id_1_a) == EGenType::kElectron && abs(ginfo->id_1_b) == EGenType::kElectron ) gchannel=0; |
26 |
< |
// else if( abs(ginfo->id_1_a) == EGenType::kMuon && abs(ginfo->id_1_b) == EGenType::kMuon ) gchannel=1; |
27 |
< |
// else if( (abs(ginfo->id_1_a) == EGenType::kElectron && abs(ginfo->id_1_b) == EGenType::kMuon) || |
28 |
< |
// (abs(ginfo->id_1_a) == EGenType::kMuon && abs(ginfo->id_1_b) == EGenType::kElectron) ) gchannel=2; |
29 |
< |
|
30 |
< |
// return gchannel; |
31 |
< |
// }; |
32 |
< |
|
33 |
< |
void initRunLumiRangeMap() { |
34 |
< |
rlrm.AddJSONFile(std::string("./data/Cert_136033-149442_7TeV_Apr21ReReco_Collisions10_JSON.txt")); |
35 |
< |
// rlrm.AddJSONFile(std::string("./data/Cert_160404-173244_7TeV_PromptReco_Collisions11_JSON_v2.txt")); |
36 |
< |
rlrm.AddJSONFile(std::string("./data/Cert_160404-178078_7TeV_PromptReco_Collisions11_JSON.txt")); |
37 |
< |
rlrm.AddJSONFile(std::string("./data/Cert_160404-163869_7TeV_May10ReReco_Collisions11_JSON_v3.txt")); |
38 |
< |
rlrm.AddJSONFile(std::string("./data/Cert_170249-172619_7TeV_ReReco5Aug_Collisions11_JSON.txt")); |
39 |
< |
TFile * puf = new TFile("data/PileupReweighting.Summer11DYmm_To_Run2011A.root"); |
40 |
< |
hpu = (TH1D*)(puf->Get("puWeights")); |
41 |
< |
}; |
42 |
< |
|
43 |
< |
void initRunLumiRangeMap(RunLumiRangeMap &rlrm) { |
44 |
< |
cout << "adding JSONS ... " << endl; |
45 |
< |
rlrm.AddJSONFile(std::string("./data/Cert_136033-149442_7TeV_Apr21ReReco_Collisions10_JSON.txt")); |
46 |
< |
// rlrm.AddJSONFile(std::string("./data/Cert_160404-173244_7TeV_PromptReco_Collisions11_JSON_v2.txt")); |
47 |
< |
rlrm.AddJSONFile(std::string("./data/Cert_160404-178078_7TeV_PromptReco_Collisions11_JSON.txt")); |
48 |
< |
rlrm.AddJSONFile(std::string("./data/Cert_160404-163869_7TeV_May10ReReco_Collisions11_JSON_v3.txt")); |
49 |
< |
rlrm.AddJSONFile(std::string("./data/Cert_170249-172619_7TeV_ReReco5Aug_Collisions11_JSON.txt")); |
50 |
< |
}; |
51 |
< |
|
52 |
< |
// unsigned fails_HZZ4L_selection(ControlFlags &ctrl, // input control |
53 |
< |
// mithep::TEventInfo *info, // input event inof |
54 |
< |
// TClonesArray *electronArr, // input electrons |
55 |
< |
// TClonesArray *muonArr, // input muons |
56 |
< |
// double eventweight, // weight |
57 |
< |
// TTree * passtuple ) { |
58 |
< |
|
59 |
< |
// fails_HZZ4L_selection( ctrl, info, electronArr, muonArr, eventweight, passtuple, NULL ); |
60 |
< |
|
61 |
< |
// }; |
62 |
< |
|
63 |
< |
|
64 |
< |
|
65 |
< |
// unsigned fails_HZZ4L_selection(ControlFlags &ctrl, // input control |
66 |
< |
// mithep::TEventInfo *info, // input event inof |
67 |
< |
// TClonesArray *electronArr, // input electrons |
68 |
< |
// TClonesArray *muonArr, // input muons |
69 |
< |
// double eventweight, // weight |
70 |
< |
// LabVectors *l ) { |
71 |
< |
|
72 |
< |
// fails_HZZ4L_selection( ctrl, info, electronArr, muonArr, eventweight, NULL, l ); |
73 |
< |
|
74 |
< |
// }; |
75 |
< |
|
76 |
< |
|
77 |
< |
unsigned fails_HZZ4L_selection(ControlFlags &ctrl, // input control |
78 |
< |
mithep::TGenInfo *ginfo , // input gen info |
79 |
< |
mithep::TEventInfo *info, // input event info |
80 |
< |
TClonesArray *electronArr, // input electrons |
81 |
< |
TClonesArray *muonArr, // input muons |
82 |
< |
double eventweight, // weight |
83 |
< |
TTree * passtuple ) { |
84 |
< |
|
85 |
< |
fails_HZZ4L_selection( ctrl, info, electronArr, muonArr, eventweight, passtuple, NULL, NULL ); |
86 |
< |
|
87 |
< |
}; |
88 |
< |
|
89 |
< |
unsigned fails_HZZ4L_selection(ControlFlags &ctrl, // input control |
90 |
< |
mithep::TEventInfo *info, // input event info |
91 |
< |
TClonesArray *electronArr, // input electrons |
92 |
< |
TClonesArray *muonArr, // input muons |
93 |
< |
double eventweight, // weight |
94 |
< |
TTree * passtuple, |
95 |
< |
LabVectors * l ) { |
96 |
< |
fails_HZZ4L_selection( ctrl, info, electronArr, muonArr, eventweight, passtuple, l, NULL ); |
97 |
< |
} |
12 |
> |
#include "ExternData.h" |
13 |
> |
#include "SelectionDefs.h" |
14 |
|
|
15 |
|
|
16 |
< |
unsigned fails_HZZ4L_selection(ControlFlags &ctrl, // input control |
17 |
< |
mithep::TEventInfo *info, // input event info |
18 |
< |
TClonesArray *electronArr, // input electrons |
19 |
< |
TClonesArray *muonArr, // input muons |
20 |
< |
double eventweight, // weight |
21 |
< |
TTree * passtuple, |
22 |
< |
LabVectors * l=NULL, |
23 |
< |
TClonesArray *jetArr=NULL ) { // output ntuple |
16 |
> |
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
17 |
> |
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
18 |
> |
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
19 |
> |
EventData apply_HZZ4L_selection(ControlFlags &ctrl, // input control |
20 |
> |
const mithep::EventHeader *info, // input event info |
21 |
> |
const mithep::Vertex & vtx, |
22 |
> |
const mithep::Array<mithep::PFCandidate> *pfCandidates, |
23 |
> |
const mithep::Array<mithep::PileupEnergyDensity> *puEnergyDensity, |
24 |
> |
const mithep::Array<mithep::Electron> *electronArr, // input electrons |
25 |
> |
SelectionStatus (*ElectronPreSelector)( ControlFlags &, |
26 |
> |
const mithep::Electron*, |
27 |
> |
const mithep::Vertex &), |
28 |
> |
SelectionStatus (*ElectronIDSelector)( ControlFlags &, |
29 |
> |
const mithep::Electron*, |
30 |
> |
const mithep::Vertex &), |
31 |
> |
SelectionStatus (*ElectronIsoSelector)( ControlFlags &, |
32 |
> |
const mithep::Electron*, |
33 |
> |
const mithep::Vertex &, |
34 |
> |
const mithep::Array<mithep::PFCandidate> *, |
35 |
> |
const mithep::Array<mithep::PileupEnergyDensity> *, |
36 |
> |
mithep::ElectronTools::EElectronEffectiveAreaTarget, |
37 |
> |
vector<const mithep::Muon*>, |
38 |
> |
vector<const mithep::Electron*> ), |
39 |
> |
const mithep::Array<mithep::Muon> *muonArr, // input muons |
40 |
> |
SelectionStatus (*MuonPreSelector)( ControlFlags &, |
41 |
> |
const mithep::Muon*, |
42 |
> |
const mithep::Vertex &, |
43 |
> |
const mithep::Array<mithep::PFCandidate> *), |
44 |
> |
SelectionStatus (*MuonIDSelector)( ControlFlags &, |
45 |
> |
const mithep::Muon*, |
46 |
> |
const mithep::Vertex &), |
47 |
> |
SelectionStatus (*MuonIsoSelector)( ControlFlags &, |
48 |
> |
const mithep::Muon*, |
49 |
> |
const mithep::Vertex &, |
50 |
> |
const mithep::Array<mithep::PFCandidate> *, |
51 |
> |
const mithep::Array<mithep::PileupEnergyDensity> *, |
52 |
> |
mithep::MuonTools::EMuonEffectiveAreaTarget, |
53 |
> |
vector<const mithep::Muon*>, |
54 |
> |
vector<const mithep::Electron*> ) |
55 |
> |
) |
56 |
> |
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
57 |
> |
{ |
58 |
|
|
59 |
+ |
EventData ret; |
60 |
|
unsigned evtfail = 0x0; |
61 |
< |
unsigned gchannel=0xdeaddead; |
62 |
< |
|
112 |
< |
// if( ctrl.mc && ginfo != NULL ) { |
113 |
< |
// gchannel = getGenChannel(ginfo); |
114 |
< |
// } |
115 |
< |
|
116 |
< |
|
61 |
> |
TRandom3 r; |
62 |
> |
|
63 |
|
if( ctrl.debug ) { |
64 |
< |
cout << "Run: " << info->runNum |
65 |
< |
<< "\tEvt: " << info->evtNum |
66 |
< |
<< "\tLumi: " << info->lumiSec |
64 |
> |
cout << "-----------------------------------------------------------------" << endl; |
65 |
> |
cout << "-----------------------------------------------------------------" << endl; |
66 |
> |
cout << "Run: " << info->RunNum() |
67 |
> |
<< "\tEvt: " << info->EvtNum() |
68 |
> |
<< "\tLumi: " << info->LumiSec() |
69 |
|
<< endl; |
70 |
+ |
cout << "-----------------------------------------------------------------" << endl; |
71 |
|
} |
72 |
|
|
124 |
– |
unsigned npu; double npuw; |
73 |
|
if( !ctrl.mc ) { |
74 |
|
// not accounting for overlap atm |
75 |
< |
RunLumiRangeMap::RunLumiPairType rl(info->runNum, info->lumiSec); |
75 |
> |
RunLumiRangeMap::RunLumiPairType rl(info->RunNum(), info->LumiSec()); |
76 |
|
if( !(rlrm.HasRunLumi(rl)) ) { |
77 |
|
if( ctrl.debug ) cout << "\tfails JSON" << endl; |
78 |
< |
evtfail |= (1<<EVTFAIL_JSON); |
79 |
< |
return evtfail; |
78 |
> |
ret.status.setStatus(0); |
79 |
> |
return ret; |
80 |
|
} |
133 |
– |
} else { |
134 |
– |
npu = info->nPU; |
135 |
– |
npuw = hpu->GetBinContent(hpu->FindBin(npu)); |
81 |
|
} |
137 |
– |
|
138 |
– |
|
82 |
|
|
83 |
+ |
mithep::MuonTools::EMuonEffectiveAreaTarget eraMu = mithep::MuonTools::kMuEAFall11MC; |
84 |
+ |
mithep::ElectronTools::EElectronEffectiveAreaTarget eraEle = mithep::ElectronTools::kEleEAFall11MC; |
85 |
+ |
if( !ctrl.mc ) { |
86 |
+ |
eraMu = mithep::MuonTools::kMuEAData2011; |
87 |
+ |
eraEle = mithep::ElectronTools::kEleEAData2011; |
88 |
+ |
} |
89 |
|
|
90 |
|
|
91 |
|
//******************************************************** |
92 |
|
// Trigger |
93 |
|
//******************************************************** |
94 |
+ |
// |
95 |
+ |
// still have to port this part to bambu |
96 |
+ |
// |
97 |
+ |
/* |
98 |
|
if( !ctrl.mc ) { |
99 |
< |
// if( !(passHLT(info->triggerBits, info->runNum, channel) ) ) { |
100 |
< |
// if( !(passHLT(info->triggerBits, info->runNum, 999) ) ) { |
101 |
< |
// evtfail |= (1<<EVTFAIL_TRIGGER); |
149 |
< |
// return evtfail; |
150 |
< |
// } |
151 |
< |
} else { |
152 |
< |
if( !(passHLTMC(info->triggerBits)) ) { |
99 |
> |
//if( !(passHLT(info->triggerBits, info->runNum, channel) ) ) { |
100 |
> |
if( !(passHLT(info->triggerBits, info->runNum, 999) ) ) { |
101 |
> |
if( ctrl.debug ) cout << "\tfails trigger" << endl; |
102 |
|
evtfail |= (1<<EVTFAIL_TRIGGER); |
103 |
< |
return evtfail; |
104 |
< |
} |
105 |
< |
// cout << "MC trigger bits: " << hex << info->triggerBits << dec << endl; |
106 |
< |
} |
103 |
> |
ret.status.setStatus(0); |
104 |
> |
return ret; |
105 |
> |
} |
106 |
> |
} |
107 |
> |
*/ |
108 |
|
|
109 |
|
if( ctrl.debug ) { |
110 |
|
cout << "presel nlep: " << muonArr->GetEntries() + electronArr->GetEntries() |
113 |
|
<< endl; |
114 |
|
} |
115 |
|
|
116 |
+ |
|
117 |
|
//******************************************************** |
118 |
|
// Lepton Selection |
119 |
|
//******************************************************** |
120 |
|
vector<SimpleLepton> lepvec; |
170 |
– |
|
171 |
– |
// |
172 |
– |
if( ctrl.debug ) cout << "\tnMuons: " << muonArr->GetEntries() << endl; |
173 |
– |
//---------------------------------------------------- |
174 |
– |
for(Int_t i=0; i<muonArr->GetEntries(); i++) { |
175 |
– |
const mithep::TMuon *mu = (mithep::TMuon*)((*muonArr)[i]); |
176 |
– |
unsigned muonfail; |
177 |
– |
if( ctrl.muSele == "ksWW" ) |
178 |
– |
muonfail = passKSMuonSelection(mu); |
179 |
– |
else |
180 |
– |
muonfail = passMuonSelectionZZ(mu); |
181 |
– |
if( ctrl.debug ) { |
182 |
– |
cout << "muon:: pt: " << mu->pt |
183 |
– |
<< "\teta: " << mu->eta |
184 |
– |
<< "\tmask: 0x" << hex << muonfail << dec |
185 |
– |
<< endl; |
186 |
– |
} |
187 |
– |
if ( !muonfail ) { |
188 |
– |
SimpleLepton tmplep; |
121 |
|
|
122 |
< |
float pt = mu->pt; |
123 |
< |
if( ctrl.do_escale_up ) pt*=(1.01); |
124 |
< |
if( ctrl.do_escale_down ) pt*=(0.99); |
125 |
< |
|
126 |
< |
tmplep.vec.SetPtEtaPhiM(pt, |
127 |
< |
mu->eta, |
128 |
< |
mu->phi, |
129 |
< |
105.658369e-3); |
130 |
< |
|
131 |
< |
tmplep.type = 13; |
132 |
< |
tmplep.index = i; |
133 |
< |
tmplep.charge = mu->q; |
134 |
< |
tmplep.isoTrk = mu->trkIso03; |
135 |
< |
tmplep.isoEcal = mu->emIso03; |
136 |
< |
tmplep.isoHcal = mu->hadIso03; |
137 |
< |
tmplep.isoPF03 = mu->pfIso03; |
206 |
< |
tmplep.isoPF04 = mu->pfIso04; |
207 |
< |
tmplep.ip3dSig = mu->ip3dSig; |
208 |
< |
tmplep.is4l = false; |
209 |
< |
tmplep.isEB = (fabs(mu->eta) < 1.479 ? 1 : 0 ); |
210 |
< |
lepvec.push_back(tmplep); |
211 |
< |
if( ctrl.debug ) { cout << "muon passes ... " << endl;} |
122 |
> |
// do something hacky for vetos for now |
123 |
> |
vector<const mithep::Muon*> muonsToVeto; |
124 |
> |
vector<const mithep::Electron*> electronsToVeto; |
125 |
> |
if( ctrl.debug ) cout << "looping for isolation ..." << endl; |
126 |
> |
for(Int_t i=0; i<muonArr->GetEntries(); i++) |
127 |
> |
{ |
128 |
> |
const mithep::Muon *mu = (mithep::Muon*)((*muonArr)[i]); |
129 |
> |
SelectionStatus musel; |
130 |
> |
musel |= (*MuonPreSelector)(ctrl,mu,vtx,pfCandidates); |
131 |
> |
if( !(musel.getStatus() & SelectionStatus::PRESELECTION) ) continue; |
132 |
> |
musel |= (*MuonIDSelector)(ctrl,mu,vtx ); |
133 |
> |
if(ctrl.debug) cout << "status : " << musel.getStatus() << endl; |
134 |
> |
if( musel.tightIDAndPre() ) { |
135 |
> |
if(ctrl.debug) cout << "pushing mu for isol veto ... " << endl; |
136 |
> |
muonsToVeto.push_back( mu ); |
137 |
> |
} |
138 |
|
} |
139 |
< |
} |
140 |
< |
|
141 |
< |
if( ctrl.debug ) { cout << "\tnElectron: " << electronArr->GetEntries() << endl; } |
142 |
< |
|
143 |
< |
//---------------------------------------------------- |
144 |
< |
for(Int_t i=0; i<electronArr->GetEntries(); i++) { |
145 |
< |
const mithep::TElectron *ele = (mithep::TElectron*)((*electronArr)[i]); |
146 |
< |
|
147 |
< |
if( !(isEleFO(ctrl,ele) ) ) continue; |
148 |
< |
if( ele->pt < 7 ) continue; //move this to ID |
149 |
< |
|
224 |
< |
Bool_t isMuonOverlap = kFALSE; |
225 |
< |
for (int k=0; k<lepvec.size(); ++k) { |
226 |
< |
TVector3 tmplep; |
227 |
< |
tmplep.SetPtEtaPhi(ele->pt, ele->eta, ele->phi); |
228 |
< |
if ( lepvec[k].type == 13 && lepvec[k].vec.Vect().DrEtaPhi(tmplep) < 0.1 ) { |
229 |
< |
if( ctrl.debug ) cout << "-----> isMuonOverlap! " << endl; |
230 |
< |
isMuonOverlap = kTRUE; |
231 |
< |
break; |
139 |
> |
for(Int_t i=0; i<electronArr->GetEntries(); i++) |
140 |
> |
{ |
141 |
> |
const mithep::Electron *ele = (mithep::Electron*)((*electronArr)[i]); |
142 |
> |
SelectionStatus esel; |
143 |
> |
esel |= (*ElectronPreSelector)(ctrl,ele,vtx); |
144 |
> |
if( !(esel.getStatus() & SelectionStatus::PRESELECTION) ) continue; |
145 |
> |
esel |= (*ElectronIDSelector)(ctrl,ele,vtx ); |
146 |
> |
if(ctrl.debug) cout << "status : " << esel.getStatus() << endl; |
147 |
> |
if( esel.tightIDAndPre() ) { |
148 |
> |
if(ctrl.debug) cout << "pushing ele for isol veto ... " << endl; |
149 |
> |
electronsToVeto.push_back( ele ); |
150 |
|
} |
151 |
|
} |
152 |
+ |
if( ctrl.debug ) cout << "done looping for isolation ..." << endl << endl;; |
153 |
|
|
154 |
< |
unsigned FAIL=0, isEleTight=0; |
155 |
< |
|
156 |
< |
unsigned failsCIC=0; |
157 |
< |
CICStruct ciccuts_tight, ciccuts_medium, ciccuts_loose; |
158 |
< |
if(ctrl.eleSele=="cic") { |
159 |
< |
if( ctrl.eleSeleScheme == "mediumloose" ) { |
160 |
< |
ciccuts_medium = getCiCCuts("medium"); |
161 |
< |
unsigned failsCICMedium = failsCicSelection(ctrl, ele, ciccuts_medium, ctrl.kinematics); |
162 |
< |
ciccuts_loose = getCiCCuts("loose"); |
163 |
< |
unsigned failsCICLoose = failsCicSelection(ctrl, ele, ciccuts_loose, ctrl.kinematics); |
164 |
< |
failsCIC = ( failsCICLoose > 0 && failsCICMedium > 0 ); |
165 |
< |
if( !failsCICMedium ) isEleTight=1; |
166 |
< |
} |
167 |
< |
else { |
168 |
< |
ciccuts_tight = getCiCCuts(ctrl.eleSeleScheme); |
169 |
< |
failsCIC = failsCicSelection(ctrl, ele, ciccuts_tight, ctrl.kinematics); |
170 |
< |
if( !failsCIC ) isEleTight=1; |
154 |
> |
// |
155 |
> |
if( ctrl.debug ) cout << "\tnMuons: " << muonArr->GetEntries() << endl; |
156 |
> |
//---------------------------------------------------- |
157 |
> |
for(Int_t i=0; i<muonArr->GetEntries(); i++) |
158 |
> |
{ |
159 |
> |
const mithep::Muon *mu = (mithep::Muon*)((*muonArr)[i]); |
160 |
> |
|
161 |
> |
SelectionStatus musel; |
162 |
> |
if(ctrl.debug) cout << "musel.status before anything: " << musel.getStatus() << endl; |
163 |
> |
musel |= (*MuonPreSelector)(ctrl,mu,vtx,pfCandidates); |
164 |
> |
if(ctrl.debug) cout << "musel.status after presel: " << musel.getStatus() << endl; |
165 |
> |
if( !(musel.getStatus() & SelectionStatus::PRESELECTION) ) continue; |
166 |
> |
musel |= (*MuonIDSelector)(ctrl,mu,vtx ); |
167 |
> |
if(ctrl.debug) cout << "musel.status after ID: " << musel.getStatus() << endl; |
168 |
> |
musel |= (*MuonIsoSelector)(ctrl,mu,vtx,pfCandidates,puEnergyDensity,eraMu,muonsToVeto,electronsToVeto); |
169 |
> |
if(ctrl.debug) cout << "musel.status after iso: " << musel.getStatus() << endl; |
170 |
> |
|
171 |
> |
if( ctrl.debug ) { |
172 |
> |
cout << "muon:: pt: " << mu->Pt() |
173 |
> |
<< "\teta: " << mu->Eta() |
174 |
> |
<< "\tstatus: " << hex << musel.getStatus() << dec |
175 |
> |
<< endl; |
176 |
|
} |
177 |
< |
FAIL = failsCIC; |
178 |
< |
} |
177 |
> |
|
178 |
> |
if ( musel.pass() ) { |
179 |
|
|
180 |
< |
LikStruct likcuts; |
181 |
< |
unsigned failsLike=0; |
182 |
< |
if(ctrl.eleSele=="lik") { |
183 |
< |
likcuts = getLikCuts(ctrl.eleSeleScheme); |
184 |
< |
failsLike = failsLikelihoodSelection(ele, likcuts, ctrl.kinematics); |
185 |
< |
FAIL = failsLike; |
186 |
< |
} |
187 |
< |
unsigned failsBDT=0; |
188 |
< |
if(ctrl.eleSele=="bdt") { |
189 |
< |
if( ctrl.eleSeleScheme == "mediumloose" ) { |
190 |
< |
unsigned failsBDTMedium = failsBDTSelection(ctrl,"medium",ele); |
191 |
< |
unsigned failsBDTLoose = failsBDTSelection(ctrl,"loose",ele); |
192 |
< |
failsBDT = ( failsBDTLoose > 0 && failsBDTMedium > 0 ); |
193 |
< |
if( !failsBDTMedium ) isEleTight=1; |
194 |
< |
} else { |
195 |
< |
failsBDT = failsBDTSelection(ctrl,"tight",ele); |
196 |
< |
if( !failsBDT ) isEleTight=1; |
180 |
> |
SimpleLepton tmplep; |
181 |
> |
float pt = mu->Pt(); |
182 |
> |
tmplep.vecorig->SetPtEtaPhiM(pt, |
183 |
> |
mu->Eta(), |
184 |
> |
mu->Phi(), |
185 |
> |
MUON_MASS); |
186 |
> |
|
187 |
> |
if( ctrl.do_escale_up ) { |
188 |
> |
pt=scale_smear_muon_Up(pt, 1, r); |
189 |
> |
} |
190 |
> |
if( ctrl.do_escale_down ) { |
191 |
> |
pt=scale_smear_muon_Down(pt, 1, r); |
192 |
> |
} |
193 |
> |
|
194 |
> |
tmplep.vec->SetPtEtaPhiM(pt, |
195 |
> |
mu->Eta(), |
196 |
> |
mu->Phi(), |
197 |
> |
MUON_MASS); |
198 |
> |
|
199 |
> |
tmplep.type = 13; |
200 |
> |
tmplep.index = i; |
201 |
> |
tmplep.charge = mu->Charge(); |
202 |
> |
tmplep.isoTrk = mu->IsoR03SumPt(); |
203 |
> |
tmplep.isoEcal = mu->IsoR03EmEt(); |
204 |
> |
tmplep.isoHcal = mu->IsoR03HadEt(); |
205 |
> |
tmplep.isoPF03 = computePFMuonIso(mu,vtx,pfCandidates,0.3); |
206 |
> |
tmplep.isoPF04 = computePFMuonIso(mu,vtx,pfCandidates,0.4); |
207 |
> |
tmplep.ip3dSig = mu->Ip3dPVSignificance(); |
208 |
> |
tmplep.is4l = false; |
209 |
> |
tmplep.isEB = (fabs(mu->Eta()) < 1.479 ? 1 : 0 ); |
210 |
> |
tmplep.isTight = musel.tight(); |
211 |
> |
tmplep.isLoose = musel.loose(); |
212 |
> |
lepvec.push_back(tmplep); |
213 |
> |
if( ctrl.debug ) { cout << "muon passes ... " << endl;} |
214 |
|
} |
215 |
< |
FAIL = failsBDT; |
216 |
< |
} |
215 |
> |
// } |
216 |
> |
} |
217 |
> |
|
218 |
> |
|
219 |
> |
|
220 |
> |
// |
221 |
> |
if( ctrl.debug ) { cout << "\tnElectron: " << electronArr->GetEntries() << endl; } |
222 |
> |
// -------------------------------------------------------------------------------- |
223 |
> |
for(Int_t i=0; i<electronArr->GetEntries(); i++) |
224 |
> |
{ |
225 |
> |
const mithep::Electron *ele = (mithep::Electron*)((*electronArr)[i]); |
226 |
> |
|
227 |
> |
Bool_t isMuonOverlap = kFALSE; |
228 |
> |
for (int k=0; k<lepvec.size(); ++k) { |
229 |
> |
TVector3 tmplep; |
230 |
> |
tmplep.SetPtEtaPhi(ele->Pt(), ele->Eta(), ele->Phi()); |
231 |
> |
if ( lepvec[k].isLoose && lepvec[k].type == 13 && lepvec[k].vec->Vect().DrEtaPhi(tmplep) < 0.1 ) { |
232 |
> |
if( ctrl.debug ) cout << "-----> isMuonOverlap! " << endl; |
233 |
> |
isMuonOverlap = kTRUE; |
234 |
> |
break; |
235 |
> |
} |
236 |
> |
} |
237 |
> |
|
238 |
> |
SelectionStatus elesel; |
239 |
> |
if( ctrl.debug ) cout << "--> status before anything: " << hex << elesel.getStatus() << dec << endl; |
240 |
> |
elesel |= (*ElectronPreSelector)(ctrl,ele,vtx); |
241 |
> |
if( ctrl.debug ) cout << "--> status after presel: " << hex << elesel.getStatus() << dec << endl; |
242 |
> |
elesel |= (*ElectronIDSelector)(ctrl,ele,vtx); |
243 |
> |
if( ctrl.debug ) cout << "--> status after ID: " << hex << elesel.getStatus() << dec << endl; |
244 |
> |
elesel |= (*ElectronIsoSelector)(ctrl,ele,vtx,pfCandidates,puEnergyDensity,eraEle,muonsToVeto,electronsToVeto); |
245 |
> |
if( ctrl.debug ) cout << "--> status after iso: " << hex << elesel.getStatus() << dec << endl; |
246 |
> |
|
247 |
> |
if( ctrl.debug ){ |
248 |
> |
cout << "\tscEt: " << ele->SCluster()->Et() |
249 |
> |
<< "\tscEta: " << ele->SCluster()->Eta() |
250 |
> |
<< "\tstatus: " << hex << elesel.getStatus() << dec |
251 |
> |
<< endl; |
252 |
> |
} |
253 |
|
|
254 |
+ |
if ( elesel.pass() && !isMuonOverlap ) |
255 |
+ |
{ |
256 |
+ |
SimpleLepton tmplep; |
257 |
+ |
|
258 |
+ |
float pt = ele->Pt(); |
259 |
+ |
tmplep.vecorig->SetPtEtaPhiM( pt, |
260 |
+ |
ele->Eta(), |
261 |
+ |
ele->Phi(), |
262 |
+ |
ELECTRON_MASS ); |
263 |
+ |
|
264 |
+ |
if( ctrl.do_escale ) { |
265 |
+ |
pt=scale_smear_electron(pt, ele->IsEB(), r); |
266 |
+ |
} |
267 |
+ |
if( ctrl.do_escale_up ) { |
268 |
+ |
pt=scale_smear_electron_Up(pt, ele->IsEB(), r); |
269 |
+ |
} |
270 |
+ |
if( ctrl.do_escale_down ) { |
271 |
+ |
pt=scale_smear_electron_Down(pt, ele->IsEB(), r); |
272 |
+ |
} |
273 |
|
|
274 |
< |
if( ctrl.debug ){ |
275 |
< |
cout << "CIC category: " << cicCategory(ele) |
276 |
< |
<< "\tlikelihood: " << ele->likelihood |
277 |
< |
<< "\tFAIL: 0x" << hex << FAIL << dec |
278 |
< |
<< "\tfailsCIC: 0x" << hex << failsCIC << dec |
279 |
< |
<< "\tfailsLike: 0x" << hex << failsLike << dec |
280 |
< |
<< "\tfailsBDT: 0x" << hex << failsBDT << dec |
281 |
< |
<< "\tscEt: " << ele->scEt |
282 |
< |
<< "\tscEta: " << ele->scEta |
283 |
< |
<< "\tncluster: " << ele->ncluster |
284 |
< |
<< endl; |
274 |
> |
|
275 |
> |
tmplep.vec->SetPtEtaPhiM( pt, |
276 |
> |
ele->Eta(), |
277 |
> |
ele->Phi(), |
278 |
> |
ELECTRON_MASS ); |
279 |
> |
|
280 |
> |
tmplep.type = 11; |
281 |
> |
tmplep.index = i; |
282 |
> |
tmplep.charge = ele->Charge(); |
283 |
> |
tmplep.isoTrk = ele->TrackIsolationDr03(); |
284 |
> |
tmplep.isoEcal = ele->EcalRecHitIsoDr03(); |
285 |
> |
tmplep.isoHcal = ele->HcalTowerSumEtDr03(); |
286 |
> |
tmplep.isoPF03 = computePFEleIso(ele,vtx,pfCandidates,0.3); |
287 |
> |
tmplep.isoPF04 = computePFEleIso(ele,vtx,pfCandidates,0.4); |
288 |
> |
tmplep.ip3dSig = ele->Ip3dPVSignificance(); |
289 |
> |
tmplep.is4l = false; |
290 |
> |
tmplep.isEB = ele->IsEB(); |
291 |
> |
tmplep.scID = ele->SCluster()->GetUniqueID(); |
292 |
> |
tmplep.isTight = elesel.tight(); |
293 |
> |
tmplep.isLoose = elesel.loose(); |
294 |
> |
lepvec.push_back(tmplep); |
295 |
> |
if( ctrl.debug ) { cout << "\telectron passes ... " << endl; } |
296 |
> |
} |
297 |
> |
} |
298 |
> |
|
299 |
> |
|
300 |
> |
//******************************************************** |
301 |
> |
// Dump Stuff |
302 |
> |
//******************************************************** |
303 |
> |
sort( lepvec.begin(), lepvec.end(), SimpleLepton::lep_pt_sort ); |
304 |
> |
int nmu=0, nele=0; |
305 |
> |
for( int i=0; i<lepvec.size(); i++ ) { |
306 |
> |
if(ctrl.debug) cout << "lepvec :: index: " << i |
307 |
> |
<< "\tpt: " << lepvec[i].vec->Pt() |
308 |
> |
<< "\ttype: " << lepvec[i].type |
309 |
> |
<< endl; |
310 |
> |
if( abs(lepvec[i].type) == 11 ) nele++; |
311 |
> |
else nmu++; |
312 |
|
} |
313 |
< |
if ( !FAIL && !isMuonOverlap ) { |
314 |
< |
SimpleLepton tmplep; |
315 |
< |
|
316 |
< |
float pt = ele->pt; |
317 |
< |
if( ctrl.do_escale_up ) pt*=(1.02); |
295 |
< |
if( ctrl.do_escale_down ) pt*=(0.98); |
296 |
< |
|
297 |
< |
tmplep.vec.SetPtEtaPhiM( pt, |
298 |
< |
ele->eta, |
299 |
< |
ele->phi, |
300 |
< |
0.51099892e-3 ); |
301 |
< |
tmplep.type = 11; |
302 |
< |
tmplep.index = i; |
303 |
< |
tmplep.charge = ele->q; |
304 |
< |
tmplep.isoTrk = ele->trkIso03; |
305 |
< |
tmplep.isoEcal = ele->emIso03; |
306 |
< |
tmplep.isoHcal = ele->hadIso03; |
307 |
< |
tmplep.isoPF03 = ele->pfIso03; |
308 |
< |
tmplep.isoPF04 = ele->pfIso04; |
309 |
< |
tmplep.ip3dSig = ele->ip3dSig; |
310 |
< |
tmplep.is4l = false; |
311 |
< |
tmplep.isTight = isEleTight; |
312 |
< |
tmplep.isEB = ele->isEB; |
313 |
< |
lepvec.push_back(tmplep); |
314 |
< |
if( ctrl.debug ) { cout << "\telectron passes ... " << endl; } |
313 |
> |
if( ctrl.debug ) { |
314 |
> |
cout << "postsel nlep: " << lepvec.size() |
315 |
> |
<< "\tnmuon: " << nmu |
316 |
> |
<< "\tnelectron: " << nele |
317 |
> |
<< endl; |
318 |
|
} |
319 |
< |
} |
320 |
< |
|
321 |
< |
sort( lepvec.begin(), lepvec.end(), SimpleLepton::lep_pt_sort ); |
322 |
< |
|
323 |
< |
for( int i=0; i<lepvec.size(); i++ ) { |
324 |
< |
// |
325 |
< |
// check for a matched btagged jet |
326 |
< |
// |
327 |
< |
lepvec[i].tche = -1; |
328 |
< |
lepvec[i].tchp = -1; |
329 |
< |
lepvec[i].csv = -1; |
330 |
< |
lepvec[i].csvMva = -1; |
331 |
< |
|
332 |
< |
if( jetArr != NULL ) { |
333 |
< |
for(int k=0; k<jetArr->GetEntries(); k++) { |
334 |
< |
const mithep::TJet *jet = (mithep::TJet*)((*jetArr)[k]); |
335 |
< |
TVector3 jvec; |
336 |
< |
jvec.SetPtEtaPhi(jet->pt, jet->eta, jet->phi); |
337 |
< |
if( jvec.DrEtaPhi( lepvec[i].vec.Vect()) < 0.2 ) { |
338 |
< |
lepvec[i].tche = jet->tche; |
339 |
< |
lepvec[i].tchp = jet->tchp; |
340 |
< |
lepvec[i].csv = jet->csv; |
341 |
< |
lepvec[i].csvMva = jet->csvMva; |
319 |
> |
|
320 |
> |
|
321 |
> |
//****************************************************************************** |
322 |
> |
// Z1 Selection |
323 |
> |
//****************************************************************************** |
324 |
> |
int Z1LeptonPlusIndex = -1; |
325 |
> |
int Z1LeptonMinusIndex = -1; |
326 |
> |
double BestZ1Mass = -999; |
327 |
> |
if( ctrl.debug ) { cout << "looking for a Z1 ..." << endl; } |
328 |
> |
for(int i = 0; i < lepvec.size(); ++i) { |
329 |
> |
if( !(lepvec[i].isLoose) ) continue; |
330 |
> |
for(int j = i+1; j < lepvec.size(); ++j) { |
331 |
> |
if( !(lepvec[j].isLoose) ) continue; |
332 |
> |
if( ctrl.debug ) { cout << "\tconsidering leptons " << i << " & " << j << endl; } |
333 |
> |
if (!(lepvec[i].vec->Pt() > 20.0 || lepvec[j].vec->Pt() > 20.0)) continue; |
334 |
> |
if( ctrl.debug ) { cout << "\tat least one is > 20 GeV" << endl; } |
335 |
> |
if (!(lepvec[i].vec->Pt() > 10.0 && lepvec[j].vec->Pt() > 10.0)) continue; |
336 |
> |
if( ctrl.debug ) { cout << "\tthe other is > 10 GeV" << endl; } |
337 |
> |
if (lepvec[i].charge == lepvec[j].charge) continue; |
338 |
> |
if( ctrl.debug ) { cout << "\tthey're opposite charge" << endl; } |
339 |
> |
if (fabs(lepvec[i].type) != fabs(lepvec[j].type)) continue; |
340 |
> |
if( ctrl.debug ) { cout << "\tthey're same flavor" << endl; } |
341 |
> |
|
342 |
> |
//Make Z1 hypothesis |
343 |
> |
TLorentzVector *leptonPlus, *leptonMinus; |
344 |
> |
if ( lepvec[i].charge > 0 ) { |
345 |
> |
leptonPlus = lepvec[i].vec; |
346 |
> |
leptonMinus = lepvec[j].vec; |
347 |
> |
} else { |
348 |
> |
leptonPlus = lepvec[j].vec; |
349 |
> |
leptonMinus = lepvec[i].vec; |
350 |
> |
} |
351 |
> |
|
352 |
> |
float tmpZ1Mass = (*leptonPlus + *leptonMinus).M(); |
353 |
> |
if( ctrl.debug ) cout << "Z1 selection, tmpZ1Mass: " << tmpZ1Mass << endl; |
354 |
> |
if( tmpZ1Mass > 50 ) { |
355 |
> |
if (fabs(tmpZ1Mass - Z_MASS) < fabs(BestZ1Mass - Z_MASS)) { |
356 |
> |
BestZ1Mass = tmpZ1Mass; |
357 |
> |
if( ctrl.debug ) cout << "Z1 selection, new BestZ1Mass: " << BestZ1Mass |
358 |
> |
<< "\tdM: " << fabs(BestZ1Mass - Z_MASS) |
359 |
> |
<< endl; |
360 |
> |
if (lepvec[i].charge > 0) { |
361 |
> |
Z1LeptonPlusIndex = i; |
362 |
> |
Z1LeptonMinusIndex = j; |
363 |
> |
} else { |
364 |
> |
Z1LeptonPlusIndex = j; |
365 |
> |
Z1LeptonMinusIndex = i; |
366 |
> |
} |
367 |
> |
} |
368 |
|
} |
369 |
|
} |
370 |
|
} |
371 |
< |
} |
372 |
< |
|
373 |
< |
int nmu=0, nele=0; |
374 |
< |
for( int i=0; i<lepvec.size(); i++ ) { |
375 |
< |
if( abs(lepvec[i].type) == 11 ) nele++; |
376 |
< |
else nmu++; |
377 |
< |
} |
378 |
< |
if( ctrl.debug ) { |
379 |
< |
cout << "postsel nlep: " << lepvec.size() |
380 |
< |
<< "\tnmuon: " << nmu |
381 |
< |
<< "\tnelectron: " << nele |
382 |
< |
<< endl; |
383 |
< |
} |
384 |
< |
|
385 |
< |
//****************************************************************************** |
386 |
< |
//Z1 Selection |
387 |
< |
//****************************************************************************** |
388 |
< |
int Z1LeptonPlusIndex = -1; |
389 |
< |
int Z1LeptonMinusIndex = -1; |
390 |
< |
double BestZ1Mass = -999; |
391 |
< |
if( ctrl.debug ) { cout << "looking for a Z1 ..." << endl; } |
392 |
< |
for(int i = 0; i < lepvec.size(); ++i) { |
393 |
< |
for(int j = i+1; j < lepvec.size(); ++j) { |
394 |
< |
if( ctrl.debug ) { cout << "\tconsidering leptons " << i << " & " << j << endl; } |
395 |
< |
if (!(lepvec[i].vec.Pt() > 20.0 || lepvec[j].vec.Pt() > 20.0)) continue; |
396 |
< |
if( ctrl.debug ) { cout << "\tat least one is > 20 GeV" << endl; } |
397 |
< |
if (!(lepvec[i].vec.Pt() > 10.0 && lepvec[j].vec.Pt() > 10.0)) continue; |
398 |
< |
if( ctrl.debug ) { cout << "\tthe other is > 10 GeV" << endl; } |
399 |
< |
if (lepvec[i].charge == lepvec[j].charge) continue; |
400 |
< |
if( ctrl.debug ) { cout << "\tthey're opposite charge" << endl; } |
401 |
< |
if (fabs(lepvec[i].type) != fabs(lepvec[j].type)) continue; |
402 |
< |
if( ctrl.debug ) { cout << "\tthey're same flavor" << endl; } |
371 |
> |
// stop if no Z1 candidate is found |
372 |
> |
if( BestZ1Mass < 0 ) { |
373 |
> |
evtfail |= (1<<EVTFAIL_Z1); |
374 |
> |
//ret.status = evtfail; |
375 |
> |
ret.status.setStatus(0); |
376 |
> |
return ret; |
377 |
> |
} |
378 |
> |
if( ctrl.debug ) cout << "\tgot a Z1 ... run: " << info->RunNum() << "\tevt: " << info->EvtNum() << endl; |
379 |
> |
if( ctrl.debug ) cout << "\tZ1 plusindex: " << Z1LeptonPlusIndex << "\tminusindex: " << Z1LeptonMinusIndex << endl; |
380 |
> |
TLorentzVector Z1LeptonPlus = *(lepvec[Z1LeptonPlusIndex].vec); |
381 |
> |
TLorentzVector Z1LeptonMinus = *(lepvec[Z1LeptonMinusIndex].vec); |
382 |
> |
TLorentzVector Z1Candidate = Z1LeptonPlus + Z1LeptonMinus; |
383 |
> |
|
384 |
> |
|
385 |
> |
//****************************************************************************** |
386 |
> |
// Z1 + l |
387 |
> |
//****************************************************************************** |
388 |
> |
if( lepvec.size() < 3 ) { |
389 |
> |
evtfail |= (1<<EVTFAIL_Z1_PLUSL); |
390 |
> |
//ret.status = evtfail; |
391 |
> |
ret.status.setStatus(0); |
392 |
> |
return ret; |
393 |
> |
} |
394 |
> |
|
395 |
> |
//****************************************************************************** |
396 |
> |
// 4l/Z2 Selection |
397 |
> |
//****************************************************************************** |
398 |
> |
Int_t Z2LeptonPlusIndex = -1; |
399 |
> |
Int_t Z2LeptonMinusIndex = -1; |
400 |
> |
Double_t BestZ2Mass = -1; |
401 |
> |
if( ctrl.debug ) cout << "looking for a Z2 ... out of " << lepvec.size() << " leptons" <<endl; |
402 |
> |
for(int i = 0; i < lepvec.size(); ++i) { |
403 |
> |
|
404 |
> |
if( ctrl.debug) cout << "i: " << i |
405 |
> |
<< "\tpt: " << lepvec[i].vec->Pt() |
406 |
> |
<< "\ttype: " << lepvec[i].type |
407 |
> |
<< endl; |
408 |
|
|
409 |
< |
//Make Z1 hypothesis |
410 |
< |
TLorentzVector leptonPlus, leptonMinus; |
411 |
< |
if ( lepvec[i].charge > 0 ) { |
412 |
< |
leptonPlus = lepvec[i].vec; |
379 |
< |
leptonMinus = lepvec[j].vec; |
380 |
< |
} else { |
381 |
< |
leptonPlus = lepvec[j].vec; |
382 |
< |
leptonMinus = lepvec[i].vec; |
409 |
> |
if( ctrl.eleSeleScheme == "mediumloose" && |
410 |
> |
!(lepvec[i].isTight) ) { |
411 |
> |
if( ctrl.debug) cout << "it's not tight, skipping ... " << endl; |
412 |
> |
continue; |
413 |
|
} |
414 |
|
|
415 |
< |
float tmpZ1Mass = (leptonPlus+leptonMinus).M(); |
416 |
< |
if( ctrl.debug ) cout << "Z1 selection, tmpZ1Mass: " << tmpZ1Mass << endl; |
417 |
< |
if( tmpZ1Mass > 60 ) { |
418 |
< |
if (fabs(tmpZ1Mass - 91.1876) < fabs(BestZ1Mass - 91.1876)) { |
419 |
< |
BestZ1Mass = tmpZ1Mass; |
420 |
< |
if( ctrl.debug ) cout << "Z1 selection, new BestZ1Mass: " << BestZ1Mass |
421 |
< |
<< "\tdM: " << fabs(BestZ1Mass - 91.1876) |
422 |
< |
<< endl; |
415 |
> |
for(int j = i+1; j < lepvec.size(); ++j) { |
416 |
> |
if( ctrl.debug) cout << "\t\tj: " << j |
417 |
> |
<< "\tpt: " << lepvec[j].vec->Pt() |
418 |
> |
<< "\ttype: " << lepvec[j].type |
419 |
> |
<< endl; |
420 |
> |
|
421 |
> |
if( ctrl.eleSeleScheme == "mediumloose" && |
422 |
> |
!(lepvec[j].isTight) ) { |
423 |
> |
if( ctrl.debug) cout << "it's not tight, skipping ... " << endl; |
424 |
> |
continue; |
425 |
> |
} |
426 |
> |
|
427 |
> |
|
428 |
> |
if (i == Z1LeptonPlusIndex || i == Z1LeptonMinusIndex) { |
429 |
> |
if( ctrl.debug) cout << "\ti matches a Z1 index, skipping ..." << endl; |
430 |
> |
continue; //skip Z1 leptons |
431 |
> |
} |
432 |
> |
if (j == Z1LeptonPlusIndex || j == Z1LeptonMinusIndex) { |
433 |
> |
if( ctrl.debug) cout << "\tj matches a Z1 index, skipping ..." << endl; |
434 |
> |
continue; //skip Z1 leptons |
435 |
> |
} |
436 |
> |
if (lepvec[i].charge == lepvec[j].charge) { |
437 |
> |
if( ctrl.debug) cout << "\ti and j are same sign, skipping ..." << endl; |
438 |
> |
continue; //require opp sign |
439 |
> |
} |
440 |
> |
if (fabs(lepvec[i].type) != fabs(lepvec[j].type)) { |
441 |
> |
if( ctrl.debug) cout << "\ti and j are not same flavor, skipping ..." << endl; |
442 |
> |
continue; //require same flavor |
443 |
> |
} |
444 |
> |
|
445 |
> |
|
446 |
> |
//Make Z2 hypothesis |
447 |
> |
TLorentzVector *leptonPlus, *leptonMinus; |
448 |
> |
|
449 |
> |
if (lepvec[i].charge > 0 ) { |
450 |
> |
leptonPlus = lepvec[i].vec; |
451 |
> |
leptonMinus = lepvec[j].vec; |
452 |
> |
} else { |
453 |
> |
leptonPlus = lepvec[j].vec; |
454 |
> |
leptonMinus = lepvec[i].vec; |
455 |
> |
} |
456 |
> |
|
457 |
> |
TLorentzVector dilepton = *leptonPlus + *leptonMinus; |
458 |
> |
TLorentzVector fourLepton = Z1Candidate + dilepton; |
459 |
> |
|
460 |
> |
if( ctrl.debug ) cout << "dilepton.M() : " << dilepton.M() << endl; |
461 |
> |
if( ctrl.debug ) cout << "fourLepton.M() : " << fourLepton.M() << endl; |
462 |
> |
|
463 |
> |
if (!(dilepton.M() > 12.0)) continue; |
464 |
> |
if (!(fourLepton.M() > 100.0)) continue; |
465 |
> |
|
466 |
> |
//for 4e and 4mu, require at least 1 of the other opp sign lepton pairs have mass > 12 |
467 |
> |
if (fabs(lepvec[i].type) == fabs(lepvec[Z1LeptonPlusIndex].type)) { |
468 |
> |
TLorentzVector pair1 = Z1LeptonPlus + *leptonMinus; |
469 |
> |
TLorentzVector pair2 = Z1LeptonMinus + *leptonPlus; |
470 |
> |
if( ctrl.debug ) cout << "pair1: " << pair1.M() << "\tpair2: "<< pair2.M() << endl; |
471 |
> |
if (!(pair1.M() > 12 || pair2.M() > 12)) continue; |
472 |
> |
} |
473 |
> |
|
474 |
> |
|
475 |
> |
//Disambiguiation is done by choosing the pair with the largest ptMax and largest ptMin |
476 |
> |
if (Z2LeptonPlusIndex < 0) { |
477 |
|
if (lepvec[i].charge > 0) { |
478 |
< |
Z1LeptonPlusIndex = i; |
479 |
< |
Z1LeptonMinusIndex = j; |
478 |
> |
Z2LeptonPlusIndex = i; |
479 |
> |
Z2LeptonMinusIndex = j; |
480 |
|
} else { |
481 |
< |
Z1LeptonPlusIndex = j; |
482 |
< |
Z1LeptonMinusIndex = i; |
481 |
> |
Z2LeptonPlusIndex = j; |
482 |
> |
Z2LeptonMinusIndex = i; |
483 |
> |
} |
484 |
> |
} else { |
485 |
> |
Double_t BestPairPtMax = lepvec[Z2LeptonPlusIndex].vec->Pt(); |
486 |
> |
Double_t BestPairPtMin = lepvec[Z2LeptonMinusIndex].vec->Pt(); |
487 |
> |
if (lepvec[Z2LeptonMinusIndex].vec->Pt() > BestPairPtMax) { |
488 |
> |
BestPairPtMax = lepvec[Z2LeptonMinusIndex].vec->Pt(); |
489 |
> |
BestPairPtMin = lepvec[Z2LeptonPlusIndex].vec->Pt(); |
490 |
|
} |
400 |
– |
} |
401 |
– |
} |
402 |
– |
} |
403 |
– |
} |
404 |
– |
// stop if no Z1 candidate is found |
405 |
– |
if( BestZ1Mass < 0 ) { |
406 |
– |
evtfail |= (1<<EVTFAIL_Z1); |
407 |
– |
return evtfail; |
408 |
– |
} |
409 |
– |
if( ctrl.debug ) cout << "\tgot a Z1 ... run: " << info->runNum << "\tevt: " << info->evtNum << endl; |
410 |
– |
if( ctrl.debug ) cout << "\tZ1 plusindex: " << Z1LeptonPlusIndex << "\tminusindex: " << Z1LeptonMinusIndex << endl; |
411 |
– |
TLorentzVector Z1LeptonPlus = lepvec[Z1LeptonPlusIndex].vec; |
412 |
– |
TLorentzVector Z1LeptonMinus = lepvec[Z1LeptonMinusIndex].vec; |
413 |
– |
TLorentzVector Z1Candidate = Z1LeptonPlus + Z1LeptonMinus; |
414 |
– |
if( l != NULL ) { |
415 |
– |
l->vecz1 = Z1Candidate; |
416 |
– |
l->vecl1p = Z1LeptonPlus; |
417 |
– |
l->vecl1m = Z1LeptonMinus; |
418 |
– |
} |
419 |
– |
|
420 |
– |
//****************************************************************************** |
421 |
– |
// Z1 + l |
422 |
– |
//****************************************************************************** |
423 |
– |
if( lepvec.size() < 3 ) { |
424 |
– |
evtfail |= (1<<EVTFAIL_Z1_PLUSL); |
425 |
– |
return evtfail; |
426 |
– |
} |
491 |
|
|
492 |
< |
//****************************************************************************** |
493 |
< |
// 4l/Z2 Selection |
494 |
< |
//****************************************************************************** |
495 |
< |
Int_t Z2LeptonPlusIndex = -1; |
496 |
< |
Int_t Z2LeptonMinusIndex = -1; |
497 |
< |
Double_t BestZ2Mass = -1; |
498 |
< |
if( ctrl.debug ) cout << "looking for a Z2 ... out of " << lepvec.size() << " leptons" <<endl; |
499 |
< |
for(int i = 0; i < lepvec.size(); ++i) { |
500 |
< |
if( abs(lepvec[i].type) == 11 && |
501 |
< |
ctrl.eleSeleScheme == "mediumloose" && |
502 |
< |
!(lepvec[i].isTight) ) continue; |
439 |
< |
|
440 |
< |
for(int j = i+1; j < lepvec.size(); ++j) { |
441 |
< |
if( abs(lepvec[j].type) == 11 && |
442 |
< |
ctrl.eleSeleScheme == "mediumloose" && |
443 |
< |
!(lepvec[j].isTight) ) continue; |
444 |
< |
|
445 |
< |
// cout << "i: " << i << "\tj: " << j << endl; |
446 |
< |
if (i == Z1LeptonPlusIndex || i == Z1LeptonMinusIndex) { |
447 |
< |
// cout << "\ti matches a Z1 index, skipping ..." << endl; |
448 |
< |
continue; //skip Z1 leptons |
449 |
< |
} |
450 |
< |
if (j == Z1LeptonPlusIndex || j == Z1LeptonMinusIndex) { |
451 |
< |
// cout << "\tj matches a Z1 index, skipping ..." << endl; |
452 |
< |
continue; //skip Z1 leptons |
453 |
< |
} |
454 |
< |
if (lepvec[i].charge == lepvec[j].charge) { |
455 |
< |
// cout << "\ti and j are same sign, skipping ..." << endl; |
456 |
< |
continue; //require opp sign |
457 |
< |
} |
458 |
< |
if (fabs(lepvec[i].type) != fabs(lepvec[j].type)) { |
459 |
< |
// cout << "\ti and j are not same flavor, skipping ..." << endl; |
460 |
< |
continue; //require same flavor |
461 |
< |
} |
462 |
< |
|
463 |
< |
|
464 |
< |
//Make Z2 hypothesis |
465 |
< |
TLorentzVector leptonPlus, leptonMinus; |
466 |
< |
|
467 |
< |
if (lepvec[i].charge > 0 ) { |
468 |
< |
leptonPlus = lepvec[i].vec; |
469 |
< |
leptonMinus = lepvec[j].vec; |
470 |
< |
} else { |
471 |
< |
leptonPlus = lepvec[j].vec; |
472 |
< |
leptonMinus = lepvec[i].vec; |
473 |
< |
} |
474 |
< |
|
475 |
< |
TLorentzVector dilepton = leptonPlus+leptonMinus; |
476 |
< |
TLorentzVector fourLepton = Z1Candidate + dilepton; |
477 |
< |
|
478 |
< |
if( ctrl.debug ) cout << "dilepton.M() : " << dilepton.M() << endl; |
479 |
< |
if( ctrl.debug ) cout << "fourLepton.M() : " << fourLepton.M() << endl; |
480 |
< |
|
481 |
< |
if (!(dilepton.M() > 12.0)) continue; |
482 |
< |
if (!(fourLepton.M() > 100.0)) continue; |
483 |
< |
|
484 |
< |
/* |
485 |
< |
//for 4e and 4mu, require at least 1 of the other opp sign lepton pairs have mass > 12 |
486 |
< |
if (fabs(lepvec[i].type) == fabs(lepvec[Z1LeptonPlusIndex].type)) { |
487 |
< |
TLorentzVector pair1 = Z1LeptonPlus+leptonMinus; |
488 |
< |
TLorentzVector pair2 = Z1LeptonMinus+leptonPlus; |
489 |
< |
if( ctrl.debug ) cout << "pair1: " << pair1.M() << "\tpair2: "<< pair2.M() << endl; |
490 |
< |
if (!(pair1.M() > 12 || pair2.M() > 12)) continue; |
491 |
< |
} |
492 |
< |
*/ |
493 |
< |
|
494 |
< |
//Disambiguiation is done by choosing the pair with the largest ptMax and largest ptMin |
495 |
< |
if (Z2LeptonPlusIndex < 0) { |
496 |
< |
if (lepvec[i].charge > 0) { |
497 |
< |
Z2LeptonPlusIndex = i; |
498 |
< |
Z2LeptonMinusIndex = j; |
499 |
< |
} else { |
500 |
< |
Z2LeptonPlusIndex = j; |
501 |
< |
Z2LeptonMinusIndex = i; |
502 |
< |
} |
503 |
< |
} else { |
504 |
< |
Double_t BestPairPtMax = lepvec[Z2LeptonPlusIndex].vec.Pt(); |
505 |
< |
Double_t BestPairPtMin = lepvec[Z2LeptonMinusIndex].vec.Pt(); |
506 |
< |
if (lepvec[Z2LeptonMinusIndex].vec.Pt() > BestPairPtMax) { |
507 |
< |
BestPairPtMax = lepvec[Z2LeptonMinusIndex].vec.Pt(); |
508 |
< |
BestPairPtMin = lepvec[Z2LeptonPlusIndex].vec.Pt(); |
509 |
< |
} |
510 |
< |
|
511 |
< |
Double_t CurrentPairPtMax = lepvec[i].vec.Pt(); |
512 |
< |
Double_t CurrentPairPtMin = lepvec[j].vec.Pt(); |
513 |
< |
if (lepvec[j].vec.Pt() > CurrentPairPtMax) { |
514 |
< |
CurrentPairPtMax = lepvec[j].vec.Pt(); |
515 |
< |
CurrentPairPtMin = lepvec[i].vec.Pt(); |
516 |
< |
} |
517 |
< |
|
518 |
< |
if (CurrentPairPtMax > BestPairPtMax) { |
519 |
< |
if (lepvec[i].charge > 0) { |
520 |
< |
Z2LeptonPlusIndex = i; |
521 |
< |
Z2LeptonMinusIndex = j; |
522 |
< |
} else { |
523 |
< |
Z2LeptonPlusIndex = j; |
524 |
< |
Z2LeptonMinusIndex = i; |
525 |
< |
} |
526 |
< |
} else if (CurrentPairPtMax == BestPairPtMax) { |
527 |
< |
if (CurrentPairPtMin > BestPairPtMin) { |
528 |
< |
if (lepvec[i].charge > 0) { |
529 |
< |
Z2LeptonPlusIndex = i; |
530 |
< |
Z2LeptonMinusIndex = j; |
531 |
< |
} else { |
532 |
< |
Z2LeptonPlusIndex = j; |
533 |
< |
Z2LeptonMinusIndex = i; |
534 |
< |
} |
535 |
< |
} |
536 |
< |
} |
537 |
< |
} |
538 |
< |
} |
539 |
< |
} |
540 |
< |
|
541 |
< |
// stop if no Z2 candidate is found |
542 |
< |
if (Z2LeptonPlusIndex == -1) { |
543 |
< |
evtfail |= ( 1<<EVTFAIL_4L ); |
544 |
< |
return evtfail; |
545 |
< |
// h_evtfail->Fill( evtfail ); |
546 |
< |
// cout << "evtfail: " << hex << evtfail << dec << endl; |
547 |
< |
// continue; |
548 |
< |
} |
549 |
< |
if( ctrl.debug ) cout << "\tgot a Z2 ..." << endl; |
550 |
< |
if( ctrl.debug ) cout << "\tZ2 plusindex: " << Z2LeptonPlusIndex |
551 |
< |
<< "\tminusindex: " << Z2LeptonMinusIndex << endl; |
552 |
< |
TLorentzVector Z2LeptonPlus = lepvec[Z2LeptonPlusIndex].vec; |
553 |
< |
TLorentzVector Z2LeptonMinus = lepvec[Z2LeptonMinusIndex].vec; |
554 |
< |
TLorentzVector Z2Candidate = Z2LeptonPlus+Z2LeptonMinus; |
555 |
< |
TLorentzVector ZZSystem = Z1Candidate + Z2Candidate; |
556 |
< |
if( l != NULL ) { |
557 |
< |
l->vecz2 = Z2Candidate; |
558 |
< |
l->vecl2p = Z2LeptonPlus; |
559 |
< |
l->vecl2m = Z2LeptonMinus; |
560 |
< |
l->vec4l = ZZSystem; |
561 |
< |
} |
562 |
< |
lepvec[Z1LeptonPlusIndex].is4l = true; |
563 |
< |
lepvec[Z1LeptonMinusIndex].is4l = true; |
564 |
< |
lepvec[Z2LeptonPlusIndex].is4l = true; |
565 |
< |
lepvec[Z2LeptonMinusIndex].is4l = true; |
566 |
< |
|
567 |
< |
//*************************************************************** |
568 |
< |
// Isolation |
569 |
< |
//*************************************************************** |
570 |
< |
bool failiso=false; |
571 |
< |
|
572 |
< |
if( ctrl.isoScheme == "pf" ) { |
573 |
< |
|
574 |
< |
for( int i=0; i<lepvec.size(); i++ ) { |
575 |
< |
|
576 |
< |
if( !(lepvec[i].is4l) ) continue; |
577 |
< |
|
578 |
< |
if( abs(lepvec[i].type) == 11 ) { |
579 |
< |
float reliso = lepvec[i].isoPF04/lepvec[i].vec.Pt(); |
580 |
< |
if( lepvec[i].isEB && lepvec[i].vec.Pt() > 20 && reliso > PFISO_ELE_LOOSE_EB_HIGHPT ) { |
581 |
< |
failiso = true; |
582 |
< |
break; |
583 |
< |
} |
584 |
< |
if( lepvec[i].isEB && lepvec[i].vec.Pt() < 20 && reliso > PFISO_ELE_LOOSE_EB_LOWPT ) { |
585 |
< |
failiso = true; |
586 |
< |
break; |
587 |
< |
} |
588 |
< |
if( !(lepvec[i].isEB) && lepvec[i].vec.Pt() > 20 && reliso > PFISO_ELE_LOOSE_EE_HIGHPT ) { |
589 |
< |
failiso = true; |
590 |
< |
break; |
591 |
< |
} |
592 |
< |
if( !(lepvec[i].isEB) && lepvec[i].vec.Pt() < 20 && reliso > PFISO_ELE_LOOSE_EE_LOWPT ) { |
593 |
< |
failiso = true; |
594 |
< |
break; |
595 |
< |
} |
596 |
< |
} |
597 |
< |
|
598 |
< |
if( abs(lepvec[i].type) == 13 ) { |
599 |
< |
|
600 |
< |
/* |
601 |
< |
float reliso = lepvec[i].isoPF03/lepvec[i].vec.Pt(); |
602 |
< |
if( lepvec[i].isEB && lepvec[i].vec.Pt() > 20 && reliso > PFISO_MU_LOOSE_EB_HIGHPT ) { //0.13 |
603 |
< |
failiso = true; |
604 |
< |
break; |
605 |
< |
} |
606 |
< |
if( lepvec[i].isEB && lepvec[i].vec.Pt() < 20 && reliso > PFISO_MU_LOOSE_EB_LOWPT ) { //0.06 |
607 |
< |
failiso = true; |
608 |
< |
break; |
609 |
< |
} |
610 |
< |
if( !(lepvec[i].isEB) && lepvec[i].vec.Pt() > 20 && reliso > PFISO_MU_LOOSE_EE_HIGHPT ) { //0.09 |
611 |
< |
failiso = true; |
612 |
< |
break; |
613 |
< |
} |
614 |
< |
if( !(lepvec[i].isEB) && lepvec[i].vec.Pt() < 20 && reliso > PFISO_MU_LOOSE_EE_LOWPT ) { //0.05 |
615 |
< |
failiso = true; |
616 |
< |
break; |
617 |
< |
} |
618 |
< |
*/ |
619 |
< |
} |
620 |
< |
} |
621 |
< |
} else if ( ctrl.isoScheme == "pairwise" ) { |
622 |
< |
float rho = info->rho; |
623 |
< |
for( int i=0; i<lepvec.size(); i++ ) { |
624 |
< |
if( !(lepvec[i].is4l) ) continue; |
625 |
< |
float effArea_ecal_i, effArea_hcal_i; |
626 |
< |
if( lepvec[i].isEB ) { |
627 |
< |
if( lepvec[i].type == 11 ) { |
628 |
< |
effArea_ecal_i = 0.101; |
629 |
< |
effArea_hcal_i = 0.021; |
630 |
< |
} else { |
631 |
< |
effArea_ecal_i = 0.074; |
632 |
< |
effArea_hcal_i = 0.022; |
633 |
< |
} |
492 |
> |
Double_t CurrentPairPtMax = lepvec[i].vec->Pt(); |
493 |
> |
Double_t CurrentPairPtMin = lepvec[j].vec->Pt(); |
494 |
> |
if (lepvec[j].vec->Pt() > CurrentPairPtMax) { |
495 |
> |
CurrentPairPtMax = lepvec[j].vec->Pt(); |
496 |
> |
CurrentPairPtMin = lepvec[i].vec->Pt(); |
497 |
> |
} |
498 |
> |
|
499 |
> |
if (CurrentPairPtMax > BestPairPtMax) { |
500 |
> |
if (lepvec[i].charge > 0) { |
501 |
> |
Z2LeptonPlusIndex = i; |
502 |
> |
Z2LeptonMinusIndex = j; |
503 |
|
} else { |
504 |
< |
if( lepvec[i].type == 11 ) { |
505 |
< |
effArea_ecal_i = 0.046; |
637 |
< |
effArea_hcal_i = 0.040; |
638 |
< |
} else { |
639 |
< |
effArea_ecal_i = 0.045; |
640 |
< |
effArea_hcal_i = 0.030; |
641 |
< |
} |
504 |
> |
Z2LeptonPlusIndex = j; |
505 |
> |
Z2LeptonMinusIndex = i; |
506 |
|
} |
507 |
< |
float isoEcal_corr_i = lepvec[i].isoEcal - (effArea_ecal_i*rho); |
508 |
< |
float isoHcal_corr_i = lepvec[i].isoHcal - (effArea_hcal_i*rho); |
509 |
< |
for( int j=i+1; j<lepvec.size(); j++ ) { |
510 |
< |
if( !(lepvec[j].is4l) ) continue; |
511 |
< |
float effArea_ecal_j, effArea_hcal_j; |
648 |
< |
if( lepvec[j].isEB ) { |
649 |
< |
if( lepvec[j].type == 11 ) { |
650 |
< |
effArea_ecal_j = 0.101; |
651 |
< |
effArea_hcal_j = 0.021; |
652 |
< |
} else { |
653 |
< |
effArea_ecal_j = 0.074; |
654 |
< |
effArea_hcal_j = 0.022; |
655 |
< |
} |
507 |
> |
} else if (CurrentPairPtMax == BestPairPtMax) { |
508 |
> |
if (CurrentPairPtMin > BestPairPtMin) { |
509 |
> |
if (lepvec[i].charge > 0) { |
510 |
> |
Z2LeptonPlusIndex = i; |
511 |
> |
Z2LeptonMinusIndex = j; |
512 |
|
} else { |
513 |
< |
if( lepvec[j].type == 11 ) { |
514 |
< |
effArea_ecal_j = 0.046; |
515 |
< |
effArea_hcal_j = 0.040; |
660 |
< |
} else { |
661 |
< |
effArea_ecal_j = 0.045; |
662 |
< |
effArea_hcal_j = 0.030; |
663 |
< |
} |
664 |
< |
} |
665 |
< |
float isoEcal_corr_j = lepvec[j].isoEcal - (effArea_ecal_j*rho); |
666 |
< |
float isoHcal_corr_j = lepvec[j].isoHcal - (effArea_hcal_j*rho); |
667 |
< |
float RIso_i = (lepvec[i].isoTrk+isoEcal_corr_i+isoHcal_corr_i)/lepvec[i].vec.Pt(); |
668 |
< |
float RIso_j = (lepvec[j].isoTrk+isoEcal_corr_j+isoHcal_corr_j)/lepvec[j].vec.Pt(); |
669 |
< |
float comboIso = RIso_i + RIso_j; |
670 |
< |
if( info->evtNum == 1038911933 ) { |
671 |
< |
float tmpdR = lepvec[i].vec.DrEtaPhi(lepvec[j].vec); |
672 |
< |
cout << "i: " << i |
673 |
< |
<< "\tdR: " << tmpdR |
674 |
< |
<< "\trho: " << rho |
675 |
< |
<< "\tRIso_i: " << RIso_i |
676 |
< |
<< "\ttkrel: " << lepvec[i].isoTrk/lepvec[i].vec.Pt() |
677 |
< |
<< "\tecalrel: " << lepvec[i].isoEcal/lepvec[i].vec.Pt() |
678 |
< |
<< "\tecalrelcor: " << isoEcal_corr_i/lepvec[i].vec.Pt() |
679 |
< |
<< "\thcalrel: " << lepvec[i].isoHcal/lepvec[i].vec.Pt() |
680 |
< |
<< "\thcalrelcor: " << isoHcal_corr_i/lepvec[i].vec.Pt() |
681 |
< |
<< "\tpt_i: " << lepvec[i].vec.Pt() |
682 |
< |
<< "\tj: " << j |
683 |
< |
<< "\tRIso_j: " << RIso_j |
684 |
< |
<< "\ttkrel: " << lepvec[j].isoTrk/lepvec[j].vec.Pt() |
685 |
< |
<< "\tecalrel: " << lepvec[j].isoEcal/lepvec[j].vec.Pt() |
686 |
< |
<< "\tecalrelcor: " << isoEcal_corr_j/lepvec[j].vec.Pt() |
687 |
< |
<< "\thcalrel: " << lepvec[j].isoHcal/lepvec[j].vec.Pt() |
688 |
< |
<< "\thcalrelcor: " << isoHcal_corr_j/lepvec[j].vec.Pt() |
689 |
< |
<< "\tpt_j: " << lepvec[j].vec.Pt() |
690 |
< |
<< "\tcombo: " << comboIso |
691 |
< |
<< endl; |
692 |
< |
cout.flush(); |
693 |
< |
} |
694 |
< |
if( comboIso > 0.35 ) { |
695 |
< |
if( ctrl.debug ) cout << "combo failing for indices: " << i << "," << j << endl; |
696 |
< |
failiso = true; |
697 |
< |
// break; |
698 |
< |
} |
513 |
> |
Z2LeptonPlusIndex = j; |
514 |
> |
Z2LeptonMinusIndex = i; |
515 |
> |
} |
516 |
|
} |
517 |
|
} |
518 |
< |
} |
519 |
< |
|
520 |
< |
|
521 |
< |
if( failiso ) { |
522 |
< |
evtfail |= ( 1<<EVTFAIL_ISOLATION ); |
523 |
< |
return evtfail; |
524 |
< |
//h_evtfail->Fill( evtfail, eventweight ); |
525 |
< |
// h_evtfail->Fill( evtfail ); |
526 |
< |
// cout << "evtfail: " << hex << evtfail << dec << endl; |
527 |
< |
// continue; |
528 |
< |
} |
529 |
< |
|
530 |
< |
//*************************************************************** |
531 |
< |
// IP significance |
532 |
< |
//*************************************************************** |
533 |
< |
bool failip = false; |
534 |
< |
for( int i=0; i<lepvec.size(); i++ ) { |
535 |
< |
if( !(lepvec[i].is4l) ) continue; |
536 |
< |
if( lepvec[i].ip3dSig > 4 ) { |
537 |
< |
failip=true; |
538 |
< |
break; |
539 |
< |
} |
540 |
< |
} |
724 |
< |
if( failip ) { |
725 |
< |
evtfail |= (1<<EVTFAIL_IP ); |
726 |
< |
return evtfail; |
727 |
< |
//h_evtfail->Fill( evtfail, eventweight ); |
728 |
< |
// h_evtfail->Fill( evtfail ); |
729 |
< |
// cout << "evtfail: " << hex << evtfail << dec << endl; |
730 |
< |
// continue; |
731 |
< |
} |
732 |
< |
|
733 |
< |
//*************************************************************** |
734 |
< |
// remaining kinematic cuts |
735 |
< |
//*************************************************************** |
736 |
< |
double Z2massCut=0; |
737 |
< |
if ( ctrl.kinematics == "loose" ) Z2massCut = 12; |
738 |
< |
else if ( ctrl.kinematics == "tight" ) Z2massCut = 20; |
739 |
< |
else { cout << "error! kinematic tightness not defined!" << endl; assert(0); } |
740 |
< |
|
741 |
< |
if ( Z1Candidate.M() > 120 || |
742 |
< |
Z2Candidate.M() < Z2massCut || |
743 |
< |
Z2Candidate.M() > 120 || |
744 |
< |
!(lepvec[Z1LeptonPlusIndex].vec.Pt() > 20.0 || lepvec[Z1LeptonMinusIndex].vec.Pt() > 20.0) || |
745 |
< |
!(lepvec[Z1LeptonPlusIndex].vec.Pt() > 10.0 && lepvec[Z1LeptonMinusIndex].vec.Pt() > 10.0) |
746 |
< |
) { |
747 |
< |
evtfail |= (1<<EVTFAIL_KINEMATICS ); |
748 |
< |
return evtfail; |
749 |
< |
//h_evtfail->Fill( evtfail, eventweight ); |
750 |
< |
// h_evtfail->Fill( evtfail ); |
751 |
< |
// cout << "evtfail: " << hex << evtfail << dec << endl; |
752 |
< |
// continue; |
753 |
< |
} |
754 |
< |
|
755 |
< |
unsigned channel; |
756 |
< |
if( lepvec[Z1LeptonMinusIndex].type == 11 && lepvec[Z2LeptonMinusIndex].type == 11 ) channel=0; |
757 |
< |
if( lepvec[Z1LeptonMinusIndex].type == 13 && lepvec[Z2LeptonMinusIndex].type == 13 ) channel=1; |
758 |
< |
if( (lepvec[Z1LeptonMinusIndex].type == 11 && lepvec[Z2LeptonMinusIndex].type == 13) || |
759 |
< |
(lepvec[Z1LeptonMinusIndex].type == 13 && lepvec[Z2LeptonMinusIndex].type == 11)) channel=2; |
760 |
< |
|
761 |
< |
|
762 |
< |
double w_offline=-1, werr_offline=0; |
763 |
< |
double w_online=-1, werr_online=0; |
764 |
< |
|
765 |
< |
if( ctrl.mc ) { |
766 |
< |
|
767 |
< |
vector< pair <double,double> > wlegs; // pair here is eff & err |
768 |
< |
vector< pair <float,float> > mvec; // pair here is eta & pt |
769 |
< |
// now deal with medium vs loose |
770 |
< |
// vector< pair <float,float> > evec; // pair here is eta & pt |
771 |
< |
vector< pair< bool, pair <float,float> > > evec; // pair here is eta & pt |
772 |
< |
|
773 |
< |
for( int k=0; k<lepvec.size(); k++ ) { |
774 |
< |
if( !(lepvec[k].is4l) ) continue; |
775 |
< |
if( abs(lepvec[k].type) == 13 ) { |
776 |
< |
mvec.push_back( std::pair<float,float> (fabs(lepvec[k].vec.Eta()), lepvec[k].vec.Pt()) ); |
777 |
< |
wlegs.push_back( muonPerLegOfflineEfficiencyWeight( fabs(lepvec[k].vec.Eta()), |
778 |
< |
lepvec[k].vec.Pt() ) ); |
779 |
< |
} else { |
780 |
< |
|
781 |
< |
// now deal with medium vs loose |
782 |
< |
// evec.push_back( std::pair<float,float> (fabs(lepvec[k].vec.Eta()), lepvec[k].vec.Pt()) ); |
783 |
< |
|
784 |
< |
std::pair<float,float> tmppair(fabs(lepvec[k].vec.Eta()), lepvec[k].vec.Pt()); |
785 |
< |
evec.push_back( std::pair<bool, std::pair<float,float> > (lepvec[k].isTight, tmppair) ); |
518 |
> |
} |
519 |
> |
} |
520 |
> |
} |
521 |
> |
|
522 |
> |
// stop if no Z2 candidate is found |
523 |
> |
if (Z2LeptonPlusIndex == -1) { |
524 |
> |
evtfail |= ( 1<<EVTFAIL_4L ); |
525 |
> |
// ret.status = evtfail; |
526 |
> |
ret.status.setStatus(0); |
527 |
> |
return ret; |
528 |
> |
} |
529 |
> |
if( ctrl.debug ) cout << "\tgot a Z2 ..." << endl; |
530 |
> |
if( ctrl.debug ) cout << "\tZ2 plusindex: " << Z2LeptonPlusIndex |
531 |
> |
<< "\tminusindex: " << Z2LeptonMinusIndex << endl; |
532 |
> |
TLorentzVector Z2LeptonPlus = *(lepvec[Z2LeptonPlusIndex].vec); |
533 |
> |
TLorentzVector Z2LeptonMinus = *(lepvec[Z2LeptonMinusIndex].vec); |
534 |
> |
TLorentzVector Z2Candidate = Z2LeptonPlus+Z2LeptonMinus; |
535 |
> |
TLorentzVector ZZSystem = Z1Candidate + Z2Candidate; |
536 |
> |
lepvec[Z1LeptonPlusIndex].is4l = true; |
537 |
> |
lepvec[Z1LeptonMinusIndex].is4l = true; |
538 |
> |
lepvec[Z2LeptonPlusIndex].is4l = true; |
539 |
> |
lepvec[Z2LeptonMinusIndex].is4l = true; |
540 |
> |
|
541 |
|
|
787 |
– |
wlegs.push_back( elePerLegOfflineEfficiencyWeight( fabs(lepvec[k].vec.Eta()), |
788 |
– |
lepvec[k].vec.Pt() ) ); |
789 |
– |
} |
790 |
– |
} |
542 |
|
|
543 |
< |
pair<double,double> offpair = getOfflineEfficiencyWeight( wlegs ); |
544 |
< |
w_offline = offpair.first; |
545 |
< |
werr_offline = offpair.second; |
546 |
< |
|
547 |
< |
pair<double,double> onpair = getOnlineEfficiencyWeight( mvec, evec ); |
548 |
< |
w_online = onpair.first; |
549 |
< |
werr_online = onpair.second; |
550 |
< |
|
551 |
< |
} // if mc |
552 |
< |
|
553 |
< |
|
554 |
< |
if( l != NULL ) { |
555 |
< |
l->vec4l = ZZSystem; |
556 |
< |
l->vecz1 = Z1Candidate; |
557 |
< |
l->vecz2 = Z2Candidate; |
558 |
< |
l->vecl1p = lepvec[Z1LeptonPlusIndex].vec; |
559 |
< |
l->vecl1m = lepvec[Z1LeptonMinusIndex].vec; |
560 |
< |
l->vecl2p = lepvec[Z2LeptonPlusIndex].vec; |
561 |
< |
l->vecl2m = lepvec[Z2LeptonMinusIndex].vec; |
562 |
< |
} |
563 |
< |
if( passtuple != NULL ) { |
564 |
< |
unsigned run = info->runNum; |
565 |
< |
unsigned evt = info->evtNum; |
566 |
< |
unsigned lumi = info->lumiSec; |
567 |
< |
unsigned chan = channel; |
568 |
< |
double w = eventweight; |
569 |
< |
float mZ1 = Z1Candidate.M() ; |
570 |
< |
float mZ2 = Z2Candidate.M() ; |
571 |
< |
float m4l = ZZSystem.M() ; |
572 |
< |
float pt4l = ZZSystem.Pt() ; |
573 |
< |
unsigned tZ1 = abs(lepvec[Z1LeptonMinusIndex].type); |
574 |
< |
unsigned tZ2 = abs(lepvec[Z2LeptonMinusIndex].type); |
575 |
< |
float l3tche = lepvec[Z2LeptonMinusIndex].tche; |
576 |
< |
float l4tche = lepvec[Z2LeptonPlusIndex].tche; |
577 |
< |
float l3tchp = lepvec[Z2LeptonMinusIndex].tchp; |
578 |
< |
float l4tchp = lepvec[Z2LeptonPlusIndex].tchp; |
579 |
< |
float l3csv = lepvec[Z2LeptonMinusIndex].csv; |
580 |
< |
float l4csv = lepvec[Z2LeptonPlusIndex].csv; |
581 |
< |
float l3csvMva = lepvec[Z2LeptonMinusIndex].csvMva; |
582 |
< |
float l4csvMva = lepvec[Z2LeptonPlusIndex].csvMva; |
583 |
< |
|
584 |
< |
|
834 |
< |
passtuple->SetBranchAddress("channel", &channel); |
835 |
< |
passtuple->SetBranchAddress("run", &run); |
836 |
< |
passtuple->SetBranchAddress("evt", &evt); |
837 |
< |
passtuple->SetBranchAddress("lumi", &lumi); |
838 |
< |
passtuple->SetBranchAddress("mZ1", &mZ1); |
839 |
< |
passtuple->SetBranchAddress("mZ2", &mZ2); |
840 |
< |
passtuple->SetBranchAddress("tZ1", &tZ1); |
841 |
< |
passtuple->SetBranchAddress("tZ2", &tZ2); |
842 |
< |
passtuple->SetBranchAddress("m4l", &m4l); |
843 |
< |
passtuple->SetBranchAddress("pt4l", &pt4l); |
844 |
< |
passtuple->SetBranchAddress("w", &w); |
845 |
< |
if( ctrl.mc ) { |
846 |
< |
passtuple->SetBranchAddress("woff", &w_offline ); |
847 |
< |
passtuple->SetBranchAddress("werroff", &werr_offline ); |
848 |
< |
passtuple->SetBranchAddress("won", &w_online ); |
849 |
< |
passtuple->SetBranchAddress("werron", &werr_online ); |
850 |
< |
passtuple->SetBranchAddress("npu", &npu ); |
851 |
< |
passtuple->SetBranchAddress("npuw", &npuw ); |
852 |
< |
passtuple->SetBranchAddress("gchannel", &gchannel); |
853 |
< |
} |
854 |
< |
if( ctrl.btag ) { |
855 |
< |
passtuple->SetBranchAddress("l3tche", &l3tche); |
856 |
< |
passtuple->SetBranchAddress("l4tche", &l4tche); |
857 |
< |
passtuple->SetBranchAddress("l3tchp", &l3tchp); |
858 |
< |
passtuple->SetBranchAddress("l4tchp", &l4tchp); |
859 |
< |
passtuple->SetBranchAddress("l3csv", &l3csv); |
860 |
< |
passtuple->SetBranchAddress("l4csv", &l4csv); |
861 |
< |
passtuple->SetBranchAddress("l3csvMva", &l3csvMva); |
862 |
< |
passtuple->SetBranchAddress("l4csvMva", &l4csvMva); |
863 |
< |
} |
543 |
> |
|
544 |
> |
//*************************************************************** |
545 |
> |
// remaining kinematic cuts |
546 |
> |
//*************************************************************** |
547 |
> |
double Z2massCut=0; |
548 |
> |
if ( ctrl.kinematics == "loose" ) Z2massCut = 12; |
549 |
> |
else if ( ctrl.kinematics == "tight" ) Z2massCut = 20; |
550 |
> |
else { cout << "error! kinematic tightness not defined!" << endl; assert(0); } |
551 |
> |
|
552 |
> |
if ( Z1Candidate.M() > 120 || |
553 |
> |
Z2Candidate.M() < Z2massCut || |
554 |
> |
Z2Candidate.M() > 120 || |
555 |
> |
!(lepvec[Z1LeptonPlusIndex].vec->Pt() > 20.0 || lepvec[Z1LeptonMinusIndex].vec->Pt() > 20.0) || |
556 |
> |
!(lepvec[Z1LeptonPlusIndex].vec->Pt() > 10.0 && lepvec[Z1LeptonMinusIndex].vec->Pt() > 10.0) |
557 |
> |
) { |
558 |
> |
evtfail |= (1<<EVTFAIL_KINEMATICS ); |
559 |
> |
// ret.status = evtfail; |
560 |
> |
ret.status.setStatus(0); |
561 |
> |
return ret; |
562 |
> |
} |
563 |
> |
|
564 |
> |
unsigned channel; |
565 |
> |
if( lepvec[Z1LeptonMinusIndex].type == 11 && lepvec[Z2LeptonMinusIndex].type == 11 ) channel=0; |
566 |
> |
if( lepvec[Z1LeptonMinusIndex].type == 13 && lepvec[Z2LeptonMinusIndex].type == 13 ) channel=1; |
567 |
> |
if( (lepvec[Z1LeptonMinusIndex].type == 11 && lepvec[Z2LeptonMinusIndex].type == 13) || |
568 |
> |
(lepvec[Z1LeptonMinusIndex].type == 13 && lepvec[Z2LeptonMinusIndex].type == 11)) channel=2; |
569 |
> |
|
570 |
> |
|
571 |
> |
|
572 |
> |
|
573 |
> |
if( ctrl.debug ) cout << "run: " << info->RunNum() |
574 |
> |
<< "\tevt: " << info->EvtNum() |
575 |
> |
<< "\tZ1channel: " << lepvec[Z1LeptonMinusIndex].type |
576 |
> |
<< "\tZ2channel: " << lepvec[Z2LeptonMinusIndex].type |
577 |
> |
<< "\tmZ1: " << Z1Candidate.M() |
578 |
> |
<< "\tmZ2: " << Z2Candidate.M() |
579 |
> |
<< "\tm4l: " << ZZSystem.M() |
580 |
> |
<< "\tevtfail: " << hex << evtfail << dec |
581 |
> |
// << "\ttrigbits: " << hex << info->triggerBits << dec |
582 |
> |
// << "\ttree: " << inputFiles[q][f] |
583 |
> |
<< endl; |
584 |
> |
|
585 |
|
|
865 |
– |
passtuple->Fill( ); |
866 |
– |
} |
586 |
|
|
587 |
< |
if( ctrl.debug ) cout << "run: " << info->runNum |
588 |
< |
<< "\tevt: " << info->evtNum |
589 |
< |
<< "\tZ1channel: " << lepvec[Z1LeptonMinusIndex].type |
590 |
< |
<< "\tZ2channel: " << lepvec[Z2LeptonMinusIndex].type |
591 |
< |
<< "\tmZ1: " << Z1Candidate.M() |
592 |
< |
<< "\tmZ2: " << Z2Candidate.M() |
593 |
< |
<< "\tm4l: " << ZZSystem.M() |
594 |
< |
<< "\tevtfail: " << hex << evtfail << dec |
595 |
< |
<< "\ttrigbits: " << hex << info->triggerBits << dec |
596 |
< |
// << "\ttree: " << inputFiles[q][f] |
597 |
< |
<< endl; |
587 |
> |
//*************************************************************** |
588 |
> |
// finish |
589 |
> |
//*************************************************************** |
590 |
> |
|
591 |
> |
if( !evtfail ) { |
592 |
> |
ret.status.setStatus(SelectionStatus::EVTPASS); |
593 |
> |
ret.Z1leptons.push_back(lepvec[Z1LeptonMinusIndex]); |
594 |
> |
ret.Z1leptons.push_back(lepvec[Z1LeptonPlusIndex]); |
595 |
> |
ret.Z2leptons.push_back(lepvec[Z2LeptonMinusIndex]); |
596 |
> |
ret.Z2leptons.push_back(lepvec[Z2LeptonPlusIndex]); |
597 |
> |
} |
598 |
|
|
599 |
< |
return evtfail; |
881 |
< |
|
599 |
> |
return ret; |
600 |
|
} |
601 |
|
|
602 |
|
|
885 |
– |
|
886 |
– |
|
887 |
– |
|