Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-11-25 02:30:04

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