Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-11-28 23:11:15

0001 # In order to produce everything that you need in one go, use the command:
0002 #
0003 # for t in {'BeamPipe','Tracker','PixBar','PixFwdMinus','PixFwdPlus','TIB','TOB','TIDB','TIDF','TEC','TkStrct','InnerServices'}; do python3 runP_Tracker.py geom=XYZ label=$t >& /dev/null &; done
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 
0011 process = cms.Process("PROD")
0012 
0013 process.load("SimGeneral.HepPDTESSource.pythiapdt_cfi")
0014 
0015 """
0016 
0017  The default geometry is Extended2017Plan1. If a different geometry
0018  is needed, the appropriate flag has to be passed at command line,
0019  e.g.: cmsRun runP_Tracker_cfg.py geom="XYZ"
0020 
0021  The default component to be monitored is the Tracker. If other
0022  components need to be studied, they must be supplied, one at a time,
0023  at the command line, e.g.: python3 runP_Tracker.py
0024  label="XYZ"
0025 
0026 """
0027 
0028 from Validation.Geometry.plot_utils import _LABELS2COMPS
0029 
0030 process.load("FWCore.MessageLogger.MessageLogger_cfi")
0031 
0032 _ALLOWED_LABELS = _LABELS2COMPS.keys()
0033 
0034 options = VarParsing('analysis')
0035 options.register('geom',             #name
0036                  'Extended2017Plan1',      #default value
0037                  VarParsing.multiplicity.singleton,   # kind of options
0038                  VarParsing.varType.string,           # type of option
0039                  "Select the geometry to be studied"  # help message
0040                 )
0041 
0042 options.register('label',         #name
0043                  'Tracker',              #default value
0044                  VarParsing.multiplicity.singleton,   # kind of options
0045                  VarParsing.varType.string,           # type of option
0046                  "Select the label to be used to create output files. Default to tracker. If multiple components are selected, it defaults to the join of all components, with '_' as separator."  # help message
0047                 )
0048 
0049 options.setDefault('inputFiles', ['file:single_neutrino_random.root'])
0050 
0051 options.parseArguments()
0052 # Option validation
0053 
0054 process.MessageLogger = cms.Service(
0055     "MessageLogger",
0056     destinations   = cms.untracked.vstring('info'),
0057     categories = cms.untracked.vstring(['logMsg','MaterialBudget']),
0058     info = cms.untracked.PSet(
0059         threshold = cms.untracked.string('INFO'),
0060         filename = cms.untracked.string('Log_%s_%s' % (options.label,options.geom)),
0061         logMsg = cms.untracked.PSet(limit = cms.untracked.int32(-1))
0062         )
0063     )
0064 
0065 if options.label not in _ALLOWED_LABELS:
0066     print("\n*** Error, '%s' not registered as a valid components to monitor." % options.label)
0067     print("Allowed components:", _ALLOWED_LABELS)
0068     raise RuntimeError("Unknown label")
0069 
0070 _components = _LABELS2COMPS[options.label]
0071 
0072 #
0073 #Geometry
0074 #
0075 def _adaptToRun2(det):
0076   if det == 'PixelForwardZminus':
0077     det = det.replace('minus', 'Minus')
0078   elif det == 'PixelForwardZplus':
0079     det = det.replace('plus', 'Plus')
0080   return det
0081 
0082 # Load geometry either from the Database of from files
0083 process.load("Configuration.Geometry.Geometry%sReco_cff" % options.geom)
0084 
0085 # Customise names for Run2
0086 if re.match('.*2016.*', options.geom):
0087   if isinstance(_components, list):
0088       for i in range(len(_components)):
0089           _components[i] = _adaptToRun2(_components[i])
0090   else:
0091       _components = _adaptToRun2(_components)
0092 
0093 #
0094 #Magnetic Field
0095 #
0096 process.load("Configuration.StandardSequences.MagneticField_38T_cff")
0097 
0098 # Output of events, etc...
0099 #
0100 # Explicit note : since some histos/tree might be dumped directly,
0101 #                 better NOT use PoolOutputModule !
0102 # Detector simulation (Geant4-based)
0103 #
0104 process.load("SimG4Core.Application.g4SimHits_cfi")
0105 
0106 process.load("IOMC.RandomEngine.IOMC_cff")
0107 process.RandomNumberGeneratorService.g4SimHits.initialSeed = 9876
0108 
0109 process.source = cms.Source("PoolSource",
0110     fileNames = cms.untracked.vstring(options.inputFiles)
0111 )
0112 
0113 process.maxEvents = cms.untracked.PSet(
0114     input = cms.untracked.int32(-1)
0115 )
0116 
0117 process.p1 = cms.Path(process.g4SimHits)
0118 process.g4SimHits.StackingAction.TrackNeutrino = cms.bool(True)
0119 process.g4SimHits.UseMagneticField = False
0120 process.g4SimHits.Physics.type = 'SimG4Core/Physics/DummyPhysics'
0121 process.g4SimHits.Physics.DummyEMPhysics = True
0122 process.g4SimHits.Physics.CutsPerRegion = False
0123 process.g4SimHits.Watchers = cms.VPSet(cms.PSet(
0124     type = cms.string('MaterialBudgetAction'),
0125     MaterialBudgetAction = cms.PSet(
0126         HistosFile = cms.string('matbdg_%s_%s.root' % (options.label,
0127                                                        options.geom)),
0128         AllStepsToTree = cms.bool(True),
0129         HistogramList = cms.string('Tracker'),
0130         SelectedVolumes = cms.vstring(_components),
0131         TreeFile = cms.string('matbdg_tree_%s_%s.root' % (options.label,
0132                                                           options.geom)),
0133         StopAfterProcess = cms.string('None'),
0134         TextFile = cms.string('matbdg_%s_%s.txt' % (options.label,
0135                                                      options.geom))
0136     )
0137 ))
0138 
0139 cmsRun = CmsRun(process)
0140 cmsRun.run()