|
| 1 | +from FWCore.ParameterSet.VarParsing import VarParsing |
| 2 | +import FWCore.ParameterSet.Config as cms |
| 3 | +import os, sys, json |
| 4 | + |
| 5 | +options = VarParsing("analysis") |
| 6 | +#options.register("address", "ailab01.fnal.gov", VarParsing.multiplicity.singleton, VarParsing.varType.string) |
| 7 | +#options.register("address", "prp-gpu-1.t2.ucsd.edu", VarParsing.multiplicity.singleton, VarParsing.varType.string) |
| 8 | +#options.register("address", "18.4.112.82", VarParsing.multiplicity.singleton, VarParsing.varType.string) |
| 9 | +#options.register("address", "34.221.148.178", VarParsing.multiplicity.singleton, VarParsing.varType.string) |
| 10 | +#options.register("address", "34.221.148.178", VarParsing.multiplicity.singleton, VarParsing.varType.string) |
| 11 | +options.register("address", "ailab01.fnal.gov", VarParsing.multiplicity.singleton, VarParsing.varType.string) |
| 12 | +options.register("port", 5001, VarParsing.multiplicity.singleton, VarParsing.varType.int) |
| 13 | +options.register("timeout", 30, VarParsing.multiplicity.singleton, VarParsing.varType.int) |
| 14 | +options.register("params", "", VarParsing.multiplicity.singleton, VarParsing.varType.string) |
| 15 | +options.register("threads", 1, VarParsing.multiplicity.singleton, VarParsing.varType.int) |
| 16 | +options.register("streams", 1, VarParsing.multiplicity.singleton, VarParsing.varType.int) |
| 17 | +options.register("batchsize", 16000, VarParsing.multiplicity.singleton, VarParsing.varType.int) |
| 18 | +options.register("modelname","facile", VarParsing.multiplicity.singleton, VarParsing.varType.string) |
| 19 | +options.register("mode", "Async", VarParsing.multiplicity.singleton, VarParsing.varType.string) |
| 20 | +options.parseArguments() |
| 21 | + |
| 22 | +if len(options.params)>0: |
| 23 | + with open(options.params,'r') as pfile: |
| 24 | + pdict = json.load(pfile) |
| 25 | + options.address = pdict["address"] |
| 26 | + options.port = int(pdict["port"]) |
| 27 | + print("server = "+options.address+":"+str(options.port)) |
| 28 | + |
| 29 | +# check mode |
| 30 | +allowed_modes = { |
| 31 | + "Async": "HcalProducerFPGAAsync", |
| 32 | + "Sync": "HcalProducerFPGASync", |
| 33 | + "PseudoAsync": "HcalProducerPseudoFPGAAsync", |
| 34 | +} |
| 35 | +if options.mode not in allowed_modes: |
| 36 | + raise ValueError("Unknown mode: "+options.mode) |
| 37 | + |
| 38 | +process = cms.Process('imageTest') |
| 39 | + |
| 40 | +#-------------------------------------------------------------------------------- |
| 41 | +# Import of standard configurations |
| 42 | +#================================================================================ |
| 43 | +process.load('FWCore/MessageService/MessageLogger_cfi') |
| 44 | +process.load('Configuration/StandardSequences/GeometryDB_cff') |
| 45 | +process.load('Configuration/StandardSequences/MagneticField_38T_cff') |
| 46 | + |
| 47 | +#process.load("Configuration.StandardSequences.FrontierConditions_GlobalTag_cff") |
| 48 | +#process.GlobalTag.globaltag = cms.string('100X_upgrade2018_realistic_v10') |
| 49 | + |
| 50 | +process.maxEvents = cms.untracked.PSet( input = cms.untracked.int32(options.maxEvents) ) |
| 51 | +process.source = cms.Source("PoolSource", |
| 52 | + fileNames = cms.untracked.vstring('file:../../Core/data/store_mc_RunIISpring18MiniAOD_BulkGravTohhTohbbhbb_narrow_M-2000_13TeV-madgraph_MINIAODSIM_100X_upgrade2018_realistic_v10-v1_30000_24A0230C-B530-E811-ADE3-14187741120B.root') |
| 53 | +) |
| 54 | + |
| 55 | +if len(options.inputFiles)>0: process.source.fileNames = options.inputFiles |
| 56 | + |
| 57 | +################### EDProducer ############################## |
| 58 | +process.HcalProducer = cms.EDProducer(allowed_modes[options.mode], |
| 59 | + topN = cms.uint32(5), |
| 60 | + Client = cms.PSet( |
| 61 | + ninput = cms.uint32(32), |
| 62 | + noutput = cms.uint32(1), |
| 63 | + batchSize = cms.uint32(options.batchsize), |
| 64 | + address = cms.string(options.address), |
| 65 | + port = cms.uint32(options.port), |
| 66 | + timeout = cms.uint32(options.timeout), |
| 67 | + modelName = cms.string(options.modelname), |
| 68 | + ) |
| 69 | +) |
| 70 | + |
| 71 | +# Let it run |
| 72 | +process.p = cms.Path( |
| 73 | + process.HcalProducer |
| 74 | +) |
| 75 | + |
| 76 | +process.MessageLogger.cerr.FwkReport.reportEvery = 1 |
| 77 | +keep_msgs = ['TRTClient']#,'HcalProducerFPGA'] |
| 78 | +for msg in keep_msgs: |
| 79 | + process.MessageLogger.categories.append(msg) |
| 80 | + setattr(process.MessageLogger.cerr,msg, |
| 81 | + cms.untracked.PSet( |
| 82 | + optionalPSet = cms.untracked.bool(True), |
| 83 | + limit = cms.untracked.int32(10000000), |
| 84 | + ) |
| 85 | + ) |
| 86 | + |
| 87 | +if options.threads>0: |
| 88 | + if not hasattr(process,"options"): |
| 89 | + process.options = cms.untracked.PSet() |
| 90 | + process.options.numberOfThreads = cms.untracked.uint32(options.threads) |
| 91 | + process.options.numberOfStreams = cms.untracked.uint32(options.streams if options.streams>0 else 0) |
0 commit comments