24 from __future__
import print_function
25 import os, sys, datetime, shutil, optparse
34 if apply==1:
return os.system(command)
35 elif apply==0:
return 0
37 print(
'[electronStore.py] UNSUPPORTED ARGUMENT VALUE FOR mysystem(,apply):',apply)
59 if __name__ ==
"__main__":
66 parser = optparse.OptionParser()
67 parser.add_option(
"-c",
"--cfg", dest=
"config", action=
"store", default=
"electronCompare.txt",
68 help=
"the configuration file describe which histogram must be displayed and how")
69 parser.add_option(
"-t",
"--title", dest=
"title", action=
"store", default=
"",
70 help=
"the title of the page")
71 parser.add_option(
"-r",
"--red-name", dest=
"red", action=
"store", default=
"",
72 help=
"short name of the red histograms")
73 parser.add_option(
"-b",
"--blue-name", dest=
"blue", action=
"store", default=
"",
74 help=
"short name of the blue histograms")
75 (options, args) = parser.parse_args()
78 print(
"[electronStore.py] I NEED AT LEAST TWO ARGUMENTS.")
81 red_file = args.pop(0)
84 if not '/afs/cern.ch/cms/' in web_dir:
85 print(
"local : ", web_dir)
88 web_url = web_dir.replace(
'/afs/cern.ch/cms/',
'http://cmsdoc.cern.ch/',1)
90 blue_file = args.pop(0)
100 if os.path.exists(web_dir+
'/gifs')==
False:
101 os.makedirs(web_dir+
'/gifs')
104 red_base = os.path.basename(red_file)
105 if os.path.isfile(red_file)==
True :
106 print(
'RED FILE =',red_file)
107 if os.path.isfile(red_base)==
True and os.path.getmtime(red_base)>os.path.getmtime(red_file) :
108 print(
'[electronCompare.py] did you forget to store '+red_base+
' ?')
110 print(
"[electronCompare.py] FILE NOT FOUND :",red_file)
111 if os.path.isfile(red_base)==
True :
112 print(
'[electronCompare.py] did you forget to store '+red_base+
' ?')
117 if os.path.isfile(blue_file)==
True :
118 print(
'BLUE FILE =',blue_file)
120 print(
'[electronCompare.py] file not found :',blue_file)
123 print(
"[electronCompare.py] no blue histograms to compare with.")
130 (red_head,red_tail) = os.path.split(red_file)
131 red_long_name = os.path.basename(red_head)+
'/'+red_tail
132 (blue_head,blue_tail) = os.path.split(blue_file)
133 blue_long_name = os.path.basename(blue_head)+
'/'+blue_tail
135 options.red = red_long_name
136 if options.blue==
'' :
137 options.blue = blue_long_name
138 if options.title==
'' :
139 options.title = red_long_name+
' vs '+blue_long_name
141 (red_hd, red_release) = os.path.split(red_head)
142 (blue_hd, blue_release) = os.path.split(blue_head)
148 mysystem(
'cp -f electronCompare.C '+options.config+
' '+web_dir)
150 os.environ[
'CMP_DIR'] = web_dir
151 os.environ[
'CMP_URL'] = web_url
152 os.environ[
'CMP_TITLE'] = options.title
153 os.environ[
'CMP_RED_FILE'] = red_file
154 os.environ[
'CMP_BLUE_FILE'] = blue_file
155 os.environ[
'CMP_RED_NAME'] = options.red
156 os.environ[
'CMP_BLUE_NAME'] = options.blue
157 os.environ[
'CMP_RED_COMMENT'] = red_file+
'.comment' 158 os.environ[
'CMP_BLUE_COMMENT'] = blue_file+
'.comment' 159 os.environ[
'CMP_CONFIG'] = options.config
160 os.environ[
'CMP_RED_RELEASE'] = red_release
161 os.environ[
'CMP_BLUE_RELEASE'] = blue_release
163 mysystem(
'root -b -l -q electronCompare.C')
165 print(
"You can access the files here:",web_dir)
166 print(
"You can browse your validation plots here:",web_url+
'/')
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
def mysystem(command, apply=1)