Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-03-26 02:44:00

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