1 from alternateValidationTemplates
import *
2 from offlineValidationTemplates
import *
3 from geometryComparisonTemplates
import *
4 from monteCarloValidationTemplates
import *
5 from trackSplittingValidationTemplates
import *
6 from zMuMuValidationTemplates
import *
7 from TkAlExceptions
import AllInOneError
20 conditionsTemplate=
"""
21 process.conditionsIn.oO[rcdName]Oo. = CalibTracker.Configuration.Common.PoolDBESSource_cfi.poolDBESSource.clone(
22 connect = cms.string('.oO[connectString]Oo.'),
23 toGet = cms.VPSet(cms.PSet(record = cms.string('.oO[rcdName]Oo.'),
24 tag = cms.string('.oO[tagName]Oo.')
28 process.prefer_conditionsIn.oO[rcdName]Oo. = cms.ESPrefer("PoolDBESSource", "conditionsIn.oO[rcdName]Oo.")
38 source /afs/cern.ch/cms/caf/setup.sh
39 cd .oO[CMSSW_BASE]Oo./src
40 export SCRAM_ARCH=.oO[SCRAM_ARCH]Oo.
42 # rfmkdir -p .oO[workdir]Oo.
43 # rfmkdir -p .oO[datadir]Oo.
45 if [[ $HOSTNAME = lxplus[0-9]*\.cern\.ch ]] # check for interactive mode
47 rfmkdir -p .oO[workdir]Oo.
48 rm -f .oO[workdir]Oo./*
51 mkdir -p $CWD/TkAllInOneTool
52 cd $CWD/TkAllInOneTool
55 # rm -f .oO[workdir]Oo./*
63 echo "List of files in $(pwd):"
70 rfmkdir -p .oO[logdir]Oo. >&! /dev/null
71 gzip -f LOGFILE_*_.oO[name]Oo..log
72 find .oO[workdir]Oo. -maxdepth 1 -name "LOGFILE*.oO[alignmentName]Oo.*" -print | xargs -I {} bash -c "rfcp {} .oO[logdir]Oo."
74 #copy root files to eos
75 cmsMkdir /store/caf/user/$USER/.oO[eosdir]Oo.
76 root_files=$(ls --color=never -d *.oO[alignmentName]Oo.*.root)
79 for file in ${root_files}
81 cmsStage -f ${file} /store/caf/user/$USER/.oO[eosdir]Oo.
86 if [[ $HOSTNAME = lxplus[0-9]*\.cern\.ch ]] # check for interactive mode
88 rm -rf .oO[workdir]Oo.
97 parallelScriptTemplate=
"""
101 #export STAGE_SVCCLASS=cmscafuser
102 #save path to the LSF batch working directory (/pool/lsf)
103 export LSFWORKDIR=$PWD
104 echo LSF working directory is $LSFWORKDIR
105 source /afs/cern.ch/cms/caf/setup.sh
106 # source /afs/cern.ch/cms/sw/cmsset_default.sh
107 cd .oO[CMSSW_BASE]Oo./src
108 # export SCRAM_ARCH=slc5_amd64_gcc462
109 export SCRAM_ARCH=.oO[SCRAM_ARCH]Oo.
110 eval `scramv1 ru -sh`
111 #rfmkdir -p ${LSFWORKDIR}
113 # make rfmkdir silent in case directory already exists
114 rfmkdir -p .oO[datadir]Oo. >&! /dev/null
115 cmsMkdir /store/caf/user/$USER/.oO[eosdir]Oo.
117 #remove possible result file from previous runs
118 previous_results=$(cmsLs -l /store/caf/user/$USER/.oO[eosdir]Oo. | awk '{print $5}')
119 for file in ${previous_results}
121 # if [ ${file} = *.oO[datadir]Oo./*.oO[alignmentName]Oo.*.root ]
122 if [ ${file} = /store/caf/user/$USER/.oO[eosdir]Oo./.oO[outputFile]Oo. ]
124 cmsStage -f ${file} ${file}.bak
128 #rm -f ${LSFWORKDIR}/*
136 echo "List of files in $(pwd):"
143 rfmkdir -p .oO[logdir]Oo. >&! /dev/null
144 gzip LOGFILE_*_.oO[name]Oo..log
145 find ${LSFWORKDIR} -maxdepth 1 -name "LOGFILE*.oO[alignmentName]Oo.*" -print | xargs -I {} bash -c "rfcp {} .oO[logdir]Oo."
147 #copy root files to eos
148 cmsMkdir /store/caf/user/$USER/.oO[eosdir]Oo.
149 root_files=$(ls --color=never -d ${LSFWORKDIR}/*.oO[alignmentName]Oo._.oO[nIndex]Oo.*.root)
152 echo "\${root_files}:"
154 for file in ${root_files}
156 # echo "cmsStage -f ${file} /store/caf/user/$USER/.oO[eosdir]Oo."
157 cmsStage -f ${file} /store/caf/user/$USER/.oO[eosdir]Oo.
161 #cleanup - do not remove workdir, since another parallel job might be running in the same node
162 find ${LSFWORKDIR} -maxdepth 1 -name "*.oO[alignmentName]Oo._.oO[nIndex]Oo.*.root" -print | xargs -I {} bash -c "rm {}"
172 cd .oO[CMSSW_BASE]Oo./src
173 export SCRAM_ARCH=.oO[SCRAM_ARCH]Oo.
174 eval `scramv1 ru -sh`
176 if [[ $HOSTNAME = lxplus[0-9]*\.cern\.ch ]] # check for interactive mode
178 mkdir -p .oO[workdir]Oo.
183 echo "Working directory: $(pwd -P)"
185 ###############################################################################
186 # download root files from eos
187 root_files=$(cmsLs -l /store/caf/user/$USER/.oO[eosdir]Oo. | awk '{print $5}' \
188 | grep ".root$" | grep -v "result.root$")
189 for file in ${root_files}
191 cmsStage -f ${file} .
198 .oO[CompareAlignments]Oo.
200 .oO[RunExtendedOfflineValidation]Oo.
201 .oO[RunTrackSplitPlot]Oo.
203 for file in $(ls -d --color=never *_result.root)
205 cmsStage -f ${file} /store/caf/user/$USER/.oO[eosdir]Oo.
212 #zip stdout and stderr from the farm jobs
214 find . -name "*.stderr" -exec gzip -f {} \;
215 find . -name "*.stdout" -exec gzip -f {} \;
221 compareAlignmentsExecution=
"""
222 #merge for .oO[validationId]Oo.
223 cp .oO[CMSSW_BASE]Oo./src/Alignment/OfflineValidation/scripts/compareAlignments.cc .
224 root -q -b 'compareAlignments.cc++(\".oO[compareStrings]Oo.\")'
225 mv result.root .oO[validationId]Oo._result.root
231 extendedValidationExecution=
"""
232 #run extended offline validation scripts
233 if [[ $HOSTNAME = lxplus[0-9]*\.cern\.ch ]] # check for interactive mode
235 rfmkdir -p .oO[workdir]Oo./ExtendedOfflineValidation_Images
237 mkdir -p ExtendedOfflineValidation_Images
240 rfcp .oO[extendeValScriptPath]Oo. .
241 rfcp .oO[CMSSW_BASE]Oo./src/Alignment/OfflineValidation/macros/PlotAlignmentValidation.C .
242 root -x -b -q TkAlExtendedOfflineValidation.C
243 rfmkdir -p .oO[datadir]Oo./ExtendedOfflineValidation_Images
245 if [[ $HOSTNAME = lxplus[0-9]*\.cern\.ch ]] # check for interactive mode
247 image_files=$(ls --color=never | find .oO[workdir]Oo./ExtendedOfflineValidation_Images/ -name \*ps -o -name \*root)
249 ls .oO[workdir]Oo./ExtendedOfflineValidation_Images
251 image_files=$(ls --color=never | find ExtendedOfflineValidation_Images/ -name \*ps -o -name \*root)
253 ls ExtendedOfflineValidation_Images
256 for image in ${image_files}
258 cp ${image} .oO[datadir]Oo./ExtendedOfflineValidation_Images
265 extendedValidationTemplate=
"""
266 void TkAlExtendedOfflineValidation()
268 // load framework lite just to find the CMSSW libs...
269 gSystem->Load("libFWCoreFWLite");
270 AutoLibraryLoader::enable();
272 gROOT->ProcessLine(".L .oO[CMSSW_BASE]Oo./src/Alignment/OfflineValidation/macros/PlotAlignmentValidation.C++");
273 // gROOT->ProcessLine(".L ./PlotAlignmentValidation.C++");
275 .oO[extendedInstantiation]Oo.
276 p.setOutputDir("./ExtendedOfflineValidation_Images");
277 p.setTreeBaseDir(".oO[OfflineTreeBaseDir]Oo.");
278 p.plotDMR(".oO[DMRMethod]Oo.",.oO[DMRMinimum]Oo.,".oO[DMROptions]Oo.");
279 p.plotSurfaceShapes(".oO[SurfaceShapes]Oo.");
280 p.plotChi2(".oO[resultPlotFile]Oo._result.root");
294 datasetpath = .oO[dataset]Oo.
295 pset = .oO[cfgFile]Oo.
296 total_number_of_.oO[McOrData]Oo.
297 number_of_jobs = .oO[numberOfJobs]Oo.
298 output_file = .oO[outputFile]Oo.
299 runselection = .oO[runRange]Oo.
300 lumi_mask = .oO[JSON]Oo.
305 storage_element = T2_CH_CERN
306 user_remote_dir = .oO[eosdir]Oo.
307 ui_working_dir = .oO[crabWorkingDir]Oo.
308 # script_exe = .oO[script]Oo.
312 queue = .oO[queue]Oo.
329 if not templateName
in globals().
keys():
330 msg =
"unkown template to replace %s"%templateName
332 if not alternateTemplateName
in globals().
keys():
333 msg =
"unkown template to replace %s"%alternateTemplateName
335 globals()[ templateName ] = globals()[ alternateTemplateName ]
def alternateTemplate
### Alternate Templates ###