Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-11-09 23:35:23

0001 
0002 from __future__ import print_function
0003 import FWCore.ParameterSet.Config as cms
0004 import FWCore.ParameterSet.VarParsing as VarParsing
0005 import sys
0006 
0007 options = VarParsing.VarParsing()
0008 
0009 options.register('producerType',
0010                  'static_DDD', #default value
0011                  VarParsing.VarParsing.multiplicity.singleton,
0012                  VarParsing.VarParsing.varType.string,
0013                  "MF producer to use. Valid values: 'static_DDD', 'static_DD4hep', 'fromDB', 'fromDB_DD4hep'")
0014 
0015 options.register('era',
0016                  'RunII', #default value
0017                  VarParsing.VarParsing.multiplicity.singleton,
0018                  VarParsing.VarParsing.varType.string,
0019                  "'RunI'or 'RunII'")
0020 
0021 options.register('current',
0022                  18000, #default value
0023                  VarParsing.VarParsing.multiplicity.singleton,
0024                  VarParsing.VarParsing.varType.float,
0025                  "Magnet current (nominal values: 18164=3.8T; 16730=3.5T; 14340=3T; 9500=2T; -1=loop in different IOV")
0026 
0027 options.parseArguments()
0028 
0029 
0030 process = cms.Process("MAGNETICFIELDTEST")
0031 
0032 process.source = cms.Source("EmptySource")
0033 
0034 process.maxEvents = cms.untracked.PSet(
0035     input = cms.untracked.int32(1)
0036 )
0037 
0038 REFERENCEFILE = 'none'
0039 
0040 if options.current < 0 : # Test all currents, simulating different IOVs with different values runInfo
0041                          # FIXME: currents are set all equal for the time being because we need to set up a way to specify the correct
0042                          # reference file file to be picked for each at runtime.
0043     if options.producerType == 'static_DDD' or options.producerType == 'static_DD4hep' :
0044         sys.exit('Invalid configuration: current=-1 mode is not supported with static prouducers')
0045     process.maxEvents.input = 4
0046     process.source.numberEventsInLuminosityBlock =cms.untracked.uint32(1)
0047 
0048     if options.era=='RunI':
0049         process.source.firstLuminosityBlockForEachRun = cms.untracked.VLuminosityBlockID(
0050             cms.LuminosityBlockID(10,1),
0051             cms.LuminosityBlockID(20,2),
0052             cms.LuminosityBlockID(30,3),
0053             cms.LuminosityBlockID(40,4),
0054             )
0055         process.add_( cms.ESProducer("RunInfoTestESProducer",
0056                                      runInfos = cms.VPSet(cms.PSet(run = cms.int32(10), avg_current = cms.double(18000.)),
0057                                                           cms.PSet(run = cms.int32(20), avg_current = cms.double(18000.)),
0058                                                           cms.PSet(run = cms.int32(30), avg_current = cms.double(18000.)),
0059                                                           cms.PSet(run = cms.int32(40), avg_current = cms.double(18000.)),
0060                                                           ) ) )
0061     else :
0062         process.source.firstLuminosityBlockForEachRun = cms.untracked.VLuminosityBlockID(
0063             cms.LuminosityBlockID(300001,1),
0064             cms.LuminosityBlockID(300002,2),
0065             cms.LuminosityBlockID(300003,3),
0066             cms.LuminosityBlockID(300004,4),
0067             )
0068         process.add_( cms.ESProducer("RunInfoTestESProducer",
0069                                      runInfos = cms.VPSet(cms.PSet(run = cms.int32(300001), avg_current = cms.double(18000.)),
0070                                                           cms.PSet(run = cms.int32(300002), avg_current = cms.double(18000.)),
0071                                                           cms.PSet(run = cms.int32(300003), avg_current = cms.double(18000.)),
0072                                                           cms.PSet(run = cms.int32(300004), avg_current = cms.double(18000.)),
0073                                                           ) ) )
0074         
0075 
0076     process.riSource = cms.ESSource("EmptyESSource", recordName = cms.string("RunInfoRcd"),
0077                                 iovIsRunNotTime = cms.bool(True),
0078                                 firstValid = cms.vuint32(10,20,30,40))
0079 
0080     REFERENCEFILE = 'MagneticField/Engine/data/Regression/referenceField_160812_RII_3_8T.bin' #FIXME cf. comment above.
0081 
0082 if options.current > 18765 or (options.current <= 4779 and options.current>0) :
0083     sys.exit('ERROR: invalid current value: ' +  str(options.current))
0084 elif options.current > 17543 :
0085     if options.era == 'RunII' :
0086         REFERENCEFILE = 'MagneticField/Engine/data/Regression/referenceField_160812_RII_3_8T.bin'
0087     elif options.era == 'RunI' :
0088         REFERENCEFILE = 'MagneticField/Engine/data/Regression/referenceField_160812_RI_3_8T.bin'
0089     else: 
0090         sys.exit('ERROR: Invalid era: ' + options.era)
0091 elif options.current > 15617 :
0092     REFERENCEFILE = 'MagneticField/Engine/data/Regression/referenceField_160812_3_5T.bin'
0093 elif options.current > 11987 :
0094     REFERENCEFILE = 'MagneticField/Engine/data/Regression/referenceField_160812_3T.bin'
0095 elif options.current > 4779 :
0096     REFERENCEFILE = 'MagneticField/Engine/data/Regression/referenceField_71212_2T.bin'
0097 
0098 
0099 if options.producerType == 'static_DDD':
0100     if options.current > 17543 :
0101         process.load("MagneticField.Engine.volumeBasedMagneticField_160812_cfi") # 3.8T, RII
0102         if options.era == 'RunI' :
0103             process.VolumeBasedMagneticFieldESProducer.version = cms.string('grid_160812_3_8t_Run1') # 3.8T, RII
0104     elif options.current > 15617 :
0105         process.load("MagneticField.Engine.volumeBasedMagneticField_160812_cfi")
0106         process.VolumeBasedMagneticFieldESProducer.version = cms.string('grid_160812_3_5t') # 3.5T
0107         process.ParametrizedMagneticFieldProducer.parameters.BValue = cms.string('3_5T')
0108     elif options.current > 11987 :
0109         process.load("MagneticField.Engine.volumeBasedMagneticField_160812_cfi")
0110         process.VolumeBasedMagneticFieldESProducer.version = cms.string('grid_160812_3t')
0111         process.ParametrizedMagneticFieldProducer.parameters.BValue = cms.string('3_0T')
0112     elif options.current > 4779 :
0113         process.load("MagneticField.Engine.volumeBasedMagneticField_71212_cfi") #2.0T
0114 
0115 
0116 elif options.producerType == 'static_DD4hep' :
0117     process.load("MagneticField.Engine.volumeBasedMagneticField_dd4hep_160812_cfi") 
0118     if options.current > 17543 :
0119         if options.era == 'RunI' :
0120             process.VolumeBasedMagneticFieldESProducer.version = cms.string('grid_160812_3_8t_Run1') # 3.8T, RII
0121     elif options.current > 15617 :
0122         process.VolumeBasedMagneticFieldESProducer.version = cms.string('grid_160812_3_5t') # 3.5T
0123         process.ParametrizedMagneticFieldProducer.parameters.BValue = cms.string('3_5T')
0124     elif options.current > 11987 :
0125         process.VolumeBasedMagneticFieldESProducer.version = cms.string('grid_160812_3t')
0126         process.ParametrizedMagneticFieldProducer.parameters.BValue = cms.string('3_0T')
0127     elif options.current > 4779 :
0128         sys.exit('ERROR: Unsupported current for static_DD4hep: ' + str(options.current))
0129 
0130 
0131 elif options.producerType == 'fromDB' or options.producerType == 'fromDB_DD4hep':
0132     if options.producerType == 'fromDB':
0133         process.load("Configuration.StandardSequences.MagneticField_cff")
0134     elif options.producerType == 'fromDB_DD4hep':
0135         process.load("MagneticField.Engine.volumeBasedMagneticFieldFromDB_dd4hep_cfi")
0136 
0137     process.load("Configuration.StandardSequences.FrontierConditions_GlobalTag_cff")
0138     from Configuration.AlCa.GlobalTag import GlobalTag
0139     process.GlobalTag = GlobalTag(process.GlobalTag, 'auto:run2_data', '') # Note: testing the proper set-up of data and MC iovs is beyond the scope of this script.
0140 
0141     if options.era == 'RunII' :
0142         process.source.firstRun = cms.untracked.uint32(300000)
0143     elif options.era == 'RunI' :
0144         process.source.firstRun = cms.untracked.uint32(100)
0145 
0146     # Note that this tests the map and the valueOverride method, but not the mechanism using the actual RunInfo, one mor set of tests could be added for this purpose.
0147     if options.current > 17543:
0148         process.VolumeBasedMagneticFieldESProducer.valueOverride = -1 #3.8T is the default
0149     elif options.current > 15617 :
0150         process.VolumeBasedMagneticFieldESProducer.valueOverride = 17000 #3.5 T
0151     elif options.current > 11987 :
0152         process.VolumeBasedMagneticFieldESProducer.valueOverride = 14000 #3 T
0153     elif options.current > 4779 :
0154         process.VolumeBasedMagneticFieldESProducer.valueOverride = 10000 #2 T
0155 
0156 
0157 
0158 else :
0159     print('\nERROR: invalid producerType', producerType,'\n')
0160 
0161 
0162 print('\nRegression for MF built with', options.producerType, 'era:', options.era, 'current:', options.current,'\n')
0163 
0164 
0165 process.testMagneticField = cms.EDAnalyzer("testMagneticField",
0166 
0167 ## Uncomment to write down the reference file
0168 #   outputTable = cms.untracked.string("newtable.bin"),
0169 
0170 ## Use the specified reference file to compare with
0171     inputTable = cms.untracked.string(REFERENCEFILE),
0172 
0173 ## Valid input file types: "xyz", "rpz_m", "xyz_m", "TOSCA" 
0174     inputTableType = cms.untracked.string("xyz"),
0175 
0176 ## Resolution used for validation, number of points
0177     resolution     = cms.untracked.double(0.0001),
0178         numberOfPoints = cms.untracked.int32(1000000),
0179 
0180 ## Size of testing volume (cm):
0181     InnerRadius = cms.untracked.double(0),    #  default: 0 
0182     OuterRadius = cms.untracked.double(900),  #  default: 900 
0183         minZ  = cms.untracked.double(-2400),      #  default: -2400 
0184         maxZ  = cms.untracked.double(2400)        #  default: 2400 
0185 
0186 )
0187 
0188 process.p1 = cms.Path(process.testMagneticField)
0189 
0190