24 import os, sys, datetime, shutil, optparse
33 if apply==1:
return os.system(command)
34 elif apply==0:
return 0
36 print '[electronStore.py] UNSUPPORTED ARGUMENT VALUE FOR mysystem(,apply):',apply
58 if __name__ ==
"__main__":
65 parser = optparse.OptionParser()
66 parser.add_option(
"-c",
"--cfg", dest=
"config", action=
"store", default=
"electronCompare.txt",
67 help=
"the configuration file describe which histogram must be displayed and how")
68 parser.add_option(
"-t",
"--title", dest=
"title", action=
"store", default=
"",
69 help=
"the title of the page")
70 parser.add_option(
"-r",
"--red-name", dest=
"red", action=
"store", default=
"",
71 help=
"short name of the red histograms")
72 parser.add_option(
"-b",
"--blue-name", dest=
"blue", action=
"store", default=
"",
73 help=
"short name of the blue histograms")
74 (options, args) = parser.parse_args()
77 print "[electronStore.py] I NEED AT LEAST TWO ARGUMENTS."
80 red_file = args.pop(0)
82 web_url = web_dir.replace(
'/afs/cern.ch/cms/',
'http://cmsdoc.cern.ch/',1)
84 blue_file = args.pop(0)
94 print 'WEB DIR =',web_dir
95 if os.path.exists(web_dir+
'/gifs')==
False:
96 os.makedirs(web_dir+
'/gifs')
99 red_base = os.path.basename(red_file)
100 if os.path.isfile(red_file)==
True :
101 print 'RED FILE =',red_file
102 if os.path.isfile(red_base)==
True and os.path.getmtime(red_base)>os.path.getmtime(red_file) :
103 print '[electronCompare.py] did you forget to store '+red_base+
' ?'
105 print "[electronCompare.py] FILE NOT FOUND :",red_file
106 if os.path.isfile(red_base)==
True :
107 print '[electronCompare.py] did you forget to store '+red_base+
' ?'
112 if os.path.isfile(blue_file)==
True :
113 print 'BLUE FILE =',blue_file
115 print '[electronCompare.py] file not found :',blue_file
118 print "[electronCompare.py] no blue histograms to compare with."
125 (red_head,red_tail) = os.path.split(red_file)
126 red_long_name = os.path.basename(red_head)+
'/'+red_tail
127 (blue_head,blue_tail) = os.path.split(blue_file)
128 blue_long_name = os.path.basename(blue_head)+
'/'+blue_tail
130 options.red = red_long_name
131 if options.blue==
'' :
132 options.blue = blue_long_name
133 if options.title==
'' :
134 options.title = red_long_name+
' vs '+blue_long_name
141 mysystem(
'cp -f electronCompare.C '+options.config+
' '+web_dir)
143 os.environ[
'CMP_DIR'] = web_dir
144 os.environ[
'CMP_URL'] = web_url
145 os.environ[
'CMP_TITLE'] = options.title
146 os.environ[
'CMP_RED_FILE'] = red_file
147 os.environ[
'CMP_BLUE_FILE'] = blue_file
148 os.environ[
'CMP_RED_NAME'] = options.red
149 os.environ[
'CMP_BLUE_NAME'] = options.blue
150 os.environ[
'CMP_RED_COMMENT'] = red_file+
'.comment'
151 os.environ[
'CMP_BLUE_COMMENT'] = blue_file+
'.comment'
152 os.environ[
'CMP_CONFIG'] = options.config
154 mysystem(
'root -b -l -q electronCompare.C')
156 print "You can access the files here:",web_dir
157 print "You can browse your validation plots here:",web_url+
'/'