3 from __future__
import print_function
4 import os, sys, optparse, math
7 for i
in range(len(copyargs)):
10 if copyargs[i].
find(
" ") != -1:
11 copyargs[i] =
"\"%s\"" % copyargs[i]
12 commandline =
" ".
join(copyargs)
16 usage =
"""./%(prog)s DIRNAME ITERATIONS INITIALGEOM INPUTFILES [options] 18 Creates (overwrites) a directory for each of the iterations and creates (overwrites) 19 submitJobs.sh with the submission sequence and dependencies. 21 DIRNAME directories will be named DIRNAME01, DIRNAME02, etc. 22 ITERATIONS number of iterations 23 INITIALGEOM SQLite file containing muon geometry with tag names 24 DTAlignmentRcd, DTAlignmentErrorExtendedRcd, CSCAlignmentRcd, CSCAlignmentErrorExtendedRcd 25 INPUTFILES Python file defining 'fileNames', a list of input files as 26 strings (create with findQualityFiles.py)""" % vars()
28 parser = optparse.OptionParser(usage)
29 parser.add_option(
"-j",
"--jobs",
30 help=
"approximate number of \"gather\" subjobs",
34 parser.add_option(
"-s",
"--submitJobs",
35 help=
"alternate name of submitJobs.sh script (please include .sh extension); a file with this name will be OVERWRITTEN",
37 default=
"submitJobs.sh",
39 parser.add_option(
"-b",
"--big",
40 help=
"if invoked, subjobs will also be run on cmscaf1nd",
43 parser.add_option(
"-u",
"--user_mail",
44 help=
"if invoked, send mail to a specified email destination. If \"-u\" is not present, the default destination LSB_MAILTO in lsf.conf will be used",
47 parser.add_option(
"--mapplots",
48 help=
"if invoked, draw \"map plots\"",
51 parser.add_option(
"--segdiffplots",
52 help=
"if invoked, draw \"segment-difference plots\"",
55 parser.add_option(
"--curvatureplots",
56 help=
"if invoked, draw \"curvature plots\"",
58 dest=
"curvatureplots")
59 parser.add_option(
"--globalTag",
60 help=
"GlobalTag for alignment/calibration conditions (typically all conditions except muon and tracker alignment)",
62 default=
"CRAFT0831X_V1::All",
64 parser.add_option(
"--trackerconnect",
65 help=
"connect string for tracker alignment (frontier://FrontierProd/CMS_COND_310X_ALIGN or sqlite_file:...)",
68 dest=
"trackerconnect")
69 parser.add_option(
"--trackeralignment",
70 help=
"name of TrackerAlignmentRcd tag",
73 dest=
"trackeralignment")
74 parser.add_option(
"--trackerAPEconnect",
75 help=
"connect string for tracker APEs (frontier://... or sqlite_file:...)",
78 dest=
"trackerAPEconnect")
79 parser.add_option(
"--trackerAPE",
80 help=
"name of TrackerAlignmentErrorExtendedRcd tag (tracker APEs)",
82 default=
"AlignmentErrorsExtended",
84 parser.add_option(
"--trackerBowsconnect",
85 help=
"connect string for tracker Surface Deformations (frontier://... or sqlite_file:...)",
88 dest=
"trackerBowsconnect")
89 parser.add_option(
"--trackerBows",
90 help=
"name of TrackerSurfaceDeformationRcd tag",
92 default=
"TrackerSurfaceDeformations",
94 parser.add_option(
"--gprcdconnect",
95 help=
"connect string for GlobalPositionRcd (frontier://... or sqlite_file:...)",
99 parser.add_option(
"--gprcd",
100 help=
"name of GlobalPositionRcd tag",
102 default=
"GlobalPosition",
104 parser.add_option(
"--iscosmics",
105 help=
"if invoked, use cosmic track refitter instead of the standard one",
108 parser.add_option(
"--station123params",
109 help=
"alignable parameters for DT stations 1, 2, 3 (see SWGuideAlignmentAlgorithms#Selection_of_what_to_align)",
112 dest=
"station123params")
113 parser.add_option(
"--station4params",
114 help=
"alignable parameters for DT station 4",
117 dest=
"station4params")
118 parser.add_option(
"--cscparams",
119 help=
"alignable parameters for CSC chambers",
123 parser.add_option(
"--minTrackPt",
124 help=
"minimum allowed track transverse momentum (in GeV)",
128 parser.add_option(
"--maxTrackPt",
129 help=
"maximum allowed track transverse momentum (in GeV)",
133 parser.add_option(
"--minTrackP",
134 help=
"minimum allowed track momentum (in GeV)",
138 parser.add_option(
"--maxTrackP",
139 help=
"maximum allowed track momentum (in GeV)",
143 parser.add_option(
"--minTrackerHits",
144 help=
"minimum number of tracker hits",
147 dest=
"minTrackerHits")
148 parser.add_option(
"--maxTrackerRedChi2",
149 help=
"maximum tracker chi^2 per degrees of freedom",
152 dest=
"maxTrackerRedChi2")
153 parser.add_option(
"--notAllowTIDTEC",
154 help=
"if invoked, do not allow tracks that pass through the tracker's TID||TEC region (not recommended)",
156 dest=
"notAllowTIDTEC")
157 parser.add_option(
"--twoBin",
158 help=
"if invoked, apply the \"two-bin method\" to control charge-antisymmetric errors",
161 parser.add_option(
"--weightAlignment",
162 help=
"if invoked, segments will be weighted by ndf/chi^2 in the alignment",
164 dest=
"weightAlignment")
165 parser.add_option(
"--minAlignmentSegments",
166 help=
"minimum number of segments required to align a chamber",
169 dest=
"minAlignmentHits")
170 parser.add_option(
"--notCombineME11",
171 help=
"if invoced, treat ME1/1a and ME1/1b as separate objects",
173 dest=
"notCombineME11")
174 parser.add_option(
"--maxEvents",
175 help=
"maximum number of events",
179 parser.add_option(
"--skipEvents",
180 help=
"number of events to be skipped",
184 parser.add_option(
"--validationLabel",
185 help=
"if given nonempty string RUNLABEL, diagnostics and creation of plots will be run in the end of the last iteration; the RUNLABEL will be used to mark a run; the results will be put into a RUNLABEL_DATESTAMP.tgz tarball",
188 dest=
"validationLabel")
189 parser.add_option(
"--maxResSlopeY",
190 help=
"maximum residual slope y component",
194 parser.add_option(
"--motionPolicyNSigma",
195 help=
"minimum nsigma(deltax) position displacement in order to move a chamber for the final alignment result; default NSIGMA=3",
198 dest=
"motionPolicyNSigma")
199 parser.add_option(
"--noCleanUp",
200 help=
"if invoked, temporary plotting???.root and *.tmp files would not be removed at the end of each align job",
203 parser.add_option(
"--noCSC",
204 help=
"if invoked, CSC endcap chambers would not be processed",
207 parser.add_option(
"--noDT",
208 help=
"if invoked, DT barrel chambers would not be processed",
211 parser.add_option(
"--createMapNtuple",
212 help=
"if invoked while mapplots are switched on, a special ntuple would be created",
214 dest=
"createMapNtuple")
215 parser.add_option(
"--inputInBlocks",
216 help=
"if invoked, assume that INPUTFILES provides a list of files already groupped into job blocks, -j has no effect in that case",
218 dest=
"inputInBlocks")
219 parser.add_option(
"--json",
220 help=
"If present with JSON file as argument, use JSON file for good lumi mask. "+\
221 "The latest JSON file is available at /afs/cern.ch/cms/CAF/CMSCOMM/COMM_DQM/certification/Collisions11/7TeV/Prompt/",
225 parser.add_option(
"--createAlignNtuple",
226 help=
"if invoked, debug ntuples with residuals would be created during gather jobs",
228 dest=
"createAlignNtuple")
229 parser.add_option(
"--residualsModel",
230 help=
"functional residuals model. Possible vaslues: pureGaussian2D (default), pureGaussian, GaussPowerTails, ROOTVoigt, powerLawTails",
232 default=
"pureGaussian2D",
233 dest=
"residualsModel")
234 parser.add_option(
"--useResiduals",
235 help=
"select residuals to use, possible values: 1111, 1110, 1100, 1010, 0010 that correspond to x y dxdz dydz residuals",
239 parser.add_option(
"--peakNSigma",
240 help=
"if >0, only residuals peaks within n-sigma multidimentional ellipsoid would be considered in the alignment fit",
244 parser.add_option(
"--preFilter",
245 help=
"if invoked, MuonAlignmentPreFilter module would be invoked in the Path's beginning. Can significantly speed up gather jobs.",
248 parser.add_option(
"--muonCollectionTag",
249 help=
"If empty, use trajectories. If not empty, it's InputTag of muons collection to use in tracker muons based approach, e.g., 'newmuons' or 'muons'",
252 dest=
"muonCollectionTag")
253 parser.add_option(
"--maxDxy",
254 help=
"maximum track impact parameter with relation to beamline",
258 parser.add_option(
"--minNCrossedChambers",
259 help=
"minimum number of muon chambers that a track is required to cross",
262 dest=
"minNCrossedChambers")
263 parser.add_option(
"--extraPlots",
264 help=
"produce additional plots with geometry, reports differences, and corrections visulizations",
268 if len(sys.argv) < 5:
269 raise SystemError(
"Too few arguments.\n\n"+parser.format_help())
271 DIRNAME = sys.argv[1]
272 ITERATIONS =
int(sys.argv[2])
273 INITIALGEOM = sys.argv[3]
274 INPUTFILES = sys.argv[4]
276 options, args = parser.parse_args(sys.argv[5:])
277 user_mail = options.user_mail
278 mapplots_ingeneral = options.mapplots
279 segdiffplots_ingeneral = options.segdiffplots
280 curvatureplots_ingeneral = options.curvatureplots
281 globaltag = options.globaltag
282 trackerconnect = options.trackerconnect
283 trackeralignment = options.trackeralignment
284 trackerAPEconnect = options.trackerAPEconnect
285 trackerAPE = options.trackerAPE
286 trackerBowsconnect = options.trackerBowsconnect
287 trackerBows = options.trackerBows
288 gprcdconnect = options.gprcdconnect
289 gprcd = options.gprcd
290 iscosmics =
str(options.iscosmics)
291 station123params = options.station123params
292 station4params = options.station4params
293 cscparams = options.cscparams
294 muonCollectionTag = options.muonCollectionTag
295 minTrackPt = options.minTrackPt
296 maxTrackPt = options.maxTrackPt
297 minTrackP = options.minTrackP
298 maxTrackP = options.maxTrackP
299 maxDxy = options.maxDxy
300 minTrackerHits =
str(options.minTrackerHits)
301 maxTrackerRedChi2 = options.maxTrackerRedChi2
302 minNCrossedChambers = options.minNCrossedChambers
303 allowTIDTEC =
str(
not options.notAllowTIDTEC)
304 twoBin =
str(options.twoBin)
305 weightAlignment =
str(options.weightAlignment)
306 minAlignmentHits =
str(options.minAlignmentHits)
307 combineME11 =
str(
not options.notCombineME11)
308 maxEvents = options.maxEvents
309 skipEvents = options.skipEvents
310 validationLabel = options.validationLabel
311 maxResSlopeY = options.maxResSlopeY
312 theNSigma = options.motionPolicyNSigma
313 residualsModel = options.residualsModel
314 peakNSigma = options.peakNSigma
315 preFilter =
not not options.preFilter
316 extraPlots = options.extraPlots
317 useResiduals = options.useResiduals
322 doCleanUp =
not options.noCleanUp
323 createMapNtuple =
not not options.createMapNtuple
324 createAlignNtuple =
not not options.createAlignNtuple
327 if options.noCSC: doCSC =
False 329 if options.noDT: doDT =
False 330 if options.noCSC
and options.noDT:
331 print(
"cannot do --noCSC and --noDT at the same time!")
334 json_file = options.json
339 njobs = options.subjobs
340 if (options.inputInBlocks):
341 njobs = len(fileNamesBlocks)
343 print(
"while --inputInBlocks is specified, the INPUTFILES has no blocks!")
346 stepsize =
int(math.ceil(1.*len(fileNames)/options.subjobs))
351 if trackerconnect[0:12] ==
"sqlite_file:": copytrackerdb +=
"%s " % trackerconnect[12:]
352 if trackerAPEconnect[0:12] ==
"sqlite_file:": copytrackerdb +=
"%s " % trackerAPEconnect[12:]
353 if trackerBowsconnect[0:12] ==
"sqlite_file:": copytrackerdb +=
"%s " % trackerBowsconnect[12:]
354 if gprcdconnect[0:12] ==
"sqlite_file:": copytrackerdb +=
"%s " % gprcdconnect[12:]
359 INITIALXML = INITIALGEOM +
'.xml' 360 if INITIALGEOM[-3:]==
'.db':
361 INITIALXML = INITIALGEOM[:-3] +
'.xml' 362 print(
"Converting",INITIALGEOM,
"to",INITIALXML,
" ...will be done in several seconds...")
363 print(
"./Alignment/MuonAlignmentAlgorithms/scripts/convertSQLiteXML.py %s %s --gprcdconnect %s --gprcd %s" % (INITIALGEOM,INITIALXML,gprcdconnect,gprcd))
364 exit_code = os.system(
"./Alignment/MuonAlignmentAlgorithms/scripts/convertSQLiteXML.py %s %s --gprcdconnect %s --gprcd %s" % (INITIALGEOM,INITIALXML,gprcdconnect,gprcd))
366 print(
"problem: conversion exited with code:", exit_code)
375 export ALIGNMENT_CAFDIR=`pwd` 378 eval `scramv1 run -sh` 379 export ALIGNMENT_AFSDIR=`pwd` 381 export ALIGNMENT_INPUTFILES='%(inputfiles)s' 382 export ALIGNMENT_ITERATION=%(iteration)d 383 export ALIGNMENT_JOBNUMBER=%(jobnumber)d 384 export ALIGNMENT_MAPPLOTS=%(mapplots)s 385 export ALIGNMENT_SEGDIFFPLOTS=%(segdiffplots)s 386 export ALIGNMENT_CURVATUREPLOTS=%(curvatureplots)s 387 export ALIGNMENT_GLOBALTAG=%(globaltag)s 388 export ALIGNMENT_INPUTDB=%(inputdb)s 389 export ALIGNMENT_TRACKERCONNECT=%(trackerconnect)s 390 export ALIGNMENT_TRACKERALIGNMENT=%(trackeralignment)s 391 export ALIGNMENT_TRACKERAPECONNECT=%(trackerAPEconnect)s 392 export ALIGNMENT_TRACKERAPE=%(trackerAPE)s 393 export ALIGNMENT_TRACKERBOWSCONNECT=%(trackerBowsconnect)s 394 export ALIGNMENT_TRACKERBOWS=%(trackerBows)s 395 export ALIGNMENT_GPRCDCONNECT=%(gprcdconnect)s 396 export ALIGNMENT_GPRCD=%(gprcd)s 397 export ALIGNMENT_ISCOSMICS=%(iscosmics)s 398 export ALIGNMENT_STATION123PARAMS=%(station123params)s 399 export ALIGNMENT_STATION4PARAMS=%(station4params)s 400 export ALIGNMENT_CSCPARAMS=%(cscparams)s 401 export ALIGNMENT_MUONCOLLECTIONTAG=%(muonCollectionTag)s 402 export ALIGNMENT_MINTRACKPT=%(minTrackPt)s 403 export ALIGNMENT_MAXTRACKPT=%(maxTrackPt)s 404 export ALIGNMENT_MINTRACKP=%(minTrackP)s 405 export ALIGNMENT_MAXTRACKP=%(maxTrackP)s 406 export ALIGNMENT_MAXDXY=%(maxDxy)s 407 export ALIGNMENT_MINTRACKERHITS=%(minTrackerHits)s 408 export ALIGNMENT_MAXTRACKERREDCHI2=%(maxTrackerRedChi2)s 409 export ALIGNMENT_MINNCROSSEDCHAMBERS=%(minNCrossedChambers)s 410 export ALIGNMENT_ALLOWTIDTEC=%(allowTIDTEC)s 411 export ALIGNMENT_TWOBIN=%(twoBin)s 412 export ALIGNMENT_WEIGHTALIGNMENT=%(weightAlignment)s 413 export ALIGNMENT_MINALIGNMENTHITS=%(minAlignmentHits)s 414 export ALIGNMENT_COMBINEME11=%(combineME11)s 415 export ALIGNMENT_MAXEVENTS=%(maxEvents)s 416 export ALIGNMENT_SKIPEVENTS=%(skipEvents)s 417 export ALIGNMENT_MAXRESSLOPEY=%(maxResSlopeY)s 418 export ALIGNMENT_DO_DT=%(doDT)s 419 export ALIGNMENT_DO_CSC=%(doCSC)s 420 export ALIGNMENT_JSON=%(json_file)s 421 export ALIGNMENT_CREATEMAPNTUPLE=%(createMapNtuple)s 422 #export ALIGNMENT_CREATEALIGNNTUPLE=%(createAlignNtuple)s 423 export ALIGNMENT_PREFILTER=%(preFilter)s 426 if [ \"zzz$ALIGNMENT_JSON\" != \"zzz\" ]; then 427 cp -f $ALIGNMENT_JSON $ALIGNMENT_CAFDIR/ 430 cp -f %(directory)sgather_cfg.py %(inputdbdir)s%(inputdb)s %(copytrackerdb)s $ALIGNMENT_CAFDIR/ 431 cd $ALIGNMENT_CAFDIR/ 435 cp -f *.tmp %(copyplots)s $ALIGNMENT_AFSDIR/%(directory)s 441 file(
"%salign.sh" % directory,
"w").
write(
"""#!/bin/sh 444 export ALIGNMENT_CAFDIR=`pwd` 447 eval `scramv1 run -sh` 448 export ALIGNMENT_AFSDIR=`pwd` 449 export ALIGNMENT_INPUTDB=%(inputdb)s 450 export ALIGNMENT_ITERATION=%(iteration)d 451 export ALIGNMENT_GLOBALTAG=%(globaltag)s 452 export ALIGNMENT_TRACKERCONNECT=%(trackerconnect)s 453 export ALIGNMENT_TRACKERALIGNMENT=%(trackeralignment)s 454 export ALIGNMENT_TRACKERAPECONNECT=%(trackerAPEconnect)s 455 export ALIGNMENT_TRACKERAPE=%(trackerAPE)s 456 export ALIGNMENT_TRACKERBOWSCONNECT=%(trackerBowsconnect)s 457 export ALIGNMENT_TRACKERBOWS=%(trackerBows)s 458 export ALIGNMENT_GPRCDCONNECT=%(gprcdconnect)s 459 export ALIGNMENT_GPRCD=%(gprcd)s 460 export ALIGNMENT_ISCOSMICS=%(iscosmics)s 461 export ALIGNMENT_STATION123PARAMS=%(station123params)s 462 export ALIGNMENT_STATION4PARAMS=%(station4params)s 463 export ALIGNMENT_CSCPARAMS=%(cscparams)s 464 export ALIGNMENT_MINTRACKPT=%(minTrackPt)s 465 export ALIGNMENT_MAXTRACKPT=%(maxTrackPt)s 466 export ALIGNMENT_MINTRACKP=%(minTrackP)s 467 export ALIGNMENT_MAXTRACKP=%(maxTrackP)s 468 export ALIGNMENT_MINTRACKERHITS=%(minTrackerHits)s 469 export ALIGNMENT_MAXTRACKERREDCHI2=%(maxTrackerRedChi2)s 470 export ALIGNMENT_ALLOWTIDTEC=%(allowTIDTEC)s 471 export ALIGNMENT_TWOBIN=%(twoBin)s 472 export ALIGNMENT_WEIGHTALIGNMENT=%(weightAlignment)s 473 export ALIGNMENT_MINALIGNMENTHITS=%(minAlignmentHits)s 474 export ALIGNMENT_COMBINEME11=%(combineME11)s 475 export ALIGNMENT_MAXRESSLOPEY=%(maxResSlopeY)s 476 export ALIGNMENT_CLEANUP=%(doCleanUp)s 477 export ALIGNMENT_CREATEALIGNNTUPLE=%(createAlignNtuple)s 478 export ALIGNMENT_RESIDUALSMODEL=%(residualsModel)s 479 export ALIGNMENT_PEAKNSIGMA=%(peakNSigma)s 480 export ALIGNMENT_USERESIDUALS=%(useResiduals)s 482 cp -f %(directory)salign_cfg.py %(inputdbdir)s%(inputdb)s %(directory)s*.tmp %(copytrackerdb)s $ALIGNMENT_CAFDIR/ 484 export ALIGNMENT_PLOTTINGTMP=`find %(directory)splotting0*.root -maxdepth 1 -size +0 -print 2> /dev/null` 486 # if it's 1st or last iteration, combine _plotting.root files into one: 487 if [ \"$ALIGNMENT_ITERATION\" != \"111\" ] || [ \"$ALIGNMENT_ITERATION\" == \"%(ITERATIONS)s\" ]; then 488 #nfiles=$(ls %(directory)splotting0*.root 2> /dev/null | wc -l) 489 if [ \"zzz$ALIGNMENT_PLOTTINGTMP\" != \"zzz\" ]; then 490 hadd -f1 %(directory)s%(director)s_plotting.root %(directory)splotting0*.root 491 #if [ $? == 0 ] && [ \"$ALIGNMENT_CLEANUP\" == \"True\" ]; then rm %(directory)splotting0*.root; fi 495 if [ \"$ALIGNMENT_CLEANUP\" == \"True\" ] && [ \"zzz$ALIGNMENT_PLOTTINGTMP\" != \"zzz\" ]; then 496 rm $ALIGNMENT_PLOTTINGTMP 499 cd $ALIGNMENT_CAFDIR/ 500 export ALIGNMENT_ALIGNMENTTMP=`find alignment*.tmp -maxdepth 1 -size +1k -print 2> /dev/null` 504 cp -f MuonAlignmentFromReference_report.py $ALIGNMENT_AFSDIR/%(directory)s%(director)s_report.py 505 cp -f MuonAlignmentFromReference_outputdb.db $ALIGNMENT_AFSDIR/%(directory)s%(director)s.db 506 cp -f MuonAlignmentFromReference_plotting.root $ALIGNMENT_AFSDIR/%(directory)s%(director)s.root 509 ./Alignment/MuonAlignmentAlgorithms/scripts/convertSQLiteXML.py %(directory)s%(director)s.db %(directory)s%(director)s.xml --noLayers --gprcdconnect $ALIGNMENT_GPRCDCONNECT --gprcd $ALIGNMENT_GPRCD 511 export ALIGNMENT_ALIGNMENTTMP=`find %(directory)salignment*.tmp -maxdepth 1 -size +1k -print 2> /dev/null` 512 if [ \"$ALIGNMENT_CLEANUP\" == \"True\" ] && [ \"zzz$ALIGNMENT_ALIGNMENTTMP\" != \"zzz\" ]; then 513 rm $ALIGNMENT_ALIGNMENTTMP 517 # if it's not 1st or last iteration, do some clean up: 518 if [ \"$ALIGNMENT_ITERATION\" != \"1\" ] && [ \"$ALIGNMENT_ITERATION\" != \"%(ITERATIONS)s\" ]; then 519 if [ \"$ALIGNMENT_CLEANUP\" == \"True\" ] && [ -e %(directory)s%(director)s.root ]; then 520 rm %(directory)s%(director)s.root 524 # if it's last iteration, apply chamber motion policy 525 if [ \"$ALIGNMENT_ITERATION\" == \"%(ITERATIONS)s\" ]; then 526 # convert this iteration's geometry into detailed xml 527 ./Alignment/MuonAlignmentAlgorithms/scripts/convertSQLiteXML.py %(directory)s%(director)s.db %(directory)s%(director)s_extra.xml --gprcdconnect $ALIGNMENT_GPRCDCONNECT --gprcd $ALIGNMENT_GPRCD 528 # perform motion policy 529 ./Alignment/MuonAlignmentAlgorithms/scripts/motionPolicyChamber.py \ 530 %(INITIALXML)s %(directory)s%(director)s_extra.xml \ 531 %(directory)s%(director)s_report.py \ 532 %(directory)s%(director)s_final.xml \ 533 --nsigma %(theNSigma)s 534 # convert the resulting xml into the final sqlite geometry 535 ./Alignment/MuonAlignmentAlgorithms/scripts/convertSQLiteXML.py %(directory)s%(director)s_final.xml %(directory)s%(director)s_final.db --gprcdconnect $ALIGNMENT_GPRCDCONNECT --gprcd $ALIGNMENT_GPRCD 546 export ALIGNMENT_CAFDIR=`pwd` 551 eval `scramv1 run -sh` 552 ALIGNMENT_AFSDIR=`pwd` 553 ALIGNMENT_ITERATION=%(iteration)d 554 ALIGNMENT_MAPPLOTS=None 555 ALIGNMENT_SEGDIFFPLOTS=None 556 ALIGNMENT_CURVATUREPLOTS=None 557 ALIGNMENT_EXTRAPLOTS=%(extraPlots)s 558 export ALIGNMENT_GPRCDCONNECT=%(gprcdconnect)s 559 export ALIGNMENT_GPRCD=%(gprcd)s 560 export ALIGNMENT_DO_DT=%(doDT)s 561 export ALIGNMENT_DO_CSC=%(doCSC)s 564 # copy the scripts to CAFDIR 565 cd Alignment/MuonAlignmentAlgorithms/scripts/ 566 cp -f plotscripts.py $ALIGNMENT_CAFDIR/ 567 cp -f mutypes.py $ALIGNMENT_CAFDIR/ 568 cp -f alignmentValidation.py $ALIGNMENT_CAFDIR/ 569 cp -f phiedges_fitfunctions.C $ALIGNMENT_CAFDIR/ 570 cp -f createTree.py $ALIGNMENT_CAFDIR/ 571 cp -f signConventions.py $ALIGNMENT_CAFDIR/ 572 cp -f convertSQLiteXML.py $ALIGNMENT_CAFDIR/ 573 cp -f wrapperExtraPlots.sh $ALIGNMENT_CAFDIR/ 575 cp Alignment/MuonAlignmentAlgorithms/test/browser/tree* $ALIGNMENT_CAFDIR/out/ 577 # copy the results to CAFDIR 578 cp -f %(directory1)s%(director1)s_report.py $ALIGNMENT_CAFDIR/files/ 579 cp -f %(directory)s%(director)s_report.py $ALIGNMENT_CAFDIR/files/ 580 cp -f %(directory1)s%(director1)s.root $ALIGNMENT_CAFDIR/files/ 581 cp -f %(directory)s%(director)s.root $ALIGNMENT_CAFDIR/files/ 582 if [ -e %(directory1)s%(director1)s_plotting.root ] && [ -e %(directory)s%(director)s_plotting.root ]; then 583 cp -f %(directory1)s%(director1)s_plotting.root $ALIGNMENT_CAFDIR/files/ 584 cp -f %(directory)s%(director)s_plotting.root $ALIGNMENT_CAFDIR/files/ 585 ALIGNMENT_MAPPLOTS=%(mapplots)s 586 ALIGNMENT_SEGDIFFPLOTS=%(segdiffplots)s 587 ALIGNMENT_CURVATUREPLOTS=%(curvatureplots)s 591 if [ $ALIGNMENT_DO_DT == \"True\" ]; then 594 if [ $ALIGNMENT_DO_CSC == \"True\" ]; then 595 dtcsc="${dtcsc} --csc" 599 cd $ALIGNMENT_CAFDIR/ 600 echo \" ### Start running ###\" 603 # do fits and median plots first 604 ./alignmentValidation.py -l %(validationLabel)s -i $ALIGNMENT_CAFDIR --i1 files --iN files --i1prefix %(director1)s --iNprefix %(director)s -o $ALIGNMENT_CAFDIR/out --createDirSructure --dt --csc --fit --median 606 if [ $ALIGNMENT_MAPPLOTS == \"True\" ]; then 607 ./alignmentValidation.py -l %(validationLabel)s -i $ALIGNMENT_CAFDIR --i1 files --iN files --i1prefix %(director1)s --iNprefix %(director)s -o $ALIGNMENT_CAFDIR/out $dtcsc --map 610 if [ $ALIGNMENT_SEGDIFFPLOTS == \"True\" ]; then 611 ./alignmentValidation.py -l %(validationLabel)s -i $ALIGNMENT_CAFDIR --i1 files --iN files --i1prefix %(director1)s --iNprefix %(director)s -o $ALIGNMENT_CAFDIR/out $dtcsc --segdiff 614 if [ $ALIGNMENT_CURVATUREPLOTS == \"True\" ]; then 615 ./alignmentValidation.py -l %(validationLabel)s -i $ALIGNMENT_CAFDIR --i1 files --iN files --i1prefix %(director1)s --iNprefix %(director)s -o $ALIGNMENT_CAFDIR/out $dtcsc --curvature 618 if [ $ALIGNMENT_EXTRAPLOTS == \"True\" ]; then 619 if [ \"zzz%(copytrackerdb)s\" != \"zzz\" ]; then 620 cp -f $ALIGNMENT_AFSDIR/%(copytrackerdb)s $ALIGNMENT_CAFDIR/ 622 cp $ALIGNMENT_AFSDIR/inertGlobalPositionRcd.db . 623 ./convertSQLiteXML.py $ALIGNMENT_AFSDIR/%(INITIALGEOM)s g0.xml --noLayers --gprcdconnect $ALIGNMENT_GPRCDCONNECT --gprcd $ALIGNMENT_GPRCD 624 ./wrapperExtraPlots.sh -n $ALIGNMENT_ITERATION -i $ALIGNMENT_AFSDIR -0 g0.xml -z -w %(station123params)s %(dir_no_)s 632 # run simple diagnostic 633 ./alignmentValidation.py -l %(validationLabel)s -i $ALIGNMENT_CAFDIR --i1 files --iN files --i1prefix %(director1)s --iNprefix %(director)s -o $ALIGNMENT_CAFDIR/out --dt --csc --diagnostic 635 # fill the tree browser structure: 636 ./createTree.py -i $ALIGNMENT_CAFDIR/out 638 timestamp=`date \"+%%y-%%m-%%d %%H:%%M:%%S\"` 639 echo \"%(validationLabel)s.plots (${timestamp})\" > out/label.txt 642 timestamp=`date +%%Y%%m%%d%%H%%M%%S` 643 tar czf %(validationLabel)s_${timestamp}.tgz out 644 cp -f %(validationLabel)s_${timestamp}.tgz $ALIGNMENT_AFSDIR/ 652 SUPER_SPECIAL_XY_AND_DXDZ_ITERATIONS =
False 654 bsubfile = [
"#!/bin/sh",
""]
659 for iteration
in range(1, ITERATIONS+1):
661 inputdb = INITIALGEOM
662 inputdbdir = directory[:]
664 inputdb = director +
".db" 665 inputdbdir = directory[:]
667 directory =
"%s%02d/" % (DIRNAME, iteration)
668 director = directory[:-1]
671 if DIRNAME[-1]==
'_': dir_no_ = DIRNAME[:-1]
673 os.system(
"rm -rf %s; mkdir %s" % (directory, directory))
674 os.system(
"cp Alignment/MuonAlignmentAlgorithms/python/gather_cfg.py %s" % directory)
675 os.system(
"cp Alignment/MuonAlignmentAlgorithms/python/align_cfg.py %s" % directory)
677 bsubfile.append(
"cd %s" % directory)
680 if mapplots_ingeneral
and (iteration == 1
or iteration == 3
or iteration == 5
or iteration == 7
or iteration == 9
or iteration == ITERATIONS): mapplots =
True 682 if segdiffplots_ingeneral
and (iteration == 1
or iteration == ITERATIONS): segdiffplots =
True 683 curvatureplots =
False 684 if curvatureplots_ingeneral
and (iteration == 1
or iteration == ITERATIONS): curvatureplots =
True 687 for jobnumber
in range(njobs):
688 if not options.inputInBlocks:
689 inputfiles =
" ".
join(fileNames[jobnumber*stepsize:(jobnumber+1)*stepsize])
691 inputfiles =
" ".
join(fileNamesBlocks[jobnumber])
693 if mapplots
or segdiffplots
or curvatureplots: copyplots =
"plotting*.root" 696 if len(inputfiles) > 0:
697 gather_fileName =
"%sgather%03d.sh" % (directory, jobnumber)
699 os.system(
"chmod +x %s" % gather_fileName)
700 bsubfile.append(
"echo %sgather%03d.sh" % (directory, jobnumber))
702 if last_align
is None: waiter =
"" 703 else: waiter =
"-w \"ended(%s)\"" % last_align
704 if options.big: queue =
"cmscaf1nd" 705 else: queue =
"cmscaf1nh" 707 bsubfile.append(
"bsub -R \"type==SLC6_64\" -q %s -J \"%s_gather%03d\" -u youremail.tamu.edu %s gather%03d.sh" % (queue, director, jobnumber, waiter, jobnumber))
709 bsubnames.append(
"ended(%s_gather%03d)" % (director, jobnumber))
713 if SUPER_SPECIAL_XY_AND_DXDZ_ITERATIONS:
714 if ( iteration == 1
or iteration == 3
or iteration == 5
or iteration == 7
or iteration == 9):
715 tmp = station123params, station123params, useResiduals
716 station123params, station123params, useResiduals =
"000010",
"000010",
"0010" 718 station123params, station123params, useResiduals = tmp
719 elif ( iteration == 2
or iteration == 4
or iteration == 6
or iteration == 8
or iteration == 10):
720 tmp = station123params, station123params, useResiduals
721 station123params, station123params, useResiduals =
"110001",
"100001",
"1100" 723 station123params, station123params, useResiduals = tmp
727 os.system(
"chmod +x %salign.sh" % directory)
729 bsubfile.append(
"echo %salign.sh" % directory)
730 if user_mail: bsubfile.append(
"bsub -R \"type==SLC6_64\" -q cmscaf1nd -J \"%s_align\" -u %s -w \"%s\" align.sh" % (director, user_mail,
" && ".
join(bsubnames)))
731 else: bsubfile.append(
"bsub -R \"type==SLC6_64\" -q cmscaf1nd -J \"%s_align\" -w \"%s\" align.sh" % (director,
" && ".
join(bsubnames)))
735 last_align =
"%s_align" % director
739 if len(validationLabel)
and iteration == ITERATIONS:
741 directory1 =
"%s01/" % DIRNAME
742 director1 = directory1[:-1]
745 os.system(
"chmod +x %svalidation.sh" % directory)
747 bsubfile.append(
"echo %svalidation.sh" % directory)
748 if user_mail: bsubfile.append(
"bsub -R \"type==SLC6_64\" -q cmscaf1nd -J \"%s_validation\" -u %s -w \"ended(%s)\" validation.sh" % (director, user_mail, last_align))
749 else: bsubfile.append(
"bsub -R \"type==SLC6_64\" -q cmscaf1nd -J \"%s_validation\" -w \"ended(%s)\" validation.sh" % (director, last_align))
751 bsubfile.append(
"cd ..")
756 os.system(
"chmod +x %s" % options.submitJobs)
def writeAlignCfg(fname, my_vars)
S & print(S &os, JobReport::InputFile const &f)
def writeGatherCfg(fname, my_vars)
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
def writeValidationCfg(fname, my_vars)
static std::string join(char **cmd)