Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:27:45

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     IgnoreCompletely = cms.untracked.vstring(),
0092     Rethrow = cms.untracked.vstring(),
0093     #TryToContinue = cms.untracked.vstring('ProductNotFound'),
0094     TryToContinue = cms.untracked.vstring(),
0095     allowUnscheduled = cms.obsolete.untracked.bool,
0096     canDeleteEarly = cms.untracked.vstring(),
0097     emptyRunLumiMode = cms.obsolete.untracked.string,
0098     eventSetup = cms.untracked.PSet(
0099         forceNumberOfConcurrentIOVs = cms.untracked.PSet(
0100             allowAnyLabel_=cms.required.untracked.uint32
0101         ),
0102         numberOfConcurrentIOVs = cms.untracked.uint32(1)
0103     ),
0104     fileMode = cms.untracked.string('FULLMERGE'),
0105     forceEventSetupCacheClearOnNewRun = cms.untracked.bool(False),
0106     makeTriggerResults = cms.obsolete.untracked.bool,
0107     numberOfConcurrentLuminosityBlocks = cms.untracked.uint32(1),
0108     numberOfConcurrentRuns = cms.untracked.uint32(1),
0109     numberOfStreams = cms.untracked.uint32(0),
0110     numberOfThreads = cms.untracked.uint32(1),
0111     printDependencies = cms.untracked.bool(False),
0112     sizeOfStackForThreadsInKB = cms.optional.untracked.uint32,
0113     throwIfIllegalParameter = cms.untracked.bool(True),
0114     wantSummary = cms.untracked.bool(False)
0115 )
0116 
0117 
0118 # Production Info
0119 process.configurationMetadata = cms.untracked.PSet(
0120     annotation = cms.untracked.string('tau_hlt nevts:-1'),
0121     name = cms.untracked.string('Applications'),
0122     version = cms.untracked.string('$Revision: 1.19 $')
0123 )
0124 
0125 # Output definition
0126 
0127 # Additional output definition
0128 
0129 # Other statements
0130 from HLTrigger.Configuration.CustomConfigs import ProcessName
0131 process = ProcessName(process)
0132 
0133 from Configuration.AlCa.GlobalTag import GlobalTag
0134 GlobalTagName = 'auto:run3_data_GRun' if isData else 'auto:run3_mc_GRun'
0135 process.GlobalTag = GlobalTag(process.GlobalTag, GlobalTagName, '')
0136 
0137 # Path and EndPath definitions
0138 process.endjob_step = cms.EndPath(process.endOfProcess)
0139 
0140 
0141 # Schedule definition
0142 # process.schedule imported from cff in HLTrigger.Configuration
0143 process.schedule.extend([process.endjob_step])
0144 from PhysicsTools.PatAlgos.tools.helpers import associatePatAlgosToolsTask
0145 associatePatAlgosToolsTask(process)
0146 
0147 
0148 # customisation of the process.
0149 
0150 
0151 # Automatic addition of the customisation function
0152 
0153 if isData:
0154     # Customisation from command line
0155     from HLTrigger.Configuration.customizeHLTforCMSSW import customiseFor2018Input
0156     process = customiseFor2018Input(process)
0157 else:
0158     from HLTrigger.Configuration.customizeHLTforMC import customizeHLTforMC
0159     process = customizeHLTforMC(process)
0160 
0161 
0162 #from applyL2TauTag import update
0163 from RecoTauTag.HLTProducers.applyL2TauTag import update
0164 process = update(process)
0165 #process.schedule = cms.Schedule(*[ process.HLTriggerFirstPath, process.HLT_DoubleMediumChargedIsoPFTauHPS35_Trk1_eta2p1_Reg_v4, process.HLTriggerFinalPath, process.endjob_step ], tasks=[process.patAlgosToolsTask])
0166 
0167 
0168 # End of customisation functions
0169 
0170 # Customisation from command line
0171 
0172 process.load('FWCore.MessageLogger.MessageLogger_cfi')
0173 x = process.maxEvents.input.value()
0174 x = x if x >= 0 else 10000
0175 process.MessageLogger.cerr.FwkReport.reportEvery = max(1, min(1000, x // 10))
0176 
0177 # Add early deletion of temporary data products to reduce peak memory need
0178 from Configuration.StandardSequences.earlyDeleteSettings_cff import customiseEarlyDelete
0179 process = customiseEarlyDelete(process)
0180 
0181 if options.dumpPython:
0182     print (process.dumpPython())
0183 
0184 process.options.wantSummary = cms.untracked.bool(options.Summary)
0185 
0186 
0187 # End adding early deletion