susy_cfa  b611ccad937ea179f86a1f5663960264616c0a20
event_handler_quick.cpp
Go to the documentation of this file.
2 
3 #include <iostream>
4 #include <iomanip>
5 #include <vector>
6 #include <string>
7 #include <limits>
8 #include <algorithm>
9 
10 #include "TString.h"
11 #include "TLorentzVector.h"
12 #include "TVector3.h"
13 #include "TVector2.h"
14 #include "TFile.h"
15 #include "TROOT.h"
16 #include "TH1F.h"
17 #include "fastjet/ClusterSequence.hh"
18 
19 #include "event_handler_base.hpp"
20 #include "phys_objects.hpp"
21 #include "utilities.hpp"
22 #include "small_tree_quick.hpp"
23 #include "timer.hpp"
24 
25 using namespace std;
26 using namespace fastjet;
27 
28 //const double CSVCuts[] = {0.244, 0.679, 0.898}; //Run 1 CSV
29 const double CSVCuts[] = {0.605, 0.890, 0.970}; //Run 2 CSV+IVF
30 
31 namespace{
32  const float fltmax = numeric_limits<float>::max();
33 }
34 
36  event_handler_base(file_name){
37 }
38 
39 void event_handler_quick::ReduceTree(int num_entries, const TString &out_file_name, int num_total_entries){
40  TFile *puweights = TFile::Open("pu_weights.root");
41  TH1F * h_wpu = static_cast<TH1F*>(puweights->Get("sf"));
42 
43  TFile out_file(out_file_name, "recreate");
44  out_file.cd();
45 
46  small_tree_quick tree;
47  float xsec = cross_section(out_file_name);
48  float luminosity = 1000.;
49 
50  vector<TString> trig_name;
51  //Leaving 50ns triggers in comments
52  trig_name.push_back("HLT_PFHT350_PFMET100_JetIdCleaned_v"); // 0 trig_name.push_back("HLT_PFHT350_PFMET100_NoiseCleaned_v"); // 0
53  trig_name.push_back("HLT_Mu15_IsoVVVL_PFHT350_PFMET50_v"); // 1 trig_name.push_back("HLT_Mu15_IsoVVVL_PFHT350_PFMET70_v"); // 1
54  trig_name.push_back("HLT_Mu15_IsoVVVL_PFHT600_v"); // 2
55  trig_name.push_back("HLT_Mu15_IsoVVVL_BTagCSV0p72_PFHT400_v"); // 3
56  trig_name.push_back("HLT_Mu15_IsoVVVL_PFHT350_v"); // 4 trig_name.push_back("HLT_Mu15_PFHT300_v"); // 4
57  trig_name.push_back("HLT_Ele15_IsoVVVL_PFHT350_PFMET50_v"); // 5 trig_name.push_back("HLT_Ele15_IsoVVVL_PFHT350_PFMET70_v"); // 5
58  trig_name.push_back("HLT_Ele15_IsoVVVL_PFHT600_v"); // 6
59  trig_name.push_back("HLT_Ele15_IsoVVVL_BTagCSV0p72_PFHT400_v"); // 7
60  trig_name.push_back("HLT_Ele15_IsoVVVL_PFHT350_v"); // 8 trig_name.push_back("HLT_Ele15_PFHT300_v"); // 8
61  trig_name.push_back("HLT_DoubleMu8_Mass8_PFHT300_v"); // 9
62  trig_name.push_back("HLT_DoubleEle8_CaloIdM_TrackIdM_Mass8_PFHT300_v"); // 10
63  trig_name.push_back("HLT_PFHT475_v"); // 11
64  trig_name.push_back("HLT_PFHT800_v"); // 12
65  trig_name.push_back("HLT_PFMET120_NoiseCleaned_Mu5_v"); // 13
66  trig_name.push_back("HLT_PFMET170_NoiseCleaned_v"); // 14
67  trig_name.push_back("HLT_DoubleIsoMu17_eta2p1_v"); // 15
68  trig_name.push_back("HLT_Mu17_TrkIsoVVL_v"); // 16
69  trig_name.push_back("HLT_IsoMu17_eta2p1_v"); // 17
70  trig_name.push_back("HLT_IsoMu20_v"); // 18
71  trig_name.push_back("HLT_IsoMu24_eta2p1_v"); // 19
72  trig_name.push_back("HLT_IsoMu27_v"); // 20
73  trig_name.push_back("HLT_Mu50_v"); // 21
74  trig_name.push_back("HLT_Ele27_eta2p1_WPLoose_Gsf_v"); // 22
75  trig_name.push_back("HLT_Ele32_eta2p1_WPLoose_Gsf_v"); // 23
76  trig_name.push_back("HLT_Ele105_CaloIdVT_GsfTrkIdT_v"); // 24
77  trig_name.push_back("HLT_DoubleEle33_CaloIdL_GsfTrkIdVL_MW_v"); // 25
78  trig_name.push_back("HLT_DoubleEle24_22_eta2p1_WPLoose_Gsf_v"); // 26
79 
80  // This is to save only events in data for which we store the trigger
81  if(isData() && yes_trig.size()==0) yes_trig=trig_name;
82 
83 
84  Timer timer(num_entries, 1.);
85  timer.Start();
86  for(int entry = 0; entry < num_entries; ++entry){
87  timer.Iterate();
88  GetEntry(entry);
89 
90  // Skipping events in the 17Jul2015 re-RECO
91  if(out_file_name.Contains("Run2015B-PromptReco") && run() < 251585) continue;
92 
94  bool golden(PassesJSONCut("golden"));
95  if(isData() && !(PassesJSONCut("dcs") || golden)) continue; // Only saving events with good DCS or golden. DCS not necessarily strict superset of golden now.
96  tree.json_golden() = golden; // Golden JSON
97  //tree.json_dcs()=PassesJSONCut("dcs"); // DCS JSON
98 
100  vector<bool> trig_decision;
101  vector<float> trig_prescale;
102  if(!GetTriggerInfo(trig_name, trig_decision, trig_prescale)) continue;
103  tree.trig()=trig_decision;
105 
106  //cout<<endl<<endl<<"Entry "<<entry<<endl;
107  for(unsigned ind(0); ind<standalone_triggerobject_collectionname()->size(); ind++){
108  TString name(standalone_triggerobject_collectionname()->at(ind));
109  float objpt(standalone_triggerobject_pt()->at(ind));
110  if(name.Contains("MET")||name.Contains("HT")||name.Contains("Combined")||name.Contains("Mu")||
111  name.Contains("Ele")||name.Contains("Egamma"))
112  // cout<<name<<": pt "<<objpt<<", energy "<<standalone_triggerobject_energy()->at(ind)
113  // <<", et "<<standalone_triggerobject_et()->at(ind)<<endl;
114 
115  if(name=="hltPFMETProducer::HLT") tree.onmet() = objpt;
116  if(name=="hltPFHT::HLT") tree.onht() = objpt; // There's 2 of these, and we want the last one
117  if(name=="hltL3MuonCandidates::HLT" && tree.onmaxmu()<objpt) tree.onmaxmu() = objpt;
118  if(name=="hltEgammaCandidates::HLT" && tree.onmaxel()<objpt) tree.onmaxel() = objpt;
119  }
120 
121  tree.event() = event();
122  tree.lumiblock() = lumiblock();
123  tree.run() = run();
124  if(isData()) tree.weight() = 1.;
125  else tree.weight() = Sign(weight())*xsec*luminosity / static_cast<double>(num_total_entries);
126 
127  tree.npv() = Npv();
128  if(isData()) tree.wpu() = 1.;
129  else tree.wpu() = h_wpu->GetBinContent(h_wpu->FindBin(tree.npv()));
130 
131  for(size_t bc(0); bc<PU_bunchCrossing()->size(); ++bc){
132  if(PU_bunchCrossing()->at(bc)==0){
133  tree.ntrupv() = PU_NumInteractions()->at(bc);
134  tree.ntrupv_mean() = PU_TrueNumInteractions()->at(bc);
135  break;
136  }
137  }
139  tree.met() = met_corr();
140  tree.met_phi() = met_phi_corr();
141  tree.met_mini() = pfType1mets_default_et()->at(0);
142  tree.met_mini_phi() = pfType1mets_default_et()->at(0);
143  tree.mindphin_metjet() = GetMinDeltaPhiMETN(3, 50., 2.4, 30., 2.4, true);
144 
145  int nnus = 0, nnus_fromw = 0;
146  double genmetx = 0., genmety = 0., genmetx_fromw = 0, genmety_fromw = 0;
147  for(size_t imc = 0; imc < mc_final_id()->size(); ++imc){
148  int id = abs(TMath::Nint(mc_final_id()->at(imc)));
149  double px = mc_final_pt()->at(imc)*cos(mc_final_phi()->at(imc));
150  double py = mc_final_pt()->at(imc)*sin(mc_final_phi()->at(imc));
151  if(id==12 || id==14 || id==16 || id==18
152  || id==1000012 || id==1000014 || id==1000016
153  || id==1000022 || id==1000023 || id==1000025 || id==1000035 || id==1000039){
154 
155  genmetx += px;
156  genmety += py;
157  nnus++;
158 
159  bool nufromw=false;
160  GetMom(mc_final_id()->at(imc),mc_final_mother_id()->at(imc),mc_final_grandmother_id()->at(imc),mc_final_ggrandmother_id()->at(imc), nufromw);
161 
162  if(nufromw){
163  genmetx_fromw += px;
164  genmety_fromw += py;
165  nnus_fromw++;
166  }
167  }
168  }
169  tree.gen_met() = AddInQuadrature(genmetx, genmety);
170  tree.gen_met_phi() = atan2(genmety, genmetx);
171  tree.ntrunus() = nnus;
172 
173  tree.gen_met_fromw() = AddInQuadrature(genmetx_fromw, genmety_fromw);
174  tree.gen_met_phi_fromw() = atan2(genmety_fromw, genmetx_fromw);
175  tree.ntrunus_fromw() = nnus_fromw;
176 
177  // MET filters
178  tree.pass_hbhe() = static_cast<bool>(HBHENoisefilter_decision());
179  tree.pass_cschalo() = static_cast<bool>(cschalofilter_decision());
180  tree.pass_eebadsc() = static_cast<bool>(eebadscfilter_decision());
181 
182  bool one_good_pv(false);
183  for(unsigned ipv(0); ipv < pv_z()->size(); ipv++){
184  const double pv_rho(sqrt(pv_x()->at(ipv)*pv_x()->at(ipv) + pv_y()->at(ipv)*pv_y()->at(ipv)));
185  if(pv_ndof()->at(ipv)>4 && fabs(pv_z()->at(ipv))<24. && pv_rho<2.0 && pv_isFake()->at(ipv)==0){
186  one_good_pv = true;
187  break;
188  }
189  } // Loop over vertices
190  tree.pass_goodv() = one_good_pv && static_cast<bool>(goodVerticesfilter_decision());
191  // pass_jets() is true if all jets in the event (not matched to leptons) pass loose ID
192  vector<int> sig_electrons = GetElectrons(true, true);
193  vector<int> sig_muons = GetMuons(true, true);
194  tree.pass_jets() = AllGoodJets(sig_electrons, sig_muons, phys_objects::MinJetPt , fltmax);
195 
196  tree.pass() = tree.pass_hbhe()&&tree.pass_goodv()&&tree.pass_cschalo()&&tree.pass_eebadsc()&&tree.pass_jets();
197 
198 
199  TLorentzVector lepmax_p4(0., 0., 0., 0.), lepmax_p4_reliso(0., 0., 0., 0.);
200  short lepmax_chg = 0, lepmax_chg_reliso = 0;
201  vector<int> sig_electrons_reliso = GetElectrons(true, false);
202  vector<int> sig_muons_reliso = GetMuons(true, false);
203  vector<int> veto_electrons = GetElectrons(false, true);
204  vector<int> veto_muons = GetMuons(false, true);
205  vector<int> veto_electrons_reliso = GetElectrons(false, false);
206  vector<int> veto_muons_reliso = GetMuons(false, false);
207  tree.nels() = sig_electrons.size(); tree.nvels() = veto_electrons.size();
208  tree.nels_reliso() = sig_electrons_reliso.size(); tree.nvels_reliso() = veto_electrons_reliso.size();
209  tree.nmus() = sig_muons.size(); tree.nvmus() = veto_muons.size();
210  tree.nmus_reliso() = sig_muons_reliso.size(); tree.nvmus_reliso() = veto_muons_reliso.size();
211 
212  int els_tru_prompt = 0;
213 
214  for(size_t index(0); index<els_pt()->size(); index++) {
215  if (els_pt()->at(index) > MinVetoLeptonPt && IsVetoIdElectron(index)) {
216  tree.els_sigid().push_back(IsSignalIdElectron(index));
217  tree.els_tight().push_back(IsIdElectron(index, kTight, false));
218  tree.els_ispf().push_back(els_isPF()->at(index));
219  tree.els_pt().push_back(els_pt()->at(index));
220  tree.els_eta().push_back(els_eta()->at(index));
221  tree.els_sceta().push_back(els_scEta()->at(index));
222  tree.els_phi().push_back(els_phi()->at(index));
223  tree.els_charge().push_back(TMath::Nint(els_charge()->at(index)));
224  tree.els_mt().push_back(GetMT(els_pt()->at(index), els_phi()->at(index),
225  met_corr(), met_phi_corr()));
226  tree.els_d0().push_back(els_d0dum()->at(index)
227  -pv_x()->at(0)*sin(els_tk_phi()->at(index))
228  +pv_y()->at(0)*cos(els_tk_phi()->at(index)));
229  tree.els_dz().push_back(els_vz()->at(index)-pv_z()->at(0));
230 
231  for(size_t iel(index+1); iel<els_pt()->size(); iel++) {
232  if(IsVetoIdElectron(index) && IsVetoIdElectron(iel)) Setllmass(tree, index, iel, 11, false);
233  if(IsSignalIdElectron(index) && IsSignalIdElectron(iel)) Setllmass(tree, index, iel, 11, true);
234  }
235 
236  // MC truth
237  bool fromW = false;
238  int mcmomID;
239  float deltaR;
240  double els_mc_pt, els_mc_phi;
241  int mcID = GetTrueElectron(static_cast<int>(index), mcmomID, fromW, deltaR, els_mc_pt, els_mc_phi);
242  tree.els_tru_id().push_back(mcID);
243  tree.els_tru_momid().push_back(mcmomID);
244  tree.els_tru_tm().push_back(abs(mcID)==pdtlund::e_minus && fromW);
245  tree.els_tru_dr().push_back(deltaR);
246  tree.els_tru_pt().push_back(els_mc_pt);
247  tree.els_tru_phi().push_back(els_mc_phi);
248 
249  if(abs(mcID)==pdtlund::e_minus && fromW && IsSignalElectron(index,true)){
250  els_tru_prompt++;
251  tree.els_genmt().push_back(GetMT(els_mc_pt, els_mc_phi,
252  tree.gen_met(), tree.gen_met_phi()));
253  tree.els_genmt_fromw().push_back(GetMT(els_mc_pt, els_mc_phi,
254  tree.gen_met_fromw(), tree.gen_met_phi_fromw()));
255  }
256 
257  // Isolation
258  tree.els_reliso().push_back(GetElectronIsolation(index, false));
259  SetMiniIso(tree, index, 11);
260 
261  // Max pT lepton
262  if(els_pt()->at(index) > lepmax_p4.Pt() && IsSignalIdElectron(index) && tree.els_miniso().back()<0.1){
263  lepmax_chg = Sign(els_charge()->at(index));
264  lepmax_p4 = TLorentzVector(els_px()->at(index), els_py()->at(index),
265  els_pz()->at(index), els_energy()->at(index));
266  }
267  if(els_pt()->at(index) > lepmax_p4_reliso.Pt() && IsSignalElectron(index)){
268  lepmax_chg_reliso = Sign(els_charge()->at(index));
269  lepmax_p4_reliso = TLorentzVector(els_px()->at(index), els_py()->at(index),
270  els_pz()->at(index), els_energy()->at(index));
271  }
272  }
273  } // Loop over els
274 
275  tree.nels_tru_prompt() = els_tru_prompt;
276 
277  int mus_tru_prompt = 0;
278 
279  for(size_t index(0); index<mus_pt()->size(); index++) {
280  if (mus_pt()->at(index) > MinVetoLeptonPt && IsVetoIdMuon(index)) {
281  tree.mus_sigid().push_back(IsSignalIdMuon(index));
282  tree.mus_tight().push_back(IsIdMuon(index, kTight));
283  tree.mus_pt().push_back(mus_pt()->at(index));
284  tree.mus_eta().push_back(mus_eta()->at(index));
285  tree.mus_phi().push_back(mus_phi()->at(index));
286  tree.mus_charge().push_back(TMath::Nint(mus_charge()->at(index)));
287  tree.mus_mt().push_back(GetMT(mus_pt()->at(index), mus_phi()->at(index),
288  met_corr(), met_phi_corr()));
289  tree.mus_d0().push_back(mus_tk_d0dum()->at(index)
290  -pv_x()->at(0)*sin(mus_tk_phi()->at(index))
291  +pv_y()->at(0)*cos(mus_tk_phi()->at(index)));
292  tree.mus_dz().push_back(mus_tk_vz()->at(index)-pv_z()->at(0));
293  for(size_t imu(index+1); imu<mus_pt()->size(); imu++) {
294  if(IsVetoIdMuon(index) && IsVetoIdMuon(imu)) Setllmass(tree, index, imu, 13, false);
295  if(IsSignalIdMuon(index) && IsSignalIdMuon(imu)) Setllmass(tree, index, imu, 13, true);
296  }
297 
298  // MC truth
299  bool fromW = false;
300  int mcmomID;
301  float deltaR;
302  double mus_mc_pt, mus_mc_phi;
303  int mcID = GetTrueMuon(static_cast<int>(index), mcmomID, fromW, deltaR, mus_mc_pt, mus_mc_phi);
304  tree.mus_tru_id().push_back(mcID);
305  tree.mus_tru_momid().push_back(mcmomID);
306  tree.mus_tru_tm().push_back(abs(mcID)==pdtlund::mu_minus && fromW);
307  tree.mus_tru_dr().push_back(deltaR);
308  tree.mus_tru_pt().push_back(mus_mc_pt);
309  tree.mus_tru_phi().push_back(mus_mc_phi);
310 
311  // Isolation
312  tree.mus_reliso().push_back(GetMuonIsolation(index, false));
313  SetMiniIso(tree, index, 13);
314 
315  if(abs(mcID)==pdtlund::mu_minus && fromW && IsSignalMuon(index,true)){
316  mus_tru_prompt++;
317  tree.mus_genmt().push_back(GetMT(mus_mc_pt, mus_mc_phi,
318  tree.gen_met(), tree.gen_met_phi()));
319  tree.mus_genmt_fromw().push_back(GetMT(mus_mc_pt, mus_mc_phi,
320  tree.gen_met_fromw(), tree.gen_met_phi_fromw()));
321  }
322 
323  // Max pT lepton
324  if(mus_pt()->at(index) > lepmax_p4.Pt() && IsSignalIdMuon(index) && tree.mus_miniso().back()<0.2){
325  lepmax_chg = Sign(mus_charge()->at(index));
326  lepmax_p4 = TLorentzVector(mus_px()->at(index), mus_py()->at(index),
327  mus_pz()->at(index), mus_energy()->at(index));
328  }
329  if(mus_pt()->at(index) > lepmax_p4_reliso.Pt() && IsSignalMuon(index)){
330  lepmax_chg_reliso = Sign(mus_charge()->at(index));
331  lepmax_p4_reliso = TLorentzVector(mus_px()->at(index), mus_py()->at(index),
332  mus_pz()->at(index), mus_energy()->at(index));
333  }
334  }
335  } // Loop over mus
336 
337  tree.nmus_tru_prompt() = mus_tru_prompt;
338 
339  tree.nleps() = tree.nels() + tree.nmus();
340  tree.nvleps() = tree.nvels() + tree.nvmus();
341 
342  tree.nleps_reliso() = tree.nels_reliso() + tree.nmus_reliso();
343 
344 
345  if(lepmax_p4.Pt()>0.){
346  tree.lep_pt() = lepmax_p4.Pt();
347  tree.lep_phi() = lepmax_p4.Phi();
348  tree.lep_eta() = lepmax_p4.Eta();
349  tree.lep_charge() = lepmax_chg;
350  tree.st() = lepmax_p4.Pt()+met_corr();
351 
352  float wx = mets_et()*cos(mets_phi()) + lepmax_p4.Px();
353  float wy = mets_et()*sin(mets_phi()) + lepmax_p4.Py();
354  float wphi = atan2(wy, wx);
355 
356  tree.dphi_wlep() = DeltaPhi(wphi, lepmax_p4.Phi());
357  tree.mt() = GetMT(lepmax_p4.Pt(), lepmax_p4.Phi(), met_corr(), met_phi_corr());
358  }
359 
360  if(lepmax_p4_reliso.Pt()>0.){
361  tree.lep_pt_reliso() = lepmax_p4_reliso.Pt();
362  tree.lep_phi_reliso() = lepmax_p4_reliso.Phi();
363  tree.lep_eta_reliso() = lepmax_p4_reliso.Eta();
364  tree.lep_charge_reliso() = lepmax_chg_reliso;
365  tree.st_reliso() = lepmax_p4_reliso.Pt()+met_corr();
366 
367  float wx = mets_et()*cos(mets_phi()) + lepmax_p4_reliso.Px();
368  float wy = mets_et()*sin(mets_phi()) + lepmax_p4_reliso.Py();
369  float wphi = atan2(wy, wx);
370 
371  tree.dphi_wlep_reliso() = DeltaPhi(wphi, lepmax_p4_reliso.Phi());
372  tree.mt_reliso() = GetMT(lepmax_p4_reliso.Pt(), lepmax_p4_reliso.Phi(), met_corr(), met_phi_corr());
373  }
374 
375  // vector<mc_particle> parts = GetMCParticles();
376  // vector<size_t> moms = GetMoms(parts);
377  // tree.mc_type() = TypeCode(parts, moms);
378 
379  //**************** No HF variables ***************//
380  //float metnohf(mets_NoHF_et()), metnohfphi(mets_NoHF_phi()), metnohfsumet(mets_NoHF_sumEt());
381  float metnohf(mets_et()), metnohfphi(mets_phi()), metnohfsumet(mets_sumEt());
382 
383  tree.met_nohf() = metnohf;
384  tree.met_nohf_phi() = metnohfphi;
385  tree.met_nohf_sumEt() = metnohfsumet;
386 
387  float met_hf_x = met_corr()*cos(met_phi_corr()) - metnohf*cos(metnohfphi);
388  float met_hf_y = met_corr()*sin(met_phi_corr()) - metnohf*sin(metnohfphi);
389  tree.met_hf() = sqrt(met_hf_x*met_hf_x + met_hf_y*met_hf_y);
390  tree.met_hf_phi() = atan2(met_hf_y,met_hf_x);
391 
392  vector<int> good_jets_nohf = GetJets(sig_electrons, sig_muons, phys_objects::MinJetPt , 3.0);
393  vector<int> good_jets_eta5 = GetJets(sig_electrons, sig_muons, phys_objects::MinJetPt , 5.0);
394 
395  float ht_nohf = GetHT(good_jets_nohf, MinJetPt);
396  float ht_eta5 = GetHT(good_jets_eta5, MinJetPt);
397  tree.ht_hf() = ht_eta5 - ht_nohf;
398 
399  int njets_nohf = GetNumJets(good_jets_nohf, MinJetPt);
400  int njets_eta5 = GetNumJets(good_jets_eta5, MinJetPt);
401  tree.njets_nohf() = njets_nohf;
402  tree.njets_hf() = njets_eta5 - njets_nohf;
403 
404  tree.hfjet() = (njets_eta5 - njets_nohf)>0;
405 
406  //**************** No HF variables ***************//
407 
408  vector<int> good_jets = GetJets(sig_electrons, sig_muons, phys_objects::MinJetPt , 2.4);
409  vector<int> good_jets_reliso = GetJets(sig_electrons_reliso, sig_muons_reliso, phys_objects::MinJetPt , 2.4);
410  tree.njets() = GetNumJets(good_jets, MinJetPt);
411  tree.nbl() = GetNumJets(good_jets, MinJetPt, CSVCuts[0]);
412  tree.nbm() = GetNumJets(good_jets, MinJetPt, CSVCuts[1]);
413  tree.nbt() = GetNumJets(good_jets, MinJetPt, CSVCuts[2]);
414  tree.ht() = GetHT(good_jets, MinJetPt);
415  tree.ht_reliso() = GetHT(good_jets_reliso, MinJetPt);
416  tree.mht() = GetMHT(good_jets, MinJetPt);
417 
418  vector<int> good_jets40 = GetJets(sig_electrons, sig_muons, 40. , 2.4);
419  tree.njets40() = GetNumJets(good_jets40, MinJetPt);
420  tree.nbl40() = GetNumJets(good_jets40, MinJetPt, CSVCuts[0]);
421  tree.nbm40() = GetNumJets(good_jets40, MinJetPt, CSVCuts[1]);
422  tree.nbt40() = GetNumJets(good_jets40, MinJetPt, CSVCuts[2]);
423  tree.ht40() = GetHT(good_jets40, MinJetPt);
424 
425  vector<int> dirty_jets = GetJets(vector<int>(0), vector<int>(0), 30., 5.0);
426  tree.jets_pt().resize(dirty_jets.size());
427  tree.jets_eta().resize(dirty_jets.size());
428  tree.jets_phi().resize(dirty_jets.size());
429  tree.jets_m().resize(dirty_jets.size());
430  tree.jets_csv().resize(dirty_jets.size());
431  tree.jets_id().resize(dirty_jets.size());
432  tree.jets_islep().resize(dirty_jets.size());
433  for(size_t idirty = 0; idirty < dirty_jets.size(); ++idirty){
434  int ijet = dirty_jets.at(idirty);
435  tree.jets_pt().at(idirty) = jets_corr_p4().at(ijet).Pt();
436  tree.jets_eta().at(idirty) = jets_corr_p4().at(ijet).Eta();
437  tree.jets_phi().at(idirty) = jets_corr_p4().at(ijet).Phi();
438  tree.jets_m().at(idirty) = jets_corr_p4().at(ijet).M();
439  tree.jets_csv().at(idirty) = jets_btag_inc_secVertexCombined()->at(ijet);
440  tree.jets_id().at(idirty) = jets_parton_Id()->at(ijet);
441  tree.jets_islep().at(idirty) = !(find(good_jets.begin(), good_jets.end(), ijet) != good_jets.end());
442  }
443  tree.mht_ra2b() = GetMHT(dirty_jets, 30);
444 
445  vector<int> ra2b_jets = GetJets(vector<int>(0), vector<int>(0), 30., 2.4);
446  tree.njets_ra2b() = GetNumJets(ra2b_jets, MinJetPt);
447  tree.nbm_ra2b() = GetNumJets(ra2b_jets, MinJetPt, CSVCuts[1]);
448  tree.ht_ra2b() = GetHT(ra2b_jets, MinJetPt);
449 
450 
451  vector<int> hlt_jets = GetJets(vector<int>(0), vector<int>(0), 40., 3.0);
452  tree.ht_hlt() = GetHT(hlt_jets, 40);
453 
454 
455  vector<int> mj_jets;
456  vector<bool> mj_jets_islep;
457  map<size_t,vector<size_t> > mu_matches, el_matches;
458  GetMatchedLeptons(sig_muons, sig_electrons, mu_matches, el_matches);
459  for(unsigned ijet(0); ijet<jets_corr_p4().size(); ijet++) {
460  if(mu_matches.find(ijet) != mu_matches.end() || el_matches.find(ijet) != el_matches.end()){
461  mj_jets.push_back(static_cast<int>(ijet));
462  mj_jets_islep.push_back(true);
463  } // If lepton in jet
464  // if(mu_matches.find(ijet) != mu_matches.end() && el_matches.find(ijet) != el_matches.end()) {
465  // size_t iel = el_matches[ijet][0];
466  // size_t imu = mu_matches[ijet][0];
467  // cout<<entry<<": Both els and mus match: jet p=("<<jets_pt()->at(ijet)<<","<<jets_eta()->at(ijet)
468  // <<","<<jets_phi()->at(ijet)<<"). el p = ("<<els_pt()->at(iel)<<","<<els_eta()->at(iel)
469  // <<","<<els_phi()->at(iel)<<"). mu p = ("<<mus_pt()->at(imu)<<","<<mus_eta()->at(imu)
470  // <<","<<mus_phi()->at(imu)<<")"<<endl;
471  // }
472  } // Loop over all jets
473  // Adding all clean jets
474  for(unsigned ijet(0); ijet<good_jets.size(); ijet++) {
475  mj_jets.push_back(good_jets[ijet]);
476  mj_jets_islep.push_back(false);
477  } // Loop over good jets
478 
479  WriteFatJets(tree.nfjets(), tree.mj(),
480  tree.fjets_pt(), tree.fjets_eta(),
481  tree.fjets_phi(), tree.fjets_m(),
482  tree.fjets_nconst(),
483  tree.fjets_sumcsv(), tree.fjets_poscsv(),
484  tree.fjets_btags(), tree.jets_fjet_index(),
485  1.2, mj_jets);
486  WriteFatJets(tree.nfjets08(), tree.mj08(),
487  tree.fjets08_pt(), tree.fjets08_eta(),
488  tree.fjets08_phi(), tree.fjets08_m(),
489  tree.fjets08_nconst(),
490  tree.fjets08_sumcsv(), tree.fjets08_poscsv(),
491  tree.fjets08_btags(), tree.jets_fjet08_index(),
492  0.8, mj_jets);
493 
495  std::vector<int> mc_mus, mc_els, mc_taush, mc_tausl;
496  GetTrueLeptons(mc_els, mc_mus, mc_taush, mc_tausl);
497  tree.ntrumus() = mc_mus.size();
498  tree.ntruels() = mc_els.size();
499  tree.ntrutaush() = mc_taush.size();
500  tree.ntrutausl() = mc_tausl.size();
501  tree.ntruleps() = tree.ntrumus()+tree.ntruels()+tree.ntrutaush()+tree.ntrutausl();
502 
503  //for systematics:
504  float toppt1(0),toppt2(0),topphi1(0),topphi2(0);
505  int nisr(0);
506  for(unsigned i = 0; i < mc_doc_id()->size(); ++i){
507  const int id = static_cast<int>(floor(fabs(mc_doc_id()->at(i))+0.5));
508  const int mom = static_cast<int>(floor(fabs(mc_doc_mother_id()->at(i))+0.5));
509  const int gmom = static_cast<int>(floor(fabs(mc_doc_grandmother_id()->at(i))+0.5));
510  const int ggmom = static_cast<int>(floor(fabs(mc_doc_ggrandmother_id()->at(i))+0.5));
511  if(mc_doc_id()->at(i)==6) {toppt1 = mc_doc_pt()->at(i); topphi1 = mc_doc_phi()->at(i);}
512  if(mc_doc_id()->at(i)==(-6)){ toppt2 = mc_doc_pt()->at(i); topphi2 = mc_doc_phi()->at(i);}
513  if(mc_doc_status()->at(i)==23 && id!=6 && mom!=6 && mom!=24 && gmom!=6 && ggmom!=6) nisr++;
514  }
515  tree.trutop1_pt() = toppt1;
516  tree.trutop2_pt() = toppt2;
517  tree.trutop1_phi() = topphi1;
518  tree.trutop2_phi() = topphi2;
519  tree.ntrumeisr() = nisr;
520 
521  tree.genht() = genHT();
522 
523  // int nobj = tree.njets() + tree.nmus() + tree.nels();
524  // int nobj_mj(0);
525  // //int nobj_list(mj_jets.size());
526  // for(unsigned ijet(0); ijet < tree.fjets_nconst().size(); ijet++)
527  // nobj_mj += tree.fjets_nconst().at(ijet);
528  // if(nobj != nobj_mj) cout<<entry<<": nobj "<<nobj<<", nobj_mj "<<nobj_mj<<endl;
529 
530  // if(tree.njets() != static_cast<int>(good_jets.size()))
531  // cout<<entry<<": njets "<<tree.njets()<<", gj_size "<<good_jets.size()<<endl;
532 
533  tree.Fill();
534  }
535 
536  tree.Write();
537 
538  TString model = model_params()->c_str();
539  TString commit = RemoveTrailingNewlines(execute("git rev-parse HEAD"));
540  TString type = tree.Type();
541  TString root_version = gROOT->GetVersion();
542  TString root_tutorial_dir = gROOT->GetTutorialsDir();
543  TTree treeglobal("treeglobal", "treeglobal");
544  treeglobal.Branch("nev_file", &num_entries);
545  treeglobal.Branch("nev_sample", &num_total_entries);
546  treeglobal.Branch("commit", &commit);
547  treeglobal.Branch("model", &model);
548  treeglobal.Branch("type", &type);
549  treeglobal.Branch("root_version", &root_version);
550  treeglobal.Branch("root_tutorial_dir", &root_tutorial_dir);
551  treeglobal.Branch("trig_name", &trig_name);
552  treeglobal.Fill();
553  treeglobal.Write();
554  out_file.Close();
555  puweights->Close();
556 }
557 
558 
559 
561 }
562 
564  float &mj,
565  vector<float> &fjets_pt,
566  vector<float> &fjets_eta,
567  vector<float> &fjets_phi,
568  vector<float> &fjets_m,
569  vector<int> &fjets_nconst,
570  vector<float> &fjets_sumcsv,
571  vector<float> &fjets_poscsv,
572  vector<int> &fjets_btags,
573  vector<int> &jets_fjet_index,
574  double radius,
575  const vector<int> &jets,
576  bool gen,
577  bool clean,
578  const vector<bool> &to_clean){
579  vector<PseudoJet> sjets(0);
580  vector<int> ijets(0);
581  vector<float> csvs(0);
582  jets_fjet_index = vector<int>(jets.size(), -1);
583 
584  if(gen){
585  for(size_t idirty = 0; idirty<jets.size(); ++idirty){
586  int jet = jets.at(idirty);
587  TLorentzVector v;
588  v.SetPtEtaPhiE(mc_jets_pt()->at(jet), mc_jets_eta()->at(jet),
589  mc_jets_phi()->at(jet), mc_jets_energy()->at(jet));
590  const PseudoJet this_pj(v.Px(), v.Py(), v.Pz(), v.E());
591  sjets.push_back(this_pj);
592  ijets.push_back(idirty);
593  csvs.push_back(0.);
594  }
595  }else{
596  for(size_t idirty = 0; idirty<jets.size(); ++idirty){
597 
598  int jet = jets.at(idirty);
599  if(is_nan(jets_corr_p4().at(jet).Px()) || is_nan(jets_corr_p4().at(jet).Py())
600  || is_nan(jets_corr_p4().at(jet).Pz()) || is_nan(jets_corr_p4().at(jet).E())
601  || (clean && to_clean.at(idirty))) continue;
602  const TLorentzVector &this_lv = jets_corr_p4().at(jet);
603  const PseudoJet this_pj(this_lv.Px(), this_lv.Py(), this_lv.Pz(), this_lv.E());
604 
605  sjets.push_back(this_pj);
606  ijets.push_back(idirty);
607  csvs.push_back(jets_btag_inc_secVertexCombined()->at(jet));
608  }
609  }
610 
611  JetDefinition jet_def(antikt_algorithm, radius);
612  ClusterSequence cs(sjets, jet_def);
613  vector<PseudoJet> fjets = sorted_by_m(cs.inclusive_jets());
614  nfjets = 0;
615  mj = 0.;
616  fjets_pt.resize(fjets.size());
617  fjets_eta.resize(fjets.size());
618  fjets_phi.resize(fjets.size());
619  fjets_m.resize(fjets.size());
620  fjets_nconst.resize(fjets.size());
621  fjets_sumcsv.resize(fjets.size());
622  fjets_poscsv.resize(fjets.size());
623  fjets_btags.resize(fjets.size());
624 
625  for(size_t ipj = 0; ipj < fjets.size(); ++ipj){
626  const PseudoJet &pj = fjets.at(ipj);
627  fjets_pt.at(ipj) = pj.pt();
628  fjets_eta.at(ipj) = pj.eta();
629  fjets_phi.at(ipj) = pj.phi_std();
630  fjets_m.at(ipj) = pj.m();
631  const vector<PseudoJet> &cjets = pj.constituents();
632  fjets_nconst.at(ipj) = cjets.size();
633  mj += pj.m();
634  ++nfjets;
635  fjets_btags.at(ipj) = 0;
636  fjets_sumcsv.at(ipj) = 0.;
637  fjets_poscsv.at(ipj) = 0.;
638  for(size_t ijet = 0; ijet < ijets.size(); ++ijet){
639  size_t i = ijets.at(ijet);
640  for(size_t cjet = 0; cjet < cjets.size(); ++ cjet){
641  if((cjets.at(cjet) - sjets.at(ijet)).pt() < 0.0001){
642  jets_fjet_index.at(i) = ipj;
643  fjets_sumcsv.at(ipj) += csvs.at(ijet);
644  if(csvs.at(ijet) > 0.){
645  fjets_poscsv.at(ipj) += csvs.at(ijet);
646  }
647  if(csvs.at(ijet) > CSVCuts[1]){
648  ++(fjets_btags.at(ipj));
649  }
650  }
651  }
652  }
653  }
654 }
655 
656 void event_handler_quick::SetMiniIso(small_tree_quick &tree, int ilep, int ParticleType){
657  // double bignum = std::numeric_limits<double>::max();
658  switch(ParticleType){
659  case 11:
660  tree.els_miniso().push_back(els_miniso()->at(ilep));
661  break;
662  case 13:
663  tree.mus_miniso().push_back(mus_miniso()->at(ilep));
664  break;
665  default:
666  break;
667  }
668 }
669 
670 float event_handler_quick::GetMinMTWb(const vector<int> &good_jets,
671  const double pt_cut,
672  const double bTag_req,
673  const bool use_W_mass) const{
674  float min_mT(fltmax);
675  for (uint ijet(0); ijet<good_jets.size(); ijet++) {
676  uint jet = good_jets[ijet];
677  if (jets_corr_p4().at(jet).Pt()<pt_cut) continue;
678  if (jets_btag_inc_secVertexCombined()->at(jet)<bTag_req) continue;
679  float mT = GetMT(use_W_mass ? 80.385 : 0., met_corr(), met_phi_corr(),
680  0., jets_corr_p4().at(jet).Pt(), jets_corr_p4().at(jet).Phi());
681  if (mT<min_mT) min_mT=mT;
682  }
683  if (min_mT==fltmax) return bad_val;
684  else return min_mT;
685 }
686 
687 unsigned event_handler_quick::TypeCode(const vector<mc_particle> &parts,
688  const vector<size_t> &moms){
689  const string sample_name = SampleName();
690  unsigned sample_code = 0xF;
691  if(Contains(sample_name, "SMS")){
692  sample_code = 0x0;
693  }else if(Contains(sample_name, "TTJets")
694  || Contains(sample_name, "TT_")){
695  sample_code = 0x1;
696  }else if(Contains(sample_name, "WJets")){
697  sample_code = 0x2;
698  }else if(Contains(sample_name, "T_s-channel")
699  || Contains(sample_name, "T_tW-channel")
700  || Contains(sample_name, "T_t-channel")
701  || Contains(sample_name, "Tbar_s-channel")
702  || Contains(sample_name, "Tbar_tW-channel")
703  || Contains(sample_name, "Tbar_t-channel")){
704  sample_code = 0x3;
705  }else if(Contains(sample_name, "QCD")){
706  sample_code = 0x4;
707  }else if(Contains(sample_name, "DY")){
708  sample_code = 0x5;
709  }else{
710  sample_code = 0xF;
711  }
712  unsigned nlep, ntau, ntaul;
713  CountLeptons(parts, moms, nlep, ntau, ntaul);
714  if(nlep > 0xF) nlep = 0xF;
715  if(ntau > 0xF) ntau = 0xF;
716  if(ntaul > 0xF) ntaul = 0xF;
717  return (sample_code << 12) | (nlep << 8) | (ntaul << 4) | ntau;
718 }
719 
720 // MC lepton counting without building the whole tree
721 void event_handler_quick::GetTrueLeptons(vector<int> &true_electrons, vector<int> &true_muons,
722  vector<int> &true_had_taus, vector<int> &true_lep_taus) {
723  true_electrons.clear();
724  true_muons.clear();
725  true_had_taus.clear();
726  true_lep_taus.clear();
727  bool tau_to_3tau(false);
728  vector<int> lep_from_tau;
729  for(unsigned i = 0; i < mc_doc_id()->size(); ++i){
730  const int id = static_cast<int>(floor(fabs(mc_doc_id()->at(i))+0.5));
731  const int mom = static_cast<int>(floor(fabs(mc_doc_mother_id()->at(i))+0.5));
732  const int gmom = static_cast<int>(floor(fabs(mc_doc_grandmother_id()->at(i))+0.5));
733  const int ggmom = static_cast<int>(floor(fabs(mc_doc_ggrandmother_id()->at(i))+0.5));
734 
735 
736  if((id == 11 || id == 13) && (mom == 24 || (mom == 15 && (gmom == 24 || (gmom == 15 && ggmom == 24))))){
737  if (mom == 24) { // Lep from W
738  if (id==11) true_electrons.push_back(i);
739  else if (id==13) true_muons.push_back(i);
740  } else if(!tau_to_3tau) { // Lep from tau, check for Brem
741  uint nlep(1);
742  for(uint j=i+1; j<mc_doc_id()->size(); ++j) {
743  const int idb = static_cast<int>(floor(fabs(mc_doc_id()->at(j))+0.5));
744  const int momb = static_cast<int>(floor(fabs(mc_doc_mother_id()->at(j))+0.5));
745  if(momb==15 && (idb==11 || idb==13)) nlep++;
746  if(momb!=15 || (momb==15&&idb==16) || j==mc_doc_id()->size()-1){
747  if(nlep==1){
748  // if (id==11) true_electrons.push_back(i); // If we want to count isolated leptons
749  // else if (id==13) true_muons.push_back(i);
750  lep_from_tau.push_back(i);
751  }
752  i = j-1; // Moving index to first particle after tau daughters
753  break;
754  }
755  } // Loop over tau daughters
756  } // if lepton comes from tau
757  }
758  if(id == 15 && mom == 24){
759  true_had_taus.push_back(i);
760  }
761  // Counting number of tau->tautautau
762  if((id == 15) && (mom == 15 && (gmom == 24 || (gmom == 15 && ggmom == 24)))){
763  uint nlep(1);
764  for(uint j=i+1; j<mc_doc_id()->size(); ++j) {
765  const int idb = static_cast<int>(floor(fabs(mc_doc_id()->at(j))+0.5));
766  const int momb = static_cast<int>(floor(fabs(mc_doc_mother_id()->at(j))+0.5));
767  if(momb==15 && idb==15) nlep++;
768  if(momb!=15 || (momb==15&&idb==16) || j==mc_doc_id()->size()-1){
769  if(nlep>1) tau_to_3tau = true;
770  i = j-1; // Moving index to first particle after tau daughters
771  break;
772  }
773  } // Loop over tau daughters
774  } // if tau comes from prompt tau
775  } // Loop over mc_doc
776  // Removing leptonic taus from tau list by finding smallest DeltaR(lep,tau)
777  for(unsigned ind = 0; ind < lep_from_tau.size(); ++ind){
778  float minDr(9999.), lepEta(mc_doc_eta()->at(lep_from_tau[ind])), lepPhi(mc_doc_phi()->at(lep_from_tau[ind]));
779  int imintau(-1);
780  for(unsigned itau=0; itau < true_had_taus.size(); itau++){
781  if(mc_doc_mother_id()->at(lep_from_tau[ind]) != mc_doc_id()->at(true_had_taus[itau])) continue;
782  float tauEta(mc_doc_eta()->at(true_had_taus[itau])), tauPhi(mc_doc_phi()->at(true_had_taus[itau]));
783  float tauDr(dR(tauEta,lepEta, tauPhi,lepPhi));
784  if(tauDr < minDr) {
785  minDr = tauDr;
786  imintau = itau;
787  }
788  }
789  if(imintau>=0) {
790  true_lep_taus.push_back(imintau);
791  true_had_taus.erase(true_had_taus.begin()+imintau);
792  } else cout<<"Not found a tau match for lepton "<<ind<<endl; // Should not happen
793  } // Loop over leptons from taus
794  return;
795 }
796 
797 bool event_handler_quick::greater_m(const fastjet::PseudoJet &a, const fastjet::PseudoJet &b){
798  return a.m() > b.m();
799 }
800 
801 vector<fastjet::PseudoJet> event_handler_quick::sorted_by_m(vector<fastjet::PseudoJet> pjs){
802  sort(pjs.begin(), pjs.end(), greater_m);
803  return pjs;
804 }
805 
806 void event_handler_quick::Setllmass(small_tree_quick &tree, size_t id1, size_t id2, int pdgid, bool isSig){
807  typedef float& (small_tree::*sm_float)() ;
808  sm_float ll_m, ll_pt1, ll_pt2, ll_zpt;
809  if(pdgid==11){
810  if(els_charge()->at(id1)*els_charge()->at(id2) > 0) return; // Only using opposite sign leptons
811  if(els_pt()->at(id2) <= MinVetoLeptonPt) return; // Momentum of id1 already checked
812  if(els_miniso()->at(id1)>=0.1 || els_miniso()->at(id2)>=0.1) return; // Use only isolated leptons
813  if(isSig){
814  ll_m = &small_tree::elel_m;
815  ll_pt1 = &small_tree::elel_pt1;
816  ll_pt2 = &small_tree::elel_pt2;
817  ll_zpt = &small_tree::elel_zpt;
818  } else {
819  ll_m = &small_tree::elelv_m;
820  ll_pt1 = &small_tree::elelv_pt1;
821  ll_pt2 = &small_tree::elelv_pt2;
822  ll_zpt = &small_tree::elelv_zpt;
823  }
824  } else if(pdgid==13){
825  if(mus_charge()->at(id1)*mus_charge()->at(id2) > 0) return; // Only using opposite sign leptons
826  if(mus_pt()->at(id2) <= MinVetoLeptonPt) return;
827  if(mus_miniso()->at(id1)>=0.2 || mus_miniso()->at(id2)>=0.2) return; // Use only isolated leptons
828  if(isSig){
829  ll_m = &small_tree::mumu_m;
830  ll_pt1 = &small_tree::mumu_pt1;
831  ll_pt2 = &small_tree::mumu_pt2;
832  ll_zpt = &small_tree::mumu_zpt;
833  } else {
834  ll_m = &small_tree::mumuv_m;
835  ll_pt1 = &small_tree::mumuv_pt1;
836  ll_pt2 = &small_tree::mumuv_pt2;
837  ll_zpt = &small_tree::mumuv_zpt;
838  }
839  } else {
840  cout<<"PDG ID "<<pdgid<<" not supported in Setllmass, you silly."<<endl;
841  return;
842  }
843  if((tree.*ll_m)() > 0) return; // We only set it with the first good ll combination
844 
845  float px1(-1.), py1(-1.), pz1(-1.), energy1(-1.), px2(-1.), py2(-1.), pz2(-1.), energy2(-1.);
846  if(pdgid==11){
847  px1 = els_px()->at(id1); py1 = els_py()->at(id1); pz1 = els_pz()->at(id1); energy1 = els_energy()->at(id1);
848  px2 = els_px()->at(id2); py2 = els_py()->at(id2); pz2 = els_pz()->at(id2); energy2 = els_energy()->at(id2);
849  }
850  if(pdgid==13){
851  px1 = mus_px()->at(id1); py1 = mus_py()->at(id1); pz1 = mus_pz()->at(id1); energy1 = mus_energy()->at(id1);
852  px2 = mus_px()->at(id2); py2 = mus_py()->at(id2); pz2 = mus_pz()->at(id2); energy2 = mus_energy()->at(id2);
853  }
854 
855  TLorentzVector lep1(px1, py1, pz1, energy1), lep2(px2, py2, pz2, energy2);
856  lep2 += lep1;
857  (tree.*ll_m)() = lep2.M();
858  (tree.*ll_zpt)() = lep2.Pt();
859  (tree.*ll_pt1)() = max(sqrt(px1*px1+py1*py1), sqrt(px2*px2+py2*py2));
860  (tree.*ll_pt2)() = min(sqrt(px1*px1+py1*py1), sqrt(px2*px2+py2*py2));
861 
862 }
int const & nfjets() const
std::vector< float > *const & els_pt() const
Definition: cfa.cpp:752
float const & ntrupv_mean() const
float const & st_reliso() const
std::vector< float > *const & els_pz() const
Definition: cfa.cpp:768
virtual void GetEntry(const long entry)
std::vector< double > const & els_tru_pt() const
std::vector< float > const & jets_pt() const
float const & ht_nohf() const
int const & lep_charge() const
const std::string & SampleName() const
Definition: cfa.cpp:31
int const & nbm_ra2b() const
std::vector< float > const & mus_d0() const
std::vector< bool > const & els_ispf() const
static int GetMom(float id, float mom, float gmom, float ggmom, bool &fromW)
float const & trutop2_pt() const
std::vector< float > *const & els_eta() const
Definition: cfa.cpp:576
int const & nbm40() const
std::vector< float > const & jets_id() const
std::vector< TString > yes_trig
std::vector< float > *const & mus_tk_d0dum() const
Definition: cfa.cpp:3492
std::vector< double > const & mus_genmt_fromw() const
std::vector< float > const & fjets08_phi() const
bool GetTriggerInfo(std::vector< TString > &trig_names, std::vector< bool > &trig_dec, std::vector< float > &trig_prescale)
long double GetMT(long double m1, long double pt1, long double phi1, long double m2, long double pt2, long double phi2)
Definition: utilities.cpp:291
bool IsSignalElectron(unsigned iel, bool mini=true) const
std::vector< float > const & jets_m() const
float const & elelv_pt2() const
std::vector< float > *const & PU_TrueNumInteractions() const
Definition: cfa.cpp:236
Definition: timer.hpp:6
float const & genht() const
float const & met_mini_phi() const
int const & nvleps() const
int const & ntrutausl() const
Int_t const & cschalofilter_decision() const
Definition: cfa.cpp:332
int const & ntruleps() const
std::vector< float > *const & pfType1mets_default_et() const
Definition: cfa.cpp:3840
std::vector< float > *const & mus_tk_vz() const
Definition: cfa.cpp:3580
std::vector< float > const & mus_dz() const
std::vector< float > const & els_tru_dr() const
int GetTrueElectron(int index, int &momID, bool &fromW, float &closest_dR, double &els_mc_pt, double &els_mc_phi) const
Int_t const & HBHENoisefilter_decision() const
Definition: cfa.cpp:60
std::vector< bool > const & els_tight() const
int const & nbl40() const
int const & ntrumus() const
std::vector< float > const & els_reliso() const
Int_t const & goodVerticesfilter_decision() const
Definition: cfa.cpp:980
bool const & pass_hbhe() const
std::vector< float > *const & els_energy() const
Definition: cfa.cpp:568
std::vector< float > const & fjets08_poscsv() const
std::vector< float > *const & mc_final_grandmother_id() const
Definition: cfa.cpp:2040
int const & nbm() const
double const & gen_met_phi_fromw() const
float met_corr() const
float const & lep_pt() const
float const & weight() const
std::vector< float > *const & jets_parton_Id() const
Definition: cfa.cpp:7409
std::vector< int > const & fjets_nconst() const
bool Contains(const std::string &text, const std::string &pattern)
float const & ht_hf() const
int const & nmus() const
int const & run() const
std::vector< float > const & jets_csv() const
std::vector< float > *const & mc_final_mother_id() const
Definition: cfa.cpp:2056
std::vector< double > const & mus_tru_pt() const
std::vector< float > *const & mc_doc_id() const
Definition: cfa.cpp:1864
std::vector< int > *const & PU_NumInteractions() const
Definition: cfa.cpp:232
const double CSVCuts[]
std::vector< float > *const & pv_isFake() const
Definition: cfa.cpp:6056
float const & elel_m() const
std::vector< float > *const & mc_final_pt() const
Definition: cfa.cpp:2072
int const & nfjets08() const
std::vector< double > const & mus_genmt() const
std::vector< int > const & mus_tru_id() const
std::vector< float > *const & pv_y() const
Definition: cfa.cpp:6080
float const & trutop2_phi() const
std::vector< int > *const & PU_bunchCrossing() const
Definition: cfa.cpp:240
void SetMiniIso(small_tree_quick &tree, int ilep, int ParticleType)
float const & mumu_zpt() const
std::vector< float > *const & pv_x() const
Definition: cfa.cpp:6072
std::vector< float > *const & mus_charge() const
Definition: cfa.cpp:2752
std::vector< int > const & fjets08_btags() const
float met_phi_corr() const
STL namespace.
float const & mumu_pt2() const
std::vector< float > *const & els_px() const
Definition: cfa.cpp:760
float const & lep_eta_reliso() const
bool const & json_golden() const
bool IsVetoIdElectron(unsigned iel, bool do_iso=false) const
int const & ntrutaush() const
bool isData() const
std::vector< float > *const & mc_doc_pt() const
Definition: cfa.cpp:1904
int const & nleps_reliso() const
std::vector< double > const & els_tru_phi() const
std::vector< float > const & fjets08_eta() const
std::vector< float > *const & mus_miniso() const
Definition: cfa.cpp:3140
int const & nmus_reliso() const
std::vector< float > const & els_eta() const
int const & nbt() const
std::vector< float > *const & els_vz() const
Definition: cfa.cpp:940
std::vector< int > const & jets_fjet_index() const
Float_t const & mets_et() const
Definition: cfa.cpp:8432
float const & elel_pt2() const
int const & lumiblock() const
std::vector< float > const & mus_phi() const
size_t GetNumJets(const std::vector< int > &good_jets, double pt_cut=0.0, double csv_cut=-std::numeric_limits< float >::max()) const
float const & st() const
int const & nels_tru_prompt() const
float const & dphi_wlep() const
std::vector< float > const & jets_phi() const
int const & ntrupv() const
std::string execute(const std::string &cmd)
std::vector< float > const & fjets08_sumcsv() const
float GetMuonIsolation(unsigned imu, bool mini=true) const
int const & nels() const
float const & mumu_pt1() const
UInt_t const & event() const
Definition: cfa.cpp:944
double GetMinDeltaPhiMETN(unsigned maxjets, float mainpt, float maineta, float otherpt, float othereta, bool useArcsin) const
std::vector< float > *const & els_d0dum() const
Definition: cfa.cpp:484
std::vector< float > *const & mc_final_id() const
Definition: cfa.cpp:2044
bool IsSignalIdMuon(unsigned iel) const
std::vector< float > const & els_miniso() const
std::vector< float > const & fjets08_pt() const
bool const & pass_eebadsc() const
Float_t const & genHT() const
Definition: cfa.cpp:976
Float_t const & mets_sumEt() const
Definition: cfa.cpp:8454
int const & event() const
std::vector< bool > const & els_sigid() const
std::vector< int > const & fjets_btags() const
bool const & pass_jets() const
int const & nvels() const
std::vector< bool > const & trig() const
void GetTrueLeptons(std::vector< int > &true_electrons, std::vector< int > &true_muons, std::vector< int > &true_had_taus, std::vector< int > &true_lep_taus)
int const & ntruels() const
std::vector< float > const & fjets_m() const
Float_t const & mets_phi() const
Definition: cfa.cpp:8443
bool IsIdElectron(unsigned iel, CutLevel threshold, bool do_iso=false) const
bool const & pass_goodv() const
std::vector< float > const & els_dz() const
std::vector< float > *const & mus_pt() const
Definition: cfa.cpp:3332
void GetMatchedLeptons(const std::vector< int > &veto_mu, const std::vector< int > &veto_el, std::map< size_t, std::vector< size_t > > &mu_matches, std::map< size_t, std::vector< size_t > > &el_matches) const
static float bad_val
std::vector< float > const & mus_eta() const
float const & mumuv_zpt() const
int const & nmus_tru_prompt() const
float const & elelv_pt1() const
std::vector< std::string > *const & standalone_triggerobject_collectionname() const
Definition: cfa.cpp:6144
float const & met_phi() const
int const & nvels_reliso() const
bool IsSignalMuon(unsigned imu, bool mini=true) const
std::vector< float > const & mus_tru_dr() const
float const & met() const
int const & lep_charge_reliso() const
float const & lep_pt_reliso() const
std::vector< bool > const & mus_tru_tm() const
void WriteFatJets(int &nfjets, float &mj, std::vector< float > &fjets_pt, std::vector< float > &fjets_eta, std::vector< float > &fjets_phi, std::vector< float > &fjets_m, std::vector< int > &fjets_nconst, std::vector< float > &fjets_sumcsv, std::vector< float > &fjets_poscsv, std::vector< int > &fjets_btags, std::vector< int > &jets_fjet_index, double radius, const std::vector< int > &jets, bool gen=false, bool clean=false, const std::vector< bool > &to_clean=std::vector< bool >(0))
float const & mht_ra2b() const
int const & njets_nohf() const
float const & ht_reliso() const
int const & nleps() const
static void CountLeptons(const std::vector< mc_particle > &parts, const std::vector< size_t > &moms, unsigned &nleps, unsigned &ntaus, unsigned &ntauleps)
std::vector< float > const & mus_mt() const
std::vector< float > const & fjets_eta() const
UInt_t const & run() const
Definition: cfa.cpp:6128
std::vector< int > GetJets(const std::vector< int > &VetoEl, const std::vector< int > &VetoMu, double pt_thresh, double eta_thresh) const
float const & trutop1_pt() const
std::vector< float > *const & mc_doc_eta() const
Definition: cfa.cpp:1852
std::vector< float > const & mus_pt() const
std::vector< int > const & mus_charge() const
std::vector< float > const & els_sceta() const
event_handler_quick(const std::string &file_name)
float const & ht_ra2b() const
std::vector< double > const & els_genmt() const
float cross_section(const TString &file)
Definition: utilities.cpp:28
std::vector< float > *const & mus_tk_phi() const
Definition: cfa.cpp:3540
float const & met_nohf_sumEt() const
static float MinVetoLeptonPt
int const & njets_ra2b() const
std::vector< float > *const & pv_z() const
Definition: cfa.cpp:6088
int const & njets40() const
float const & lep_phi() const
std::vector< float > *const & jets_btag_inc_secVertexCombined() const
Definition: cfa.cpp:6771
std::vector< float > *const & mc_final_phi() const
Definition: cfa.cpp:2068
float const & mht() const
std::vector< float > const & fjets_sumcsv() const
std::vector< int > GetMuons(bool doSignal=true, bool mini=true) const
static std::vector< fastjet::PseudoJet > sorted_by_m(std::vector< fastjet::PseudoJet > pjs)
static float MinJetPt
std::vector< float > *const & mc_doc_status() const
Definition: cfa.cpp:1920
std::vector< float > *const & mc_doc_phi() const
Definition: cfa.cpp:1900
short Sign(T val)
Definition: utilities.hpp:56
std::vector< float > const & fjets08_m() const
float dR(float eta1, float eta2, float phi1, float phi2)
Definition: utilities.cpp:241
int const & nbt40() const
float const & lep_eta() const
bool IsSignalIdElectron(unsigned iel, bool do_iso=false) const
float const & lep_phi_reliso() const
float const & mumuv_m() const
std::vector< float > *const & els_py() const
Definition: cfa.cpp:764
std::vector< int > GetElectrons(bool doSignal=true, bool mini=true) const
std::vector< int > const & mus_tru_momid() const
float const & elel_zpt() const
std::vector< float > const & mus_reliso() const
int const & ntrunus_fromw() const
std::vector< float > const & fjets_poscsv() const
std::vector< float > *const & mus_px() const
Definition: cfa.cpp:3336
float const & met_hf() const
std::vector< float > *const & els_miniso() const
Definition: cfa.cpp:704
std::vector< double > const & els_genmt_fromw() const
std::vector< float > *const & mus_energy() const
Definition: cfa.cpp:2884
float const & mj() const
float const & mt() const
float const & elel_pt1() const
int const & nvmus_reliso() const
void Setllmass(small_tree_quick &tree, size_t id1, size_t id2, int pdgid, bool isSig)
std::string *const & model_params() const
Definition: cfa.cpp:2676
float const & onmaxel() const
virtual void Fill()
std::vector< float > *const & pv_ndof() const
Definition: cfa.cpp:6064
std::vector< float > *const & mus_eta() const
Definition: cfa.cpp:2892
bool const & pass_cschalo() const
int const & njets() const
std::vector< float > *const & mus_phi() const
Definition: cfa.cpp:3208
bool PassesJSONCut(TString type)
float const & elelv_m() const
float const & onmaxmu() const
int const & njets_hf() const
bool is_nan(const T &x)
Definition: utilities.hpp:53
Int_t const & eebadscfilter_decision() const
Definition: cfa.cpp:348
std::string RemoveTrailingNewlines(std::string str)
Definition: utilities.cpp:348
std::vector< bool > const & mus_sigid() const
int const & nbl() const
float const & onht() const
std::vector< float > *const & mc_doc_ggrandmother_id() const
Definition: cfa.cpp:1856
double GetMHT(const std::vector< int > &good_jets, double pt_cut) const
std::vector< float > const & els_phi() const
bool const & pass() const
float const & met_mini() const
std::vector< float > const & els_mt() const
float const & wpu() const
std::vector< float > *const & els_scEta() const
Definition: cfa.cpp:800
std::vector< float > *const & mc_jets_phi() const
Definition: cfa.cpp:2108
std::vector< float > *const & mc_jets_eta() const
Definition: cfa.cpp:2092
std::vector< int > const & fjets08_nconst() const
std::vector< float > *const & mus_py() const
Definition: cfa.cpp:3340
std::vector< float > *const & mc_doc_grandmother_id() const
Definition: cfa.cpp:1860
std::vector< float > const & els_d0() const
std::vector< float > *const & standalone_triggerobject_pt() const
Definition: cfa.cpp:6164
bool AllGoodJets(const std::vector< int > &VetoEl, const std::vector< int > &VetoMu, double pt_thresh, double eta_thresh) const
float const & mindphin_metjet() const
double const & gen_met_phi() const
std::vector< int > const & els_tru_momid() const
void Write()
float const & mj08() const
std::vector< float > *const & mc_jets_pt() const
Definition: cfa.cpp:2112
UInt_t const & lumiblock() const
Definition: cfa.cpp:1840
float const & mumu_m() const
std::vector< float > *const & mc_doc_mother_id() const
Definition: cfa.cpp:1880
void Iterate()
Definition: timer.cpp:28
virtual void ReduceTree(int num_entries, const TString &out_file_name, int num_total_entries)
std::vector< float > const & trig_prescale() const
const std::vector< TLorentzVector > & jets_corr_p4() const
void Start()
Definition: timer.cpp:22
bool IsVetoIdMuon(unsigned iel) const
float const & met_nohf() const
float const & met_hf_phi() const
int const & nels_reliso() const
long double DeltaPhi(long double phi1, long double phi2)
Definition: utilities.cpp:225
std::vector< int > const & els_tru_id() const
std::vector< float > *const & mc_final_ggrandmother_id() const
Definition: cfa.cpp:2036
float const & mumuv_pt2() const
float const & mumuv_pt1() const
double const & gen_met_fromw() const
std::vector< bool > *const & els_isPF() const
Definition: cfa.cpp:692
std::vector< float > *const & mus_pz() const
Definition: cfa.cpp:3344
bool IsIdMuon(unsigned imu, CutLevel threshold) const
int const & ntrumeisr() const
static bool greater_m(const fastjet::PseudoJet &a, const fastjet::PseudoJet &b)
int const & ntrunus() const
std::vector< float > *const & els_phi() const
Definition: cfa.cpp:744
std::vector< float > const & jets_eta() const
float const & met_nohf_phi() const
std::vector< float > const & mus_miniso() const
unsigned TypeCode(const std::vector< mc_particle > &parts, const std::vector< size_t > &moms)
UInt_t const & Npv() const
Definition: cfa.cpp:216
std::vector< double > const & mus_tru_phi() const
float const & ht() const
float GetElectronIsolation(unsigned iel, bool mini=true) const
int GetTrueMuon(int index, int &momID, bool &fromW, float &closest_dR, double &mus_mc_pt, double &mus_mc_phi) const
float const & trutop1_phi() const
std::vector< float > *const & els_tk_phi() const
Definition: cfa.cpp:908
virtual std::string Type() const
std::vector< float > const & fjets_phi() const
std::vector< float > const & els_pt() const
std::vector< int > const & jets_fjet08_index() const
std::vector< bool > const & els_tru_tm() const
double GetHT(const std::vector< int > &good_jets, double pt_cut=0.0) const
std::vector< int > const & els_charge() const
float const & elelv_zpt() const
std::vector< float > *const & els_charge() const
Definition: cfa.cpp:424
float const & ht_hlt() const
float const & mt_reliso() const
float const & dphi_wlep_reliso() const
float const & ht40() const
int const & npv() const
bool const & hfjet() const
double const & gen_met() const
std::vector< float > *const & mc_jets_energy() const
Definition: cfa.cpp:2084
std::vector< bool > const & mus_tight() const
std::vector< float > const & fjets_pt() const
int const & nvmus() const
float const & onmet() const
Float_t const & weight() const
Definition: cfa.cpp:6704
long double AddInQuadrature(long double x, long double y)
Definition: utilities.cpp:275
std::vector< bool > const & jets_islep() const
float GetMinMTWb(const std::vector< int > &good_jets, const double pt_cut, const double bTag_req, const bool use_W_mass) const