Skip to content

Commit

Permalink
Merge pull request #1407 from ingabu/Adding-MC-PU-reweighting
Browse files Browse the repository at this point in the history
Changing pt threshold to 5GeV
  • Loading branch information
smuzaffar committed Nov 26, 2013
2 parents 5154114 + b7d68d5 commit 6f9b488
Show file tree
Hide file tree
Showing 10 changed files with 450 additions and 7 deletions.
2 changes: 1 addition & 1 deletion HLTrigger/HLTanalyzers/interface/HLTMCtruth.h
Expand Up @@ -47,7 +47,7 @@ class HLTMCtruth {
float *mcvx, *mcvy, *mcvz, *mcpt, *mceta, *mcphi;
int *mcpid, *mcstatus;
int nmcpart,nmu3,nel3,nab,nbb,nwenu,nwmunu,nzee,nzmumu;
int npubx0;
int npubx0, npuvertbx0;
float pthatf;
float ptEleMax,ptMuMax;
// input variables
Expand Down
13 changes: 9 additions & 4 deletions HLTrigger/HLTanalyzers/src/HLTMCtruth.cc
Expand Up @@ -63,6 +63,7 @@ void HLTMCtruth::setup(const edm::ParameterSet& pSet, TTree* HltTree) {
HltTree->Branch("MCptEleMax",&ptEleMax,"MCptEleMax/F");
HltTree->Branch("MCptMuMax",&ptMuMax,"MCptMuMax/F");
HltTree->Branch("NPUTrueBX0",&npubx0, "NPUTrueBX0/I");
HltTree->Branch("NPUgenBX0",&npuvertbx0, "NPUgenBX0/I");
}

/* **Analyze the event** */
Expand Down Expand Up @@ -90,15 +91,17 @@ void HLTMCtruth::analyze(const edm::Handle<reco::CandidateView> & mctruth,
ptMuMax = -999.0;
pthatf = pthat;
npubx0 = 0.0;
npuvertbx0 = 0;

int npvtrue = 0;
int npuvert = 0;

if((simTracks.isValid())&&(simVertices.isValid())){
for (unsigned int j=0; j<simTracks->size(); j++) {
int pdgid = simTracks->at(j).type();
if (abs(pdgid)!=13) continue;
double pt = simTracks->at(j).momentum().pt();
if (pt<2.5) continue;
if (pt<5.) continue;
double eta = simTracks->at(j).momentum().eta();
if (abs(eta)>2.5) continue;
if (simTracks->at(j).noVertex()) continue;
Expand All @@ -118,10 +121,12 @@ void HLTMCtruth::analyze(const edm::Handle<reco::CandidateView> & mctruth,
for(PVI = PupInfo->begin(); PVI != PupInfo->end(); ++PVI) {

int BX = PVI->getBunchCrossing();
npvtrue = PVI->getTrueNumInteractions();
npvtrue = PVI->getTrueNumInteractions();
npuvert = PVI->getPU_NumInteractions();
if(BX == 0)
{
npubx0+=npvtrue;
npuvertbx0+=npuvert;
}
}

Expand Down Expand Up @@ -164,8 +169,8 @@ void HLTMCtruth::analyze(const edm::Handle<reco::CandidateView> & mctruth,

// Set-up flags, based on Pythia-generator information, for avoiding double-counting events when
// using both pp->{e,mu}X AND QCD samples
if (((mcpid[nmc]==13)||(mcpid[nmc]==-13))&&(mcpt[nmc]>2.5)) {mu3 += 1;} // Flag for muons with pT > 2.5 GeV/c
if (((mcpid[nmc]==11)||(mcpid[nmc]==-11))&&(mcpt[nmc]>2.5)) {el3 += 1;} // Flag for electrons with pT > 2.5 GeV/c
if (((mcpid[nmc]==13)||(mcpid[nmc]==-13))&&(mcpt[nmc]>5.0)) {mu3 += 1;} // Flag for muons with pT > 2.5 GeV/c
if (((mcpid[nmc]==11)||(mcpid[nmc]==-11))&&(mcpt[nmc]>5.0)) {el3 += 1;} // Flag for electrons with pT > 2.5 GeV/c

if (mcpid[nmc]==-5) {mab += 1;} // Flag for bbar
if (mcpid[nmc]==5) {mbb += 1;} // Flag for b
Expand Down
104 changes: 104 additions & 0 deletions HLTrigger/HLTanalyzers/test/HLTBitAnalysis_cfg_forEMantiMu.py
@@ -0,0 +1,104 @@
import FWCore.ParameterSet.Config as cms

##################################################################

# useful options
gtDigisExist=0 # =1 use existing gtDigis on the input file, =0 extract gtDigis from the RAW data collection
isData=0 # =1 running on real data, =0 running on MC

OUTPUT_HIST='hltbitsmc.root'
NEVTS=-1

##################################################################

process = cms.Process("ANALYSIS")

process.load("FWCore.MessageService.MessageLogger_cfi")
process.MessageLogger.cerr.FwkReport.reportEvery = 100

process.options = cms.untracked.PSet(
wantSummary = cms.untracked.bool(False)
)

process.source = cms.Source("PoolSource",
skipBadFiles = cms.untracked.bool( True ),
fileNames = cms.untracked.vstring(
'root://xrootd.unl.edu//store/mc/Summer13dr53X/QCD_Pt_30_80_EMEnriched_TuneZ2star_13TeV-pythia6/GEN-SIM-RAW/PU25bx25_START53_V19D-v1/20000/0042293B-89E1-E211-A506-485B39800B97.root'
)
)

process.maxEvents = cms.untracked.PSet(
input = cms.untracked.int32( NEVTS ),
skipBadFiles = cms.bool(True)
)

process.load('Configuration/StandardSequences/GeometryExtended_cff')
process.load('Configuration/StandardSequences/MagneticField_38T_cff')

process.load("Configuration.StandardSequences.FrontierConditions_GlobalTag_cff")
process.GlobalTag.globaltag = 'START53_V19D::All'
process.GlobalTag.pfnPrefix=cms.untracked.string('frontier://FrontierProd/')

process.load('Configuration/StandardSequences/SimL1Emulator_cff')
process.load("HLTrigger.HLTanalyzers.HLTopen_cff")

# OpenHLT specificss
# Define the HLT reco paths
#process.load("HLTrigger.HLTanalyzers.HLT_FULL_cff")
# Remove the PrescaleService which, in 31X, it is expected once HLT_XXX_cff is imported

process.DQM = cms.Service( "DQM",)
process.DQMStore = cms.Service( "DQMStore",)

# AlCa OpenHLT specific settings

# Define the analyzer modules
process.load("HLTrigger.HLTanalyzers.HLTBitAnalyser_cfi")
process.hltbitanalysis.hltresults = cms.InputTag( 'TriggerResults','','HLT' )
process.hltbitanalysis.RunParameters.HistogramFile=OUTPUT_HIST
process.hltbitanalysis.l1GtObjectMapRecord = cms.InputTag("l1L1GtObjectMap::RECO")
process.hltbitanalysis.l1GtReadoutRecord = cms.InputTag("gtDigis::RECO")
process.hltbitanalysis.l1extramc = cms.string('l1extraParticles')
process.hltbitanalysis.l1extramu = cms.string('l1extraParticles')


process.mugenfilter = cms.EDFilter("MCSmartSingleParticleFilter",
MinPt = cms.untracked.vdouble(5.,5.),
MinEta = cms.untracked.vdouble(-2.5,-2.5),
MaxEta = cms.untracked.vdouble(2.5,2.5),
ParticleID = cms.untracked.vint32(13,-13),
Status = cms.untracked.vint32(1,1),
# Decay cuts are in mm
MaxDecayRadius = cms.untracked.vdouble(2000.,2000.),
MinDecayZ = cms.untracked.vdouble(-4000.,-4000.),
MaxDecayZ = cms.untracked.vdouble(4000.,4000.)
)


if (gtDigisExist):
process.analyzeA = cms.Path(~process.mugenfilter * process.hltbitanalysis)
else:
process.analyzeA = cms.Path(process.HLTBeginSequence * ~process.mugenfilter * process.hltbitanalysis)
process.hltbitanalysis.l1GtReadoutRecord = cms.InputTag( 'hltGtDigis','',process.name_() )

# pdt
process.load("SimGeneral.HepPDTESSource.pythiapdt_cfi")

# Schedule the whole thing
process.schedule = cms.Schedule(
process.analyzeA)

#########################################################################################
#
#nc=0
if (isData): # replace all instances of "rawDataCollector" with "source" in InputTags
from FWCore.ParameterSet import Mixins
for module in process.__dict__.itervalues():
if isinstance(module, Mixins._Parameterizable):
for parameter in module.__dict__.itervalues():
if isinstance(parameter, cms.InputTag):
if parameter.moduleLabel == 'rawDataCollector':
parameter.moduleLabel = 'source'
#print "Replacing in module: ", module
#nc=nc+1
#print "Number of replacements: ", nc
124 changes: 124 additions & 0 deletions HLTrigger/HLTanalyzers/test/HLTBitAnalysis_cfg_forMuantiEM.py
@@ -0,0 +1,124 @@
import FWCore.ParameterSet.Config as cms

##################################################################

# useful options
gtDigisExist=0 # =1 use existing gtDigis on the input file, =0 extract gtDigis from the RAW data collection
isData=0 # =1 running on real data, =0 running on MC

OUTPUT_HIST='hltbitsmc.root'
NEVTS=-1

##################################################################

process = cms.Process("ANALYSIS")

process.load("FWCore.MessageService.MessageLogger_cfi")
process.MessageLogger.cerr.FwkReport.reportEvery = 100

process.options = cms.untracked.PSet(
wantSummary = cms.untracked.bool(False)
)

process.source = cms.Source("PoolSource",
skipBadFiles = cms.untracked.bool( True ),
fileNames = cms.untracked.vstring(
'root://xrootd.unl.edu//store/mc/Summer13dr53X/QCD_Pt-30to50_MuEnrichedPt5_TuneZ2star_13TeV-pythia6/GEN-SIM-RAW/PU25bx25_START53_V19D-v1/20000/00C62B95-77E0-E211-8971-20CF305B04CC.root'
)
)

process.maxEvents = cms.untracked.PSet(
input = cms.untracked.int32( NEVTS ),
skipBadFiles = cms.bool(True)
)

process.load('Configuration/StandardSequences/GeometryExtended_cff')
process.load('Configuration/StandardSequences/MagneticField_38T_cff')

process.load("Configuration.StandardSequences.FrontierConditions_GlobalTag_cff")
process.GlobalTag.globaltag = 'START53_V19D::All'
process.GlobalTag.pfnPrefix=cms.untracked.string('frontier://FrontierProd/')

process.load('Configuration/StandardSequences/SimL1Emulator_cff')
process.load("HLTrigger.HLTanalyzers.HLTopen_cff")

# OpenHLT specificss
# Define the HLT reco paths
#process.load("HLTrigger.HLTanalyzers.HLT_FULL_cff")
# Remove the PrescaleService which, in 31X, it is expected once HLT_XXX_cff is imported

process.DQM = cms.Service( "DQM",)
process.DQMStore = cms.Service( "DQMStore",)

# AlCa OpenHLT specific settings

# Define the analyzer modules
process.load("HLTrigger.HLTanalyzers.HLTBitAnalyser_cfi")
process.hltbitanalysis.hltresults = cms.InputTag( 'TriggerResults','','HLT' )
process.hltbitanalysis.RunParameters.HistogramFile=OUTPUT_HIST
process.hltbitanalysis.l1GtObjectMapRecord = cms.InputTag("l1L1GtObjectMap::RECO")
process.hltbitanalysis.l1GtReadoutRecord = cms.InputTag("gtDigis::RECO")
process.hltbitanalysis.l1extramc = cms.string('l1extraParticles')
process.hltbitanalysis.l1extramu = cms.string('l1extraParticles')


process.genParticlesForFilter = cms.EDProducer("GenParticleProducer",
saveBarCodes = cms.untracked.bool(True),
src = cms.InputTag("generator"),
abortOnUnknownPDGCode = cms.untracked.bool(True)
)

process.bctoefilter = cms.EDFilter("BCToEFilter",
filterAlgoPSet = cms.PSet(eTThreshold = cms.double(10),
genParSource = cms.InputTag("genParticlesForFilter")
)
)


process.emenrichingfilter = cms.EDFilter("EMEnrichingFilter",
filterAlgoPSet = cms.PSet(isoGenParETMin=cms.double(20.),
isoGenParConeSize=cms.double(0.1),
clusterThreshold=cms.double(20.),
isoConeSize=cms.double(0.2),
hOverEMax=cms.double(0.5),
tkIsoMax=cms.double(5.),
caloIsoMax=cms.double(10.),
requireTrackMatch=cms.bool(False),
genParSource = cms.InputTag("genParticlesForFilter")
)
)


if (gtDigisExist):
process.analyzeA = cms.Path((process.genParticlesForFilter + ~process.emenrichingfilter + process.bctoefilter) * process.hltbitanalysis)
process.analyzeB = cms.Path((process.genParticlesForFilter + process.emenrichingfilter + process.bctoefilter) * process.hltbitanalysis)
process.analyzeC = cms.Path((process.genParticlesForFilter + ~process.emenrichingfilter + ~process.bctoefilter) * process.hltbitanalysis)
else:
process.analyzeA = cms.Path(process.HLTBeginSequence * (process.genParticlesForFilter + ~process.emenrichingfilter + process.bctoefilter) * process.hltbitanalysis)
process.analyzeB = cms.Path(process.HLTBeginSequence * (process.genParticlesForFilter + process.emenrichingfilter + process.bctoefilter) * process.hltbitanalysis)
process.analyzeC = cms.Path(process.HLTBeginSequence * (process.genParticlesForFilter + ~process.emenrichingfilter + ~process.bctoefilter) * process.hltbitanalysis)
process.hltbitanalysis.l1GtReadoutRecord = cms.InputTag( 'hltGtDigis','',process.name_() )

# pdt
process.load("SimGeneral.HepPDTESSource.pythiapdt_cfi")

# Schedule the whole thing
process.schedule = cms.Schedule(
process.analyzeA,
process.analyzeB,
process.analyzeC)

#########################################################################################
#
#nc=0
if (isData): # replace all instances of "rawDataCollector" with "source" in InputTags
from FWCore.ParameterSet import Mixins
for module in process.__dict__.itervalues():
if isinstance(module, Mixins._Parameterizable):
for parameter in module.__dict__.itervalues():
if isinstance(parameter, cms.InputTag):
if parameter.moduleLabel == 'rawDataCollector':
parameter.moduleLabel = 'source'
#print "Replacing in module: ", module
#nc=nc+1
#print "Number of replacements: ", nc

0 comments on commit 6f9b488

Please sign in to comment.