CMS 3D CMS Logo

configTemplates.py
Go to the documentation of this file.
1 from alternateValidationTemplates import *
2 from offlineValidationTemplates import *
3 from primaryVertexValidationTemplates import *
4 from geometryComparisonTemplates import *
5 from monteCarloValidationTemplates import *
6 from trackSplittingValidationTemplates import *
7 from zMuMuValidationTemplates import *
8 from TkAlExceptions import AllInOneError
9 
10 ######################################################################
11 ######################################################################
12 ### ###
13 ### General Templates ###
14 ### ###
15 ######################################################################
16 ######################################################################
17 
18 ######################################################################
19 ######################################################################
20 loadGlobalTagTemplate="""
21 #Global tag
22 process.load("Configuration.StandardSequences.FrontierConditions_GlobalTag_cff")
23 from Configuration.AlCa.GlobalTag import GlobalTag
24 process.GlobalTag = GlobalTag(process.GlobalTag,".oO[GlobalTag]Oo.")
25 """
26 
27 
28 ######################################################################
29 ######################################################################
30 conditionsTemplate="""
31 process.conditionsIn.oO[rcdName]Oo. = CalibTracker.Configuration.Common.PoolDBESSource_cfi.poolDBESSource.clone(
32  connect = cms.string('.oO[connectString]Oo.'),
33  toGet = cms.VPSet(cms.PSet(record = cms.string('.oO[rcdName]Oo.'),
34  tag = cms.string('.oO[tagName]Oo.')
35  )
36  )
37  )
38 process.prefer_conditionsIn.oO[rcdName]Oo. = cms.ESPrefer("PoolDBESSource", "conditionsIn.oO[rcdName]Oo.")
39 """
40 
41 
42 ######################################################################
43 ######################################################################
44 #batch job execution
45 scriptTemplate="""
46 #!/bin/bash
47 #init
48 #ulimit -v 3072000
49 #export STAGE_SVCCLASS=cmscafuser
50 #save path to the LSF batch working directory (/pool/lsf)
51 
52 export LSFWORKDIR=`pwd -P`
53 echo LSF working directory is $LSFWORKDIR
54 source /afs/cern.ch/cms/caf/setup.sh
55 eos='/afs/cern.ch/project/eos/installation/cms/bin/eos.select'
56 cd .oO[CMSSW_BASE]Oo./src
57 export SCRAM_ARCH=.oO[SCRAM_ARCH]Oo.
58 eval `scramv1 ru -sh`
59 #rfmkdir -p .oO[datadir]Oo. &>! /dev/null
60 
61 #remove possible result file from previous runs
62 previous_results=$($eos ls /store/caf/user/$USER/.oO[eosdir]Oo.)
63 for file in ${previous_results}
64 do
65  if [ ${file} = /store/caf/user/$USER/.oO[eosdir]Oo./.oO[outputFile]Oo. ]
66  then
67  xrdcp -f root://eoscms//eos/cms${file} root://eoscms//eos/cms${file}.bak
68  fi
69 done
70 
71 if [[ $HOSTNAME = lxplus[0-9]*\.cern\.ch ]] # check for interactive mode
72 then
73  rfmkdir -p .oO[workdir]Oo.
74  rm -f .oO[workdir]Oo./*
75  cd .oO[workdir]Oo.
76 else
77  mkdir -p $LSFWORKDIR/TkAllInOneTool
78  cd $LSFWORKDIR/TkAllInOneTool
79 fi
80 
81 # rm -f .oO[workdir]Oo./*
82 # cd .oO[workdir]Oo.
83 
84 #run
85 pwd
86 df -h .
87 .oO[CommandLine]Oo.
88 echo "----"
89 echo "List of files in $(pwd):"
90 ls -ltr
91 echo "----"
92 echo ""
93 
94 
95 #retrieve
96 rfmkdir -p .oO[logdir]Oo. >&! /dev/null
97 gzip -f LOGFILE_*_.oO[name]Oo..log
98 find . -maxdepth 1 -name "LOGFILE*.oO[alignmentName]Oo.*" -print | xargs -I {} bash -c "rfcp {} .oO[logdir]Oo."
99 
100 #copy root files to eos
101 $eos mkdir -p /store/caf/user/$USER/.oO[eosdir]Oo.
102 if [ .oO[parallelJobs]Oo. -eq 1 ]
103 then
104  root_files=$(ls --color=never -d *.oO[alignmentName]Oo.*.root)
105 else
106  root_files=$(ls --color=never -d *.oO[alignmentName]Oo._.oO[nIndex]Oo.*.root)
107 fi
108 echo ${root_files}
109 
110 for file in ${root_files}
111 do
112  xrdcp -f ${file} root://eoscms//eos/cms/store/caf/user/$USER/.oO[eosdir]Oo.
113  echo ${file}
114 done
115 
116 #cleanup
117 if [[ $HOSTNAME = lxplus[0-9]*\.cern\.ch ]] # check for interactive mode
118 then
119  rm -rf .oO[workdir]Oo.
120 fi
121 echo "done."
122 """
123 
124 
125 ######################################################################
126 ######################################################################
127 mergeTemplate="""
128 #!/bin/bash
129 eos='/afs/cern.ch/project/eos/installation/cms/bin/eos.select'
130 CWD=`pwd -P`
131 cd .oO[CMSSW_BASE]Oo./src
132 export SCRAM_ARCH=.oO[SCRAM_ARCH]Oo.
133 eval `scramv1 ru -sh`
134 
135 #create results-directory and copy used configuration there
136 rfmkdir -p .oO[datadir]Oo.
137 rfcp .oO[logdir]Oo./usedConfiguration.ini .oO[datadir]Oo.
138 
139 if [[ $HOSTNAME = lxplus[0-9]*\.cern\.ch ]] # check for interactive mode
140 then
141  mkdir -p .oO[workdir]Oo.
142  cd .oO[workdir]Oo.
143 else
144  cd $CWD
145 fi
146 echo "Working directory: $(pwd -P)"
147 
148 ###############################################################################
149 # download root files from eos
150 root_files=$($eos ls /store/caf/user/$USER/.oO[eosdir]Oo. \
151  | grep ".root$" | grep -v "result.root$")
152 #for file in ${root_files}
153 #do
154 # xrdcp -f root://eoscms//eos/cms/store/caf/user/$USER/.oO[eosdir]Oo./${file} .
155 # echo ${file}
156 #done
157 
158 
159 #run
160 .oO[DownloadData]Oo.
161 .oO[CompareAlignments]Oo.
162 
163 .oO[RunExtendedOfflineValidation]Oo.
164 .oO[RunTrackSplitPlot]Oo.
165 .oO[MergeZmumuPlots]Oo.
166 .oO[RunPrimaryVertexPlot]Oo.
167 
168 # clean-up
169 # ls -l *.root
170 rm -f *.root
171 
172 #zip stdout and stderr from the farm jobs
173 cd .oO[logdir]Oo.
174 find . -name "*.stderr" -exec gzip -f {} \;
175 find . -name "*.stdout" -exec gzip -f {} \;
176 """
177 
178 
179 ######################################################################
180 ######################################################################
181 mergeParallelResults="""
182 
183 .oO[copyMergeScripts]Oo.
184 .oO[haddLoop]Oo.
185 
186 # create log file
187 ls -al .oO[mergeParallelFilePrefixes]Oo. > .oO[datadir]Oo./log_rootfilelist.txt
188 
189 # Remove parallel job files
190 .oO[rmUnmerged]Oo.
191 """
192 
193 
194 ######################################################################
195 ######################################################################
196 compareAlignmentsExecution="""
197 #merge for .oO[validationId]Oo. if it does not exist or is not up-to-date
198 echo -e "\n\nComparing validations"
199 $eos mkdir -p /store/caf/user/$USER/.oO[eosdir]Oo./
200 cp .oO[Alignment/OfflineValidation]Oo./scripts/compareFileAges.C .
201 root -x -q -b -l "compareFileAges.C(\\\"root://eoscms.cern.ch//eos/cms/store/caf/user/$USER/.oO[eosdir]Oo./.oO[validationId]Oo._result.root\\\", \\\".oO[compareStringsPlain]Oo.\\\")"
202 comparisonNeeded=${?}
203 
204 if [[ ${comparisonNeeded} -eq 1 ]]
205 then
206  cp .oO[Alignment/OfflineValidation]Oo./scripts/compareAlignments.cc .
207  root -x -q -b -l 'compareAlignments.cc++(\".oO[compareStrings]Oo.\", ".oO[legendheader]Oo.", ".oO[customtitle]Oo.", ".oO[customrighttitle]Oo.", .oO[bigtext]Oo.)'
208  mv result.root .oO[validationId]Oo._result.root
209  xrdcp -f .oO[validationId]Oo._result.root root://eoscms//eos/cms/store/caf/user/$USER/.oO[eosdir]Oo.
210 else
211  echo ".oO[validationId]Oo._result.root is up-to-date, no need to compare again."
212  xrdcp -f root://eoscms//eos/cms/store/caf/user/$USER/.oO[eosdir]Oo./.oO[validationId]Oo._result.root .
213 fi
214 """
215 
216 
217 ######################################################################
218 ######################################################################
219 crabCfgTemplate="""
220 [CRAB]
221 jobtype = cmssw
222 scheduler = caf
223 use_server = 0
224 
225 [CMSSW]
226 datasetpath = .oO[dataset]Oo.
227 pset = .oO[cfgFile]Oo.
228 total_number_of_.oO[McOrData]Oo.
229 number_of_jobs = .oO[numberOfJobs]Oo.
230 output_file = .oO[outputFile]Oo.
231 runselection = .oO[runRange]Oo.
232 lumi_mask = .oO[JSON]Oo.
233 
234 [USER]
235 return_data = 0
236 copy_data = 1
237 storage_element = T2_CH_CERN
238 user_remote_dir = .oO[eosdir]Oo.
239 ui_working_dir = .oO[crabWorkingDir]Oo.
240 # script_exe = .oO[script]Oo.
241 # .oO[email]Oo.
242 
243 [CAF]
244 queue = .oO[queue]Oo.
245 """
246 
247 
248 
249 
250 ######################################################################
251 ######################################################################
252 ### ###
253 ### Alternate Templates ###
254 ### ###
255 ######################################################################
256 ######################################################################
257 
258 
259 def alternateTemplate( templateName, alternateTemplateName ):
260 
261  if not templateName in globals().keys():
262  msg = "unknown template to replace %s"%templateName
263  raise AllInOneError(msg)
264  if not alternateTemplateName in globals().keys():
265  msg = "unknown template to replace %s"%alternateTemplateName
266  raise AllInOneError(msg)
267  globals()[ templateName ] = globals()[ alternateTemplateName ]
268  # = eval("configTemplates.%s"%"alternateTemplate")
def alternateTemplate(templateName, alternateTemplateName)
Alternate Templates ###