CMS 3D CMS Logo

configTemplates.py
Go to the documentation of this file.
1 from __future__ import absolute_import
2 from .alternateValidationTemplates import *
3 from .offlineValidationTemplates import *
4 from .primaryVertexValidationTemplates import *
5 from .primaryVertexResolutionTemplates import *
6 from .geometryComparisonTemplates import *
7 from .monteCarloValidationTemplates import *
8 from .trackSplittingValidationTemplates import *
9 from .zMuMuValidationTemplates import *
10 from .TkAlExceptions import AllInOneError
11 from .overlapValidationTemplates import *
12 
13 
20 
21 
23 loadGlobalTagTemplate="""
24 #Global tag
25 process.load("Configuration.StandardSequences.FrontierConditions_GlobalTag_cff")
26 from Configuration.AlCa.GlobalTag import GlobalTag
27 process.GlobalTag = GlobalTag(process.GlobalTag,".oO[GlobalTag]Oo.")
28 """
29 
30 
31 
33 conditionsTemplate="""
34 process.conditionsIn.oO[rcdName]Oo. = CalibTracker.Configuration.Common.PoolDBESSource_cfi.poolDBESSource.clone(
35  connect = cms.string('.oO[connectString]Oo.'),
36  toGet = cms.VPSet(cms.PSet(record = cms.string('.oO[rcdName]Oo.'),
37  tag = cms.string('.oO[tagName]Oo.')
38  )
39  )
40  )
41 process.prefer_conditionsIn.oO[rcdName]Oo. = cms.ESPrefer("PoolDBESSource", "conditionsIn.oO[rcdName]Oo.")
42 """
43 
44 
45 
48 scriptTemplate="""#!/bin/bash
49 #init
50 #ulimit -v 3072000
51 #export STAGE_SVCCLASS=cmscafuser
52 #save path to the condor batch working directory (/pool/condor)
53 
54 export CONDORWORKDIR=`pwd -P`
55 echo CONDOR working directory is $CONDORWORKDIR
56 source /afs/cern.ch/cms/caf/setup.sh
57 export X509_USER_PROXY=.oO[scriptsdir]Oo./.user_proxy
58 cd .oO[CMSSW_BASE]Oo./src
59 export SCRAM_ARCH=.oO[SCRAM_ARCH]Oo.
60 eval `scramv1 ru -sh`
61 #mkdir -p .oO[datadir]Oo. &>! /dev/null
62 
63 #remove possible result file from previous runs
64 previous_results=$(ls /eos/cms/store/group/alca_trackeralign/AlignmentValidation/.oO[eosdir]Oo.)
65 for file in ${previous_results}
66 do
67  if [ ${file} = /eos/cms/store/group/alca_trackeralign/AlignmentValidation/.oO[eosdir]Oo./.oO[outputFile]Oo. ]
68  then
69  xrdcp -f root://eoscms//eos/cms${file} root://eoscms//eos/cms${file}.bak
70  fi
71 done
72 
73 if [[ $HOSTNAME = lxplus[0-9]*[.a-z0-9]* ]] # check for interactive mode
74 then
75  mkdir -p .oO[workdir]Oo.
76  rm -f .oO[workdir]Oo./*
77  cd .oO[workdir]Oo.
78 else
79  mkdir -p $CONDORWORKDIR/TkAllInOneTool
80  cd $CONDORWORKDIR/TkAllInOneTool
81 fi
82 
83 # rm -f .oO[workdir]Oo./*
84 # cd .oO[workdir]Oo.
85 
86 #run
87 pwd
88 df -h .
89 which cmsRun
90 .oO[CommandLine]Oo.
91 echo "----"
92 echo "List of files in $(pwd):"
93 ls -ltr
94 echo "----"
95 echo ""
96 
97 
98 #retrieve
99 mkdir -p .oO[logdir]Oo. >&! /dev/null
100 gzip -f LOGFILE_*_.oO[name]Oo..log
101 find . -maxdepth 1 -name "LOGFILE*.oO[alignmentName]Oo.*" -print | xargs -I {} bash -c "cp {} .oO[logdir]Oo."
102 
103 #copy root files to eos
104 mkdir -p /eos/cms/store/group/alca_trackeralign/AlignmentValidation/.oO[eosdir]Oo.
105 if [ .oO[parallelJobs]Oo. -eq 1 ]
106 then
107  root_files=$(ls --color=never -d *.oO[alignmentName]Oo.*.root)
108 else
109  root_files=$(ls --color=never -d *.oO[alignmentName]Oo._.oO[nIndex]Oo.*.root)
110 fi
111 echo ${root_files}
112 
113 for file in ${root_files}
114 do
115  xrdcp -f ${file} root://eoscms//eos/cms/store/group/alca_trackeralign/AlignmentValidation/.oO[eosdir]Oo.
116  echo ${file}
117 done
118 
119 #cleanup
120 if [[ $HOSTNAME = lxplus[0-9]*[.a-z0-9]* ]] # check for interactive mode
121 then
122  rm -rf .oO[workdir]Oo.
123 fi
124 echo "done."
125 """
126 
127 
128 
130 cfgTemplate="""
131 import FWCore.ParameterSet.Config as cms
132 
133 process = cms.Process(".oO[ProcessName]Oo.")
134 
135 .oO[datasetDefinition]Oo.
136 .oO[Bookkeeping]Oo.
137 .oO[LoadBasicModules]Oo.
138 .oO[TrackSelectionRefitting]Oo.
139 .oO[LoadGlobalTagTemplate]Oo.
140 .oO[condLoad]Oo.
141 .oO[ValidationConfig]Oo.
142 .oO[FileOutputTemplate]Oo.
143 
144 .oO[DefinePath]Oo.
145 
146 print("Done")
147 """
148 
149 
150 
152 Bookkeeping = """
153 process.options = cms.untracked.PSet(
154  wantSummary = cms.untracked.bool(False),
155  Rethrow = cms.untracked.vstring("ProductNotFound"), # make this exception fatal
156  fileMode = cms.untracked.string('NOMERGE') # no ordering needed, but calls endRun/beginRun etc. at file boundaries
157 )
158 
159 process.load("FWCore.MessageLogger.MessageLogger_cfi")
160 process.MessageLogger.destinations = ['cout', 'cerr']
161 process.MessageLogger.cerr.FwkReport.reportEvery = 1000
162 process.MessageLogger.statistics.append('cout')
163 """
164 
165 
166 
168 CommonTrackSelectionRefitting = """
169 import Alignment.CommonAlignment.tools.trackselectionRefitting as trackselRefit
170 process.seqTrackselRefit = trackselRefit.getSequence(process, '.oO[trackcollection]Oo.',
171  isPVValidation=.oO[ispvvalidation]Oo.,
172  TTRHBuilder='.oO[ttrhbuilder]Oo.',
173  usePixelQualityFlag=.oO[usepixelqualityflag]Oo.,
174  openMassWindow=.oO[openmasswindow]Oo.,
175  cosmicsDecoMode=.oO[cosmicsdecomode]Oo.,
176  cosmicsZeroTesla=.oO[cosmics0T]Oo.,
177  momentumConstraint=.oO[momentumconstraint]Oo.,
178  cosmicTrackSplitting=.oO[istracksplitting]Oo.,
179  use_d0cut=.oO[use_d0cut]Oo.,
180  )
181 
182 .oO[trackhitfiltercommands]Oo.
183 """
184 
185 
186 
188 SingleTrackRefitter = """
189 process.load("RecoTracker.TrackProducer.TrackRefitters_cff")
190 process.TrackRefitter.src = ".oO[TrackCollection]Oo."
191 process.TrackRefitter.TTRHBuilder = ".oO[ttrhbuilder]Oo."
192 process.TrackRefitter.NavigationSchool = ""
193 """
194 
195 
196 
198 LoadBasicModules = """
199 process.load("RecoVertex.BeamSpotProducer.BeamSpot_cff")
200 process.load("Configuration.Geometry.GeometryDB_cff")
201 process.load('Configuration.StandardSequences.Services_cff')
202 process.load("Configuration.StandardSequences..oO[magneticField]Oo._cff")
203 """
204 
205 
206 
208 FileOutputTemplate = """
209 process.TFileService = cms.Service("TFileService",
210  fileName = cms.string('.oO[outputFile]Oo.')
211 )
212 """
213 
214 
215 
217 DefinePath_CommonSelectionRefitting = """
218 process.p = cms.Path(
219 process.seqTrackselRefit*.oO[ValidationSequence]Oo.)
220 """
221 
222 
224 mergeTemplate="""#!/bin/bash
225 CWD=`pwd -P`
226 cd .oO[CMSSW_BASE]Oo./src
227 export SCRAM_ARCH=.oO[SCRAM_ARCH]Oo.
228 eval `scramv1 ru -sh`
229 
230 
231 .oO[createResultsDirectory]Oo.
232 
233 if [[ $HOSTNAME = lxplus[0-9]*[.a-z0-9]* ]] # check for interactive mode
234 then
235  mkdir -p .oO[workdir]Oo.
236  cd .oO[workdir]Oo.
237 else
238  cd $CWD
239 fi
240 echo "Working directory: $(pwd -P)"
241 
242 ###############################################################################
243 # download root files from eos
244 root_files=$(ls /eos/cms/store/group/alca_trackeralign/AlignmentValidation/.oO[eosdir]Oo. \
245  | grep ".root$" | grep -v "result.root$")
246 #for file in ${root_files}
247 #do
248 # xrdcp -f root://eoscms//eos/cms/store/group/alca_trackeralign/AlignmentValidation/.oO[eosdir]Oo./${file} .
249 # echo ${file}
250 #done
251 
252 
253 #run
254 .oO[DownloadData]Oo.
255 .oO[CompareAlignments]Oo.
256 
257 .oO[RunValidationPlots]Oo.
258 
259 # clean-up
260 # ls -l *.root
261 rm -f *.root
262 
263 #zip stdout and stderr from the farm jobs
264 cd .oO[logdir]Oo.
265 find . -name "*.stderr" -exec gzip -f {} \;
266 find . -name "*.stdout" -exec gzip -f {} \;
267 """
268 
269 
270 
271 
273 mergeParallelOfflineTemplate="""#!/bin/bash
274 CWD=`pwd -P`
275 cd .oO[CMSSW_BASE]Oo./src
276 export SCRAM_ARCH=.oO[SCRAM_ARCH]Oo.
277 eval `scramv1 ru -sh`
278 
279 if [[ $HOSTNAME = lxplus[0-9]*[.a-z0-9]* ]] # check for interactive mode
280 then
281  mkdir -p .oO[workdir]Oo.
282  cd .oO[workdir]Oo.
283 else
284  cd $CWD
285 fi
286 echo "Working directory: $(pwd -P)"
287 
288 ###############################################################################
289 # download root files from eos
290 root_files=$(ls /eos/cms/store/group/alca_trackeralign/AlignmentValidation/.oO[eosdir]Oo. \
291  | grep ".root$" | grep -v "result.root$")
292 #for file in ${root_files}
293 #do
294 # xrdcp -f root://eoscms//eos/cms/store/group/alca_trackeralign/AlignmentValidation/.oO[eosdir]Oo./${file} .
295 # echo ${file}
296 #done
297 
298 
299 #run
300 .oO[DownloadData]Oo.
301 """
302 
303 
305 createResultsDirectoryTemplate="""
306 #create results-directory and copy used configuration there
307 mkdir -p .oO[datadir]Oo.
308 cp .oO[logdir]Oo./usedConfiguration.ini .oO[datadir]Oo.
309 """
310 
311 
312 
314 mergeParallelResults="""
315 
316 .oO[beforeMerge]Oo.
317 .oO[doMerge]Oo.
318 
319 # create log file
320 ls -al .oO[mergeParallelFilePrefixes]Oo. > .oO[datadir]Oo./log_rootfilelist.txt
321 
322 # Remove parallel job files
323 .oO[rmUnmerged]Oo.
324 """
325 
326 
327 
329 compareAlignmentsExecution="""
330 #merge for .oO[validationId]Oo. if it does not exist or is not up-to-date
331 echo -e "\n\nComparing validations"
332 mkdir -p /eos/cms/store/group/alca_trackeralign/AlignmentValidation/.oO[eosdir]Oo./
333 cp .oO[Alignment/OfflineValidation]Oo./scripts/compareFileAges.C .
334 root -x -q -b -l "compareFileAges.C(\\\"root://eoscms.cern.ch//eos/cms/store/group/alca_trackeralign/AlignmentValidation/.oO[eosdir]Oo./.oO[validationId]Oo._result.root\\\", \\\".oO[compareStringsPlain]Oo.\\\")"
335 comparisonNeeded=${?}
336 
337 if [[ ${comparisonNeeded} -eq 1 ]]
338 then
339  cp .oO[compareAlignmentsPath]Oo. .
340  root -x -q -b -l '.oO[compareAlignmentsName]Oo.++(\".oO[compareStrings]Oo.\", ".oO[legendheader]Oo.", ".oO[customtitle]Oo.", ".oO[customrighttitle]Oo.", .oO[bigtext]Oo.)'
341  mv result.root .oO[validationId]Oo._result.root
342  xrdcp -f .oO[validationId]Oo._result.root root://eoscms//eos/cms/store/group/alca_trackeralign/AlignmentValidation/.oO[eosdir]Oo.
343 else
344  echo ".oO[validationId]Oo._result.root is up-to-date, no need to compare again."
345  xrdcp -f root://eoscms//eos/cms/store/group/alca_trackeralign/AlignmentValidation/.oO[eosdir]Oo./.oO[validationId]Oo._result.root .
346 fi
347 """
348 
349 
350 
352 crabCfgTemplate="""
353 [CRAB]
354 jobtype = cmssw
355 scheduler = caf
356 use_server = 0
357 
358 [CMSSW]
359 datasetpath = .oO[dataset]Oo.
360 pset = .oO[cfgFile]Oo.
361 total_number_of_.oO[McOrData]Oo.
362 number_of_jobs = .oO[numberOfJobs]Oo.
363 output_file = .oO[outputFile]Oo.
364 runselection = .oO[runRange]Oo.
365 lumi_mask = .oO[JSON]Oo.
366 
367 [USER]
368 return_data = 0
369 copy_data = 1
370 storage_element = T2_CH_CERN
371 user_remote_dir = .oO[eosdir]Oo.
372 ui_working_dir = .oO[crabWorkingDir]Oo.
373 # script_exe = .oO[script]Oo.
374 # .oO[email]Oo.
375 
376 [CAF]
377 queue = .oO[queue]Oo.
378 """
379 
380 
381 
382 
383 
390 
391 
392 def alternateTemplate( templateName, alternateTemplateName ):
393 
394  if not templateName in globals().keys():
395  msg = "unknown template to replace %s"%templateName
396  raise AllInOneError(msg)
397  if not alternateTemplateName in globals().keys():
398  msg = "unknown template to replace %s"%alternateTemplateName
399  raise AllInOneError(msg)
400  globals()[ templateName ] = globals()[ alternateTemplateName ]
401  # = eval("configTemplates.%s"%"alternateTemplate")
relativeConstraints.keys
keys
Definition: relativeConstraints.py:89
configTemplates.alternateTemplate
def alternateTemplate(templateName, alternateTemplateName)
Definition: configTemplates.py:392
TkAlExceptions.AllInOneError
Definition: TkAlExceptions.py:1