Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:05:37

0001 #------------------------------------------------------------------------------------
0002 # Imports
0003 #------------------------------------------------------------------------------------
0004 import FWCore.ParameterSet.Config as cms
0005 import FWCore.ParameterSet.VarParsing as VarParsing
0006 from Configuration.StandardSequences.Eras import eras
0007 
0008 #------------------------------------------------------------------------------------
0009 # Options
0010 #------------------------------------------------------------------------------------
0011 options = VarParsing.VarParsing()
0012 
0013 options.register('skipEvents',
0014                  0, # default value
0015                  VarParsing.VarParsing.multiplicity.singleton,
0016                  VarParsing.VarParsing.varType.int,
0017                  "Number of events to skip")
0018 
0019 options.register('processEvents',
0020                  -1, # default value
0021                  VarParsing.VarParsing.multiplicity.singleton,
0022                  VarParsing.VarParsing.varType.int,
0023                  "Number of events to process")
0024 
0025 options.register('inputFiles',
0026                  "file:inputFile.root",
0027                  VarParsing.VarParsing.multiplicity.list,
0028                  VarParsing.VarParsing.varType.string,
0029                  "Input files")
0030 
0031 options.register('outputFile',
0032                  "file:hcalnano.root", # default value
0033                  VarParsing.VarParsing.multiplicity.singleton,
0034                  VarParsing.VarParsing.varType.string,
0035                  "Output file")
0036 
0037 options.register('nThreads', 
0038                 4, 
0039                 VarParsing.VarParsing.multiplicity.singleton, 
0040                 VarParsing.VarParsing.varType.int)
0041 
0042 options.register('compressionAlgorithm', 
0043                 "ZLIB", 
0044                 VarParsing.VarParsing.multiplicity.singleton, 
0045                 VarParsing.VarParsing.varType.string)
0046 
0047 options.register('compressionLevel', 
0048                 5, 
0049                 VarParsing.VarParsing.multiplicity.singleton, 
0050                 VarParsing.VarParsing.varType.int)
0051 
0052 options.register('reportEvery', 
0053                 100, 
0054                 VarParsing.VarParsing.multiplicity.singleton, 
0055                 VarParsing.VarParsing.varType.int)
0056 
0057 options.parseArguments()
0058 
0059 print(" ")
0060 print("Using options:")
0061 print(" skipEvents    =", options.skipEvents)
0062 print(" processEvents =", options.processEvents)
0063 print(" inputFiles    =", options.inputFiles)
0064 print(" outputFile    =", options.outputFile)
0065 print(" nThreads.     =", options.nThreads)
0066 print(" ")
0067 
0068 #------------------------------------------------------------------------------------
0069 # Declare the process and input variables
0070 #------------------------------------------------------------------------------------
0071 process = cms.Process('HCALNANO', eras.Run3)
0072 
0073 #------------------------------------------------------------------------------------
0074 # Get and parse the command line arguments
0075 #------------------------------------------------------------------------------------
0076 process.maxEvents = cms.untracked.PSet( input = cms.untracked.int32(options.processEvents) )
0077 
0078 process.source = cms.Source(
0079     "PoolSource",
0080     fileNames  = cms.untracked.vstring(options.inputFiles),
0081     skipEvents = cms.untracked.uint32(options.skipEvents)
0082     )
0083 
0084 process.TFileService = cms.Service(
0085     "TFileService",
0086     fileName = cms.string(options.outputFile)
0087     )
0088 process.options.numberOfThreads=cms.untracked.uint32(options.nThreads)
0089 process.options.numberOfStreams=cms.untracked.uint32(0)
0090 #------------------------------------------------------------------------------------
0091 # import of standard configurations
0092 #------------------------------------------------------------------------------------
0093 
0094 # Reduce message log output
0095 process.load('FWCore.MessageService.MessageLogger_cfi')
0096 process.MessageLogger.cerr.FwkReport.reportEvery = cms.untracked.int32(options.reportEvery)
0097 
0098 process.load('Configuration.StandardSequences.GeometryRecoDB_cff')
0099 process.load('Configuration.StandardSequences.RawToDigi_Data_cff')
0100 process.load('Configuration.StandardSequences.L1Reco_cff')
0101 process.load('Configuration.StandardSequences.Reconstruction_Data_cff')
0102 
0103 #------------------------------------------------------------------------------------
0104 # Specify Global Tag
0105 #------------------------------------------------------------------------------------
0106 process.load('Configuration.StandardSequences.FrontierConditions_GlobalTag_cff')
0107 process.GlobalTag.globaltag = '122X_dataRun3_HLT_v3'
0108 print("GlobalTag = ", str(process.GlobalTag.globaltag).split("'")[1])
0109 print(" ")
0110 
0111 #------------------------------------------------------------------------------------
0112 # HcalNano sequence definition
0113 #------------------------------------------------------------------------------------
0114 #from PhysicsTools.NanoAOD.common_cff import *
0115 process.load("PhysicsTools.NanoAOD.nano_cff")
0116 process.load("RecoLocalCalo/Configuration/hcalLocalReco_cff")
0117 process.load("RecoLocalCalo/Configuration/hcalGlobalReco_cff")
0118 process.load("DPGAnalysis.HcalNanoAOD.hcalRecHitTable_cff")
0119 process.load("DPGAnalysis.HcalNanoAOD.hcalDetIdTable_cff")
0120 process.load("DPGAnalysis.HcalNanoAOD.hcalDigiSortedTable_cff")
0121 
0122 # This creates a sorted list of HcalDetIds for use by downstream HcalNano table producers
0123 process.hcalNanoPrep = cms.Sequence(process.hcalDetIdTable)
0124 
0125 process.hcalNanoTask = cms.Task(
0126     process.hcalDigis, 
0127 
0128     ## Do energy reconstruction
0129     process.hcalLocalRecoTask,
0130     process.hcalGlobalRecoTask,
0131 
0132     # Make digi tables
0133     process.hcalDigiSortedTable,
0134 
0135     # Make RecHit tables
0136     process.hbheRecHitTable,
0137     process.hfRecHitTable,
0138     process.hoRecHitTable,
0139 )
0140 
0141 process.preparation = cms.Path(process.hcalNanoPrep, process.hcalNanoTask)
0142 
0143 process.NanoAODEDMEventContent.outputCommands = cms.untracked.vstring(
0144         'drop *',
0145         "keep nanoaodFlatTable_*Table_*_*",     # event data
0146         "keep edmTriggerResults_*_*_*",  # event data
0147         "keep String_*_genModel_*",  # generator model data
0148         "keep nanoaodMergeableCounterTable_*Table_*_*", # accumulated per/run or per/lumi data
0149         "keep nanoaodUniqueString_nanoMetadata_*_*",   # basic metadata
0150     )
0151 
0152 process.out = cms.OutputModule("NanoAODOutputModule",
0153     fileName = cms.untracked.string(options.outputFile),
0154     outputCommands = process.NanoAODEDMEventContent.outputCommands,
0155     compressionLevel = cms.untracked.int32(options.compressionLevel),
0156     compressionAlgorithm = cms.untracked.string(options.compressionAlgorithm),
0157 
0158 )
0159 process.end = cms.EndPath(process.out)