File indexing completed on 2023-03-17 10:57:44
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024 from __future__ import print_function
0025 import os, sys, datetime, shutil, optparse
0026
0027
0028
0029
0030
0031
0032 def mysystem(command,apply=1):
0033 print(command)
0034 if apply==1: return os.system(command)
0035 elif apply==0: return 0
0036 else:
0037 print('[electronStore.py] UNSUPPORTED ARGUMENT VALUE FOR mysystem(,apply):',apply)
0038 exit(1)
0039
0040
0041
0042
0043
0044
0045 class flushfile(object):
0046 def __init__(self,f):
0047 self.f = f
0048 def write(self,x):
0049 self.f.write(x)
0050 self.f.flush()
0051
0052 sys.stdout = flushfile(sys.stdout)
0053
0054
0055
0056
0057
0058
0059 if __name__ == "__main__":
0060
0061
0062
0063
0064
0065
0066 parser = optparse.OptionParser()
0067 parser.add_option("-c", "--cfg", dest="config", action="store", default="electronCompare.txt",
0068 help="the configuration file describe which histogram must be displayed and how")
0069 parser.add_option("-t", "--title", dest="title", action="store", default="",
0070 help="the title of the page")
0071 parser.add_option("-r", "--red-name", dest="red", action="store", default="",
0072 help="short name of the red histograms")
0073 parser.add_option("-b", "--blue-name", dest="blue", action="store", default="",
0074 help="short name of the blue histograms")
0075 (options, args) = parser.parse_args()
0076
0077 if len(args)<2:
0078 print("[electronStore.py] I NEED AT LEAST TWO ARGUMENTS.")
0079 exit(2)
0080
0081 red_file = args.pop(0)
0082 web_dir = args.pop()
0083
0084 if not '/afs/cern.ch/cms/' in web_dir:
0085 print("local : ", web_dir)
0086 web_url = web_dir
0087 else:
0088 web_url = web_dir.replace('/afs/cern.ch/cms/','http://cmsdoc.cern.ch/',1)
0089 if len(args)>0 :
0090 blue_file = args.pop(0)
0091 else :
0092 blue_file = ''
0093
0094
0095
0096
0097
0098
0099
0100 if os.path.exists(web_dir+'/gifs')==False:
0101 os.makedirs(web_dir+'/gifs')
0102
0103
0104 red_base = os.path.basename(red_file)
0105 if os.path.isfile(red_file)==True :
0106 print('RED FILE =',red_file)
0107 if os.path.isfile(red_base)==True and os.path.getmtime(red_base)>os.path.getmtime(red_file) :
0108 print('[electronCompare.py] did you forget to store '+red_base+' ?')
0109 else :
0110 print("[electronCompare.py] FILE NOT FOUND :",red_file)
0111 if os.path.isfile(red_base)==True :
0112 print('[electronCompare.py] did you forget to store '+red_base+' ?')
0113 exit(3)
0114
0115
0116 if blue_file!='' :
0117 if os.path.isfile(blue_file)==True :
0118 print('BLUE FILE =',blue_file)
0119 else :
0120 print('[electronCompare.py] file not found :',blue_file)
0121 blue_file = ''
0122 else :
0123 print("[electronCompare.py] no blue histograms to compare with.")
0124
0125
0126
0127
0128
0129
0130 (red_head,red_tail) = os.path.split(red_file)
0131 red_long_name = os.path.basename(red_head)+'/'+red_tail
0132 (blue_head,blue_tail) = os.path.split(blue_file)
0133 blue_long_name = os.path.basename(blue_head)+'/'+blue_tail
0134 if options.red=='' :
0135 options.red = red_long_name
0136 if options.blue=='' :
0137 options.blue = blue_long_name
0138 if options.title=='' :
0139 options.title = red_long_name+' vs '+blue_long_name
0140
0141 (red_hd, red_release) = os.path.split(red_head)
0142 (blue_hd, blue_release) = os.path.split(blue_head)
0143
0144
0145
0146
0147
0148 mysystem('cp -f electronCompare.C '+options.config+' '+web_dir)
0149
0150 os.environ['CMP_DIR'] = web_dir
0151 os.environ['CMP_URL'] = web_url
0152 os.environ['CMP_TITLE'] = options.title
0153 os.environ['CMP_RED_FILE'] = red_file
0154 os.environ['CMP_BLUE_FILE'] = blue_file
0155 os.environ['CMP_RED_NAME'] = options.red
0156 os.environ['CMP_BLUE_NAME'] = options.blue
0157 os.environ['CMP_RED_COMMENT'] = red_file+'.comment'
0158 os.environ['CMP_BLUE_COMMENT'] = blue_file+'.comment'
0159 os.environ['CMP_CONFIG'] = options.config
0160 os.environ['CMP_RED_RELEASE'] = red_release
0161 os.environ['CMP_BLUE_RELEASE'] = blue_release
0162
0163 mysystem('root -b -l -q electronCompare.C')
0164
0165 print("You can access the files here:",web_dir)
0166 print("You can browse your validation plots here:",web_url+'/')