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 .oO[copyMergeScripts]Oo.
172 ls -al .oO[mergeParallelFilePrefixes]Oo. > .oO[datadir]Oo./log_rootfilelist.txt
174 # Remove parallel job files
181 compareAlignmentsExecution=
"""
182 #merge for .oO[validationId]Oo. if it does not exist or is not up-to-date
183 echo -e "\n\nComparing validations"
184 cmsMkdir /store/caf/user/$USER/.oO[eosdir]Oo./
185 cp .oO[CMSSW_BASE]Oo./src/Alignment/OfflineValidation/scripts/compareFileAges.C .
186 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.\\\")"
187 comparisonNeeded=${?}
189 if [[ ${comparisonNeeded} -eq 1 ]]
191 cp .oO[CMSSW_BASE]Oo./src/Alignment/OfflineValidation/scripts/compareAlignments.cc .
192 root -x -q -b -l 'compareAlignments.cc++(\".oO[compareStrings]Oo.\")'
193 mv result.root .oO[validationId]Oo._result.root
194 cmsStage -f .oO[validationId]Oo._result.root /store/caf/user/$USER/.oO[eosdir]Oo.
196 echo ".oO[validationId]Oo._result.root is up-to-date, no need to compare again."
197 cmsStage -f /store/caf/user/$USER/.oO[eosdir]Oo./.oO[validationId]Oo._result.root .
204 extendedValidationExecution=
"""
205 #run extended offline validation scripts
206 echo -e "\n\nRunning extended offline validation"
207 if [[ $HOSTNAME = lxplus[0-9]*\.cern\.ch ]] # check for interactive mode
209 rfmkdir -p .oO[workdir]Oo./ExtendedOfflineValidation_Images
211 mkdir -p ExtendedOfflineValidation_Images
214 rfcp .oO[extendedValScriptPath]Oo. .
215 rfcp .oO[CMSSW_BASE]Oo./src/Alignment/OfflineValidation/macros/PlotAlignmentValidation.C .
216 root -x -b -q -l TkAlExtendedOfflineValidation.C
217 rfmkdir -p .oO[datadir]Oo./ExtendedOfflineValidation_Images
219 if [[ $HOSTNAME = lxplus[0-9]*\.cern\.ch ]] # check for interactive mode
221 image_files=$(ls --color=never | find .oO[workdir]Oo./ExtendedOfflineValidation_Images/ -name \*ps -o -name \*root)
222 echo -e "\n\nProduced plot files:"
224 ls .oO[workdir]Oo./ExtendedOfflineValidation_Images
226 image_files=$(ls --color=never | find ExtendedOfflineValidation_Images/ -name \*ps -o -name \*root)
227 echo -e "\n\nProduced plot files:"
229 ls ExtendedOfflineValidation_Images
232 for image in ${image_files}
234 cp ${image} .oO[datadir]Oo./ExtendedOfflineValidation_Images
241 extendedValidationTemplate=
"""
242 #include ".oO[CMSSW_BASE]Oo./src/Alignment/OfflineValidation/macros/PlotAlignmentValidation.C"
243 void TkAlExtendedOfflineValidation()
245 // load framework lite just to find the CMSSW libs...
246 gSystem->Load("libFWCoreFWLite");
247 FWLiteEnabler::enable();
249 //gROOT->ProcessLine(".L .oO[CMSSW_BASE]Oo./src/Alignment/OfflineValidation/macros/PlotAlignmentValidation.C++");
250 // gROOT->ProcessLine(".L ./PlotAlignmentValidation.C++");
252 .oO[extendedInstantiation]Oo.
253 p.setOutputDir("./ExtendedOfflineValidation_Images");
254 p.setTreeBaseDir(".oO[OfflineTreeBaseDir]Oo.");
255 p.plotDMR(".oO[DMRMethod]Oo.",.oO[DMRMinimum]Oo.,".oO[DMROptions]Oo.");
256 p.plotSurfaceShapes(".oO[SurfaceShapes]Oo.");
257 p.plotChi2("root://eoscms//eos/cms/store/caf/user/$USER/.oO[eosdir]Oo./.oO[resultPlotFile]Oo._result.root");
271 datasetpath = .oO[dataset]Oo.
272 pset = .oO[cfgFile]Oo.
273 total_number_of_.oO[McOrData]Oo.
274 number_of_jobs = .oO[numberOfJobs]Oo.
275 output_file = .oO[outputFile]Oo.
276 runselection = .oO[runRange]Oo.
277 lumi_mask = .oO[JSON]Oo.
282 storage_element = T2_CH_CERN
283 user_remote_dir = .oO[eosdir]Oo.
284 ui_working_dir = .oO[crabWorkingDir]Oo.
285 # script_exe = .oO[script]Oo.
289 queue = .oO[queue]Oo.
306 if not templateName
in globals().
keys():
307 msg =
"unknown template to replace %s"%templateName
309 if not alternateTemplateName
in globals().
keys():
310 msg =
"unknown template to replace %s"%alternateTemplateName
312 globals()[ templateName ] = globals()[ alternateTemplateName ]
def alternateTemplate
### Alternate Templates ###