Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 import os, sys, datetime, shutil, optparse
00025
00026
00027
00028
00029
00030
00031 def mysystem(command,apply=1):
00032 print command
00033 if apply==1: return os.system(command)
00034 elif apply==0: return 0
00035 else:
00036 print '[electronStore.py] UNSUPPORTED ARGUMENT VALUE FOR mysystem(,apply):',apply
00037 exit(1)
00038
00039
00040
00041
00042
00043
00044 class flushfile(object):
00045 def __init__(self,f):
00046 self.f = f
00047 def write(self,x):
00048 self.f.write(x)
00049 self.f.flush()
00050
00051 sys.stdout = flushfile(sys.stdout)
00052
00053
00054
00055
00056
00057
00058 if __name__ == "__main__":
00059
00060
00061
00062
00063
00064
00065 parser = optparse.OptionParser()
00066 parser.add_option("-c", "--cfg", dest="config", action="store", default="electronCompare.txt",
00067 help="the configuration file describe which histogram must be displayed and how")
00068 parser.add_option("-t", "--title", dest="title", action="store", default="",
00069 help="the title of the page")
00070 parser.add_option("-r", "--red-name", dest="red", action="store", default="",
00071 help="short name of the red histograms")
00072 parser.add_option("-b", "--blue-name", dest="blue", action="store", default="",
00073 help="short name of the blue histograms")
00074 (options, args) = parser.parse_args()
00075
00076 if len(args)<2:
00077 print "[electronStore.py] I NEED AT LEAST TWO ARGUMENTS."
00078 exit(2)
00079
00080 red_file = args.pop(0)
00081 web_dir = args.pop()
00082 web_url = web_dir.replace('/afs/cern.ch/cms/','http://cmsdoc.cern.ch/',1)
00083 if len(args)>0 :
00084 blue_file = args.pop(0)
00085 else :
00086 blue_file = ''
00087
00088
00089
00090
00091
00092
00093
00094 print 'WEB DIR =',web_dir
00095 if os.path.exists(web_dir+'/gifs')==False:
00096 os.makedirs(web_dir+'/gifs')
00097
00098
00099 red_base = os.path.basename(red_file)
00100 if os.path.isfile(red_file)==True :
00101 print 'RED FILE =',red_file
00102 if os.path.isfile(red_base)==True and os.path.getmtime(red_base)>os.path.getmtime(red_file) :
00103 print '[electronCompare.py] did you forget to store '+red_base+' ?'
00104 else :
00105 print "[electronCompare.py] FILE NOT FOUND :",red_file
00106 if os.path.isfile(red_base)==True :
00107 print '[electronCompare.py] did you forget to store '+red_base+' ?'
00108 exit(3)
00109
00110
00111 if blue_file!='' :
00112 if os.path.isfile(blue_file)==True :
00113 print 'BLUE FILE =',blue_file
00114 else :
00115 print '[electronCompare.py] file not found :',blue_file
00116 blue_file = ''
00117 else :
00118 print "[electronCompare.py] no blue histograms to compare with."
00119
00120
00121
00122
00123
00124
00125 (red_head,red_tail) = os.path.split(red_file)
00126 red_long_name = os.path.basename(red_head)+'/'+red_tail
00127 (blue_head,blue_tail) = os.path.split(blue_file)
00128 blue_long_name = os.path.basename(blue_head)+'/'+blue_tail
00129 if options.red=='' :
00130 options.red = red_long_name
00131 if options.blue=='' :
00132 options.blue = blue_long_name
00133 if options.title=='' :
00134 options.title = red_long_name+' vs '+blue_long_name
00135
00136
00137
00138
00139
00140
00141 mysystem('cp -f electronCompare.C '+options.config+' '+web_dir)
00142
00143 os.environ['CMP_DIR'] = web_dir
00144 os.environ['CMP_URL'] = web_url
00145 os.environ['CMP_TITLE'] = options.title
00146 os.environ['CMP_RED_FILE'] = red_file
00147 os.environ['CMP_BLUE_FILE'] = blue_file
00148 os.environ['CMP_RED_NAME'] = options.red
00149 os.environ['CMP_BLUE_NAME'] = options.blue
00150 os.environ['CMP_RED_COMMENT'] = red_file+'.comment'
00151 os.environ['CMP_BLUE_COMMENT'] = blue_file+'.comment'
00152 os.environ['CMP_CONFIG'] = options.config
00153
00154 mysystem('root -b -l -q electronCompare.C')
00155
00156 print "You can access the files here:",web_dir
00157 print "You can browse your validation plots here:",web_url+'/'