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
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)
42 export LSFWORKDIR=`pwd -P`
43 echo LSF working directory is $LSFWORKDIR
44 source /afs/cern.ch/cms/caf/setup.sh
45 eos='/afs/cern.ch/project/eos/installation/cms/bin/eos.select'
46 cd .oO[CMSSW_BASE]Oo./src
47 export SCRAM_ARCH=.oO[SCRAM_ARCH]Oo.
49 #rfmkdir -p .oO[datadir]Oo. &>! /dev/null
51 #remove possible result file from previous runs
52 previous_results=$($eos ls /store/caf/user/$USER/.oO[eosdir]Oo.)
53 for file in ${previous_results}
55 if [ ${file} = /store/caf/user/$USER/.oO[eosdir]Oo./.oO[outputFile]Oo. ]
57 xrdcp -f root://eoscms//eos/cms${file} root://eoscms//eos/cms${file}.bak
61 if [[ $HOSTNAME = lxplus[0-9]*\.cern\.ch ]] # check for interactive mode
63 rfmkdir -p .oO[workdir]Oo.
64 rm -f .oO[workdir]Oo./*
67 mkdir -p $LSFWORKDIR/TkAllInOneTool
68 cd $LSFWORKDIR/TkAllInOneTool
71 # rm -f .oO[workdir]Oo./*
79 echo "List of files in $(pwd):"
86 rfmkdir -p .oO[logdir]Oo. >&! /dev/null
87 gzip -f LOGFILE_*_.oO[name]Oo..log
88 find . -maxdepth 1 -name "LOGFILE*.oO[alignmentName]Oo.*" -print | xargs -I {} bash -c "rfcp {} .oO[logdir]Oo."
90 #copy root files to eos
91 $eos mkdir -p /store/caf/user/$USER/.oO[eosdir]Oo.
92 if [ .oO[parallelJobs]Oo. -eq 1 ]
94 root_files=$(ls --color=never -d *.oO[alignmentName]Oo.*.root)
96 root_files=$(ls --color=never -d *.oO[alignmentName]Oo._.oO[nIndex]Oo.*.root)
100 for file in ${root_files}
102 xrdcp -f ${file} root://eoscms//eos/cms/store/caf/user/$USER/.oO[eosdir]Oo.
107 if [[ $HOSTNAME = lxplus[0-9]*\.cern\.ch ]] # check for interactive mode
109 rm -rf .oO[workdir]Oo.
119 eos='/afs/cern.ch/project/eos/installation/cms/bin/eos.select'
121 cd .oO[CMSSW_BASE]Oo./src
122 export SCRAM_ARCH=.oO[SCRAM_ARCH]Oo.
123 eval `scramv1 ru -sh`
125 #create results-directory and copy used configuration there
126 rfmkdir -p .oO[datadir]Oo.
127 rfcp .oO[logdir]Oo./usedConfiguration.ini .oO[datadir]Oo.
129 if [[ $HOSTNAME = lxplus[0-9]*\.cern\.ch ]] # check for interactive mode
131 mkdir -p .oO[workdir]Oo.
136 echo "Working directory: $(pwd -P)"
138 ###############################################################################
139 # download root files from eos
140 root_files=$($eos ls /store/caf/user/$USER/.oO[eosdir]Oo. \
141 | grep ".root$" | grep -v "result.root$")
142 #for file in ${root_files}
144 # xrdcp -f root://eoscms//eos/cms/store/caf/user/$USER/.oO[eosdir]Oo./${file} .
151 .oO[CompareAlignments]Oo.
153 .oO[RunExtendedOfflineValidation]Oo.
154 .oO[RunTrackSplitPlot]Oo.
155 .oO[MergeZmumuPlots]Oo.
156 .oO[RunPrimaryVertexPlot]Oo.
162 #zip stdout and stderr from the farm jobs
164 find . -name "*.stderr" -exec gzip -f {} \;
165 find . -name "*.stdout" -exec gzip -f {} \;
171 mergeParallelResults=
"""
173 .oO[copyMergeScripts]Oo.
177 ls -al .oO[mergeParallelFilePrefixes]Oo. > .oO[datadir]Oo./log_rootfilelist.txt
179 # Remove parallel job files
186 compareAlignmentsExecution=
"""
187 #merge for .oO[validationId]Oo. if it does not exist or is not up-to-date
188 echo -e "\n\nComparing validations"
189 $eos mkdir -p /store/caf/user/$USER/.oO[eosdir]Oo./
190 cp .oO[Alignment/OfflineValidation]Oo./scripts/compareFileAges.C .
191 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.\\\")"
192 comparisonNeeded=${?}
194 if [[ ${comparisonNeeded} -eq 1 ]]
196 cp .oO[Alignment/OfflineValidation]Oo./scripts/compareAlignments.cc .
197 root -x -q -b -l 'compareAlignments.cc++(\".oO[compareStrings]Oo.\", ".oO[legendheader]Oo.", ".oO[customtitle]Oo.", ".oO[customrighttitle]Oo.", .oO[bigtext]Oo.)'
198 mv result.root .oO[validationId]Oo._result.root
199 xrdcp -f .oO[validationId]Oo._result.root root://eoscms//eos/cms/store/caf/user/$USER/.oO[eosdir]Oo.
201 echo ".oO[validationId]Oo._result.root is up-to-date, no need to compare again."
202 xrdcp -f root://eoscms//eos/cms/store/caf/user/$USER/.oO[eosdir]Oo./.oO[validationId]Oo._result.root .
209 extendedValidationExecution=
"""
210 #run extended offline validation scripts
211 echo -e "\n\nRunning extended offline validation"
213 rfcp .oO[extendedValScriptPath]Oo. .
214 root -x -b -q -l TkAlExtendedOfflineValidation.C
221 extendedValidationTemplate=
"""
222 #include "Alignment/OfflineValidation/macros/PlotAlignmentValidation.C"
223 #include "FWCore/FWLite/interface/FWLiteEnabler.h"
225 void TkAlExtendedOfflineValidation()
227 TkAlStyle::legendheader = ".oO[legendheader]Oo.";
228 TkAlStyle::legendoptions = ".oO[legendoptions]Oo.";
229 TkAlStyle::set(.oO[publicationstatus]Oo., .oO[era]Oo., ".oO[customtitle]Oo.", ".oO[customrighttitle]Oo.");
230 gStyle->SetTitleH ( 0.07 );
231 gStyle->SetTitleW ( 1.00 );
232 gStyle->SetTitleFont ( 132 );
233 // load framework lite just to find the CMSSW libs...
234 gSystem->Load("libFWCoreFWLite");
235 FWLiteEnabler::enable();
237 .oO[extendedInstantiation]Oo.
238 p.setOutputDir(".oO[datadir]Oo./ExtendedOfflineValidation_Images");
239 p.setTreeBaseDir(".oO[OfflineTreeBaseDir]Oo.");
240 p.plotDMR(".oO[DMRMethod]Oo.",.oO[DMRMinimum]Oo.,".oO[DMROptions]Oo.");
241 p.plotSurfaceShapes(".oO[SurfaceShapes]Oo.");
242 p.plotChi2("root://eoscms//eos/cms/store/caf/user/$USER/.oO[eosdir]Oo./.oO[resultPlotFile]Oo._result.root");
256 datasetpath = .oO[dataset]Oo.
257 pset = .oO[cfgFile]Oo.
258 total_number_of_.oO[McOrData]Oo.
259 number_of_jobs = .oO[numberOfJobs]Oo.
260 output_file = .oO[outputFile]Oo.
261 runselection = .oO[runRange]Oo.
262 lumi_mask = .oO[JSON]Oo.
267 storage_element = T2_CH_CERN
268 user_remote_dir = .oO[eosdir]Oo.
269 ui_working_dir = .oO[crabWorkingDir]Oo.
270 # script_exe = .oO[script]Oo.
274 queue = .oO[queue]Oo.
291 if not templateName
in globals().
keys():
292 msg =
"unknown template to replace %s"%templateName
294 if not alternateTemplateName
in globals().
keys():
295 msg =
"unknown template to replace %s"%alternateTemplateName
297 globals()[ templateName ] = globals()[ alternateTemplateName ]
def alternateTemplate
### Alternate Templates ###