File indexing completed on 2024-04-06 12:02:53
0001
0002
0003
0004
0005
0006
0007
0008 from __future__ import print_function
0009 from __future__ import absolute_import
0010 import os,sys,getopt
0011
0012
0013 def usage():
0014 print()
0015 print("NAME ")
0016 print(" EcalCondDB - inpect EcalCondDB")
0017 print()
0018 print("SYNOPSIS")
0019 print(" EcalCondDB [options] [command] [command_options]")
0020 print()
0021 print("OPTIONS")
0022 print()
0023 print("Specify short options as '-o foo', long options as '--option=foo'")
0024 print()
0025 print(" -c, --connect= [connectstring]")
0026 print(" specify database, default frontier://FrontierProd/CMS_COND_31X_ECAL")
0027 print()
0028 print(" -P, --authpath= [authenticationpath], default /afs/cern.ch/cms/DB/conddb ")
0029 print()
0030 print("COMMAND OPTIONS")
0031 print()
0032 print(" -t, --tag= [tag,file] specify tag or xml file (histo,compare)")
0033 print()
0034 print(" -s, --since= [runnumber] specify since")
0035
0036 print("COMMANDS")
0037
0038 print(" -l, --listtags list all tags and exit")
0039 print()
0040 print(" -m, --listiovs list iovs for a given tag")
0041 print(" Example EcalCondDB.py -t tag")
0042 print()
0043 print(" -d, --dump= [file] dump record to xml file")
0044 print(" Example EcalCondDB.py -d file.xml -t tag -s since")
0045 print()
0046 print(" -p, --plot= [file] plot record to file, extension specifies ",\
0047 "format (.root,.png,.jpg,.gif,.svg)")
0048 print(" Example: EcalCondDB.py -p=plot.png -t tag -s since")
0049 print()
0050
0051 print(" -q, --compare= [file]")
0052 print(" compare two tags and write histograms to file, extension",\
0053 " specifies format.")
0054 print(" Example:")
0055 print(" EcalCondDB -q=h.root -t tag1 -s since1 -t tag2 -s since2")
0056 print()
0057 print(" -g, --histo= [file] make histograms and write to file")
0058 print(" Example : ")
0059 print(" EcalCondDB -g=h.png -t tag1 -s since1 ")
0060 print()
0061
0062 try:
0063 opts, args = getopt.getopt(sys.argv[1:],
0064 "c:P:t:ld:p:q:g:ms:h",
0065 ["connect=","authpath=","tag=","listtags",\
0066 "dump=","plot=","compare=","histo=","listiovs",\
0067 "since=","help"])
0068
0069 if not len(opts):
0070 usage()
0071 sys.exit(0)
0072
0073 except getopt.GetoptError as ex:
0074 print()
0075 print(ex," , use -h or --help for help")
0076 sys.exit(0)
0077
0078 dbName = "frontier://FrontierProd/CMS_COND_31X_ECAL"
0079 authpath= "/afs/cern.ch/cms/DB/conddb"
0080
0081 tags=[]
0082 sinces=[]
0083
0084
0085
0086 do_list=0
0087 do_liio=0
0088 do_dump=0
0089 do_plot=0
0090 do_comp=0
0091 do_hist=0
0092
0093 outfilename=None
0094
0095
0096 inf="4294967295"
0097
0098 for opt,arg in opts:
0099
0100 if opt in ("-c","--connect"):
0101 dbName=arg
0102
0103 if opt in ("-P","--authpath"):
0104 authpath=arg
0105
0106 if opt in ("-h","--help"):
0107 usage()
0108 sys.exit(0)
0109
0110 if opt in ("-t","--tag"):
0111 tags.append(arg)
0112 if arg.find(".xml")>0 :
0113 print("WARNING : plot from XML is not protected against changes")
0114 print(" in DetId or CondFormats")
0115
0116 if opt in ("-l","--listtags"):
0117 do_list=1
0118
0119 if opt in ("-q","--compare"):
0120 do_comp=1
0121 outfilename=arg
0122
0123 if opt in ("-d","--dump"):
0124 do_dump=1
0125 outfilename=arg
0126
0127 if opt in ("-p","--plot"):
0128 do_plot=1
0129 outfilename=arg
0130
0131 if opt in ("-g","--histo"):
0132 do_hist=1
0133 outfilename=arg
0134
0135 if opt in ("-m","--listiovs"):
0136 do_liio=1
0137
0138 if opt in ("-s","--since"):
0139 sinces.append(arg)
0140
0141
0142
0143
0144
0145
0146 import DLFCN
0147 sys.setdlopenflags(DLFCN.RTLD_GLOBAL+DLFCN.RTLD_LAZY)
0148 from pluginCondDBPyInterface import *
0149
0150 a = FWIncantation()
0151
0152 rdbms = RDBMS(authpath)
0153 db = rdbms.getReadOnlyDB(dbName)
0154
0155 from . import EcalCondTools
0156
0157 if do_list :
0158 EcalCondTools.listTags(db)
0159
0160 if do_dump :
0161 if not len(tags):
0162 print("Must specify tag with -t")
0163 sys.exit(0)
0164 EcalCondTools.dumpXML(db,tags[0],sinces[0],outfilename)
0165
0166 if do_plot:
0167 if not len(tags) or not len (sinces):
0168 print("Must specify tag with -t [tag] -s [since]")
0169 sys.exit(0)
0170 EcalCondTools.plot(db,tags[0],sinces[0],outfilename)
0171
0172 if do_comp:
0173 if len(tags) != 2 :
0174 print("Must give exactly two tags to compare: -t tag1 -t tag2")
0175 sys.exit(0)
0176 if tags[0].find('.xml')<0 and len(sinces)!=2 :
0177 print("Must specify tag, since to compare with -t [tag1] \
0178 -s [since1] -t [tag2] -s [since2] ")
0179 sys.exit(0)
0180
0181 EcalCondTools.compare(tags[0],db,sinces[0],
0182 tags[1],db,sinces[1],outfilename)
0183
0184 if do_hist:
0185 if not len(tags):
0186 print("Must specify tag, since, with -t [tag] \
0187 -s [runsince] (since not needed for xml)")
0188 sys.exit(0)
0189
0190 if tags[0].find('.xml')<0 and not len(sinces) :
0191 print("Must specify tag, since, with -t [tag] \
0192 -s [runsince] ")
0193 sys.exit(0)
0194
0195 EcalCondTools.histo(db,tags[0],sinces[0],outfilename)
0196
0197 if do_liio:
0198 if not len(tags):
0199 print("Must specify tag with -t [tag]")
0200 sys.exit(0)
0201 EcalCondTools.listIovs(db,tags[0])
0202
0203