Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-11-25 02:29:11

0001 #!/usr/bin/env python
0002 # -*- coding: utf-8 -*-
0003 
0004 # This script creates all the tags required in the "tagList"
0005 # The tagList needs: tag name, tag type (e.g. Ideal, StartUp, ...) and possible additional
0006 # sed commands where the " are escaped as \".
0007 
0008 import os
0009 import sys
0010 
0011 class Tag:
0012     """Holds all the information about a tag"""
0013     def __init__(self, inputTagName, inputTagType, inputReplaceStrings = "", inputRcdName = ""):
0014         self.tagName = inputTagName
0015         self.tagType = inputTagType
0016         self.replaceStrings = inputReplaceStrings
0017         if( inputRcdName == "" ):
0018             self.rcdName = inputTagName+"Rcd"
0019         else:
0020             self.rcdName = inputRcdName
0021 
0022 # Function actually performing all the system actions and running the cmssw job
0023 def systemActions(tag, actionType):
0024     fileName = "DummyCondDB"+actionType+"_"+tag.tagName+"_cfg.py"
0025     os.system("cat "+fileName+" | sed -e \"s@"+oldDest+"@"+newDest+"@\" -e \"s@Ideal_"+oldTag+"@"+tag.tagType+"_"+newTag+"@\" "+tag.replaceStrings+" > DummyCondDB"+actionType+"_tmp_cfg.py")
0026     returnValue = os.system("cmsRun DummyCondDB"+actionType+"_tmp_cfg.py")
0027     # For some jobs it outputs: exit code = 65.
0028     # From here https://twiki.cern.ch/twiki/bin/view/CMS/JobExitCodes
0029     # you see that 65: End of job from user application (CMSSW)
0030     # returnValue = 0
0031     signal = returnValue & 0xFF
0032     exitCode = (returnValue >> 8) & 0xFF
0033     if( exitCode == 65 ):
0034         print("Exit code = 65")
0035     if( exitCode != 0 and exitCode != 65 ):
0036         print("Error: return value = ", returnValue)
0037         print("signal = ", end=' ')
0038         print(signal, end=' ')
0039         print("exit code = ", end=' ')
0040         print(exitCode)
0041         os.system("cat "+fileName)
0042         sys.exit()
0043 
0044 
0045 # Function used to create the tags
0046 def createAllTags(tagList, actionType="Writer"):
0047     # Loop on all the tags in the tagList and fill the destination
0048     for tag in tagList:
0049         print("--------------------------------------------------")
0050         print("Creating tag "+tag.tagName+" of type "+tag.tagType, end=' ')
0051         if( tag.replaceStrings != "" ):
0052             print("with additional options: "+tag.replaceStrings)
0053         else:
0054             print()
0055         print("--------------------------------------------------")
0056         systemActions(tag, "Writer")
0057 
0058 
0059 # Function used to read all the tags and create a summary
0060 def readAllTags(tagList):
0061     # Read all the tags and write a summary
0062     for tag in tagList:
0063         print("--------------------------------------------------")
0064         print("Reading tag"+tag.tagName+" of type "+tag.tagType)
0065         print("--------------------------------------------------")
0066         # Use the additional replaces to change the log name
0067         os.system("cat DummyCondDBReaderTemplate_cfg.py | sed -e \"s@TAGNAME@"+tag.tagName+"@\" -e \"s@RCDNAME@"+tag.rcdName+"@\" > DummyCondDBReader_"+tag.tagName+"_cfg.py")
0068         tag.replaceStrings = "-e \"s@Ideal.log@"+tag.tagType+"@\""
0069         systemActions(tag, "Reader")
0070 
0071 
0072 
0073 
0074 # Settings
0075 # --------
0076 oldDest="sqlite_file:dbfile.db"
0077 newDest="sqlite_file:dbfile.db"
0078 # newDest="oracle://cms_orcoff_prep/CMS_COND_STRIP"
0079 
0080 oldTag = "31X"
0081 newTag = "31X"
0082 
0083 
0084 # Define the list of tags to create
0085 # Additional commands must have the " character escaped as \"
0086 # The fourth field is used to specify the rcd name for the DummyPrinter in case it is different from the tag name
0087 tagList = [
0088     # ApvGain
0089     Tag("SiStripApvGain", "Ideal"),
0090     Tag("SiStripApvGain", "IdealSim"),
0091     Tag("SiStripApvGain", "StartUp", "-e \"s@SigmaGain=0.0@SigmaGain=0.10@\" -e \"s@default@gaussian@\""),
0092     # Thresholds
0093     Tag("SiStripThreshold", "Ideal"),
0094     Tag("SiStripClusterThreshold", "Ideal", "", "SiStripThresholdRcd"),
0095     # BadComponents (note that the record name is SiStripBadStrip, NOT SiStripBadStripRcd
0096     Tag("SiStripBadChannel", "Ideal"),
0097     Tag("SiStripBadFiber", "Ideal"),
0098     Tag("SiStripBadModule", "Ideal"),
0099     # FedCabling
0100     Tag("SiStripFedCabling", "Ideal"),
0101     # LorentzAngle
0102     Tag("SiStripLorentzAngle", "Ideal"),
0103     Tag("SiStripLorentzAngle", "IdealSim"),
0104     Tag("SiStripLorentzAngle", "StartUp", "-e \"s@TIB_PerCent_Errs       = cms.vdouble(0.,    0.,    0.,    0.)@TIB_PerCent_Errs=cms.vdouble(20.,20.,20.,20.)@\" -e \"s@TOB_PerCent_Errs       = cms.vdouble(0.,    0.,    0.,    0.,    0.,    0.)@TOB_PerCent_Errs=cms.vdouble(20.,20.,20.,20.,20.,20.)@\""),
0105     # Voltages from DCS
0106     Tag("SiStripDetVOff", "Ideal"),
0107     # Noise
0108     Tag("SiStripNoises_DecMode", "Ideal", "", "SiStripNoisesRcd"),
0109     Tag("SiStripNoises_PeakMode", "Ideal", "", "SiStripNoisesRcd"),
0110     # Pedestals
0111     Tag("SiStripPedestals", "Ideal"),
0112     # Latency
0113     Tag("SiStripLatency", "Ideal"),
0114     # BaseDelay
0115     Tag("SiStripBaseDelay", "Ideal"),
0116     # Configuration object
0117     Tag("SiStripConfObject", "Ideal")
0118     ]
0119 
0120 # Create the tables in the destination db (for now hardcoded sqlite_file for safety)
0121 # os.system("rm dbfile.db")
0122 # os.system("$CMSSW_RELEASE_BASE/src/CondTools/SiStrip/scripts/CreatingTables.sh sqlite_file:dbfile.db a a")
0123 
0124 createAllTags(tagList)
0125 
0126 readAllTags(tagList)
0127