From 6735f64559272319f72eb1caad3fcfa425079dcf Mon Sep 17 00:00:00 2001 From: Markus Seidel <markus.seidel@cern.ch> Date: Thu, 9 Feb 2017 14:40:52 +0100 Subject: [PATCH 1/3] Small improvements for dealing with bad files --- TopAnalysis/scripts/mergeOutputs.py | 4 +++- TopAnalysis/scripts/runLocalAnalysis.py | 2 +- TopAnalysis/src/TOPJetShape.cc | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/TopAnalysis/scripts/mergeOutputs.py b/TopAnalysis/scripts/mergeOutputs.py index 1c3f8eeb..0b0808ad 100755 --- a/TopAnalysis/scripts/mergeOutputs.py +++ b/TopAnalysis/scripts/mergeOutputs.py @@ -78,4 +78,6 @@ for basename, files in counters.iteritems(): if (len(badFiles) > 0): print '-----------------------' - print 'The following files are not done yet or require resubmission, please check LSF output:', badFiles + print 'The following files are not done yet or require resubmission, please check LSF output:' + for file in badFiles: + print file, diff --git a/TopAnalysis/scripts/runLocalAnalysis.py b/TopAnalysis/scripts/runLocalAnalysis.py index 3176314f..148c00b9 100755 --- a/TopAnalysis/scripts/runLocalAnalysis.py +++ b/TopAnalysis/scripts/runLocalAnalysis.py @@ -124,7 +124,7 @@ def main(): nexisting += 1 continue task_list.append( (opt.method,inF,outF,opt.channel,opt.charge,opt.flav,opt.runSysts,opt.era,tag,opt.debug) ) - if (opt.skipexisting): print '--skipexisting: skipping %d of %d tasks as files already exist'%(nexisting,len(input_list)) + if (opt.skipexisting and nexisting): print '--skipexisting: skipping %d of %d tasks as files already exist'%(nexisting,len(input_list)) #run the analysis jobs if opt.queue=='local': diff --git a/TopAnalysis/src/TOPJetShape.cc b/TopAnalysis/src/TOPJetShape.cc index 9ca3497a..6bd05b8d 100644 --- a/TopAnalysis/src/TOPJetShape.cc +++ b/TopAnalysis/src/TOPJetShape.cc @@ -51,7 +51,7 @@ void RunTopJetShape(TString filename, /////////////////// - bool isTTbar( filename.Contains("_TTJets") or TString(normH->GetTitle()).Contains("_TTJets")); + bool isTTbar( filename.Contains("_TTJets") or (normH and TString(normH->GetTitle()).Contains("_TTJets"))); //PREPARE OUTPUT -- GitLab From 4ce9849745bbbf6e25737fb1a80d4bcfd1678eb3 Mon Sep 17 00:00:00 2001 From: Markus Seidel <markus.seidel@cern.ch> Date: Tue, 14 Feb 2017 10:42:22 +0100 Subject: [PATCH 2/3] Jet shape fixes --- TopAnalysis/src/TOPJetShape.cc | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/TopAnalysis/src/TOPJetShape.cc b/TopAnalysis/src/TOPJetShape.cc index 6bd05b8d..879ff81c 100644 --- a/TopAnalysis/src/TOPJetShape.cc +++ b/TopAnalysis/src/TOPJetShape.cc @@ -68,7 +68,7 @@ void RunTopJetShape(TString filename, //READ TREE FROM FILE MiniEvent_t ev; TFile *f = TFile::Open(filename); - TH1 *genPU=(TH1 *)f->Get("analysis/pu"); + TH1 *genPU=(TH1 *)f->Get("analysis/putrue"); TTree *t = (TTree*)f->Get("analysis/data"); attachToMiniEventTree(t,ev,true); Int_t nentries(t->GetEntriesFast()); @@ -77,7 +77,16 @@ void RunTopJetShape(TString filename, cout << "...producing " << outname << " from " << nentries << " events" << endl; - + //lumi + TH1F *ratevsrunH=0; + std::map<Int_t,Float_t> lumiMap; + if( filename.Contains("Data") ) + { + std::pair<std::map<Int_t,Float_t>, TH1F *> result=parseLumiInfo(era); + lumiMap = result.first; + ratevsrunH = result.second; + } + //PILEUP WEIGHTING std::vector<TGraph *>puWgtGr; if( !filename.Contains("Data") ) puWgtGr=getPileupWeights(era,genPU); @@ -124,6 +133,8 @@ void RunTopJetShape(TString filename, for(auto& channel : chTags) { TString tag(stage+channel); + if(ratevsrunH) + allPlots["ratevsrun_"+tag] = (TH1 *)ratevsrunH->Clone("ratevsrun_"+tag); allPlots["nvtx_"+tag] = new TH1F("nvtx_"+tag,";Vertex multiplicity;Events",30,0,30); allPlots["nleps_"+tag] = new TH1F("nleps_"+tag,";Lepton multiplicity;Events",5,-0.5,4.5); allPlots["njets_"+tag] = new TH1F("njets_"+tag,";Jet multiplicity;Events",10,-0.5,9.5); @@ -229,7 +240,10 @@ void RunTopJetShape(TString filename, /////////////////////// // LOOP OVER EVENTS // ///////////////////// - SelectionTool selector; + + //EVENT SELECTION WRAPPER + SelectionTool selector(filename); + for (Int_t iev=0;iev<nentries;iev++) { t->GetEntry(iev); @@ -284,10 +298,14 @@ void RunTopJetShape(TString filename, //event weight float wgt(1.0); + allPlots["puwgtctr"]->Fill(0.,1.0); if(!ev.isData) { + float puWgt(puWgtGr[0]->Eval(ev.g_pu)); + allPlots["puwgtctr"]->Fill(1,puWgt); + wgt = (normH? normH->GetBinContent(1) : 1.0); - wgt *= puWgtGr[0]->Eval(ev.g_pu); + wgt *= puWgt; wgt *= (ev.g_nw>0 ? ev.g_w[0] : 1.0); } @@ -330,6 +348,9 @@ void RunTopJetShape(TString filename, if (channel == "M" and chTag != "M") continue; TString tag(stageVec[istage]+channel); + std::map<Int_t,Float_t>::iterator rIt=lumiMap.find(ev.run); + if(rIt!=lumiMap.end() && ratevsrunH) allPlots["ratevsrun_"+tag]->Fill(std::distance(lumiMap.begin(),rIt),1./rIt->second); + allPlots["nvtx_"+tag]->Fill(ev.nvtx, wgt); allPlots["nleps_"+tag]->Fill(leptons.size(), wgt); allPlots["njets_"+tag]->Fill(jets.size(), wgt); -- GitLab From 996c469e3994c9e9bafaeaeb0fd032294f637d05 Mon Sep 17 00:00:00 2001 From: Markus Seidel <markus.seidel@cern.ch> Date: Tue, 14 Feb 2017 12:39:31 +0100 Subject: [PATCH 3/3] New PseudoTopProducer --- TopAnalysis/README.md | 3 +++ TopAnalysis/plugins/MiniAnalyzer.cc | 12 +++++------- TopAnalysis/test/runMiniAnalyzer_cfg.py | 11 ++++++++++- 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/TopAnalysis/README.md b/TopAnalysis/README.md index cb3d15e8..08309d77 100644 --- a/TopAnalysis/README.md +++ b/TopAnalysis/README.md @@ -39,6 +39,9 @@ wget http://home.fnal.gov/~verzetti//DeepFlavour/training/DeepFlavourNoSL.json wget http://mon.iihe.ac.be/~smoortga/DeepFlavour/CMSSW_implementation_DeepCMVA/Model_DeepCMVA.json cd - +#New PseudoTopProducer +git cms-merge-topic -u intrepid42:pseudotoprivet_80x + #ntuplizer git clone git@github.com:pfs/TopLJets2015.git cd TopLJets2015/TopAnalysis diff --git a/TopAnalysis/plugins/MiniAnalyzer.cc b/TopAnalysis/plugins/MiniAnalyzer.cc index 6dec7a73..c501044d 100644 --- a/TopAnalysis/plugins/MiniAnalyzer.cc +++ b/TopAnalysis/plugins/MiniAnalyzer.cc @@ -110,7 +110,8 @@ private: edm::EDGetTokenT<LHEEventProduct> generatorlheToken_; edm::EDGetTokenT<LHERunInfoProduct> generatorRunInfoToken_; edm::EDGetTokenT<std::vector<PileupSummaryInfo> > puToken_; - edm::EDGetTokenT<std::vector<reco::GenJet> > genLeptonsToken_, genJetsToken_; + edm::EDGetTokenT<reco::GenParticleCollection> genLeptonsToken_; + edm::EDGetTokenT<std::vector<reco::GenJet> > genJetsToken_; edm::EDGetTokenT<pat::PackedGenParticleCollection> genParticlesToken_; edm::EDGetTokenT<reco::GenParticleCollection> prunedGenParticlesToken_; edm::EDGetTokenT<reco::GenParticleCollection> pseudoTopToken_; @@ -168,7 +169,7 @@ MiniAnalyzer::MiniAnalyzer(const edm::ParameterSet& iConfig) : generatorlheToken_(consumes<LHEEventProduct>(edm::InputTag("externalLHEProducer",""))), generatorRunInfoToken_(consumes<LHERunInfoProduct,edm::InRun>({"externalLHEProducer"})), puToken_(consumes<std::vector<PileupSummaryInfo>>(edm::InputTag("slimmedAddPileupInfo"))), - genLeptonsToken_(consumes<std::vector<reco::GenJet> >(edm::InputTag("pseudoTop:leptons"))), + genLeptonsToken_(consumes<reco::GenParticleCollection>(edm::InputTag("pseudoTop:leptons"))), genJetsToken_(consumes<std::vector<reco::GenJet> >(edm::InputTag("pseudoTop:jets"))), genParticlesToken_(consumes<pat::PackedGenParticleCollection>(edm::InputTag("packedGenParticles"))), prunedGenParticlesToken_(consumes<reco::GenParticleCollection>(edm::InputTag("prunedGenParticles"))), @@ -318,14 +319,11 @@ int MiniAnalyzer::genAnalysis(const edm::Event& iEvent, const edm::EventSetup& i //leptons int ngleptons(0); - edm::Handle<std::vector<reco::GenJet> > dressedLeptons; + //edm::Handle<std::vector<reco::GenJet> > dressedLeptons; + edm::Handle<reco::GenParticleCollection> dressedLeptons; iEvent.getByToken(genLeptonsToken_,dressedLeptons); for(auto genLep = dressedLeptons->begin(); genLep != dressedLeptons->end(); ++genLep) { - //map the gen particles which are clustered in this lepton - std::vector< const reco::Candidate * > jconst=genLep->getJetConstituentsQuick(); - for(size_t ijc=0; ijc <jconst.size(); ijc++) jetConstsMap[ jconst[ijc] ] = ev_.ng; - ev_.g_pt[ev_.ng] = genLep->pt(); ev_.g_id[ev_.ng] = genLep->pdgId(); ev_.g_eta[ev_.ng] = genLep->eta(); diff --git a/TopAnalysis/test/runMiniAnalyzer_cfg.py b/TopAnalysis/test/runMiniAnalyzer_cfg.py index 6850bfa6..1e8bfff9 100644 --- a/TopAnalysis/test/runMiniAnalyzer_cfg.py +++ b/TopAnalysis/test/runMiniAnalyzer_cfg.py @@ -118,7 +118,16 @@ process.options = cms.untracked.PSet( #pseudo-top if not options.runOnData: - process.load('TopQuarkAnalysis.TopEventProducers.producers.pseudoTop_cfi') + process.load('SimGeneral.HepPDTESSource.pythiapdt_cfi') + process.mergedGenParticles = cms.EDProducer("MergedGenParticleProducer", + inputPruned = cms.InputTag("prunedGenParticles"), + inputPacked = cms.InputTag("packedGenParticles"), + ) + process.genParticles2HepMC = cms.EDProducer("GenParticles2HepMCConverter", + genParticles = cms.InputTag("mergedGenParticles"), + genEventInfo = cms.InputTag("generator"), + ) + process.load("TopQuarkAnalysis.TopEventProducers.producers.pseudoTop_cfi") process.pseudoTop.leptonMinPt=cms.double(20) process.pseudoTop.leptonMaxEta=cms.double(2.5) process.pseudoTop.jetMaxEta=cms.double(5.0) -- GitLab