Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:51:22

0001 import FWCore.ParameterSet.Config as cms
0002 import os
0003 
0004 #SET = "71212"
0005 #SET = "90322"
0006 #SET = "120812"
0007 #SET = "130503"
0008 SET = "160812"
0009 
0010 #SUBSET = ""
0011 #SUBSET = "2pi_scaled"
0012 #SUBSET = "Run1"
0013 SUBSET = "Run2"
0014 
0015 #B_NOM = "0T"
0016 #B_NOM = "2T"
0017 #B_NOM = "3T"
0018 #B_NOM = "3_5T"
0019 B_NOM = "3_8T"
0020 #B_NOM = "4T"
0021 
0022 
0023 process = cms.Process("DumpToDB")
0024 
0025 process.load('CondCore.CondDB.CondDB_cfi')
0026 process.CondDBSetup = process.CondDB.clone()
0027 process.CondDBSetup.__delattr__('connect')
0028 
0029 process.source = cms.Source("EmptySource",
0030     numberEventsInRun = cms.untracked.uint32(1),
0031     firstRun = cms.untracked.uint32(300000)
0032 )
0033 
0034 process.maxEvents = cms.untracked.PSet(
0035     input = cms.untracked.int32(1)
0036 )
0037 
0038 #process.load('Configuration.StandardSequences.FrontierConditions_GlobalTag_cff')
0039 #from Configuration.AlCa.GlobalTag import GlobalTag
0040 #process.GlobalTag = GlobalTag(process.GlobalTag, 'auto:run2_mc', '')
0041 
0042 
0043 if SUBSET == "" : 
0044     TAG = "MFConfig_"+SET+"_"+B_NOM
0045 else :
0046     TAG = "MFConfig_"+SET+"_"+SUBSET+"_"+B_NOM
0047 
0048 FILE = TAG+".db"
0049 
0050 try:
0051     os.remove(FILE)
0052 except OSError:
0053     pass
0054 
0055 process.PoolDBOutputService = cms.Service("PoolDBOutputService",
0056                                           process.CondDBSetup,
0057                                           connect = cms.string("sqlite_file:"+FILE),
0058                                           toPut = cms.VPSet(cms.PSet(record = cms.string("MagFieldConfigRcd"),
0059                                                                      tag = cms.string("MagFieldConfig"))))
0060 
0061 def createMetadata(aTag,aComment):
0062     txtfile = open(aTag+'.txt', 'w')
0063     txtfile.write('{\n')
0064     txtfile.write('   "destinationDatabase": "oracle://cms_orcon_prod/CMS_CONDITIONS",\n')
0065     txtfile.write('   "destinationTags": {\n')
0066     txtfile.write('      "'+TAG+'": {\n')
0067 #    txtfile.write('         "dependencies": {},\n')
0068 #    txtfile.write('         "synchronizeTo": "offline"\n')
0069     txtfile.write('        }\n')
0070     txtfile.write('    },\n')
0071     txtfile.write('    "inputTag": "MagFieldConfig",\n')
0072     txtfile.write('    "since": 1,\n')
0073     txtfile.write('    "userText": "'+aComment+'"\n')
0074     txtfile.write('}\n')
0075     return
0076 
0077 
0078 
0079 if SET=="71212" :
0080     if SUBSET!="": raise NameError("configuration invalid: "+SET)
0081     versions = {'0T':   'grid_1103l_071212_4t',
0082                 '2T':   'grid_1103l_071212_2t',
0083                 '3T':   'grid_1103l_071212_3t',
0084                 '3_5T': 'grid_1103l_071212_3_5t',
0085                 #'3.8T': 'grid_1103l_071212_3_8t', #Deprecated
0086                 '4T':   'grid_1103l_071212_4t'} 
0087     param    = {'0T':   0.,
0088                 '2T':   2.,
0089                 '3T':   3.,
0090                 '3_5T': 3.5,
0091                 #'3_8T': 3.8,
0092                 '4T':   4.}
0093     process.dumpToDB = cms.EDAnalyzer("MagFieldConfigDBWriter",
0094           scalingVolumes = cms.vint32(),
0095           scalingFactors = cms.vdouble(),
0096           version = cms.string(versions[B_NOM]),
0097           geometryVersion = cms.int32(90322),
0098           paramLabel = cms.string('OAE_1103l_071212'),
0099           paramData = cms.vdouble(param[B_NOM]),
0100           gridFiles = cms.VPSet(
0101             cms.PSet( # Default tables, replicate sector 1
0102                volumes   = cms.string('1-312'),
0103                sectors   = cms.string('0') ,
0104                master    = cms.int32(1),
0105                path      = cms.string('grid.[v].bin'),
0106            )
0107          )
0108     )
0109     if B_NOM == '0T' :
0110         process.dumpToDB.paramLabel = 'Uniform'
0111     
0112 
0113 if SET=="90322" :
0114     if B_NOM!="3_8T" or SUBSET!="2pi_scaled":  raise NameError("configuration invalid: "+SET)
0115 
0116     from MagneticField.Engine.ScalingFactors_090322_2pi_090520_cfi import *
0117     
0118     process.dumpToDB = cms.EDAnalyzer("MagFieldConfigDBWriter",
0119       fieldScaling,
0120       version = cms.string('grid_1103l_090322_3_8t'),
0121       geometryVersion = cms.int32(90322),
0122       paramLabel = cms.string('OAE_1103l_071212'),
0123       paramData = cms.vdouble(3.8),
0124     
0125       gridFiles = cms.VPSet(
0126           cms.PSet( # Default tables, replicate sector 1
0127               volumes   = cms.string('1-312'),
0128               sectors   = cms.string('0') ,
0129               master    = cms.int32(1),
0130               path      = cms.string('grid.[v].bin'),
0131           ),
0132           cms.PSet( # Specific volumes in Barrel, sector 3
0133               volumes   = cms.string('176-186,231-241,286-296'),
0134               sectors   = cms.string('3') ,
0135               master    = cms.int32(3),
0136               path      = cms.string('S3/grid.[v].bin'),
0137           ),
0138           cms.PSet( # Specific volumes in Barrel, sector 4
0139               volumes   = cms.string('176-186,231-241,286-296'),
0140               sectors   = cms.string('4') ,
0141               master    = cms.int32(4),
0142               path      = cms.string('S4/grid.[v].bin'),
0143           ),
0144           cms.PSet(  # Specific volumes in Barrel and endcaps, sector 9
0145               volumes   = cms.string('14,15,20,21,24-27,32,33,40,41,48,49,56,57,62,63,70,71,286-296'),
0146               sectors   = cms.string('9') ,
0147               master    = cms.int32(9),
0148               path      = cms.string('S9/grid.[v].bin'),
0149           ),
0150           cms.PSet(  # Specific volumes in Barrel and endcaps, sector 10
0151               volumes   = cms.string('14,15,20,21,24-27,32,33,40,41,48,49,56,57,62,63,70,71,286-296'),
0152               sectors   = cms.string('10') ,
0153               master    = cms.int32(10),
0154               path      = cms.string('S10/grid.[v].bin'),
0155           ),                                              
0156           cms.PSet( # Specific volumes in Barrel and endcaps, sector 11
0157               volumes   = cms.string('14,15,20,21,24-27,32,33,40,41,48,49,56,57,62,63,70,71,286-296'),
0158               sectors   = cms.string('11') ,
0159               master    = cms.int32(11),
0160               path      = cms.string('S11/grid.[v].bin'),
0161           ),
0162        )
0163     )
0164       
0165 
0166 elif SET=="120812" :
0167   if B_NOM!="3_8T" :  raise NameError("B_NOM invalid for SET "+SET)
0168   if    SUBSET=="Run1" : VERSION = 'grid_120812_3_8t_v7_small'
0169   elif  SUBSET=="Run2" : VERSION = 'grid_120812_3_8t_v7_large'
0170   else : raise NameError("invalid SUBSET: "+SUBSET+ " for "+TAG )
0171   
0172   process.dumpToDB = cms.EDAnalyzer("MagFieldConfigDBWriter",
0173       scalingVolumes = cms.vint32(),
0174       scalingFactors = cms.vdouble(),
0175       version = cms.string(VERSION),
0176       geometryVersion = cms.int32(120812),
0177       paramLabel = cms.string('OAE_1103l_071212'),
0178       paramData = cms.vdouble(3.8),
0179     
0180       gridFiles = cms.VPSet(
0181           # Specific tables for each sector
0182           cms.PSet( 
0183               volumes   = cms.string('1001-1010,1012-1027,1030-1033,1036-1041,1044-1049,1052-1057,1060-1063,1066-1071,1074-1077,1080-1083,1130-1133,1138-1360'),
0184               sectors   = cms.string('0') ,
0185               master    = cms.int32(0),
0186               path      = cms.string('s[s]_1/grid.[v].bin'),
0187           ),
0188           cms.PSet(
0189               volumes   = cms.string('2001-2010,2012-2027,2030-2033,2036-2041,2044-2049,2052-2057,2060-2063,2066-2071,2074-2077,2080-2083,2130-2133,2138-2360'),
0190               sectors   = cms.string('0'),
0191               master    = cms.int32(0),
0192               path      = cms.string('s[s]_2/grid.[v].bin'),
0193           ),
0194           # Replicate sector 1 for volumes outside any detector
0195           cms.PSet( 
0196               volumes   = cms.string('1011,1028-1029,1034-1035,1042-1043,1050-1051,1058-1059,1064-1065,1072-1073,1078-1079,1084-1129,1136-1137'),
0197               sectors   = cms.string('0'),
0198               master    = cms.int32(1),
0199               path      = cms.string('s01_1/grid.[v].bin'),
0200           ),
0201           cms.PSet(
0202               volumes   = cms.string('2011,2028-2029,2034-2035,2042-2043,2050-2051,2058-2059,2064-2065,2072-2073,2078-2079,2084-2129,2136-2137'),
0203               sectors   = cms.string('0'),
0204               master    = cms.int32(1),
0205               path      = cms.string('s01_2/grid.[v].bin'),
0206           ),   
0207          # Replicate sector 4 for the volume outside CASTOR, to avoid aliasing due to the plates in the cylinder gap
0208          # between the collar and the rotating shielding.
0209          cms.PSet(
0210              volumes   = cms.string('1134-1135'),
0211              sectors   = cms.string('0'),
0212              master    = cms.int32(4),
0213              path      = cms.string('s04_1/grid.[v].bin'),
0214          ),
0215          cms.PSet(
0216              volumes   = cms.string('2134-2135'),
0217              sectors   = cms.string('0'),
0218              master    = cms.int32(4),
0219              path      = cms.string('s04_2/grid.[v].bin'),
0220          ),
0221       )
0222     )
0223     
0224 
0225     
0226 elif SET=="130503" :
0227   versions = {'3_5T': 'grid_130503_3_5t_v9',
0228               '3_8T': 'grid_130503_3_8t_v9'}
0229   param    = {'3_5T': 3.5,
0230               '3_8T': 3.8}
0231   
0232   if    SUBSET=="Run1" : VERSION = versions[B_NOM]+'_small'
0233   elif  SUBSET=="Run2" : VERSION = versions[B_NOM]+'_large'
0234   else : raise NameError("invalid SUBSET: "+SUBSET+ " for "+TAG )
0235 
0236   process.dumpToDB = cms.EDAnalyzer("MagFieldConfigDBWriter",
0237       scalingVolumes = cms.vint32(),
0238       scalingFactors = cms.vdouble(),
0239       version = cms.string(VERSION),
0240       geometryVersion = cms.int32(130503),
0241       paramLabel = cms.string('OAE_1103l_071212'),
0242       paramData = cms.vdouble(param[B_NOM]),
0243     
0244       gridFiles = cms.VPSet(
0245           # Volumes for which specific tables are used for each sector
0246           cms.PSet(
0247               volumes   = cms.string('1001-1010,1012-1027,1030-1033,1036-1041,1044-1049,1052-1057,1060-1063,1066-1071,1074-1077,1080-1083,1130-1133,1138-1402,' + 
0248                                      '2001-2010,2012-2027,2030-2033,2036-2041,2044-2049,2052-2057,2060-2063,2066-2071,2074-2077,2080-2083,2130-2133,2138-2402'),
0249               sectors   = cms.string('0') ,
0250               master    = cms.int32(0),
0251               path      = cms.string('s[s]/grid.[v].bin'),
0252           ),
0253          # Replicate sector 1 for volumes outside any detector
0254            cms.PSet(
0255               volumes   = cms.string('1011,1028-1029,1034-1035,1042-1043,1050-1051,1058-1059,1064-1065,1072-1073,1078-1079,1084-1129,1136-1137,' +
0256                                      '2011,2028-2029,2034-2035,2042-2043,2050-2051,2058-2059,2064-2065,2072-2073,2078-2079,2084-2129,2136-2137'),
0257               sectors   = cms.string('0'),
0258               master    = cms.int32(1),
0259               path      = cms.string('s01/grid.[v].bin'),
0260           ),
0261 
0262          # Replicate sector 4 for the volume outside CASTOR, to avoid aliasing due to the plates in the cylinder gap
0263          # between the collar and the rotating shielding.
0264          cms.PSet(
0265              volumes   = cms.string('1134-1135,2134-2135'),
0266              sectors   = cms.string('0'),
0267              master    = cms.int32(4),
0268              path      = cms.string('s04/grid.[v].bin'),
0269          ),
0270     )
0271   )
0272 
0273 elif SET=="160812" :
0274   versions = {'3T'  : 'grid_160812_3t',
0275               '3_5T': 'grid_160812_3_5t',
0276               '3_8T': 'grid_160812_3_8t'}
0277   param    = {'3T': 3.,
0278               '3_5T': 3.5,
0279               '3_8T': 3.8}
0280   
0281   if    SUBSET=="Run2" : VERSION = versions[B_NOM]
0282   elif  SUBSET=="Run1" : VERSION = versions[B_NOM]+'_Run1'
0283   else : raise NameError("invalid SUBSET: "+SUBSET+ " for "+TAG )
0284 
0285   process.dumpToDB = cms.EDAnalyzer("MagFieldConfigDBWriter",
0286       scalingVolumes = cms.vint32(),
0287       scalingFactors = cms.vdouble(),
0288       version = cms.string(VERSION),
0289       geometryVersion = cms.int32(160812),
0290       paramLabel = cms.string('OAE_1103l_071212'),
0291       paramData = cms.vdouble(param[B_NOM]),
0292 
0293       gridFiles = cms.VPSet(
0294           # Volumes for which specific tables are used for each sector
0295           cms.PSet(
0296                volumes   = cms.string('1001-1010,1012-1027,1030-1033,1036-1041,1044-1049,1052-1057,1060-1063,1066-1071,1074-1077,1080-1097,1102-1129,1138-1402,1415-1416,' + 
0297                                       '2001-2010,2012-2027,2030-2033,2036-2041,2044-2049,2052-2057,2060-2063,2066-2071,2074-2077,2080-2097,2102-2129,2138-2402,2415-2416'),
0298                sectors   = cms.string('0') ,
0299                master    = cms.int32(0),
0300                path      = cms.string('s[s]/grid.[v].bin'),
0301           ),
0302 
0303           # Replicate sector 1 for volumes outside any detector
0304           cms.PSet(
0305                volumes   = cms.string('1011,1028-1029,1034-1035,1042-1043,1050-1051,1058-1059,1064-1065,1072-1073,1078-1079,'+ # volumes extending from R~7.6 m to to R=9 m,
0306                                       '1098-1101,1130-1137,' + # Forward volumes, ouside CASTOR/HF
0307                                       '1403-1414,1417-1464,' # Volumes beyond |Z|>17.74
0308                                       '2011,2028-2029,2034-2035,2042-2043,2050-2051,2058-2059,2064-2065,2072-2073,2078-2079,'+
0309                                       '2098-2101,2130-2137,'+
0310                                       '2403-2414,2417-2464'),
0311                sectors   = cms.string('0'),
0312                master    = cms.int32(1),
0313                path      = cms.string('s01/grid.[v].bin'),
0314           ),
0315       )
0316   )
0317 
0318 
0319 process.p = cms.Path(process.dumpToDB)
0320     
0321 createMetadata(TAG,"Mag field configuration for map "+TAG)
0322