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.")
39 #export STAGE_SVCCLASS=cmscafuser
40 #save path to the LSF batch working directory (/pool/lsf)
41 export LSFWORKDIR=`pwd -P`
42 echo LSF working directory is $LSFWORKDIR
43 source /afs/cern.ch/cms/caf/setup.sh
44 cd .oO[CMSSW_BASE]Oo./src
45 export SCRAM_ARCH=.oO[SCRAM_ARCH]Oo.
47 rfmkdir -p .oO[datadir]Oo. &>! /dev/null
49 #remove possible result file from previous runs
50 previous_results=$(cmsLs -l /store/caf/user/$USER/.oO[eosdir]Oo. | awk '{print $5}')
51 for file in ${previous_results}
53 if [ ${file} = /store/caf/user/$USER/.oO[eosdir]Oo./.oO[outputFile]Oo. ]
55 cmsStage -f ${file} ${file}.bak
59 if [[ $HOSTNAME = lxplus[0-9]*\.cern\.ch ]] # check for interactive mode
61 rfmkdir -p .oO[workdir]Oo.
62 rm -f .oO[workdir]Oo./*
65 mkdir -p $LSFWORKDIR/TkAllInOneTool
66 cd $LSFWORKDIR/TkAllInOneTool
69 # rm -f .oO[workdir]Oo./*
77 echo "List of files in $(pwd):"
84 rfmkdir -p .oO[logdir]Oo. >&! /dev/null
85 gzip -f LOGFILE_*_.oO[name]Oo..log
86 find . -maxdepth 1 -name "LOGFILE*.oO[alignmentName]Oo.*" -print | xargs -I {} bash -c "rfcp {} .oO[logdir]Oo."
88 #copy root files to eos
89 cmsMkdir /store/caf/user/$USER/.oO[eosdir]Oo.
90 if [ .oO[parallelJobs]Oo. -eq 1 ]
92 root_files=$(ls --color=never -d *.oO[alignmentName]Oo.*.root)
94 root_files=$(ls --color=never -d *.oO[alignmentName]Oo._.oO[nIndex]Oo.*.root)
98 for file in ${root_files}
100 cmsStage -f ${file} /store/caf/user/$USER/.oO[eosdir]Oo.
105 if [[ $HOSTNAME = lxplus[0-9]*\.cern\.ch ]] # check for interactive mode
107 rm -rf .oO[workdir]Oo.
118 cd .oO[CMSSW_BASE]Oo./src
119 export SCRAM_ARCH=.oO[SCRAM_ARCH]Oo.
120 eval `scramv1 ru -sh`
122 #create results-directory and copy used configuration there
123 rfmkdir -p .oO[datadir]Oo.
124 rfcp .oO[logdir]Oo./usedConfiguration.ini .oO[datadir]Oo.
126 if [[ $HOSTNAME = lxplus[0-9]*\.cern\.ch ]] # check for interactive mode
128 mkdir -p .oO[workdir]Oo.
133 echo "Working directory: $(pwd -P)"
135 ###############################################################################
136 # download root files from eos
137 root_files=$(cmsLs -l /store/caf/user/$USER/.oO[eosdir]Oo. | awk '{print $5}' \
138 | grep ".root$" | grep -v "result.root$")
139 for file in ${root_files}
141 cmsStage -f ${file} .
148 .oO[CompareAlignments]Oo.
150 .oO[RunExtendedOfflineValidation]Oo.
151 .oO[RunTrackSplitPlot]Oo.
157 #zip stdout and stderr from the farm jobs
159 find . -name "*.stderr" -exec gzip -f {} \;
160 find . -name "*.stdout" -exec gzip -f {} \;
166 mergeParallelResults=
"""
168 #set directory to which TkAlOfflineJobsMerge.C saves the merged file
169 # export OUTPUTDIR=.oO[datadir]Oo.
171 .oO[copyMergeScripts]Oo.
175 ls -al .oO[mergeParallelFilePrefixes]Oo. > .oO[datadir]Oo./log_rootfilelist.txt
177 # Remove parallel job files
184 compareAlignmentsExecution=
"""
185 #merge for .oO[validationId]Oo. if it does not exist or is not up-to-date
186 echo -e "\n\nComparing validations"
187 cp .oO[CMSSW_BASE]Oo./src/Alignment/OfflineValidation/scripts/compareFileAges.C .
188 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.\\\")"
189 comparisonNeeded=${?}
191 if [[ ${comparisonNeeded} -eq 1 ]]
193 cp .oO[CMSSW_BASE]Oo./src/Alignment/OfflineValidation/scripts/compareAlignments.cc .
194 root -x -q -b -l 'compareAlignments.cc++(\".oO[compareStrings]Oo.\")'
195 mv result.root .oO[validationId]Oo._result.root
196 cmsStage -f .oO[validationId]Oo._result.root /store/caf/user/$USER/.oO[eosdir]Oo.
198 echo ".oO[validationId]Oo._result.root is up-to-date, no need to compare again."
199 cmsStage -f /store/caf/user/$USER/.oO[eosdir]Oo./.oO[validationId]Oo._result.root .
206 extendedValidationExecution=
"""
207 #run extended offline validation scripts
208 echo -e "\n\nRunning extended offline validation"
209 if [[ $HOSTNAME = lxplus[0-9]*\.cern\.ch ]] # check for interactive mode
211 rfmkdir -p .oO[workdir]Oo./ExtendedOfflineValidation_Images
213 mkdir -p ExtendedOfflineValidation_Images
216 rfcp .oO[extendedValScriptPath]Oo. .
217 rfcp .oO[CMSSW_BASE]Oo./src/Alignment/OfflineValidation/macros/PlotAlignmentValidation.C .
218 root -x -b -q -l TkAlExtendedOfflineValidation.C
219 rfmkdir -p .oO[datadir]Oo./ExtendedOfflineValidation_Images
221 if [[ $HOSTNAME = lxplus[0-9]*\.cern\.ch ]] # check for interactive mode
223 image_files=$(ls --color=never | find .oO[workdir]Oo./ExtendedOfflineValidation_Images/ -name \*ps -o -name \*root)
224 echo -e "\n\nProduced plot files:"
226 ls .oO[workdir]Oo./ExtendedOfflineValidation_Images
228 image_files=$(ls --color=never | find ExtendedOfflineValidation_Images/ -name \*ps -o -name \*root)
229 echo -e "\n\nProduced plot files:"
231 ls ExtendedOfflineValidation_Images
234 for image in ${image_files}
236 cp ${image} .oO[datadir]Oo./ExtendedOfflineValidation_Images
243 extendedValidationTemplate=
"""
244 void TkAlExtendedOfflineValidation()
246 // load framework lite just to find the CMSSW libs...
247 gSystem->Load("libFWCoreFWLite");
248 AutoLibraryLoader::enable();
250 gROOT->ProcessLine(".L .oO[CMSSW_BASE]Oo./src/Alignment/OfflineValidation/macros/PlotAlignmentValidation.C++");
251 // gROOT->ProcessLine(".L ./PlotAlignmentValidation.C++");
253 .oO[extendedInstantiation]Oo.
254 p.setOutputDir("./ExtendedOfflineValidation_Images");
255 p.setTreeBaseDir(".oO[OfflineTreeBaseDir]Oo.");
256 p.plotDMR(".oO[DMRMethod]Oo.",.oO[DMRMinimum]Oo.,".oO[DMROptions]Oo.");
257 p.plotSurfaceShapes(".oO[SurfaceShapes]Oo.");
258 p.plotChi2(".oO[resultPlotFile]Oo._result.root");
272 datasetpath = .oO[dataset]Oo.
273 pset = .oO[cfgFile]Oo.
274 total_number_of_.oO[McOrData]Oo.
275 number_of_jobs = .oO[numberOfJobs]Oo.
276 output_file = .oO[outputFile]Oo.
277 runselection = .oO[runRange]Oo.
278 lumi_mask = .oO[JSON]Oo.
283 storage_element = T2_CH_CERN
284 user_remote_dir = .oO[eosdir]Oo.
285 ui_working_dir = .oO[crabWorkingDir]Oo.
286 # script_exe = .oO[script]Oo.
290 queue = .oO[queue]Oo.
307 if not templateName
in globals().
keys():
308 msg =
"unknown template to replace %s"%templateName
310 if not alternateTemplateName
in globals().
keys():
311 msg =
"unknown template to replace %s"%alternateTemplateName
313 globals()[ templateName ] = globals()[ alternateTemplateName ]
def alternateTemplate
### Alternate Templates ###