Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:14:54

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