|
| 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("port", 8001, VarParsing.multiplicity.singleton, VarParsing.varType.int) |
| 10 | +options.register("timeout", 30, VarParsing.multiplicity.singleton, VarParsing.varType.int) |
| 11 | +options.register("params", "", VarParsing.multiplicity.singleton, VarParsing.varType.string) |
| 12 | +options.register("threads", 1, VarParsing.multiplicity.singleton, VarParsing.varType.int) |
| 13 | +options.register("streams", 0, VarParsing.multiplicity.singleton, VarParsing.varType.int) |
| 14 | +options.register("batchsize", 1, VarParsing.multiplicity.singleton, VarParsing.varType.int) |
| 15 | +options.register("modelname","deepcalo_e", VarParsing.multiplicity.singleton, VarParsing.varType.string) |
| 16 | +options.register("mode", "Async", VarParsing.multiplicity.singleton, VarParsing.varType.string) |
| 17 | +options.parseArguments() |
| 18 | + |
| 19 | +if len(options.params)>0: |
| 20 | + with open(options.params,'r') as pfile: |
| 21 | + pdict = json.load(pfile) |
| 22 | + options.address = pdict["address"] |
| 23 | + options.port = int(pdict["port"]) |
| 24 | + print("server = "+options.address+":"+str(options.port)) |
| 25 | + |
| 26 | +# check mode |
| 27 | +allowed_modes = { |
| 28 | + "Async": "DeepCaloProducerAsync", |
| 29 | + "Sync": "DeepCaloProducerSync", |
| 30 | + "PseudoAsync": "DeepCaloProducerPseudoAsync", |
| 31 | +} |
| 32 | +if options.mode not in allowed_modes: |
| 33 | + raise ValueError("Unknown mode: "+options.mode) |
| 34 | + |
| 35 | +process = cms.Process('imageTest') |
| 36 | + |
| 37 | +#-------------------------------------------------------------------------------- |
| 38 | +# Import of standard configurations |
| 39 | +#================================================================================ |
| 40 | +process.load('FWCore/MessageService/MessageLogger_cfi') |
| 41 | +process.load('Configuration/StandardSequences/GeometryDB_cff') |
| 42 | +process.load('Configuration/StandardSequences/MagneticField_38T_cff') |
| 43 | + |
| 44 | +process.load("Configuration.StandardSequences.FrontierConditions_GlobalTag_cff") |
| 45 | +process.GlobalTag.globaltag = cms.string('100X_upgrade2018_realistic_v10') |
| 46 | + |
| 47 | +process.maxEvents = cms.untracked.PSet( input = cms.untracked.int32(options.maxEvents) ) |
| 48 | +process.source = cms.Source("PoolSource", |
| 49 | + #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') |
| 50 | + fileNames = cms.untracked.vstring(['file:../../Core/data/skim.root']*100), |
| 51 | + duplicateCheckMode = cms.untracked.string('noDuplicateCheck') |
| 52 | +) |
| 53 | + |
| 54 | + |
| 55 | +if len(options.inputFiles)>0: process.source.fileNames = options.inputFiles |
| 56 | + |
| 57 | +################### EDProducer ############################## |
| 58 | +process.DeepCaloProducer = cms.EDProducer(allowed_modes[options.mode], |
| 59 | + topN = cms.uint32(5), |
| 60 | + #binDataPath = cms.string("../../Core/data/image0_1000.bin"), |
| 61 | + binDataPath = cms.string("../../Core/data/deepcalo_all.bin"), |
| 62 | + Client = cms.PSet( |
| 63 | + ninput = cms.uint32(56*11*4), |
| 64 | + noutput = cms.uint32(1), |
| 65 | + batchSize = cms.uint32(options.batchsize), |
| 66 | + address = cms.string(options.address), |
| 67 | + port = cms.uint32(options.port), |
| 68 | + timeout = cms.uint32(options.timeout), |
| 69 | + modelName = cms.string(options.modelname), |
| 70 | + ) |
| 71 | +) |
| 72 | + |
| 73 | +# Let it run |
| 74 | +process.p = cms.Path( |
| 75 | + process.DeepCaloProducer |
| 76 | +) |
| 77 | + |
| 78 | +process.MessageLogger.cerr.FwkReport.reportEvery = 500 |
| 79 | +keep_msgs = ['TRTClient','DeepCaloProducer'] |
| 80 | +for msg in keep_msgs: |
| 81 | + process.MessageLogger.categories.append(msg) |
| 82 | + setattr(process.MessageLogger.cerr,msg, |
| 83 | + cms.untracked.PSet( |
| 84 | + optionalPSet = cms.untracked.bool(True), |
| 85 | + limit = cms.untracked.int32(10000000), |
| 86 | + ) |
| 87 | + ) |
| 88 | + |
| 89 | +if options.threads>0: |
| 90 | + if not hasattr(process,"options"): |
| 91 | + process.options = cms.untracked.PSet() |
| 92 | + process.options.numberOfThreads = cms.untracked.uint32(options.threads) |
| 93 | + process.options.numberOfStreams = cms.untracked.uint32(options.streams if options.streams>0 else 0) |
| 94 | + |
| 95 | +process.Timing = cms.Service("Timing", |
| 96 | + summaryOnly = cms.untracked.bool(True), |
| 97 | + useJobReport = cms.untracked.bool(True) |
| 98 | + ) |
0 commit comments