Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-03-17 11:21:46

0001 import FWCore.ParameterSet.Config as cms
0002 from FWCore.ParameterSet.VarParsing import VarParsing
0003 from Configuration.Eras.Era_Run3_cff import Run3
0004 import os
0005 import re
0006 
0007 options = VarParsing('analysis')
0008 options.register('sampleType', 'Run3MC', VarParsing.multiplicity.singleton, VarParsing.varType.string,
0009                  "Indicates the sample type: Run3MC or Run2Data")
0010 options.register('fileList', '', VarParsing.multiplicity.singleton, VarParsing.varType.string,
0011                  "List of root files to process.")
0012 options.register('fileNamePrefix', '', VarParsing.multiplicity.singleton, VarParsing.varType.string,
0013                  "Prefix to add to input file names.")
0014 options.register('lumiFile', '', VarParsing.multiplicity.singleton, VarParsing.varType.string,
0015                  "JSON file with lumi mask.")
0016 options.register('eventList', '', VarParsing.multiplicity.singleton, VarParsing.varType.string,
0017                  "List of events to process.")
0018 options.register('dumpPython', False, VarParsing.multiplicity.singleton, VarParsing.varType.bool,
0019                  "Dump full config into stdout.")
0020 options.register('Summary', False, VarParsing.multiplicity.singleton, VarParsing.varType.bool,
0021                  "want summary")
0022 
0023 options.parseArguments()
0024 dataDict = {"Run3MC" : False, "Run2Data" : True}
0025 isData = dataDict[options.sampleType]
0026 processName = 'MLProva'
0027 process = cms.Process(processName, Run3)
0028 # import of standard configurations
0029 process.load('Configuration.StandardSequences.Services_cff')
0030 process.load('SimGeneral.HepPDTESSource.pythiapdt_cfi')
0031 process.load('FWCore.MessageService.MessageLogger_cfi')
0032 process.load('Configuration.EventContent.EventContent_cff')
0033 process.load('Configuration.StandardSequences.GeometryRecoDB_cff')
0034 process.load('Configuration.StandardSequences.MagneticField_cff')
0035 process.load('HLTrigger.Configuration.HLT_GRun_cff')
0036 process.load('Configuration.StandardSequences.EndOfProcess_cff')
0037 process.load('Configuration.StandardSequences.FrontierConditions_GlobalTag_cff')
0038 
0039 if not isData:
0040     process.load('SimGeneral.MixingModule.mixNoPU_cfi')
0041 
0042 process.source = cms.Source('PoolSource', fileNames = cms.untracked.vstring())
0043 
0044 # Input source
0045 def readFileList(fileList, inputFileName, fileNamePrefix):
0046     with open(inputFileName, 'r') as inputFile:
0047         for name in inputFile.readlines():
0048             if len(name) > 0 and name[0] != '#':
0049                 fileList.append(fileNamePrefix + name)
0050 
0051 def addFilesToList(fileList, inputFiles, fileNamePrefix):
0052     """read intput file list from a another list"""
0053     for name in inputFiles:
0054         if len(name) > 0 and name[0] != '#':
0055             fileList.append(fileNamePrefix + name)
0056 
0057 if len(options.fileList) > 0:
0058     readFileList(process.source.fileNames, options.fileList, options.fileNamePrefix)
0059 elif len(options.inputFiles) > 0:
0060     addFilesToList(process.source.fileNames, options.inputFiles, options.fileNamePrefix)
0061 else:
0062     #print(options.inputFiles)
0063     #print(options.fileList)
0064 
0065     #process.source.fileNames = cms.untracked.vstring('file:/store/mc/Run3Winter20DRPremixMiniAOD/VBFHToTauTau_M125_TuneCUETP8M1_14TeV_powheg_pythia8/GEN-SIM-RAW/110X_mcRun3_2021_realistic_v6-v1/20000/1E71AB01-1FF5-F049-94D4-642325AFF937.root')  # 5000 evts
0066 
0067     #process.source.fileNames = cms.untracked.vstring('/store/mc/Run3Winter20DRPremixMiniAOD/VBFHToTauTau_M125_TuneCUETP8M1_14TeV_powheg_pythia8/GEN-SIM-RAW/110X_mcRun3_2021_realistic_v6-v1/20000/A95D23CB-88AC-6849-8980-5D12C8417007.root') # 11000 evts
0068     #process.source.fileNames = cms.untracked.vstring('file:/eos/home-v/vdamante/A95D23CB-88AC-6849-8980-5D12C8417007.root') # 11000 evts
0069     process.source.fileNames = cms.untracked.vstring('/store/mc/Run3Winter21DRMiniAOD/VBFHToTauTau_M125_TuneCP5_14TeV-powheg-pythia8/GEN-SIM-DIGI-RAW/FlatPU30to80FEVT_112X_mcRun3_2021_realistic_v16-v1/270000/005b56c1-0107-46b3-9740-1c6efc559295.root') #1000 evts
0070     #process.source.fileNames = cms.untracked.vstring('file:/store/mc/Run3Winter20DRPremixMiniAOD/VBFHToTauTau_M125_TuneCUETP8M1_14TeV_powheg_pythia8/GEN-SIM-RAW/110X_mcRun3_2021_realistic_v6-v1/20000/F2760E46-A3DB-DA4F-A6EC-525C10EDCBC7.root') # 1000 evts
0071     #process.source.fileNames = cms.untracked.vstring('file:/store/mc/Run3Winter20DRPremixMiniAOD/VBFHToTauTau_M125_TuneCUETP8M1_14TeV_powheg_pythia8/GEN-SIM-RAW/110X_mcRun3_2021_realistic_v6-v1/20000/657F58E7-64E3-AA4D-B505-6D0F39997487.root')
0072 
0073 
0074 
0075 if len(options.lumiFile) > 0:
0076     import FWCore.PythonUtilities.LumiList as LumiList
0077     process.source.lumisToProcess = LumiList.LumiList(filename = options.lumiFile).getVLuminosityBlockRange()
0078 
0079 if options.eventList != '':
0080     process.source.eventsToProcess = cms.untracked.VEventRange(re.split(',', options.eventList))
0081 
0082 process.maxEvents = cms.untracked.PSet(
0083     input = cms.untracked.int32(options.maxEvents),
0084     output = cms.optional.untracked.allowed(cms.int32,cms.PSet)
0085 )
0086 
0087 
0088 
0089 
0090 process.options = cms.untracked.PSet(
0091     FailPath = cms.untracked.vstring(),
0092     IgnoreCompletely = cms.untracked.vstring(),
0093     Rethrow = cms.untracked.vstring(),
0094     #SkipEvent = cms.untracked.vstring('ProductNotFound'),
0095     SkipEvent = cms.untracked.vstring(),
0096     allowUnscheduled = cms.obsolete.untracked.bool,
0097     canDeleteEarly = cms.untracked.vstring(),
0098     emptyRunLumiMode = cms.obsolete.untracked.string,
0099     eventSetup = cms.untracked.PSet(
0100         forceNumberOfConcurrentIOVs = cms.untracked.PSet(
0101             allowAnyLabel_=cms.required.untracked.uint32
0102         ),
0103         numberOfConcurrentIOVs = cms.untracked.uint32(1)
0104     ),
0105     fileMode = cms.untracked.string('FULLMERGE'),
0106     forceEventSetupCacheClearOnNewRun = cms.untracked.bool(False),
0107     makeTriggerResults = cms.obsolete.untracked.bool,
0108     numberOfConcurrentLuminosityBlocks = cms.untracked.uint32(1),
0109     numberOfConcurrentRuns = cms.untracked.uint32(1),
0110     numberOfStreams = cms.untracked.uint32(0),
0111     numberOfThreads = cms.untracked.uint32(1),
0112     printDependencies = cms.untracked.bool(False),
0113     sizeOfStackForThreadsInKB = cms.optional.untracked.uint32,
0114     throwIfIllegalParameter = cms.untracked.bool(True),
0115     wantSummary = cms.untracked.bool(False)
0116 )
0117 
0118 
0119 # Production Info
0120 process.configurationMetadata = cms.untracked.PSet(
0121     annotation = cms.untracked.string('tau_hlt nevts:-1'),
0122     name = cms.untracked.string('Applications'),
0123     version = cms.untracked.string('$Revision: 1.19 $')
0124 )
0125 
0126 # Output definition
0127 
0128 # Additional output definition
0129 
0130 # Other statements
0131 from HLTrigger.Configuration.CustomConfigs import ProcessName
0132 process = ProcessName(process)
0133 
0134 from Configuration.AlCa.GlobalTag import GlobalTag
0135 GlobalTagName = 'auto:run3_data_GRun' if isData else 'auto:run3_mc_GRun'
0136 process.GlobalTag = GlobalTag(process.GlobalTag, GlobalTagName, '')
0137 
0138 # Path and EndPath definitions
0139 process.endjob_step = cms.EndPath(process.endOfProcess)
0140 
0141 
0142 # Schedule definition
0143 # process.schedule imported from cff in HLTrigger.Configuration
0144 process.schedule.extend([process.endjob_step])
0145 from PhysicsTools.PatAlgos.tools.helpers import associatePatAlgosToolsTask
0146 associatePatAlgosToolsTask(process)
0147 
0148 
0149 # customisation of the process.
0150 
0151 
0152 # Automatic addition of the customisation function
0153 
0154 if isData:
0155     # Customisation from command line
0156     from HLTrigger.Configuration.customizeHLTforCMSSW import customiseFor2018Input
0157     process = customiseFor2018Input(process)
0158 else:
0159     from HLTrigger.Configuration.customizeHLTforMC import customizeHLTforMC
0160     process = customizeHLTforMC(process)
0161 
0162 
0163 #from applyL2TauTag import update
0164 from RecoTauTag.HLTProducers.applyL2TauTag import update
0165 process = update(process)
0166 #process.schedule = cms.Schedule(*[ process.HLTriggerFirstPath, process.HLT_DoubleMediumChargedIsoPFTauHPS35_Trk1_eta2p1_Reg_v4, process.HLTriggerFinalPath, process.endjob_step ], tasks=[process.patAlgosToolsTask])
0167 
0168 
0169 # End of customisation functions
0170 
0171 # Customisation from command line
0172 
0173 process.load('FWCore.MessageLogger.MessageLogger_cfi')
0174 x = process.maxEvents.input.value()
0175 x = x if x >= 0 else 10000
0176 process.MessageLogger.cerr.FwkReport.reportEvery = max(1, min(1000, x // 10))
0177 
0178 # Add early deletion of temporary data products to reduce peak memory need
0179 from Configuration.StandardSequences.earlyDeleteSettings_cff import customiseEarlyDelete
0180 process = customiseEarlyDelete(process)
0181 
0182 if options.dumpPython:
0183     print (process.dumpPython())
0184 
0185 process.options.wantSummary = cms.untracked.bool(options.Summary)
0186 
0187 
0188 # End adding early deletion