Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-09-16 03:24:16

0001 #Check the material bugdet sections of the HGCAL DPG website for the recipe. Namely,
0002 #HGCAL only: https://hgcal.web.cern.ch/MaterialBudget/MaterialBudget/
0003 #From vertex: https://hgcal.web.cern.ch/MaterialBudget/MaterialBudgetFromVertexUpToInfrontOfMuonStations/
0004 
0005 import FWCore.ParameterSet.Config as cms
0006 from FWCore.ParameterSet.VarParsing import VarParsing
0007 import sys, re
0008 
0009 from FWCore.PythonFramework.CmsRun import CmsRun
0010 from Configuration.Eras.Era_Phase2_cff import Phase2
0011 
0012 process = cms.Process("PROD", Phase2)
0013 
0014 process.load("SimGeneral.HepPDTESSource.pythiapdt_cfi")
0015 
0016 # The default geometry is Extended2023D86Reco. If a different geoemtry
0017 # is needed, the appropriate flag has to be passed at command line,
0018 # e.g.: cmsRun runP_FromVertexUpToInFrontOfMuonStations_cfg.py geom="XYZ"
0019 
0020 # The default component to be monitored is the HGCal. If other
0021 # components need to be studied, they must be supplied, one at a time,
0022 # at the command line, e.g.: cmsRun runP_FromVertexUpToInFrontOfMuonStations_cfg.py
0023 # label="XYZ"
0024 
0025 from Validation.Geometry.plot_hgcal_utils import _LABELS2COMPS
0026 
0027 _ALLOWED_LABELS = _LABELS2COMPS.keys()
0028 
0029 options = VarParsing('analysis')
0030 options.register('geom',             #name
0031                  'Extended2023D86',      #default value
0032                  VarParsing.multiplicity.singleton,   # kind of options
0033                  VarParsing.varType.string,           # type of option
0034                  "Select the geometry to be studied"  # help message
0035                 )
0036 
0037 options.register('label',         #name
0038                  'HGCal',              #default value
0039                  VarParsing.multiplicity.singleton,   # kind of options
0040                  VarParsing.varType.string,           # type of option
0041                  "Select the label to be used to create output files. Default to HGCal. If multiple components are selected, it defaults to the join of all components, with '_' as separator."  # help message
0042                 )
0043 
0044 options.setDefault('inputFiles', ['file:single_neutrino_random.root'])
0045 
0046 options.parseArguments()
0047 # Option validation
0048 
0049 if options.label not in _ALLOWED_LABELS:
0050     print("\n*** Error, '%s' not registered as a valid components to monitor." % options.label)
0051     print("Allowed components:", _ALLOWED_LABELS)
0052     print()
0053     raise RuntimeError("Unknown label")
0054 
0055 _components = _LABELS2COMPS[options.label]
0056 
0057 # Load geometry either from the Database of from files
0058 process.load("Configuration.Geometry.Geometry%sReco_cff" % options.geom)
0059 
0060 #
0061 #Magnetic Field
0062 #
0063 process.load("Configuration.StandardSequences.MagneticField_38T_cff")
0064 
0065 # Output of events, etc...
0066 #
0067 # Explicit note : since some histos/tree might be dumped directly,
0068 #                 better NOT use PoolOutputModule !
0069 # Detector simulation (Geant4-based)
0070 #
0071 process.load("SimG4Core.Application.g4SimHits_cfi")
0072 
0073 process.load("IOMC.RandomEngine.IOMC_cff")
0074 process.RandomNumberGeneratorService.g4SimHits.initialSeed = 9876
0075 
0076 process.source = cms.Source("PoolSource",
0077     fileNames = cms.untracked.vstring(options.inputFiles)
0078 )
0079 
0080 process.maxEvents = cms.untracked.PSet(
0081     input = cms.untracked.int32(-1)
0082 )
0083 
0084 process.p1 = cms.Path(process.g4SimHits)
0085 process.g4SimHits.StackingAction.TrackNeutrino = cms.bool(True)
0086 process.g4SimHits.UseMagneticField = False
0087 process.g4SimHits.Physics.type = 'SimG4Core/Physics/DummyPhysics'
0088 process.g4SimHits.Physics.DummyEMPhysics = True
0089 process.g4SimHits.Physics.CutsPerRegion = False
0090 process.g4SimHits.Watchers = cms.VPSet(cms.PSet(
0091     type = cms.string('MaterialBudgetAction'),
0092     MaterialBudgetAction = cms.PSet(
0093         HistosFile = cms.string('matbdg_%s.root' % options.label),
0094         AllStepsToTree = cms.bool(True),
0095         HistogramList = cms.string('HGCal'),
0096         SelectedVolumes = cms.vstring(_components),
0097         TreeFile = cms.string('None'), ## is NOT requested
0098 
0099         StopAfterProcess = cms.string('None'),
0100         #        TextFile = cms.string("matbdg_HGCal.txt")
0101         TextFile = cms.string('None'), 
0102         #Setting ranges for histos
0103         #Make z 4mm per bin. Be careful this could lead to memory crashes if too low. 
0104         minZ = cms.double(-7000.),
0105         maxZ = cms.double(7000.),
0106         nintZ = cms.int32(3500), 
0107         # Make r 1cm per bin
0108         rMin = cms.double(-50.), 
0109         rMax = cms.double(8000.),
0110         nrbin = cms.int32(805),
0111         # eta
0112         etaMin = cms.double(-5.), 
0113         etaMax = cms.double(5.),
0114         netabin = cms.int32(250),
0115         # phi
0116         phiMin = cms.double(-3.2), 
0117         phiMax = cms.double(3.2),
0118         nphibin = cms.int32(180),
0119         # R for profile histos
0120         RMin =  cms.double(0.), 
0121         RMax =  cms.double(8000.), 
0122         nRbin = cms.int32(800)
0123 
0124      )
0125 ))
0126 
0127 
0128 cmsRun = CmsRun(process)
0129 cmsRun.run()
0130 
0131