diff --git a/NTupleMaker/bin/SynchNTupleProducer_em.cpp b/NTupleMaker/bin/SynchNTupleProducer_em.cpp index cabf2dc..7017baa 100644 --- a/NTupleMaker/bin/SynchNTupleProducer_em.cpp +++ b/NTupleMaker/bin/SynchNTupleProducer_em.cpp @@ -25,8 +25,8 @@ #include "DesyTauAnalyses/NTupleMaker/interface/Config.h" #include "DesyTauAnalyses/NTupleMaker/interface/AC1B.h" -#include "DesyTauAnalyses/NTupleMaker/interface/RunLumiReader.h" #include "DesyTauAnalyses/NTupleMaker/interface/json.h" +#include "DesyTauAnalyses/NTupleMaker/interface/PileUp.h" const float MuMass = 0.105658367; @@ -354,9 +354,6 @@ int main(int argc, char * argv[]) { const bool applyJetPfId = cfg.get("ApplyJetPfId"); const bool applyJetPuId = cfg.get("ApplyJetPuId"); - // check overlap - const bool checkOverlap = cfg.get("CheckOverlap"); - TString LowPtLegElectron(lowPtLegElectron); TString HighPtLegElectron(highPtLegElectron); @@ -372,6 +369,7 @@ int main(int argc, char * argv[]) { std::ifstream fileList(argv[2]); std::ifstream fileList0(argv[2]); std::string ntupleName("makeroottree/AC1B"); + std::string initNtupleName("initroottree/AC1B"); TString TStrName(rootFileName); std::cout <cd(""); - TH1F * inputEventsH = new TH1F("inputEventsH","",1,-0.5,0.5); + TH1D * inputEventsH = new TH1D("inputEventsH","",1,-0.5,0.5); + TH1D * ZMM = new TH1D("ZMM","",1,-0.5,0.5); + TH1D * ZEE = new TH1D("ZEE","",1,-0.5,0.5); + TH1D * ZTT = new TH1D("ZTT","",1,-0.5,0.5); + TH1D * ALL = new TH1D("ALL","",1,-0.5,0.5); + TH1D * histWeightsH = new TH1D("histWeightsH","",1,-0.5,0.5); + TTree * tree = new TTree("TauCheck","TauCheck"); // Declaration of leaf types unsigned int minRun = 99999999; @@ -501,7 +505,7 @@ int main(int argc, char * argv[]) { Bool_t isZLL; Bool_t isZMM; Bool_t isZEE; - + Bool_t isZTT; tree->Branch("run", &run, "run/I"); tree->Branch("lumi", &lumi, "lumi/I"); @@ -513,6 +517,7 @@ int main(int argc, char * argv[]) { tree->Branch("isZLL",&isZLL,"isZLL/O"); tree->Branch("isZEE",&isZEE,"isZEE/O"); tree->Branch("isZMM",&isZMM,"isZMM/O"); + tree->Branch("isZTT",&isZTT,"isZTT/O"); tree->Branch("mcweight", &mcweight, "mcweight/F"); tree->Branch("puweight", &puweight, "puweight/F"); @@ -561,23 +566,23 @@ int main(int argc, char * argv[]) { 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("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"); @@ -652,6 +657,15 @@ int main(int argc, char * argv[]) { } } + PileUp * PUofficial = new PileUp(); + + TFile * filePUdistribution_data = new TFile(TString(cmsswBase)+"/src/DesyTauAnalyses/NTupleMaker/data/PileUpDistrib/Data_Pileup_2015D_Nov17.root","read"); + TFile * filePUdistribution_MC = new TFile (TString(cmsswBase)+"/src/DesyTauAnalyses/NTupleMaker/data/PileUpDistrib/MC_Spring15_PU25_Startup.root", "read"); + TH1D * PU_data = (TH1D *)filePUdistribution_data->Get("pileup"); + TH1D * PU_mc = (TH1D *)filePUdistribution_MC->Get("pileup"); + PUofficial->set_h_data(PU_data); + PUofficial->set_h_MC(PU_mc); + int nEvents = 0; int selEvents = 0; int nFiles = 0; @@ -661,20 +675,6 @@ int main(int argc, char * argv[]) { vector runList; runList.clear(); vector eventList; eventList.clear(); - std::vector allRuns; allRuns.clear(); - std::vector allGoodRuns; allGoodRuns.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; iFGet(TString(initNtupleName)); + if (_inittree==NULL) continue; + Float_t genweight; + if (!isData) + _inittree->SetBranchAddress("genweight",&genweight); + Long64_t numberOfEntriesInitTree = _inittree->GetEntries(); + std::cout << " number of entries in Init Tree = " << numberOfEntriesInitTree << std::endl; + for (Long64_t iEntry=0; iEntryGetEntry(iEntry); + if (isData) + histWeightsH->Fill(0.,1.); + else + histWeightsH->Fill(0.,genweight); + } + 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.); @@ -720,59 +730,62 @@ int main(int argc, char * argv[]) { if (nEvents%10000==0) cout << " processed " << nEvents << " events" << endl; - bool isNewRun = true; - if (allRuns.size()>0) { - for (unsigned int iR=0; iRFill(0.0); + if (isZMM) ZMM->Fill(0.); + if (isZEE) ZEE->Fill(0.); + if (isZTT) ZTT->Fill(0.); } - if (isNewRun) - allRuns.push_back(analysisTree.event_run); + // if (isZEE&&isZMM) { + // cout << "Warning : isZEE && isZMM simultaneously" << endl; + // cout << "Mu+:" << isPrompMuPlus + // << " Mu-:" << isPrompMuMinus + // << " E+:" << isPrompElePlus + // << " E-:" << isPrompEleMinus << endl; + // } + + // if ((isPrompElePlus&&!isPrompEleMinus)||(!isPrompElePlus&&isPrompEleMinus)) + // cout << "Warning : only one prompt electron!" << endl; + + // if ((isPrompMuPlus&&!isPrompMuMinus)||(!isPrompMuPlus&&isPrompMuMinus)) + // cout << "Warning : only one prompt muon!" << endl; + + isZLL = isZEE || isZMM; run = int(analysisTree.event_run); lumi = int(analysisTree.event_luminosityblock); evt = int(analysisTree.event_nr); - bool nonOverlap = false; - if (checkOverlap) { - for (unsigned int iRuns=0; iRunsget_PUweight(double(analysisTree.numtruepileupinteractions))); + // cout << "Ok1 : " << puweight << endl; unsigned int nLowPtLegElectron = 0; bool isLowPtLegElectron = false; @@ -906,22 +910,13 @@ int main(int argc, char * argv[]) { // bool trigAccept = (analysisTree.hltriggerresults_second[5]==1)||(analysisTree.hltriggerresults_second[6]==1); // if (!trigAccept) continue; - if (nonOverlap&&checkOverlap) - fileOutput << "Muons = " << analysisTree.muon_count - << " Electrons = " << analysisTree.electron_count << std::endl; + // if (nonOverlap&&checkOverlap) + // cout << "Muons = " << analysisTree.muon_count + // << " Electrons = " << analysisTree.electron_count << std::endl; // electron selection vector electrons; electrons.clear(); for (unsigned int ie = 0; ieisoElectronHighCut) continue; } + // cout << "dilepton_veto : " << dilepton_veto + // << " extraelec_veto : " << extraelec_veto + // << " extramuon_veto : " << extramuon_veto << endl; // filling muon variables pt_2 = analysisTree.muon_pt[muonIndex]; @@ -1224,6 +1213,8 @@ int main(int argc, char * argv[]) { metcov10 = analysisTree.pfmet_sigyx; metcov11 = analysisTree.pfmet_sigyy; + // cout << "m_vis = " << endl; + // visible ditau pt pt_tt = dileptonLV.Pt(); @@ -1243,21 +1234,21 @@ int main(int argc, char * argv[]) { zetaY = zetaY/normZeta; // choosing mva met - unsigned int metEMu = 0; - for (unsigned int iMet=0; iMetcd(""); file->Write(); file->Close(); diff --git a/NTupleMaker/test/analysisMacroSynch_em.conf b/NTupleMaker/test/analysisMacroSynch_em.conf index e5ffeeb..6ac9d52 100644 --- a/NTupleMaker/test/analysisMacroSynch_em.conf +++ b/NTupleMaker/test/analysisMacroSynch_em.conf @@ -3,7 +3,11 @@ ######################################## # apply inclusive selection -ApplyInclusiveSelection = false +IsData = true +ApplyGoodRunSelection = true +ApplyInclusiveSelection = true + +jsonFile = Cert_256630-260627_13TeV_PromptReco_Collisions15_25ns_JSON.json # electron kinematic cuts ptElectronLowCut = 13 diff --git a/NTupleMaker/test/analysisMacroSynch_em_mc.conf b/NTupleMaker/test/analysisMacroSynch_em_mc.conf new file mode 100644 index 0000000..978b993 --- /dev/null +++ b/NTupleMaker/test/analysisMacroSynch_em_mc.conf @@ -0,0 +1,80 @@ +######################################## +# configuration file for AnalysisMacro # +######################################## + +# apply inclusive selection +IsData = false +ApplyGoodRunSelection = false +ApplyInclusiveSelection = true + +jsonFile = Cert_256630-260627_13TeV_PromptReco_Collisions15_25ns_JSON.json + +# electron kinematic cuts +ptElectronLowCut = 13 +ptElectronHighCut = 18 +etaElectronCut = 2.5 +dxyElectronCut = 0.045 +dzElectronCut = 0.2 +isoElectronLowCut = -0.1 +isoElectronHighCut = 0.15 +ApplyElectronId = true +LowPtLegElectron = hltMu17TrkIsoVVLEle12CaloIdLTrackIdLIsoVLElectronlegTrackIsoFilter +# hltMu23TrkIsoVVLEle12CaloIdLTrackIdLIsoVLElectronlegTrackIsoFilter +HighPtLegElectron = hltMu8TrkIsoVVLEle17CaloIdLTrackIdLIsoVLElectronlegTrackIsoFilter +# hltMu8TrkIsoVVLEle23CaloIdLTrackIdLIsoVLElectronlegTrackIsoFilter + +# electron veto +ptVetoElectronCut = 10 +etaVetoElectronCut = 2.5 +dxyVetoElectronCut = 0.045 +dzVetoElectronCut = 0.2 +isoVetoElectronCut = 0.3 +ApplyVetoElectronId = true + +# muon kinematic cuts +ptMuonLowCut = 10 +ptMuonHighCut = 18 +etaMuonCut = 2.4 +dxyMuonCut = 0.045 +dzMuonCut = 0.2 +isoMuonLowCut = -0.1 +isoMuonHighCut = 0.15 +ApplyMuonId = true +LowPtLegMuon = hltMu8TrkIsoVVLEle17CaloIdLTrackIdLIsoVLMuonlegL3IsoFiltered8 +# hltMu8TrkIsoVVLEle23CaloIdLTrackIdLIsoVLMuonlegL3IsoFiltered8 +HighPtLegMuon = hltMu17TrkIsoVVLEle12CaloIdLTrackIdLIsoVLMuonlegL3IsoFiltered17 +# 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 +ApplyTriggerMatch = true +DRTrigMatch = 0.5 + +# btag discriminator +BTagDiscriminator = pfCombinedInclusiveSecondaryVertexV2BJetTags + +# jet cuts +JetEtaCut = 4.7 +JetPtLowCut = 20 +JetPtHighCut = 30 +dRJetLeptonCut = 0.5 +bJetEtaCut = 2.4 +btagCut = 0.89 +ApplyJetPfId = true +ApplyJetPuId = false + +# vertex cuts +NdofVertexCut = 4 +ZVertexCut = 25 +DVertexCut = 2 + +CheckOverlap = false \ No newline at end of file