Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:31:13

0001 from __future__ import print_function
0002 import FWCore.ParameterSet.Config as cms
0003 import FWCore.ParameterSet.VarParsing as VarParsing
0004 import sys
0005 import os
0006 
0007 process = cms.Process("Analyzer")
0008 
0009 process.task = cms.Task()
0010 
0011 ## enabling unscheduled mode for modules
0012 process.options = cms.untracked.PSet(
0013     wantSummary = cms.untracked.bool(True)
0014 )
0015 options = VarParsing.VarParsing ('standard')
0016 options.register('runOnPythia8', True, 
0017                  VarParsing.VarParsing.multiplicity.singleton, 
0018                  VarParsing.VarParsing.varType.bool, 
0019                  "decide to run on Pythia8 or Pythia6")
0020 options.register('useRun2Code', True, 
0021                  VarParsing.VarParsing.multiplicity.singleton, 
0022                  VarParsing.VarParsing.varType.bool, 
0023                  "decide to use Run1 or Run2 code")
0024 
0025 # Get and parse the command line arguments
0026 if( hasattr(sys, "argv") ):
0027     for args in sys.argv :
0028         arg = args.split(',')
0029         for val in arg:
0030             val = val.split('=')
0031             if(len(val)==2):
0032                 setattr(options,val[0], val[1])
0033 
0034 if options.runOnPythia8:
0035     print('Running on Pythia8')
0036 else:
0037     print('Running on Pythia6')
0038 
0039 ## configure message logger
0040 process.load("FWCore.MessageLogger.MessageLogger_cfi")
0041 process.MessageLogger.cerr.threshold = 'INFO'
0042 process.MessageLogger.cerr.FwkReport.reportEvery = 100
0043 
0044 ## define input
0045 if options.runOnPythia8:
0046     process.source = cms.Source("PoolSource",
0047        fileNames = cms.untracked.vstring(    
0048          '/store/mc/Spring14dr/TTbarH_M-125_13TeV_amcatnlo-pythia8-tauola/AODSIM/PU20bx25_POSTLS170_V5-v1/00000/0E3D08A9-C610-E411-A862-0025B3E0657E.root',
0049        ),
0050        skipEvents = cms.untracked.uint32(0)
0051     )
0052 else:
0053     process.source = cms.Source("PoolSource",
0054        fileNames = cms.untracked.vstring(
0055         '/store/mc/Spring14dr/TTbarH_HToBB_M-125_13TeV_pythia6/AODSIM/PU20bx25_POSTLS170_V5-v1/00000/1CAB7E58-0BD0-E311-B688-00266CFFBC3C.root',
0056        ),
0057        skipEvents = cms.untracked.uint32(0)
0058     )
0059 
0060 ## define maximal number of events to loop over
0061 process.maxEvents = cms.untracked.PSet(
0062     input = cms.untracked.int32(1000)
0063 )
0064 
0065 ####################################################################
0066 genParticleCollection = 'genParticles'
0067 
0068 process.load("TopQuarkAnalysis.TopEventProducers.sequences.ttGenEvent_cff")
0069 process.task.add(process.makeGenEvtTask)
0070 process.initSubset.src = genParticleCollection
0071 process.decaySubset.src = genParticleCollection
0072 process.decaySubset.fillMode = "kME" # Status3, use kStable for Status2
0073 runMode = "Run2"
0074 if options.useRun2Code:
0075     runMode = "Run2"
0076 else:
0077     runMode = "Run1"
0078 process.decaySubset.runMode = runMode
0079 process.ttGenEventSequence = cms.Sequence(process.makeGenEvt)
0080 
0081 ## module to store raw output from the processed modules into the ROOT file
0082 output_file = 'output.root'
0083 if options.runOnPythia8:
0084     output_file = 'Pythia8_' + runMode + '.root'
0085 else:
0086     output_file = 'Pythia6_' + runMode + '.root'
0087 
0088 process.out = cms.OutputModule("PoolOutputModule",
0089     fileName = cms.untracked.string(output_file),
0090     outputCommands = cms.untracked.vstring('drop *', 'keep *_*_*_Analyzer')
0091 )
0092 process.outpath = cms.EndPath(process.out, process.task)