diff --git a/DesyTauAnalyses/NTupleMaker/bin/SynchNTupleProducer_em.cpp b/DesyTauAnalyses/NTupleMaker/bin/SynchNTupleProducer_em.cpp index cfb4bdc..18b95df 100644 --- a/DesyTauAnalyses/NTupleMaker/bin/SynchNTupleProducer_em.cpp +++ b/DesyTauAnalyses/NTupleMaker/bin/SynchNTupleProducer_em.cpp @@ -293,6 +293,7 @@ int main(int argc, char * argv[]) { const float isoElectronLowCut = cfg.get("isoElectronLowCut"); const float isoElectronHighCut = cfg.get("isoElectronHighCut"); const bool applyElectronId = cfg.get("ApplyElectronId"); + const bool applyElectronConversionVeto = cfg.get("ApplyElectronConversionVeto"); const string lowPtLegElectron = cfg.get("LowPtLegElectron"); const string highPtLegElectron = cfg.get("HighPtLegElectron"); @@ -302,6 +303,7 @@ int main(int argc, char * argv[]) { const float dxyVetoElectronCut = cfg.get("dxyVetoElectronCut"); const float dzVetoElectronCut = cfg.get("dzVetoElectronCut"); const float isoVetoElectronCut = cfg.get("isoVetoElectronCut"); + const bool applyVetoElectronConversionVeto = cfg.get("ApplyVetoElectronConversionVeto"); const bool applyVetoElectronId = cfg.get("ApplyVetoElectronId"); // kinematic cuts on muons @@ -332,6 +334,7 @@ int main(int argc, char * argv[]) { // topological cuts const float dRleptonsCut = cfg.get("dRleptonsCut"); const bool isIsoR03 = cfg.get("IsIsoR03"); + const bool applyTriggerMatch = cfg.get("ApplyTriggerMatch"); const float deltaRTrigMatch = cfg.get("DRTrigMatch"); // jets @@ -665,12 +668,11 @@ int main(int argc, char * argv[]) { Long64_t numberOfEntries = analysisTree.GetEntries(); std::cout << " number of entries in Tree = " << numberOfEntries << std::endl; - + for (Long64_t iEntry=0; iEntry1||electrons.size()>1) + // std::cout << "muons = " << muons.size() << " electrons = " << electrons.size() << std::endl; for (unsigned int im=0; im +#include +#include +#include +#include +#include + +#include "TFile.h" +#include "TH1.h" +#include "TH2.h" +#include "TGraph.h" +#include "TTree.h" +#include "TROOT.h" +#include "TLorentzVector.h" +#include "TVector3.h" +#include "TRFIOFile.h" +#include "TH1F.h" +#include "TH1D.h" +#include "TChain.h" +#include "TMath.h" + +#include "TLorentzVector.h" + +#include "TRandom.h" + +#include "DesyTauAnalyses/NTupleMaker/interface/Config.h" +#include "DesyTauAnalyses/NTupleMaker/interface/AC1B.h" + +const float MuMass = 0.105658367; + +int binNumber(float x, int nbins, float * bins) { + + int binN = 0; + + for (int iB=0; iB=bins[iB]&&x0.73) passed = true; + } + else if (absEta<1.479) { + if (mva>0.57) passed = true; + } + else { + if (mva>0.05) passed = true; + } + + return passed; + +} +bool electronMvaIdLoose(float eta, float mva) { + + float absEta = fabs(eta); + + bool passed = false; + if (absEta<0.8) { + if (mva>0.35) passed = true; + } + else if (absEta<1.479) { + if (mva>0.20) passed = true; + } + else { + if (mva>-0.52) passed = true; + } + + return passed; + +} +bool electronMvaIdWP80(float pt, float eta, float mva) { + + float absEta = fabs(eta); + bool passed = false; + if (absEta<0.8) { + if (pt<10) + passed = mva > -0.253; + else + passed = mva > 0.965; + } + else if (absEta<1.479) { + if (pt<10) + passed = mva > 0.081; + else + passed = mva > 0.917; + } + else { + if (pt<10) + passed = mva > -0.081; + else + passed = mva > 0.683; + } + + return passed; + +} +bool electronMvaIdWP90(float pt, float eta, float mva) { + + float absEta = fabs(eta); + bool passed = false; + if (absEta<0.8) { + if (pt<10) + passed = mva > -0.483; + else + passed = mva > 0.933; + } + else if (absEta<1.479) { + if (pt<10) + passed = mva > -0.267; + else + passed = mva > 0.825; + } + else { + if (pt<10) + passed = mva > -0.323; + else + passed = mva > 0.337; + } + + return passed; + +} + + +const float electronMass = 0; +const float muonMass = 0.10565837; +const float pionMass = 0.1396; + +int main(int argc, char * argv[]) { + + // first argument - config file + // second argument - filelist + + using namespace std; + + // **** configuration + Config cfg(argv[1]); + + // kinematic cuts on electrons + const float ptTauCut = cfg.get("ptTauCut"); + const float etaTauCut = cfg.get("etaTauCut"); + const float dzTauCut = cfg.get("dzTauCut"); + + // veto electrons + const float ptVetoElectronCut = cfg.get("ptVetoElectronCut"); + const float etaVetoElectronCut = cfg.get("etaVetoElectronCut"); + const float dxyVetoElectronCut = cfg.get("dxyVetoElectronCut"); + const float dzVetoElectronCut = cfg.get("dzVetoElectronCut"); + const float isoVetoElectronCut = cfg.get("isoVetoElectronCut"); + const bool applyVetoElectronId = cfg.get("ApplyVetoElectronId"); + + // kinematic cuts on muons + const float ptMuonCut = cfg.get("ptMuonCut"); + const float etaMuonCut = cfg.get("etaMuonCut"); + const float dxyMuonCut = cfg.get("dxyMuonCut"); + const float dzMuonCut = cfg.get("dzMuonCut"); + const float isoMuonLowCut = cfg.get("isoMuonLowCut"); + const float isoMuonHighCut = cfg.get("isoMuonHighCut"); + const bool applyMuonId = cfg.get("ApplyMuonId"); + + // HLT filters + const string isoMuon24Leg = cfg.get("IsoMuon24Leg"); + const string muonTauMuonLeg = cfg.get("MuonTauMuonLeg"); + const string muonTauOverlap = cfg.get("MuonTauOverlap"); + const string muonTauTauLeg = cfg.get("MuonTauTauLeg"); + + // veto muons + const float ptVetoMuonCut = cfg.get("ptVetoMuonCut"); + const float etaVetoMuonCut = cfg.get("etaVetoMuonCut"); + const float dxyVetoMuonCut = cfg.get("dxyVetoMuonCut"); + const float dzVetoMuonCut = cfg.get("dzVetoMuonCut"); + const float isoVetoMuonCut = cfg.get("isoVetoMuonCut"); + const bool applyVetoMuonId = cfg.get("ApplyVetoMuonId"); + + // vertex cuts + const float ndofVertexCut = cfg.get("NdofVertexCut"); + const float zVertexCut = cfg.get("ZVertexCut"); + const float dVertexCut = cfg.get("DVertexCut"); + + // topological cuts + const float dRleptonsCut = cfg.get("dRleptonsCut"); + const bool isIsoR03 = cfg.get("IsIsoR03"); + const bool applyTriggerMatch = cfg.get("ApplyTriggerMatch"); + const float deltaRTrigMatch = cfg.get("DRTrigMatch"); + + // jets + const float jetEtaCut = cfg.get("JetEtaCut"); + const float jetPtLowCut = cfg.get("JetPtLowCut"); + const float jetPtHighCut = cfg.get("JetPtHighCut"); + const float dRJetLeptonCut = cfg.get("dRJetLeptonCut"); + const float bJetEtaCut = cfg.get("bJetEtaCut"); + const float btagCut = cfg.get("btagCut"); + const bool applyJetPfId = cfg.get("ApplyJetPfId"); + const bool applyJetPuId = cfg.get("ApplyJetPuId"); + + // check overlap + const bool checkOverlap = cfg.get("CheckOverlap"); + + TString IsoMuon24Leg(isoMuon24Leg); + TString MuonTauMuonLeg(muonTauMuonLeg); + TString MuonTauOverlap(muonTauOverlap); + TString MuonTauTauLeg(muonTauTauLeg); + + // **** end of configuration + + // file name and tree name + std::string rootFileName(argv[2]); + std::ifstream fileList(argv[2]); + std::ifstream fileList0(argv[2]); + std::string ntupleName("makeroottree/AC1B"); + + TString TStrName(rootFileName); + std::cout <cd(""); + + TH1F * inputEventsH = new TH1F("inputEventsH","",1,-0.5,0.5); + TTree * tree = new TTree("TauCheck","TauCheck"); + // Declaration of leaf types + + Int_t run; + Int_t lumi; + Int_t evt; + Int_t npv; + Int_t npu; + Float_t rho; + Float_t mcweight; + Float_t puweight; + Float_t trigweight_1; + Float_t trigweight_2; + Float_t idweight_1; + Float_t idweight_2; + Float_t isoweight_1; + Float_t isoweight_2; + Float_t effweight; + Float_t fakeweight; + Float_t embeddedWeight; + Float_t signalWeight; + Float_t weight; + Float_t m_vis; + Float_t m_sv; + Float_t pt_sv; + Float_t eta_sv; + Float_t phi_sv; + Float_t pt_1; + Float_t phi_1; + Float_t eta_1; + Float_t m_1; + Int_t q_1; + Float_t iso_1; + Float_t mva_1; + Float_t d0_1; + Float_t dZ_1; + Float_t mt_1; + Float_t pt_2; + Float_t phi_2; + Float_t eta_2; + Float_t m_2; + Int_t q_2; + Float_t iso_2; + Float_t d0_2; + Float_t dZ_2; + Float_t mva_2; + Float_t mt_2; + + Bool_t os; + Bool_t dilepton_veto; + Bool_t extraelec_veto; + Bool_t extramuon_veto; + + Float_t byCombinedIsolationDeltaBetaCorrRaw3Hits_1; + Float_t againstElectronLooseMVA5_1; + Float_t againstElectronMediumMVA5_1; + Float_t againstElectronTightMVA5_1; + Float_t againstElectronVLooseMVA5_1; + Float_t againstElectronVTightMVA5_1; + Float_t againstMuonLoose3_1; + Float_t againstMuonTight3_1; + Float_t byCombinedIsolationDeltaBetaCorrRaw3Hits_2; + Float_t againstElectronLooseMVA5_2; + Float_t againstElectronMediumMVA5_2; + Float_t againstElectronTightMVA5_2; + Float_t againstElectronVLooseMVA5_2; + Float_t againstElectronVTightMVA5_2; + Float_t againstMuonLoose3_2; + Float_t againstMuonTight3_2; + + Float_t met; + Float_t metphi; + Float_t metcov00; + Float_t metcov01; + Float_t metcov10; + Float_t metcov11; + + Float_t mvamet; + Float_t mvametphi; + Float_t mvacov00; + Float_t mvacov01; + Float_t mvacov10; + Float_t mvacov11; + + Float_t pt_tt; + Float_t pzetavis; + Float_t pzetamiss; + Float_t mva_gf; + + Int_t njets; + Int_t njetspt20; + Float_t jpt_1; + Float_t jeta_1; + Float_t jphi_1; + Float_t jptraw_1; + Float_t jptunc_1; + Float_t jmva_1; + Float_t jlrm_1; + Int_t jctm_1; + Float_t jpt_2; + Float_t jeta_2; + Float_t jphi_2; + Float_t jptraw_2; + Float_t jptunc_2; + Float_t jmva_2; + Float_t jlrm_2; + Int_t jctm_2; + Float_t mjj; + Float_t jdeta; + Int_t njetingap; + + Int_t nbtag; + Float_t bpt; + Float_t beta; + Float_t bphi; + + + tree->Branch("run", &run, "run/I"); + tree->Branch("lumi", &lumi, "lumi/I"); + tree->Branch("evt", &evt, "evt/I"); + tree->Branch("npv", &npv, "npv/I"); + tree->Branch("npu", &npu, "npu/I"); + tree->Branch("rho", &rho, "rho/F"); + + tree->Branch("mcweight", &mcweight, "mcweight/F"); + tree->Branch("puweight", &puweight, "puweight/F"); + tree->Branch("trigweight_1", &trigweight_1, "trigweight_1/F"); + tree->Branch("trigweight_2", &trigweight_2, "trigweight_2/F"); + tree->Branch("idweight_1", &idweight_1, "idweight_1/F"); + tree->Branch("idweight_2", &idweight_2, "idweight_2/F"); + tree->Branch("isoweight_1", &isoweight_1, "isoweight_1/F"); + tree->Branch("isoweight_2", &isoweight_2, "isoweight_2/F"); + tree->Branch("effweight", &effweight, "effweight/F"); + tree->Branch("fakeweight", &fakeweight, "fakeweight/F"); + tree->Branch("embeddedWeight", &embeddedWeight, "embeddedWeight/F"); + tree->Branch("signalWeight", &signalWeight, "signalWeight/F"); + tree->Branch("weight", &weight, "weight/F"); + + tree->Branch("m_vis", &m_vis, "m_vis/F"); + tree->Branch("m_sv", &m_sv, "m_sv/F"); + tree->Branch("pt_sv", &pt_sv, "pt_sv/F"); + tree->Branch("eta_sv", &eta_sv, "eta_sv/F"); + tree->Branch("phi_sv", &phi_sv, "phi_sv/F"); + + tree->Branch("pt_1", &pt_1, "pt_1/F"); + tree->Branch("phi_1", &phi_1, "phi_1/F"); + tree->Branch("eta_1", &eta_1, "eta_1/F"); + tree->Branch("m_1", &m_1, "m_1/F"); + tree->Branch("q_1", &q_1, "q_1/I"); + tree->Branch("iso_1", &iso_1, "iso_1/F"); + tree->Branch("mva_1", &mva_1, "mva_1/F"); + tree->Branch("d0_1", &d0_1, "d0_1/F"); + tree->Branch("dZ_1", &dZ_1, "dZ_1/F"); + tree->Branch("mt_1", &mt_1, "mt_1/F"); + + tree->Branch("pt_2", &pt_2, "pt_2/F"); + tree->Branch("phi_2", &phi_2, "phi_2/F"); + tree->Branch("eta_2", &eta_2, "eta_2/F"); + tree->Branch("m_2", &m_2, "m_2/F"); + tree->Branch("q_2", &q_2, "q_2/I"); + tree->Branch("iso_2", &iso_2, "iso_2/F"); + tree->Branch("d0_2", &d0_2, "d0_2/F"); + tree->Branch("dZ_2", &dZ_2, "dZ_2/F"); + tree->Branch("mva_2", &mva_2, "mva_2/F"); + tree->Branch("mt_2", &mt_2, "mt_2/F"); + + tree->Branch("os", &os, "os/O"); + tree->Branch("dilepton_veto", &dilepton_veto, "dilepton_veto/O"); + tree->Branch("extraelec_veto", &extraelec_veto, "extraelec_veto/O"); + tree->Branch("extramuon_veto", &extramuon_veto, "extramuon_veto/O"); + + tree->Branch("byCombinedIsolationDeltaBetaCorrRaw3Hits_1", &byCombinedIsolationDeltaBetaCorrRaw3Hits_1, "byCombinedIsolationDeltaBetaCorrRaw3Hits_1/F"); + tree->Branch("againstElectronLooseMVA5_1", &againstElectronLooseMVA5_1, "againstElectronLooseMVA5_1/F"); + tree->Branch("againstElectronMediumMVA5_1", &againstElectronMediumMVA5_1, "againstElectronMediumMVA5_1/F"); + tree->Branch("againstElectronTightMVA5_1", &againstElectronTightMVA5_1, "againstElectronTightMVA5_1/F"); + tree->Branch("againstElectronVLooseMVA5_1", &againstElectronVLooseMVA5_1, "againstElectronVLooseMVA5_1/F"); + tree->Branch("againstElectronVTightMVA5_1", &againstElectronVTightMVA5_1, "againstElectronVTightMVA5_1/F"); + tree->Branch("againstMuonLoose3_1", &againstMuonLoose3_1, "againstMuonLoose3_1/F"); + tree->Branch("againstMuonTight3_1", &againstMuonTight3_1, "againstMuonTight3_1/F"); + + tree->Branch("byCombinedIsolationDeltaBetaCorrRaw3Hits_2", &byCombinedIsolationDeltaBetaCorrRaw3Hits_2, "byCombinedIsolationDeltaBetaCorrRaw3Hits_2/F"); + tree->Branch("againstElectronLooseMVA5_2", &againstElectronLooseMVA5_2, "againstElectronLooseMVA5_2/F"); + tree->Branch("againstElectronMediumMVA5_2", &againstElectronMediumMVA5_2, "againstElectronMediumMVA5_2/F"); + tree->Branch("againstElectronTightMVA5_2", &againstElectronTightMVA5_2, "againstElectronTightMVA5_2/F"); + tree->Branch("againstElectronVLooseMVA5_2", &againstElectronVLooseMVA5_2, "againstElectronVLooseMVA5_2/F"); + tree->Branch("againstElectronVTightMVA5_2", &againstElectronVTightMVA5_2, "againstElectronVTightMVA5_2/F"); + tree->Branch("againstMuonLoose3_2", &againstMuonLoose3_2, "againstMuonLoose3_2/F"); + tree->Branch("againstMuonTight3_2", &againstMuonTight3_2, "againstMuonTight3_2/F"); + + tree->Branch("met", &met, "met/F"); + tree->Branch("metphi", &metphi, "metphi/F"); + tree->Branch("metcov00", &metcov00, "metcov00/F"); + tree->Branch("metcov01", &metcov01, "metcov01/F"); + tree->Branch("metcov10", &metcov10, "metcov10/F"); + tree->Branch("metcov11", &metcov11, "metcov11/F"); + + tree->Branch("mvamet", &mvamet, "mvamet/F"); + tree->Branch("mvametphi", &mvametphi, "mvametphi/F"); + tree->Branch("mvacov00", &mvacov00, "mvacov00/F"); + tree->Branch("mvacov01", &mvacov01, "mvacov01/F"); + tree->Branch("mvacov10", &mvacov10, "mvacov10/F"); + tree->Branch("mvacov11", &mvacov11, "mvacov11/F"); + + tree->Branch("pt_tt", &pt_tt, "pt_tt/F"); + tree->Branch("pzetavis", &pzetavis, "pzetavis/F"); + tree->Branch("pzetamiss", &pzetamiss, "pzetamiss/F"); + tree->Branch("mva_gf", &mva_gf, "mva_gf/F"); + + tree->Branch("njets", &njets, "njets/I"); + tree->Branch("njetspt20", &njetspt20, "njetspt20/I"); + + tree->Branch("jpt_1", &jpt_1, "jpt_1/F"); + tree->Branch("jeta_1", &jeta_1, "jeta_1/F"); + tree->Branch("jphi_1", &jphi_1, "jphi_1/F"); + tree->Branch("jptraw_1", &jptraw_1, "jptraw_1/F"); + tree->Branch("jptunc_1", &jptunc_1, "jptunc_1/F"); + tree->Branch("jmva_1", &jmva_1, "jmva_1/F"); + tree->Branch("jlrm_1", &jlrm_1, "jlrm_1/F"); + tree->Branch("jctm_1", &jctm_1, "jctm_1/I"); + + tree->Branch("jpt_2", &jpt_2, "jpt_2/F"); + tree->Branch("jeta_2", &jeta_2, "jeta_2/F"); + tree->Branch("jphi_2", &jphi_2, "jphi_2/F"); + tree->Branch("jptraw_2", &jptraw_2, "jptraw_2/F"); + tree->Branch("jptunc_2", &jptunc_2, "jptunc_2/F"); + tree->Branch("jmva_2", &jmva_2, "jlrm_2/F"); + tree->Branch("jlrm_2", &jlrm_2, "jlrm_2/F"); + tree->Branch("jctm_2", &jctm_2, "jctm_2/I"); + + tree->Branch("mjj", &mjj, "mjj/F"); + tree->Branch("jdeta", &jdeta, "jdeta/F"); + tree->Branch("njetingap", &njetingap, "njetingap/I"); + + tree->Branch("nbtag", &nbtag, "nbtag/I"); + tree->Branch("bpt", &bpt, "bpt/F"); + tree->Branch("beta", &beta, "beta/F"); + tree->Branch("bphi", &bphi, "bphi/F"); + + int nTotalFiles = 0; + std::string dummy; + // count number of files ---> + while (fileList0 >> dummy) nTotalFiles++; + + int nEvents = 0; + int selEvents = 0; + int nFiles = 0; + + int nonOverlap = 0; + + vector runList; runList.clear(); + vector eventList; eventList.clear(); + + if (checkOverlap) { + std::ifstream fileEvents("overlap.txt"); + int Run, Event, Lumi; + std::cout << "Non-overlapping events ->" << std::endl; + while (fileEvents >> Run >> Event >> Lumi) { + runList.push_back(Run); + eventList.push_back(Event); + std::cout << Run << ":" << Event << std::endl; + } + std::cout << std::endl; + } + std::ofstream fileOutput("overlap.out"); + + for (int iF=0; iF> filen; + + std::cout << "file " << iF+1 << " out of " << nTotalFiles << " filename : " << filen << std::endl; + TFile * file_ = TFile::Open(TString(filen)); + + TTree * _tree = NULL; + _tree = (TTree*)file_->Get(TString(ntupleName)); + + if (_tree==NULL) continue; + + TH1D * histoInputEvents = NULL; + + histoInputEvents = (TH1D*)file_->Get("makeroottree/nEvents"); + + if (histoInputEvents==NULL) continue; + + int NE = int(histoInputEvents->GetEntries()); + + std::cout << " number of input events = " << NE << std::endl; + + for (int iE=0;iEFill(0.); + + AC1B analysisTree(_tree); + + Long64_t numberOfEntries = analysisTree.GetEntries(); + + std::cout << " number of entries in Tree = " << numberOfEntries << std::endl; + + for (Long64_t iEntry=0; iEntrysize(); + // std::cout << "nfiltres = " << nfilters << std::endl; + for (unsigned int i=0; izVertexCut) continue; + if (analysisTree.primvertex_ndofdVertexCut) continue; + + // tau selection + vector taus; taus.clear(); + for (unsigned int it = 0; itetaTauCut) continue; + if (fabs(analysisTree.tau_leadchargedhadrcand_dz[it])>dzTauCut) continue; + taus.push_back(it); + } + + // muon selection + vector muons; muons.clear(); + for (unsigned int im = 0; imetaMuonCut) continue; + if (fabs(analysisTree.muon_dxy[im])>dxyMuonCut) continue; + if (fabs(analysisTree.muon_dz[im])>dzMuonCut) continue; + if (applyMuonId && !analysisTree.muon_isMedium[im]) continue; + muons.push_back(im); + } + + if (taus.size()==0) continue; + if (muons.size()==0) continue; + + // selecting muon and electron pair (OS or SS); + int tauIndex = -1; + int muonIndex = -1; + + float isoMuMin = 1e+10; + float isoTauMin = 1e+10; + float ptMu = 0; + float ptTau = 0; + // if (muons.size()>1||electrons.size()>1) + // std::cout << "muons = " << muons.size() << " taus = " << taus.size() << std::endl; + for (unsigned int im=0; imetaVetoElectronCut) continue; + if (fabs(analysisTree.electron_dxy[ie])>dxyVetoElectronCut) continue; + if (fabs(analysisTree.electron_dz[ie])>dzVetoElectronCut) continue; + bool electronMvaId = electronMvaIdWP90(analysisTree.electron_pt[ie], + analysisTree.electron_superclusterEta[ie], + analysisTree.electron_mva_id_nontrigPhys14[ie]); + if (!electronMvaId&&applyVetoElectronId) continue; + if (!analysisTree.electron_pass_conversion[ie]&&applyVetoElectronId) continue; + if (analysisTree.electron_nmissinginnerhits[ie]!=0&&applyVetoElectronId) continue; + float neutralHadIsoEle = analysisTree.electron_neutralHadIso[ie]; + float photonIsoEle = analysisTree.electron_photonIso[ie]; + float chargedHadIsoEle = analysisTree.electron_chargedHadIso[ie]; + float puIsoEle = analysisTree.electron_puIso[ie]; + if (isIsoR03) { + neutralHadIsoEle = analysisTree.electron_r03_sumNeutralHadronEt[ie]; + photonIsoEle = analysisTree.electron_r03_sumPhotonEt[ie]; + chargedHadIsoEle = analysisTree.electron_r03_sumChargedHadronPt[ie]; + puIsoEle = analysisTree.electron_r03_sumPUPt[ie]; + } + float neutralIsoEle = neutralHadIsoEle + photonIsoEle - 0.5*puIsoEle; + neutralIsoEle = TMath::Max(float(0),neutralIsoEle); + float absIsoEle = chargedHadIsoEle + neutralIsoEle; + float relIsoEle = absIsoEle/analysisTree.electron_pt[ie]; + if (relIsoEle>isoVetoElectronCut) continue; + foundExtraElectron = true; + } + + // looking for extra muon + bool foundExtraMuon = false; + for (unsigned int im = 0; imetaVetoMuonCut) continue; + if (fabs(analysisTree.muon_dxy[im])>dxyVetoMuonCut) continue; + if (fabs(analysisTree.muon_dz[im])>dzVetoMuonCut) continue; + if (applyVetoMuonId && !analysisTree.muon_isMedium[im]) continue; + float neutralHadIsoMu = analysisTree.muon_neutralHadIso[im]; + float photonIsoMu = analysisTree.muon_photonIso[im]; + float chargedHadIsoMu = analysisTree.muon_chargedHadIso[im]; + float puIsoMu = analysisTree.muon_puIso[im]; + if (isIsoR03) { + neutralHadIsoMu = analysisTree.muon_r03_sumNeutralHadronEt[im]; + photonIsoMu = analysisTree.muon_r03_sumPhotonEt[im]; + chargedHadIsoMu = analysisTree.muon_r03_sumChargedHadronPt[im]; + puIsoMu = analysisTree.muon_r03_sumPUPt[im]; + } + float neutralIsoMu = neutralHadIsoMu + photonIsoMu - 0.5*puIsoMu; + neutralIsoMu = TMath::Max(float(0),neutralIsoMu); + float absIsoMu = chargedHadIsoMu + neutralIsoMu; + float relIsoMu = absIsoMu/analysisTree.muon_pt[im]; + if (relIsoMu>isoVetoMuonCut) continue; + foundExtraMuon = true; + } + + dilepton_veto = false; + extraelec_veto = !foundExtraElectron; + extramuon_veto = !foundExtraMuon; + + // met + met = TMath::Sqrt(analysisTree.pfmet_ex*analysisTree.pfmet_ex + analysisTree.pfmet_ey*analysisTree.pfmet_ey); + metphi = TMath::ATan2(analysisTree.pfmet_ey,analysisTree.pfmet_ex); + metcov00 = analysisTree.pfmet_sigxx; + metcov01 = analysisTree.pfmet_sigxy; + metcov10 = analysisTree.pfmet_sigyx; + metcov11 = analysisTree.pfmet_sigyy; + + + // filling muon variables + pt_1 = analysisTree.muon_pt[muonIndex]; + eta_1 = analysisTree.muon_eta[muonIndex]; + phi_1 = analysisTree.muon_phi[muonIndex]; + q_1 = -1; + if (analysisTree.muon_charge[muonIndex]>0) + q_1 = 1; + mva_1 = -9999; + d0_1 = analysisTree.muon_dxy[muonIndex]; + dZ_1 = analysisTree.muon_dz[muonIndex]; + iso_1 = isoMuMin; + m_1 = muonMass; + float dPhiMETMuon = dPhiFrom2P(analysisTree.muon_px[muonIndex],analysisTree.muon_py[muonIndex], + analysisTree.pfmet_ex,analysisTree.pfmet_ey); + mt_1 = TMath::Sqrt(2*met*analysisTree.muon_pt[muonIndex]*(1-dPhiMETMuon)); + + + // filling tau variables + pt_2 = analysisTree.tau_pt[tauIndex]; + eta_2 = analysisTree.tau_eta[tauIndex]; + phi_2 = analysisTree.tau_phi[tauIndex]; + q_2 = -1; + if (analysisTree.tau_charge[tauIndex]>0) + q_2 = 1; + mva_2 = -9999; + d0_2 = analysisTree.tau_leadchargedhadrcand_dxy[tauIndex]; + dZ_2 = analysisTree.tau_leadchargedhadrcand_dz[tauIndex]; + iso_2 = isoTauMin; + m_2 = analysisTree.tau_mass[tauIndex]; + float dPhiMETTau = dPhiFrom2P(analysisTree.tau_px[tauIndex],analysisTree.tau_py[tauIndex], + analysisTree.pfmet_ex,analysisTree.pfmet_ey); + mt_2 = TMath::Sqrt(2*met*analysisTree.tau_pt[tauIndex]*(1-dPhiMETTau)); + + + byCombinedIsolationDeltaBetaCorrRaw3Hits_2 = analysisTree.tau_byCombinedIsolationDeltaBetaCorrRaw3Hits[tauIndex]; + againstElectronLooseMVA5_2 = analysisTree.tau_againstElectronLooseMVA5[tauIndex]; + againstElectronMediumMVA5_2 = analysisTree.tau_againstElectronMediumMVA5[tauIndex]; + againstElectronTightMVA5_2 = analysisTree.tau_againstElectronTightMVA5[tauIndex]; + againstElectronVLooseMVA5_2 = analysisTree.tau_againstElectronVLooseMVA5[tauIndex]; + againstElectronVTightMVA5_2 = analysisTree.tau_againstElectronVTightMVA5[tauIndex]; + againstMuonLoose3_2 = analysisTree.tau_againstMuonLoose3[tauIndex]; + againstMuonTight3_2 = analysisTree.tau_againstMuonTight3[tauIndex]; + + TLorentzVector muonLV; muonLV.SetXYZM(analysisTree.muon_px[muonIndex], + analysisTree.muon_py[muonIndex], + analysisTree.muon_pz[muonIndex], + muonMass); + + TLorentzVector tauLV; tauLV.SetXYZT(analysisTree.tau_px[tauIndex], + analysisTree.tau_py[tauIndex], + analysisTree.tau_pz[tauIndex], + analysisTree.tau_e[tauIndex]); + + TLorentzVector dileptonLV = muonLV + tauLV; + + // visible mass + m_vis = dileptonLV.M(); + // visible ditau pt + pt_tt = dileptonLV.Pt(); + + // bisector of electron and muon transverse momenta + float tauUnitX = tauLV.Px()/tauLV.Pt(); + float tauUnitY = tauLV.Py()/tauLV.Pt(); + + float muonUnitX = muonLV.Px()/muonLV.Pt(); + float muonUnitY = muonLV.Py()/muonLV.Pt(); + + float zetaX = tauUnitX + muonUnitX; + float zetaY = tauUnitY + muonUnitY; + + float normZeta = TMath::Sqrt(zetaX*zetaX+zetaY*zetaY); + + zetaX = zetaX/normZeta; + zetaY = zetaY/normZeta; + + // choosing mva met + // unsigned int metEMu = 0; + // for (unsigned int iMet=0; iMet jets; jets.clear(); + vector jetspt20; jetspt20.clear(); + vector bjets; bjets.clear(); + + int indexLeadingJet = -1; + float ptLeadingJet = -1; + + int indexSubLeadingJet = -1; + float ptSubLeadingJet = -1; + + int indexLeadingBJet = -1; + float ptLeadingBJet = -1; + + for (unsigned int jet=0; jetjetEtaCut) continue; + + float jetPt = analysisTree.pfjet_pt[jet]; + if (jetPt1 && phf<0.99 && nhf<0.99) && (absJetEta>2.4 || (elf<0.99 && chf>0 && chm>0)); + if (!isPFJetId) continue; + + jetspt20.push_back(jet); + + if (absJetEtabtagCut) { // b-jet + bjets.push_back(jet); + if (jetPt>ptLeadingBJet) { + ptLeadingBJet = jetPt; + indexLeadingBJet = jet; + } + } + + if (jetPt=0) { + if (jetPtptSubLeadingJet) { + indexSubLeadingJet = jet; + ptSubLeadingJet = jetPt; + } + } + + if (jetPt>ptLeadingJet) { + indexLeadingJet = jet; + ptLeadingJet = jetPt; + } + } + + njets = jets.size(); + njetspt20 = jetspt20.size(); + nbtag = bjets.size(); + + bpt = -9999; + beta = -9999; + bphi = -9999; + + if (indexLeadingBJet>=0) { + bpt = analysisTree.pfjet_pt[indexLeadingBJet]; + beta = analysisTree.pfjet_eta[indexLeadingBJet]; + bphi = analysisTree.pfjet_phi[indexLeadingBJet]; + } + + jpt_1 = -9999; + jeta_1 = -9999; + jphi_1 = -9999; + jptraw_1 = -9999; + jptunc_1 = -9999; + jmva_1 = -9999; + jlrm_1 = -9999; + jctm_1 = -9999; + + if (indexLeadingJet>=0&&indexSubLeadingJet>=0&&indexLeadingJet==indexSubLeadingJet) + cout << "warning : indexLeadingJet ==indexSubLeadingJet = " << indexSubLeadingJet << endl; + + if (indexLeadingJet>=0) { + jpt_1 = analysisTree.pfjet_pt[indexLeadingJet]; + jeta_1 = analysisTree.pfjet_eta[indexLeadingJet]; + jphi_1 = analysisTree.pfjet_phi[indexLeadingJet]; + jptraw_1 = analysisTree.pfjet_pt[indexLeadingJet]*analysisTree.pfjet_energycorr[indexLeadingJet]; + jmva_1 = analysisTree.pfjet_pu_jet_full_mva[indexLeadingJet]; + } + + jpt_2 = -9999; + jeta_2 = -9999; + jphi_2 = -9999; + jptraw_2 = -9999; + jptunc_2 = -9999; + jmva_2 = -9999; + jlrm_2 = -9999; + jctm_2 = -9999; + + if (indexSubLeadingJet>=0) { + jpt_2 = analysisTree.pfjet_pt[indexSubLeadingJet]; + jeta_2 = analysisTree.pfjet_eta[indexSubLeadingJet]; + jphi_2 = analysisTree.pfjet_phi[indexSubLeadingJet]; + jptraw_2 = analysisTree.pfjet_pt[indexSubLeadingJet]*analysisTree.pfjet_energycorr[indexSubLeadingJet]; + jmva_2 = analysisTree.pfjet_pu_jet_full_mva[indexSubLeadingJet]; + } + + mjj = -9999; + jdeta = -9999; + njetingap = 0; + + if (indexLeadingJet>=0 && indexSubLeadingJet>=0) { + + TLorentzVector jet1; jet1.SetPxPyPzE(analysisTree.pfjet_px[indexLeadingJet], + analysisTree.pfjet_py[indexLeadingJet], + analysisTree.pfjet_pz[indexLeadingJet], + analysisTree.pfjet_e[indexLeadingJet]); + + TLorentzVector jet2; jet2.SetPxPyPzE(analysisTree.pfjet_px[indexSubLeadingJet], + analysisTree.pfjet_py[indexSubLeadingJet], + analysisTree.pfjet_pz[indexSubLeadingJet], + analysisTree.pfjet_e[indexSubLeadingJet]); + + mjj = (jet1+jet2).M(); + jdeta = abs(analysisTree.pfjet_eta[indexLeadingJet]- + analysisTree.pfjet_eta[indexSubLeadingJet]); + + float etamax = analysisTree.pfjet_eta[indexLeadingJet]; + float etamin = analysisTree.pfjet_eta[indexSubLeadingJet]; + if (etamaxetamin&&etaXFill(); + selEvents++; + + } // end of file processing (loop over events in one file) + nFiles++; + delete _tree; + file_->Close(); + delete file_; + } + std::cout << std::endl; + int allEvents = int(inputEventsH->GetEntries()); + std::cout << "Total number of input events = " << allEvents << std::endl; + std::cout << "Total number of events in Tree = " << nEvents << std::endl; + std::cout << "Total number of selected events = " << selEvents << std::endl; + std::cout << std::endl; + + file->cd(""); + file->Write(); + file->Close(); + delete file; + +} + + + diff --git a/DesyTauAnalyses/NTupleMaker/test/analysisMacroSynch.conf b/DesyTauAnalyses/NTupleMaker/test/analysisMacroSynch.conf deleted file mode 100644 index 1eaf5aa..0000000 --- a/DesyTauAnalyses/NTupleMaker/test/analysisMacroSynch.conf +++ /dev/null @@ -1,69 +0,0 @@ -######################################## -# configuration file for AnalysisMacro # -######################################## - -# electron kinematic cuts -ptElectronLowCut = 13 -ptElectronHighCut = -1 -etaElectronCut = 2.5 -dxyElectronCut = 0.045 -dzElectronCut = 0.2 -isoElectronLowCut = -0.1 -isoElectronHighCut = 0.15 -ApplyElectronId = true -LowPtLegElectron = hltMu23TrkIsoVVLEle12CaloIdLTrackIdLIsoVLElectronlegTrackIsoFilter -# hltMu23TrkIsoVVLEle12CaloIdLTrackIdLIsoVLElectronlegTrackIsoFilter -HighPtLegElectron = hltMu8TrkIsoVVLEle23CaloIdLTrackIdLIsoVLElectronlegTrackIsoFilter -# hltMu8TrkIsoVVLEle23CaloIdLTrackIdLIsoVLElectronlegTrackIsoFilter - -# electron veto -ptVetoElectronCut = 10 -etaVetoElectronCut = 2.5 -dxyVetoElectronCut = 0.045 -dzVetoElectronCut = 0.2 -isoVetoElectronCut = 0.3 -ApplyVetoElectronId = true - -# muon kinematic cuts -ptMuonLowCut = 9 -ptMuonHighCut = -1 -etaMuonCut = 2.4 -dxyMuonCut = 0.045 -dzMuonCut = 0.2 -isoMuonLowCut = -0.1 -isoMuonHighCut = 0.15 -ApplyMuonId = true -LowPtLegMuon = hltMu8TrkIsoVVLEle23CaloIdLTrackIdLIsoVLMuonlegL3IsoFiltered8 -# hltMu8TrkIsoVVLEle23CaloIdLTrackIdLIsoVLMuonlegL3IsoFiltered8 -HighPtLegMuon = hltMu23TrkIsoVVLEle12CaloIdLTrackIdLIsoVLMuonlegL3IsoFiltered23 -# hltMu23TrkIsoVVLEle12CaloIdLTrackIdLIsoVLMuonlegL3IsoFiltered23 - -# muon veto -ptVetoMuonCut = 10 -etaVetoMuonCut = 2.4 -dxyVetoMuonCut = 0.045 -dzVetoMuonCut = 0.2 -isoVetoMuonCut = 0.3 -ApplyVetoMuonId = true - -# topological cuts -dRleptonsCut = 0.3 -IsIsoR03 = true -DRTrigMatch = 0.5 - -# jet cuts -JetEtaCut = 4.7 -JetPtLowCut = 20 -JetPtHighCut = 30 -dRJetLeptonCut = 0.4 -bJetEtaCut = 2.4 -btagCut = 0.814 -ApplyJetPfId = true -ApplyJetPuId = false - -# vertex cuts -NdofVertexCut = 4 -ZVertexCut = 25 -DVertexCut = 2 - -CheckOverlap = false \ No newline at end of file