Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-11-22 00:47:20

0001 #!/usr/bin/env python
0002 from __future__ import print_function
0003 import sys
0004 
0005 """
0006 The parameters can be changed by adding command line arguments of the form:
0007     testVectorCode_data.py nevents=-1
0008 The latter can be used to change parameters in crab.
0009 """
0010 
0011 job = 0 #job number
0012 njob = 1 #number of jobs
0013 nevents = 3564 #number of events
0014 rootout = False #whether to produce root file
0015 dump = False #dump python
0016 newXML = False #whether running with the new Grammar
0017 
0018 # ----------------
0019 # Argument parsing
0020 # ----------------
0021 if len(sys.argv) > 1 and sys.argv[1].endswith('.py'):
0022     sys.argv.pop(0)
0023 if len(sys.argv) == 2 and ':' in sys.argv[1]:
0024     argv = sys.argv[1].split(':')
0025 else:
0026     argv = sys.argv[1:]
0027 
0028 for arg in argv:
0029     (k, v) = map(str.strip, arg.split('='))
0030     if k not in globals():
0031         raise "Unknown argument '%s'!" % (k,)
0032     if isinstance(globals()[k], bool):
0033         globals()[k] = v.lower() in ('y', 'yes', 'true', 't', '1')
0034     elif isinstance(globals()[k], int):
0035         globals()[k] = int(v)
0036     else:
0037         globals()[k] = v
0038 
0039 neventsPerJob = int(nevents/njob)
0040 skip = job * neventsPerJob
0041 
0042 if skip>4:
0043     skip = skip-4
0044     neventsPerJob = neventsPerJob+4
0045 
0046 # ------------------------------------------------------------
0047 # Set up Run 3 conditions to get the proper emulation sequence
0048 # ------------------------------------------------------------
0049 import FWCore.ParameterSet.Config as cms
0050 from Configuration.Eras.Era_Run3_cff import Run3
0051 process = cms.Process('L1TEMULATION', Run3)
0052 
0053 process.load('Configuration.StandardSequences.Services_cff')
0054 process.load('FWCore.MessageService.MessageLogger_cfi')
0055 process.load('Configuration/StandardSequences/FrontierConditions_GlobalTag_cff')
0056 
0057 # ---------------------
0058 # Message Logger output
0059 # ---------------------
0060 process.load('FWCore.MessageService.MessageLogger_cfi')
0061 #process.load('L1Trigger/L1TYellow/l1t_debug_messages_cfi')
0062 #process.load('L1Trigger/L1TYellow/l1t_info_messages_cfi')
0063 
0064 process.load('L1Trigger/L1TGlobal/debug_messages_cfi')
0065 process.MessageLogger.l1t_debug.l1t.limit = cms.untracked.int32(100000)
0066 
0067 process.MessageLogger.categories.append('l1t|Global')
0068 
0069 # DEBUG
0070 #process.MessageLogger.debugModules = cms.untracked.vstring('simGtStage2Digis') 
0071 #process.MessageLogger.cerr.threshold = cms.untracked.string('DEBUG') 
0072 
0073 # ------------
0074 # Input source
0075 # ------------
0076 # Set the number of events
0077 process.maxEvents = cms.untracked.PSet(
0078     input = cms.untracked.int32(neventsPerJob)
0079     )
0080 
0081 # Set file: it needs to be a RAW format
0082 process.source = cms.Source("PoolSource",
0083     secondaryFileNames = cms.untracked.vstring(),
0084     fileNames = cms.untracked.vstring(
0085         "/store/data/Run2022E/EphemeralHLTPhysics0/RAW/v1/000/359/661/00000/355c33ec-6253-4590-bc11-94e0ce1b45be.root"
0086     ),
0087     skipEvents = cms.untracked.uint32(skip)
0088     )
0089 
0090 process.output =cms.OutputModule("PoolOutputModule",
0091         outputCommands = cms.untracked.vstring('keep *'),
0092     fileName = cms.untracked.string('testGlobalMCInputProducer_'+repr(job)+'.root')
0093     )
0094 
0095 process.options = cms.untracked.PSet(
0096     wantSummary = cms.bool(True)
0097 )
0098 
0099 # -----------------------------------------------
0100 # Additional output definition: TTree output file
0101 # -----------------------------------------------
0102 process.load("CommonTools.UtilAlgos.TFileService_cfi")
0103 process.TFileService.fileName = cms.string('l1t_histos.root')
0104 
0105 # ----------
0106 # Global Tag
0107 # ----------
0108 from Configuration.AlCa.GlobalTag import GlobalTag
0109 process.GlobalTag = GlobalTag(process.GlobalTag, '124X_dataRun3_Prompt_v4', '')
0110 
0111 # ----------------
0112 # Load the L1 menu
0113 # ----------------
0114 process.load('L1Trigger.L1TGlobal.GlobalParameters_cff')
0115 process.load("L1Trigger.L1TGlobal.TriggerMenu_cff")
0116 xmlMenu="L1Menu_Collisions2022_v1_3_0.xml"
0117 process.TriggerMenu.L1TriggerMenuFile = cms.string(xmlMenu)
0118 process.ESPreferL1TXML = cms.ESPrefer("L1TUtmTriggerMenuESProducer","TriggerMenu")
0119 
0120 process.dumpMenu = cms.EDAnalyzer("L1MenuViewer")
0121 # DEBUG: Information about names and types of algos parsed by the emulator from the menu
0122 #process.menuDumper = cms.EDAnalyzer("L1TUtmTriggerMenuDumper") 
0123 
0124 # -----------------------------------------
0125 # Load the GT inputs from the unpacker step
0126 # -----------------------------------------
0127 process.load('Configuration.StandardSequences.RawToDigi_cff')
0128 process.raw2digi_step = cms.Path(process.RawToDigi)
0129 
0130 process.dumpGT = cms.EDAnalyzer("l1t::GtInputDump",
0131                 egInputTag    = cms.InputTag("gtInput"),
0132         muInputTag    = cms.InputTag("gtInput"),
0133         tauInputTag   = cms.InputTag("gtInput"),
0134         jetInputTag   = cms.InputTag("gtInput"),
0135         etsumInputTag = cms.InputTag("gtInput"),
0136         minBx         = cms.int32(0),
0137         maxBx         = cms.int32(0)
0138          )
0139 process.dumpED = cms.EDAnalyzer("EventContentAnalyzer")
0140 process.dumpES = cms.EDAnalyzer("PrintEventSetupContent")
0141 
0142 # ------------------------
0143 # Fill External conditions
0144 # ------------------------
0145 process.load('L1Trigger.L1TGlobal.simGtExtFakeProd_cfi')
0146 process.simGtExtFakeProd.bxFirst = cms.int32(-2)
0147 process.simGtExtFakeProd.bxLast = cms.int32(2)
0148 process.simGtExtFakeProd.setBptxAND   = cms.bool(True)
0149 process.simGtExtFakeProd.setBptxPlus  = cms.bool(True)
0150 process.simGtExtFakeProd.setBptxMinus = cms.bool(True)
0151 process.simGtExtFakeProd.setBptxOR    = cms.bool(True)
0152 
0153 # ----------------------------
0154 # Run the Stage 2 uGT emulator
0155 # ----------------------------
0156 process.load('L1Trigger.L1TGlobal.simGtStage2Digis_cfi')
0157 process.simGtStage2Digis.PrescaleSet = cms.uint32(1)
0158 process.simGtStage2Digis.ExtInputTag = cms.InputTag("simGtExtFakeProd")
0159 process.simGtStage2Digis.MuonInputTag = cms.InputTag("gtStage2Digis", "Muon")
0160 process.simGtStage2Digis.EGammaInputTag = cms.InputTag("gtStage2Digis", "EGamma")
0161 process.simGtStage2Digis.TauInputTag = cms.InputTag("gtStage2Digis", "Tau")
0162 process.simGtStage2Digis.JetInputTag = cms.InputTag("gtStage2Digis", "Jet")
0163 process.simGtStage2Digis.EtSumInputTag = cms.InputTag("gtStage2Digis", "ETSum")
0164 process.simGtStage2Digis.EmulateBxInEvent = cms.int32(1)
0165 
0166 process.dumpGTRecord = cms.EDAnalyzer("l1t::GtRecordDump",
0167                                       egInputTag    = cms.InputTag("gtStage2Digis", "EGamma"),
0168                               muInputTag    = cms.InputTag("gtStage2Digis", "Muon"),
0169                               tauInputTag   = cms.InputTag("gtStage2Digis", "Tau"),
0170                                       jetInputTag   = cms.InputTag("gtStage2Digis", "Jet"),
0171                                       etsumInputTag = cms.InputTag("gtStage2Digis", "ETSum"),
0172                                       uGtAlgInputTag = cms.InputTag("simGtStage2Digis"),
0173                                       uGtExtInputTag = cms.InputTag("simGtExtFakeProd"),
0174                                       uGtObjectMapInputTag = cms.InputTag("simGtStage2Digis"),
0175                                       bxOffset       = cms.int32(skip),
0176                                       minBx          = cms.int32(-2),
0177                                       maxBx          = cms.int32(2),
0178                                       minBxVec       = cms.int32(0),
0179                                       maxBxVec       = cms.int32(0),
0180                                       dumpGTRecord   = cms.bool(True),
0181                                       dumpGTObjectMap= cms.bool(False),
0182                                       dumpTrigResults= cms.bool(False),
0183                                       dumpVectors    = cms.bool(True),
0184                                       tvFileName     = cms.string( ("TestVector_%03d.txt") % job ),
0185                                       tvVersion      = cms.int32(3),
0186                                       ReadPrescalesFromFile = cms.bool(True),
0187                                       psFileName     = cms.string( "prescale_L1TGlobal.csv" ),
0188                                       psColumn       = cms.int32(1),
0189                                       unprescaleL1Algos = cms.bool(False),
0190                                       unmaskL1Algos     = cms.bool(False)
0191          )
0192 
0193 process.load("L1Trigger.GlobalTriggerAnalyzer.l1GtTrigReport_cfi")
0194 process.l1GtTrigReport.L1GtRecordInputTag = "simGtStage2Digis"
0195 process.l1GtTrigReport.PrintVerbosity = 2
0196 process.report = cms.Path(process.l1GtTrigReport)
0197 
0198 process.MessageLogger.categories.append("MuConditon")
0199 
0200 # -------------------------
0201 # Setup Digi to Raw to Digi
0202 # -------------------------
0203 process.load('EventFilter.L1TRawToDigi.gtStage2Raw_cfi')
0204 process.gtStage2Raw.GtInputTag = cms.InputTag("simGtStage2Digis")
0205 process.gtStage2Raw.ExtInputTag = cms.InputTag("simGtExtFakeProd")
0206 process.gtStage2Raw.EGammaInputTag = cms.InputTag("gtInput")
0207 process.gtStage2Raw.TauInputTag = cms.InputTag("gtInput")
0208 process.gtStage2Raw.JetInputTag = cms.InputTag("gtInput")
0209 process.gtStage2Raw.EtSumInputTag = cms.InputTag("gtInput")
0210 process.gtStage2Raw.MuonInputTag = cms.InputTag("gtInput")
0211 
0212 process.load('EventFilter.L1TRawToDigi.gtStage2Digis_cfi')
0213 process.newGtStage2Digis = process.gtStage2Digis.clone()
0214 process.newGtStage2Digis.InputLabel = cms.InputTag('gtStage2Raw')
0215 # DEBUG 
0216 #process.newGtStage2Digis.debug = cms.untracked.bool(True) 
0217 
0218 process.dumpRaw = cms.EDAnalyzer(
0219     "DumpFEDRawDataProduct",
0220     label = cms.untracked.string("gtStage2Raw"),
0221     feds = cms.untracked.vint32 ( 1404 ),
0222     dumpPayload = cms.untracked.bool ( True )
0223 )
0224 
0225 process.newDumpGTRecord = cms.EDAnalyzer("l1t::GtRecordDump",
0226                 egInputTag    = cms.InputTag("newGtStage2Digis","EGamma"),
0227         muInputTag    = cms.InputTag("newGtStage2Digis","Muon"),
0228         tauInputTag   = cms.InputTag("newGtStage2Digis","Tau"),
0229         jetInputTag   = cms.InputTag("newGtStage2Digis","Jet"),
0230         etsumInputTag = cms.InputTag("newGtStage2Digis","EtSum"),
0231         uGtAlgInputTag = cms.InputTag("newGtStage2Digis"),
0232         uGtExtInputTag = cms.InputTag("newGtStage2Digis"),
0233         uGtObjectMapInputTag = cms.InputTag("simGtStage2Digis"),
0234         bxOffset       = cms.int32(skip),
0235         minBx          = cms.int32(0),
0236         maxBx          = cms.int32(0),
0237         minBxVec       = cms.int32(0),
0238         maxBxVec       = cms.int32(0),
0239         dumpGTRecord   = cms.bool(True),
0240         dumpGTObjectMap= cms.bool(True),
0241                 dumpTrigResults= cms.bool(False),
0242         dumpVectors    = cms.bool(False),
0243         tvFileName     = cms.string( ("TestVector_%03d.txt") % job ),
0244                 ReadPrescalesFromFile = cms.bool(False),
0245                 psFileName     = cms.string( "prescale_L1TGlobal.csv" ),
0246                 psColumn       = cms.int32(1)
0247          )
0248 
0249 # -----------
0250 # GT analyzer
0251 # -----------
0252 process.l1tGlobalAnalyzer = cms.EDAnalyzer('L1TGlobalAnalyzer',
0253                                            doText = cms.untracked.bool(False),
0254                                            gmuToken = cms.InputTag("None"),
0255                                            dmxEGToken = cms.InputTag("None"),
0256                                            dmxTauToken = cms.InputTag("None"),
0257                                            dmxJetToken = cms.InputTag("None"),
0258                                            dmxEtSumToken = cms.InputTag("None"),
0259                                            muToken = cms.InputTag("gtStage2Digis", "Muon"),
0260                                            egToken = cms.InputTag("gtStage2Digis", "EGamma"),
0261                                            tauToken = cms.InputTag("gtStage2Digis", "Tau"),
0262                                            jetToken = cms.InputTag("gtStage2Digis", "Jet"),
0263                                            etSumToken = cms.InputTag("gtStage2Digis", "EtSum"),
0264                                            gtAlgToken = cms.InputTag("simGtStage2Digis"),
0265                                            emulDxAlgToken = cms.InputTag("None"),
0266                                            emulGtAlgToken = cms.InputTag("simGtStage2Digis")
0267 )
0268 
0269 # ------------------
0270 # Process definition
0271 # ------------------
0272 process.p1 = cms.Path(
0273     ## Input, emulation, dump of the results
0274     process.dumpMenu
0275     *process.RawToDigi
0276     #*process.gtInput
0277     #*process.dumpGT
0278     *process.simGtExtFakeProd
0279     *process.simGtStage2Digis
0280     *process.dumpGTRecord
0281 
0282     ## Sequence for packing and unpacking uGT data
0283     #+process.gtStage2Raw
0284     #+process.dumpRaw
0285     #+process.newGtStage2Digis
0286     #+process.newDumpGTRecord
0287 
0288     ## Analysis/Dumping
0289     *process.l1tGlobalAnalyzer
0290     #*process.menuDumper # DEBUG -> to activate the menuDumper
0291     #*process.debug
0292     #*process.dumpED
0293     #*process.dumpES
0294     )
0295 
0296 # -------------------
0297 # Schedule definition
0298 # -------------------
0299 process.schedule = cms.Schedule(
0300     process.p1
0301 )
0302 #process.schedule.append(process.report)
0303 
0304 if rootout:
0305     process.outpath = cms.EndPath(process.output)
0306     process.schedule.append(process.outpath)
0307 
0308 # Spit out filter efficiency at the end
0309 process.options = cms.untracked.PSet(wantSummary = cms.untracked.bool(True))
0310 
0311 # Options for multithreading
0312 #process.options.numberOfThreads = cms.untracked.uint32( 2 )
0313 #process.options.numberOfStreams = cms.untracked.uint32( 0 )
0314 
0315 if dump:
0316     outfile = open('dump_runGlobalFakeInputProducer_'+repr(job)+'.py','w')
0317     print(process.dumpPython(), file=outfile)
0318     outfile.close()