From dcf20b9a6ee79f3e807f972810ec1df1c49d6af8 Mon Sep 17 00:00:00 2001 From: Carlo Battilana Date: Thu, 13 Oct 2016 11:20:25 +0200 Subject: [PATCH 1/4] Configuration using HLT2 and stage2 L1 trigger --- test/zmumu/tp_from_aod_MC.py | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/test/zmumu/tp_from_aod_MC.py b/test/zmumu/tp_from_aod_MC.py index 5c4d0547b52cf..7b410869a94dc 100644 --- a/test/zmumu/tp_from_aod_MC.py +++ b/test/zmumu/tp_from_aod_MC.py @@ -19,15 +19,13 @@ import os if "CMSSW_8_0_" in os.environ['CMSSW_VERSION']: - process.GlobalTag.globaltag = cms.string('80X_mcRun2_asymptotic_v4') + process.GlobalTag.globaltag = cms.string('80X_mcRun2_asymptotic_v14') process.source.fileNames = [ - '/store/relval/CMSSW_8_0_0/RelValZMM_13/GEN-SIM-RECO/PU25ns_80X_mcRun2_asymptotic_v4-v1/10000/382BADA2-A3DA-E511-9E07-0CC47A4D769E.root', - '/store/relval/CMSSW_8_0_0/RelValZMM_13/GEN-SIM-RECO/PU25ns_80X_mcRun2_asymptotic_v4-v1/10000/6200B483-9EDA-E511-A354-0CC47A4D7636.root', - '/store/relval/CMSSW_8_0_0/RelValZMM_13/GEN-SIM-RECO/PU25ns_80X_mcRun2_asymptotic_v4-v1/10000/70B70BFF-32DB-E511-A4C6-0CC47A4C8E1C.root', - '/store/relval/CMSSW_8_0_0/RelValZMM_13/GEN-SIM-RECO/PU25ns_80X_mcRun2_asymptotic_v4-v1/10000/80CC4165-9FDA-E511-815B-0CC47A78A4A0.root', - '/store/relval/CMSSW_8_0_0/RelValZMM_13/GEN-SIM-RECO/PU25ns_80X_mcRun2_asymptotic_v4-v1/10000/80F7131A-33DB-E511-A2B5-0CC47A4D75F6.root', - '/store/relval/CMSSW_8_0_0/RelValZMM_13/GEN-SIM-RECO/PU25ns_80X_mcRun2_asymptotic_v4-v1/10000/8AC339C5-A0DA-E511-9B02-0CC47A4C8E96.root', - '/store/relval/CMSSW_8_0_0/RelValZMM_13/GEN-SIM-RECO/PU25ns_80X_mcRun2_asymptotic_v4-v1/10000/D279741B-9EDA-E511-A88D-0025905A6110.root', + '/store/mc/RunIISpring16reHLT80/DYJetsToLL_M-50_TuneCUETP8M1_13TeV-amcatnloFXFX-pythia8/AODSIM/PUSpring16RAWAODSIM_reHLT_80X_mcRun2_asymptotic_v14-v1/40001/3459A4AB-D85C-E611-81F5-02163E011488.root', + '/store/mc/RunIISpring16reHLT80/DYJetsToLL_M-50_TuneCUETP8M1_13TeV-amcatnloFXFX-pythia8/AODSIM/PUSpring16RAWAODSIM_reHLT_80X_mcRun2_asymptotic_v14-v1/40001/8AB9296A-C55C-E611-9291-02163E012E69.root', + '/store/mc/RunIISpring16reHLT80/DYJetsToLL_M-50_TuneCUETP8M1_13TeV-amcatnloFXFX-pythia8/AODSIM/PUSpring16RAWAODSIM_reHLT_80X_mcRun2_asymptotic_v14-v1/40001/9A8A076A-C55C-E611-BE5A-02163E012E69.root', + '/store/mc/RunIISpring16reHLT80/DYJetsToLL_M-50_TuneCUETP8M1_13TeV-amcatnloFXFX-pythia8/AODSIM/PUSpring16RAWAODSIM_reHLT_80X_mcRun2_asymptotic_v14-v1/40002/4AC3D851-C45C-E611-8BFD-02163E012E69.root', + '/store/mc/RunIISpring16reHLT80/DYJetsToLL_M-50_TuneCUETP8M1_13TeV-amcatnloFXFX-pythia8/AODSIM/PUSpring16RAWAODSIM_reHLT_80X_mcRun2_asymptotic_v14-v1/40003/ACAA69A9-D85C-E611-983F-02163E011488.root', ] else: raise RuntimeError, "Unknown CMSSW version %s" % os.environ['CMSSW_VERSION'] @@ -77,11 +75,13 @@ process.muonMatchHLTL3.maxDeltaR = 0.1 from MuonAnalysis.MuonAssociators.patMuonsWithTrigger_cff import * changeRecoMuonInput(process, "mergedMuons") -#useL1Stage2Candidates(process) -#appendL1MatchingAlgo(process) +useL1Stage2Candidates(process) +appendL1MatchingAlgo(process) #addHLTL1Passthrough(process) +changeTriggerProcessName(process, "HLT2") # auto-guess #changeTriggerProcessName(process, "*") # auto-guess + from MuonAnalysis.TagAndProbe.common_variables_cff import * process.load("MuonAnalysis.TagAndProbe.common_modules_cff") @@ -475,7 +475,7 @@ if True: # turn on for tracking efficiency using L1 seeds process.probeL1 = cms.EDFilter("CandViewSelector", - src = cms.InputTag("l1extraParticles"), + src = cms.InputTag("gmtStage2Digis:Muon:HLT2"), cut = cms.string("pt >= 5 && abs(eta) < 2.4"), ) process.tpPairsTkL1 = process.tpPairs.clone(decay = "tagMuons@+ probeL1@-", cut = 'mass > 30') @@ -489,8 +489,8 @@ arbitration = "OneProbe", variables = cms.PSet( KinematicVariables, - bx = cms.string("bx"), - quality = cms.string("gmtMuonCand.quality"), + ## bx = cms.string("bx"), + ## quality = cms.string("hwQual"), ## track matching variables tk_deltaR = cms.InputTag("l1ToTkMatch","deltaR"), tk_deltaEta = cms.InputTag("l1ToTkMatch","deltaEta"), From ea73ec07eaf12d65fdf5469b6aedf493b354a84b Mon Sep 17 00:00:00 2001 From: Carlo Battilana Date: Thu, 13 Oct 2016 12:41:11 +0200 Subject: [PATCH 2/4] Add to GenWeightInfo true and actual PU information and rename it GenAdditionalInfo --- plugins/GenAdditionalInfo.cc | 133 +++++++++++++++++++++++++++++++++++ plugins/GenWeightInfo.cc | 102 --------------------------- python/common_modules_cff.py | 5 +- test/zmumu/tp_from_aod_MC.py | 8 ++- 4 files changed, 141 insertions(+), 107 deletions(-) create mode 100644 plugins/GenAdditionalInfo.cc delete mode 100644 plugins/GenWeightInfo.cc diff --git a/plugins/GenAdditionalInfo.cc b/plugins/GenAdditionalInfo.cc new file mode 100644 index 0000000000000..389aeaf7a22cd --- /dev/null +++ b/plugins/GenAdditionalInfo.cc @@ -0,0 +1,133 @@ +// +// $Id: GenAdditionalInfo.cc,v 1.1 2015/08/23 13:49:16 battilan Exp $ +// + +/** + \class GenAdditionalInfo + \brief Adds generator level information to the T&P according to 74X interface. + https://indico.cern.ch/event/402279/contribution/5/attachments/805964/1104514/mcaod-Jun17-2015.pdf + + \Author Carlo Battilana + \version $Id: GenAdditionalInfo.cc,v 1.1 2015/08/23 13:49:16 battilan Exp $ +*/ + + +#include "FWCore/Framework/interface/EDProducer.h" +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/Run.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "FWCore/Utilities/interface/InputTag.h" + +#include "DataFormats/Common/interface/ValueMap.h" +#include "SimDataFormats/GeneratorProducts/interface/GenEventInfoProduct.h" +#include "SimDataFormats/PileupSummaryInfo/interface/PileupSummaryInfo.h" +#include "DataFormats/Candidate/interface/CompositeCandidate.h" + +class GenAdditionalInfo : public edm::EDProducer +{ + +public: + + explicit GenAdditionalInfo(const edm::ParameterSet & iConfig); + virtual ~GenAdditionalInfo() { } + + virtual void produce(edm::Event & iEvent, const edm::EventSetup & iSetup) final; + +private: + + edm::EDGetTokenT m_genInfoTag; + edm::EDGetTokenT> m_pileUpInfoTag; + edm::EDGetTokenT> m_pairTag; + + /// Write a ValueMap in the event + template void writeValueMap(edm::Event &ev, const edm::Handle > & handle, + const std::vector & values, const std::string & label) const ; + +}; + + +GenAdditionalInfo::GenAdditionalInfo(const edm::ParameterSet & iConfig) : + m_genInfoTag(consumes(iConfig.getParameter("genInfoTag"))), + m_pileUpInfoTag(consumes>(iConfig.getParameter("pileUpInfoTag"))), + m_pairTag(consumes>(iConfig.getParameter("pairTag"))) +{ + + produces >("genWeight"); + produces >("truePileUp"); + produces >("actualPileUp"); + +} + +void GenAdditionalInfo::produce(edm::Event & ev, const edm::EventSetup & iSetup) +{ + + float weight = 1.; + + float truePU = -1.; + float actualPU = -1.; + + if (!ev.isRealData()) + { + edm::Handle genInfo; + ev.getByToken(m_genInfoTag, genInfo); + + edm::Handle > puInfo; + ev.getByToken(m_pileUpInfoTag, puInfo); + + weight = genInfo->weight(); + + for( auto & puInfoEntry : *puInfo.product() ) + { + int bx = puInfoEntry.getBunchCrossing(); + + if(bx == 0) + { + truePU = puInfoEntry.getTrueNumInteractions(); + actualPU = puInfoEntry.getPU_NumInteractions(); + continue; + } + } + + } + + edm::Handle > pairs; + ev.getByToken(m_pairTag, pairs); + + size_t n = pairs->size(); + std::vector genWeight(n,0); + std::vector truePileUp(n,0); + std::vector actualPileUp(n,0); + + for (size_t iPair = 0; iPair < n; ++iPair) + { + const reco::Candidate & pair = (*pairs)[iPair]; + if (pair.numberOfDaughters() != 2) throw cms::Exception("CorruptData") << + "[GenAdditionalInfo::produce] GenAdditionalInfo should be used on composite candidates with two daughters, this one has " << pair.numberOfDaughters() << "\n"; + + genWeight[iPair] = weight; + truePileUp[iPair] = truePU; + actualPileUp[iPair] = actualPU; + + } + + writeValueMap(ev, pairs, genWeight, "genWeight"); + writeValueMap(ev, pairs, truePileUp, "truePileUp"); + writeValueMap(ev, pairs, actualPileUp, "actualPileUp"); + +} + +template void GenAdditionalInfo::writeValueMap(edm::Event & ev, const edm::Handle > & handle, + const std::vector & values, const std::string & label) const +{ + + std::auto_ptr > valMap(new edm::ValueMap()); + typename edm::ValueMap::Filler filler(*valMap); + filler.insert(handle, values.begin(), values.end()); + filler.fill(); + ev.put(valMap, label); + +} + + +#include "FWCore/Framework/interface/MakerMacros.h" +DEFINE_FWK_MODULE(GenAdditionalInfo); diff --git a/plugins/GenWeightInfo.cc b/plugins/GenWeightInfo.cc deleted file mode 100644 index b8ad0d7639092..0000000000000 --- a/plugins/GenWeightInfo.cc +++ /dev/null @@ -1,102 +0,0 @@ -// -// $Id: GenWeightInfo.cc,v 1.1 2015/08/23 13:49:16 battilan Exp $ -// - -/** - \class GenWeightInfo - \brief Adds generator level information to the T&P according to 74X interface. - https://indico.cern.ch/event/402279/contribution/5/attachments/805964/1104514/mcaod-Jun17-2015.pdf - - \Author Carlo Battilana - \version $Id: GenWeightInfo.cc,v 1.1 2015/08/23 13:49:16 battilan Exp $ -*/ - - -#include "FWCore/Framework/interface/EDProducer.h" -#include "FWCore/Framework/interface/Event.h" -#include "FWCore/Framework/interface/Run.h" -#include "FWCore/ParameterSet/interface/ParameterSet.h" -#include "FWCore/Utilities/interface/InputTag.h" - -#include "DataFormats/Common/interface/ValueMap.h" -#include "SimDataFormats/GeneratorProducts/interface/GenEventInfoProduct.h" -#include "DataFormats/Candidate/interface/CompositeCandidate.h" - -class GenWeightInfo : public edm::EDProducer -{ - -public: - - explicit GenWeightInfo(const edm::ParameterSet & iConfig); - virtual ~GenWeightInfo() { } - - virtual void produce(edm::Event & iEvent, const edm::EventSetup & iSetup) final; - -private: - - edm::EDGetTokenT m_genInfoTag; - edm::EDGetTokenT> m_pairTag; - - /// Write a ValueMap in the event - void writeValueMap(edm::Event &ev, const edm::Handle > & handle, - const std::vector & values, const std::string & label) const ; - -}; - - -GenWeightInfo::GenWeightInfo(const edm::ParameterSet & iConfig) : - m_genInfoTag(consumes(iConfig.getParameter("genInfoTag"))), - m_pairTag(consumes>(iConfig.getParameter("pairTag"))) -{ - - produces >("genWeight"); - -} - -void GenWeightInfo::produce(edm::Event & ev, const edm::EventSetup & iSetup) -{ - - float weight = 1.; - - if (!ev.isRealData()) - { - edm::Handle genInfo; - ev.getByToken(m_genInfoTag, genInfo); - - weight = genInfo->weight(); - } - - edm::Handle > pairs; - ev.getByToken(m_pairTag, pairs); - - size_t n = pairs->size(); - std::vector genWeight(n,0); - - for (size_t iPair = 0; iPair < n; ++iPair) - { - const reco::Candidate & pair = (*pairs)[iPair]; - if (pair.numberOfDaughters() != 2) throw cms::Exception("CorruptData") << - "[GenWeightInfo::produce] GenWeightInfo should be used on composite candidates with two daughters, this one has " << pair.numberOfDaughters() << "\n"; - - genWeight[iPair] = weight; - } - - writeValueMap(ev, pairs, genWeight, "genWeight"); - -} - -void GenWeightInfo::writeValueMap(edm::Event & ev, const edm::Handle > & handle, - const std::vector & values, const std::string & label) const -{ - - std::auto_ptr > valMap(new edm::ValueMap()); - edm::ValueMap::Filler filler(*valMap); - filler.insert(handle, values.begin(), values.end()); - filler.fill(); - ev.put(valMap, label); - -} - - -#include "FWCore/Framework/interface/MakerMacros.h" -DEFINE_FWK_MODULE(GenWeightInfo); diff --git a/python/common_modules_cff.py b/python/common_modules_cff.py index 43baaba3b986d..6f974654d6d11 100644 --- a/python/common_modules_cff.py +++ b/python/common_modules_cff.py @@ -236,9 +236,10 @@ src = cms.InputTag("tpPairs"), ) -genWeightInfo = cms.EDProducer("GenWeightInfo", +genAdditionalInfo = cms.EDProducer("GenAdditionalInfo", pairTag= cms.InputTag("tpPairs"), - genInfoTag= cms.InputTag("generator") + genInfoTag = cms.InputTag("generator"), + pileUpInfoTag = cms.InputTag("addPileupInfo") ) l1hltprescale = cms.EDProducer("ComputeL1HLTPrescales", diff --git a/test/zmumu/tp_from_aod_MC.py b/test/zmumu/tp_from_aod_MC.py index 7b410869a94dc..d71de8bf78c8e 100644 --- a/test/zmumu/tp_from_aod_MC.py +++ b/test/zmumu/tp_from_aod_MC.py @@ -198,8 +198,10 @@ probeMultiplicity = cms.InputTag("probeMultiplicity"), probeMultiplicity_TMGM = cms.InputTag("probeMultiplicityTMGM"), probeMultiplicity_Pt10_M60140 = cms.InputTag("probeMultiplicityPt10M60140"), - ## Gen Weight variable - genWeight = cms.InputTag("genWeightInfo", "genWeight"), + ## Gen related variables + genWeight = cms.InputTag("genAdditionalInfo", "genWeight"), + truePileUp = cms.InputTag("genAdditionalInfo", "truePileUp"), + actualPileUp = cms.InputTag("genAdditionalInfo", "actualPileUp"), ## New TuneP variables newTuneP_probe_pt = cms.InputTag("newTunePVals", "pt"), newTuneP_probe_sigmaPtOverPt = cms.InputTag("newTunePVals", "ptRelError"), @@ -262,7 +264,7 @@ process.probeMultiplicities + process.bestPairByZMass + process.newTunePVals + - process.genWeightInfo + + process.genAdditionalInfo + process.muonDxyPVdzminTags + process.tpTree ) From 63e6f243b2616b603bbb0a64759c1cff230893de Mon Sep 17 00:00:00 2001 From: Carlo Battilana Date: Thu, 13 Oct 2016 17:36:54 +0200 Subject: [PATCH 3/4] Fix --- test/zmumu/tp_from_aod_MC.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/zmumu/tp_from_aod_MC.py b/test/zmumu/tp_from_aod_MC.py index d71de8bf78c8e..f2dc73f4bdad6 100644 --- a/test/zmumu/tp_from_aod_MC.py +++ b/test/zmumu/tp_from_aod_MC.py @@ -477,7 +477,7 @@ if True: # turn on for tracking efficiency using L1 seeds process.probeL1 = cms.EDFilter("CandViewSelector", - src = cms.InputTag("gmtStage2Digis:Muon:HLT2"), + src = cms.InputTag("gmtStage2Digis:Muon"), cut = cms.string("pt >= 5 && abs(eta) < 2.4"), ) process.tpPairsTkL1 = process.tpPairs.clone(decay = "tagMuons@+ probeL1@-", cut = 'mass > 30') From e1079eb87864ac9a5424be099c5722889da3eec2 Mon Sep 17 00:00:00 2001 From: Carlo Battilana Date: Thu, 13 Oct 2016 18:30:36 +0200 Subject: [PATCH 4/4] customising HLT with auto guess --- test/zmumu/tp_from_aod_MC.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/test/zmumu/tp_from_aod_MC.py b/test/zmumu/tp_from_aod_MC.py index f2dc73f4bdad6..5dd25969a8d98 100644 --- a/test/zmumu/tp_from_aod_MC.py +++ b/test/zmumu/tp_from_aod_MC.py @@ -78,8 +78,7 @@ useL1Stage2Candidates(process) appendL1MatchingAlgo(process) #addHLTL1Passthrough(process) -changeTriggerProcessName(process, "HLT2") # auto-guess -#changeTriggerProcessName(process, "*") # auto-guess +changeTriggerProcessName(process, "*") # auto-guess from MuonAnalysis.TagAndProbe.common_variables_cff import *