3 import os, sys, optparse, math
6 for i
in range(len(copyargs)):
9 if copyargs[i].
find(
" ") != -1:
10 copyargs[i] =
"\"%s\"" % copyargs[i]
11 commandline =
" ".
join(copyargs)
15 usage =
"""./%(prog)s DIRNAME ITERATIONS INITIALGEOM INPUTFILES [options]
17 Creates (overwrites) a directory for each of the iterations and creates (overwrites)
18 submitJobs.sh with the submission sequence and dependencies.
20 DIRNAME directories will be named DIRNAME01, DIRNAME02, etc.
21 ITERATIONS number of iterations
22 INITIALGEOM SQLite file containing muon geometry with tag names
23 DTAlignmentRcd, DTAlignmentErrorRcd, CSCAlignmentRcd, CSCAlignmentErrorRcd
24 INPUTFILES Python file defining 'fileNames', a list of input files as
25 strings (create with findQualityFiles.py)""" % vars()
27 parser = optparse.OptionParser(usage)
28 parser.add_option(
"-j",
"--jobs",
29 help=
"approximate number of \"gather\" subjobs",
33 parser.add_option(
"-s",
"--submitJobs",
34 help=
"alternate name of submitJobs.sh script (please include .sh extension); a file with this name will be OVERWRITTEN",
36 default=
"submitJobs.sh",
38 parser.add_option(
"-b",
"--big",
39 help=
"if invoked, subjobs will also be run on cmscaf1nd",
42 parser.add_option(
"-u",
"--user_mail",
43 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",
46 parser.add_option(
"--mapplots",
47 help=
"if invoked, draw \"map plots\"",
50 parser.add_option(
"--segdiffplots",
51 help=
"if invoked, draw \"segment-difference plots\"",
54 parser.add_option(
"--curvatureplots",
55 help=
"if invoked, draw \"curvature plots\"",
57 dest=
"curvatureplots")
58 parser.add_option(
"--globalTag",
59 help=
"GlobalTag for alignment/calibration conditions (typically all conditions except muon and tracker alignment)",
61 default=
"CRAFT0831X_V1::All",
63 parser.add_option(
"--trackerconnect",
64 help=
"connect string for tracker alignment (frontier://FrontierProd/CMS_COND_310X_ALIGN or sqlite_file:...)",
67 dest=
"trackerconnect")
68 parser.add_option(
"--trackeralignment",
69 help=
"name of TrackerAlignmentRcd tag",
72 dest=
"trackeralignment")
73 parser.add_option(
"--trackerAPEconnect",
74 help=
"connect string for tracker APEs (frontier://... or sqlite_file:...)",
77 dest=
"trackerAPEconnect")
78 parser.add_option(
"--trackerAPE",
79 help=
"name of TrackerAlignmentErrorRcd tag (tracker APEs)",
81 default=
"AlignmentErrors",
83 parser.add_option(
"--trackerBowsconnect",
84 help=
"connect string for tracker Surface Deformations (frontier://... or sqlite_file:...)",
87 dest=
"trackerBowsconnect")
88 parser.add_option(
"--trackerBows",
89 help=
"name of TrackerSurfaceDeformationRcd tag",
91 default=
"TrackerSurfaceDeformations",
93 parser.add_option(
"--gprcdconnect",
94 help=
"connect string for GlobalPositionRcd (frontier://... or sqlite_file:...)",
98 parser.add_option(
"--gprcd",
99 help=
"name of GlobalPositionRcd tag",
101 default=
"GlobalPosition",
103 parser.add_option(
"--iscosmics",
104 help=
"if invoked, use cosmic track refitter instead of the standard one",
107 parser.add_option(
"--station123params",
108 help=
"alignable parameters for DT stations 1, 2, 3 (see SWGuideAlignmentAlgorithms#Selection_of_what_to_align)",
111 dest=
"station123params")
112 parser.add_option(
"--station4params",
113 help=
"alignable parameters for DT station 4",
116 dest=
"station4params")
117 parser.add_option(
"--cscparams",
118 help=
"alignable parameters for CSC chambers",
122 parser.add_option(
"--minTrackPt",
123 help=
"minimum allowed track transverse momentum (in GeV)",
127 parser.add_option(
"--maxTrackPt",
128 help=
"maximum allowed track transverse momentum (in GeV)",
132 parser.add_option(
"--minTrackP",
133 help=
"minimum allowed track momentum (in GeV)",
137 parser.add_option(
"--maxTrackP",
138 help=
"maximum allowed track momentum (in GeV)",
142 parser.add_option(
"--minTrackerHits",
143 help=
"minimum number of tracker hits",
146 dest=
"minTrackerHits")
147 parser.add_option(
"--maxTrackerRedChi2",
148 help=
"maximum tracker chi^2 per degrees of freedom",
151 dest=
"maxTrackerRedChi2")
152 parser.add_option(
"--notAllowTIDTEC",
153 help=
"if invoked, do not allow tracks that pass through the tracker's TID||TEC region (not recommended)",
155 dest=
"notAllowTIDTEC")
156 parser.add_option(
"--twoBin",
157 help=
"if invoked, apply the \"two-bin method\" to control charge-antisymmetric errors",
160 parser.add_option(
"--weightAlignment",
161 help=
"if invoked, segments will be weighted by ndf/chi^2 in the alignment",
163 dest=
"weightAlignment")
164 parser.add_option(
"--minAlignmentSegments",
165 help=
"minimum number of segments required to align a chamber",
168 dest=
"minAlignmentHits")
169 parser.add_option(
"--notCombineME11",
170 help=
"if invoced, treat ME1/1a and ME1/1b as separate objects",
172 dest=
"notCombineME11")
173 parser.add_option(
"--maxEvents",
174 help=
"maximum number of events",
178 parser.add_option(
"--skipEvents",
179 help=
"number of events to be skipped",
183 parser.add_option(
"--validationLabel",
184 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",
187 dest=
"validationLabel")
188 parser.add_option(
"--maxResSlopeY",
189 help=
"maximum residual slope y component",
193 parser.add_option(
"--motionPolicyNSigma",
194 help=
"minimum nsigma(deltax) position displacement in order to move a chamber for the final alignment result; default NSIGMA=3",
197 dest=
"motionPolicyNSigma")
198 parser.add_option(
"--noCleanUp",
199 help=
"if invoked, temporary plotting???.root and *.tmp files would not be removed at the end of each align job",
202 parser.add_option(
"--noCSC",
203 help=
"if invoked, CSC endcap chambers would not be processed",
206 parser.add_option(
"--noDT",
207 help=
"if invoked, DT barrel chambers would not be processed",
210 parser.add_option(
"--createMapNtuple",
211 help=
"if invoked while mapplots are switched on, a special ntuple would be created",
213 dest=
"createMapNtuple")
214 parser.add_option(
"--inputInBlocks",
215 help=
"if invoked, assume that INPUTFILES provides a list of files already groupped into job blocks, -j has no effect in that case",
217 dest=
"inputInBlocks")
218 parser.add_option(
"--json",
219 help=
"If present with JSON file as argument, use JSON file for good lumi mask. "+\
220 "The latest JSON file is available at /afs/cern.ch/cms/CAF/CMSCOMM/COMM_DQM/certification/Collisions11/7TeV/Prompt/",
224 parser.add_option(
"--createAlignNtuple",
225 help=
"if invoked, debug ntuples with residuals would be created during gather jobs",
227 dest=
"createAlignNtuple")
228 parser.add_option(
"--residualsModel",
229 help=
"functional residuals model. Possible vaslues: pureGaussian2D (default), pureGaussian, GaussPowerTails, ROOTVoigt, powerLawTails",
231 default=
"pureGaussian2D",
232 dest=
"residualsModel")
233 parser.add_option(
"--useResiduals",
234 help=
"select residuals to use, possible values: 1111, 1110, 1100, 1010, 0010 that correspond to x y dxdz dydz residuals",
238 parser.add_option(
"--peakNSigma",
239 help=
"if >0, only residuals peaks within n-sigma multidimentional ellipsoid would be considered in the alignment fit",
243 parser.add_option(
"--preFilter",
244 help=
"if invoked, MuonAlignmentPreFilter module would be invoked in the Path's beginning. Can significantly speed up gather jobs.",
247 parser.add_option(
"--muonCollectionTag",
248 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'",
251 dest=
"muonCollectionTag")
252 parser.add_option(
"--maxDxy",
253 help=
"maximum track impact parameter with relation to beamline",
257 parser.add_option(
"--minNCrossedChambers",
258 help=
"minimum number of muon chambers that a track is required to cross",
261 dest=
"minNCrossedChambers")
262 parser.add_option(
"--extraPlots",
263 help=
"produce additional plots with geometry, reports differences, and corrections visulizations",
267 if len(sys.argv) < 5:
268 raise SystemError,
"Too few arguments.\n\n"+parser.format_help()
270 DIRNAME = sys.argv[1]
271 ITERATIONS = int(sys.argv[2])
272 INITIALGEOM = sys.argv[3]
273 INPUTFILES = sys.argv[4]
275 options, args = parser.parse_args(sys.argv[5:])
276 user_mail = options.user_mail
277 mapplots_ingeneral = options.mapplots
278 segdiffplots_ingeneral = options.segdiffplots
279 curvatureplots_ingeneral = options.curvatureplots
280 globaltag = options.globaltag
281 trackerconnect = options.trackerconnect
282 trackeralignment = options.trackeralignment
283 trackerAPEconnect = options.trackerAPEconnect
284 trackerAPE = options.trackerAPE
285 trackerBowsconnect = options.trackerBowsconnect
286 trackerBows = options.trackerBows
287 gprcdconnect = options.gprcdconnect
288 gprcd = options.gprcd
289 iscosmics = str(options.iscosmics)
290 station123params = options.station123params
291 station4params = options.station4params
292 cscparams = options.cscparams
293 muonCollectionTag = options.muonCollectionTag
294 minTrackPt = options.minTrackPt
295 maxTrackPt = options.maxTrackPt
296 minTrackP = options.minTrackP
297 maxTrackP = options.maxTrackP
298 maxDxy = options.maxDxy
299 minTrackerHits = str(options.minTrackerHits)
300 maxTrackerRedChi2 = options.maxTrackerRedChi2
301 minNCrossedChambers = options.minNCrossedChambers
302 allowTIDTEC = str(
not options.notAllowTIDTEC)
303 twoBin = str(options.twoBin)
304 weightAlignment = str(options.weightAlignment)
305 minAlignmentHits = str(options.minAlignmentHits)
306 combineME11 = str(
not options.notCombineME11)
307 maxEvents = options.maxEvents
308 skipEvents = options.skipEvents
309 validationLabel = options.validationLabel
310 maxResSlopeY = options.maxResSlopeY
311 theNSigma = options.motionPolicyNSigma
312 residualsModel = options.residualsModel
313 peakNSigma = options.peakNSigma
314 preFilter =
not not options.preFilter
315 extraPlots = options.extraPlots
316 useResiduals = options.useResiduals
321 doCleanUp =
not options.noCleanUp
322 createMapNtuple =
not not options.createMapNtuple
323 createAlignNtuple =
not not options.createAlignNtuple
326 if options.noCSC: doCSC =
False
328 if options.noDT: doDT =
False
329 if options.noCSC
and options.noDT:
330 print "cannot do --noCSC and --noDT at the same time!"
333 json_file = options.json
338 njobs = options.subjobs
339 if (options.inputInBlocks):
340 njobs = len(fileNamesBlocks)
342 print "while --inputInBlocks is specified, the INPUTFILES has no blocks!"
345 stepsize = int(math.ceil(1.*len(fileNames)/options.subjobs))
347 pwd = str(os.getcwdu())
350 if trackerconnect[0:12] ==
"sqlite_file:": copytrackerdb +=
"%s " % trackerconnect[12:]
351 if trackerAPEconnect[0:12] ==
"sqlite_file:": copytrackerdb +=
"%s " % trackerAPEconnect[12:]
352 if trackerBowsconnect[0:12] ==
"sqlite_file:": copytrackerdb +=
"%s " % trackerBowsconnect[12:]
353 if gprcdconnect[0:12] ==
"sqlite_file:": copytrackerdb +=
"%s " % gprcdconnect[12:]
358 INITIALXML = INITIALGEOM +
'.xml'
359 if INITIALGEOM[-3:]==
'.db':
360 INITIALXML = INITIALGEOM[:-3] +
'.xml'
361 print "Converting",INITIALGEOM,
"to",INITIALXML,
" ...will be done in several seconds..."
362 print "./Alignment/MuonAlignmentAlgorithms/scripts/convertSQLiteXML.py %s %s --gprcdconnect %s --gprcd %s" % (INITIALGEOM,INITIALXML,gprcdconnect,gprcd)
363 exit_code = os.system(
"./Alignment/MuonAlignmentAlgorithms/scripts/convertSQLiteXML.py %s %s --gprcdconnect %s --gprcd %s" % (INITIALGEOM,INITIALXML,gprcdconnect,gprcd))
365 print "problem: conversion exited with code:", exit_code
374 export ALIGNMENT_CAFDIR=`pwd`
377 eval `scramv1 run -sh`
378 export ALIGNMENT_AFSDIR=`pwd`
380 export ALIGNMENT_INPUTFILES='%(inputfiles)s'
381 export ALIGNMENT_ITERATION=%(iteration)d
382 export ALIGNMENT_JOBNUMBER=%(jobnumber)d
383 export ALIGNMENT_MAPPLOTS=%(mapplots)s
384 export ALIGNMENT_SEGDIFFPLOTS=%(segdiffplots)s
385 export ALIGNMENT_CURVATUREPLOTS=%(curvatureplots)s
386 export ALIGNMENT_GLOBALTAG=%(globaltag)s
387 export ALIGNMENT_INPUTDB=%(inputdb)s
388 export ALIGNMENT_TRACKERCONNECT=%(trackerconnect)s
389 export ALIGNMENT_TRACKERALIGNMENT=%(trackeralignment)s
390 export ALIGNMENT_TRACKERAPECONNECT=%(trackerAPEconnect)s
391 export ALIGNMENT_TRACKERAPE=%(trackerAPE)s
392 export ALIGNMENT_TRACKERBOWSCONNECT=%(trackerBowsconnect)s
393 export ALIGNMENT_TRACKERBOWS=%(trackerBows)s
394 export ALIGNMENT_GPRCDCONNECT=%(gprcdconnect)s
395 export ALIGNMENT_GPRCD=%(gprcd)s
396 export ALIGNMENT_ISCOSMICS=%(iscosmics)s
397 export ALIGNMENT_STATION123PARAMS=%(station123params)s
398 export ALIGNMENT_STATION4PARAMS=%(station4params)s
399 export ALIGNMENT_CSCPARAMS=%(cscparams)s
400 export ALIGNMENT_MUONCOLLECTIONTAG=%(muonCollectionTag)s
401 export ALIGNMENT_MINTRACKPT=%(minTrackPt)s
402 export ALIGNMENT_MAXTRACKPT=%(maxTrackPt)s
403 export ALIGNMENT_MINTRACKP=%(minTrackP)s
404 export ALIGNMENT_MAXTRACKP=%(maxTrackP)s
405 export ALIGNMENT_MAXDXY=%(maxDxy)s
406 export ALIGNMENT_MINTRACKERHITS=%(minTrackerHits)s
407 export ALIGNMENT_MAXTRACKERREDCHI2=%(maxTrackerRedChi2)s
408 export ALIGNMENT_MINNCROSSEDCHAMBERS=%(minNCrossedChambers)s
409 export ALIGNMENT_ALLOWTIDTEC=%(allowTIDTEC)s
410 export ALIGNMENT_TWOBIN=%(twoBin)s
411 export ALIGNMENT_WEIGHTALIGNMENT=%(weightAlignment)s
412 export ALIGNMENT_MINALIGNMENTHITS=%(minAlignmentHits)s
413 export ALIGNMENT_COMBINEME11=%(combineME11)s
414 export ALIGNMENT_MAXEVENTS=%(maxEvents)s
415 export ALIGNMENT_SKIPEVENTS=%(skipEvents)s
416 export ALIGNMENT_MAXRESSLOPEY=%(maxResSlopeY)s
417 export ALIGNMENT_DO_DT=%(doDT)s
418 export ALIGNMENT_DO_CSC=%(doCSC)s
419 export ALIGNMENT_JSON=%(json_file)s
420 export ALIGNMENT_CREATEMAPNTUPLE=%(createMapNtuple)s
421 #export ALIGNMENT_CREATEALIGNNTUPLE=%(createAlignNtuple)s
422 export ALIGNMENT_PREFILTER=%(preFilter)s
425 if [ \"zzz$ALIGNMENT_JSON\" != \"zzz\" ]; then
426 cp -f $ALIGNMENT_JSON $ALIGNMENT_CAFDIR/
429 cp -f %(directory)sgather_cfg.py %(inputdbdir)s%(inputdb)s %(copytrackerdb)s $ALIGNMENT_CAFDIR/
430 cd $ALIGNMENT_CAFDIR/
434 cp -f *.tmp %(copyplots)s $ALIGNMENT_AFSDIR/%(directory)s
440 file(
"%salign.sh" % directory,
"w").
write(
"""#!/bin/sh
443 export ALIGNMENT_CAFDIR=`pwd`
446 eval `scramv1 run -sh`
447 export ALIGNMENT_AFSDIR=`pwd`
448 export ALIGNMENT_INPUTDB=%(inputdb)s
449 export ALIGNMENT_ITERATION=%(iteration)d
450 export ALIGNMENT_GLOBALTAG=%(globaltag)s
451 export ALIGNMENT_TRACKERCONNECT=%(trackerconnect)s
452 export ALIGNMENT_TRACKERALIGNMENT=%(trackeralignment)s
453 export ALIGNMENT_TRACKERAPECONNECT=%(trackerAPEconnect)s
454 export ALIGNMENT_TRACKERAPE=%(trackerAPE)s
455 export ALIGNMENT_TRACKERBOWSCONNECT=%(trackerBowsconnect)s
456 export ALIGNMENT_TRACKERBOWS=%(trackerBows)s
457 export ALIGNMENT_GPRCDCONNECT=%(gprcdconnect)s
458 export ALIGNMENT_GPRCD=%(gprcd)s
459 export ALIGNMENT_ISCOSMICS=%(iscosmics)s
460 export ALIGNMENT_STATION123PARAMS=%(station123params)s
461 export ALIGNMENT_STATION4PARAMS=%(station4params)s
462 export ALIGNMENT_CSCPARAMS=%(cscparams)s
463 export ALIGNMENT_MINTRACKPT=%(minTrackPt)s
464 export ALIGNMENT_MAXTRACKPT=%(maxTrackPt)s
465 export ALIGNMENT_MINTRACKP=%(minTrackP)s
466 export ALIGNMENT_MAXTRACKP=%(maxTrackP)s
467 export ALIGNMENT_MINTRACKERHITS=%(minTrackerHits)s
468 export ALIGNMENT_MAXTRACKERREDCHI2=%(maxTrackerRedChi2)s
469 export ALIGNMENT_ALLOWTIDTEC=%(allowTIDTEC)s
470 export ALIGNMENT_TWOBIN=%(twoBin)s
471 export ALIGNMENT_WEIGHTALIGNMENT=%(weightAlignment)s
472 export ALIGNMENT_MINALIGNMENTHITS=%(minAlignmentHits)s
473 export ALIGNMENT_COMBINEME11=%(combineME11)s
474 export ALIGNMENT_MAXRESSLOPEY=%(maxResSlopeY)s
475 export ALIGNMENT_CLEANUP=%(doCleanUp)s
476 export ALIGNMENT_CREATEALIGNNTUPLE=%(createAlignNtuple)s
477 export ALIGNMENT_RESIDUALSMODEL=%(residualsModel)s
478 export ALIGNMENT_PEAKNSIGMA=%(peakNSigma)s
479 export ALIGNMENT_USERESIDUALS=%(useResiduals)s
481 cp -f %(directory)salign_cfg.py %(inputdbdir)s%(inputdb)s %(directory)s*.tmp %(copytrackerdb)s $ALIGNMENT_CAFDIR/
483 export ALIGNMENT_PLOTTINGTMP=`ls %(directory)splotting0*.root 2> /dev/null`
485 # if it's 1st or last iteration, combine _plotting.root files into one:
486 if [ \"$ALIGNMENT_ITERATION\" != \"111\" ] || [ \"$ALIGNMENT_ITERATION\" == \"%(ITERATIONS)s\" ]; then
487 #nfiles=$(ls %(directory)splotting0*.root 2> /dev/null | wc -l)
488 if [ \"zzz$ALIGNMENT_PLOTTINGTMP\" != \"zzz\" ]; then
489 hadd -f1 %(directory)s%(director)s_plotting.root %(directory)splotting0*.root
490 #if [ $? == 0 ] && [ \"$ALIGNMENT_CLEANUP\" == \"True\" ]; then rm %(directory)splotting0*.root; fi
494 if [ \"$ALIGNMENT_CLEANUP\" == \"True\" ] && [ \"zzz$ALIGNMENT_PLOTTINGTMP\" != \"zzz\" ]; then
495 rm $ALIGNMENT_PLOTTINGTMP
498 cd $ALIGNMENT_CAFDIR/
499 export ALIGNMENT_ALIGNMENTTMP=`ls alignment*.tmp 2> /dev/null`
503 cp -f MuonAlignmentFromReference_report.py $ALIGNMENT_AFSDIR/%(directory)s%(director)s_report.py
504 cp -f MuonAlignmentFromReference_outputdb.db $ALIGNMENT_AFSDIR/%(directory)s%(director)s.db
505 cp -f MuonAlignmentFromReference_plotting.root $ALIGNMENT_AFSDIR/%(directory)s%(director)s.root
508 ./Alignment/MuonAlignmentAlgorithms/scripts/convertSQLiteXML.py %(directory)s%(director)s.db %(directory)s%(director)s.xml --noLayers --gprcdconnect $ALIGNMENT_GPRCDCONNECT --gprcd $ALIGNMENT_GPRCD
510 export ALIGNMENT_ALIGNMENTTMP=`ls %(directory)salignment*.tmp 2> /dev/null`
511 if [ \"$ALIGNMENT_CLEANUP\" == \"True\" ] && [ \"zzz$ALIGNMENT_ALIGNMENTTMP\" != \"zzz\" ]; then
512 rm $ALIGNMENT_ALIGNMENTTMP
516 # if it's not 1st or last iteration, do some clean up:
517 if [ \"$ALIGNMENT_ITERATION\" != \"1\" ] && [ \"$ALIGNMENT_ITERATION\" != \"%(ITERATIONS)s\" ]; then
518 if [ \"$ALIGNMENT_CLEANUP\" == \"True\" ] && [ -e %(directory)s%(director)s.root ]; then
519 rm %(directory)s%(director)s.root
523 # if it's last iteration, apply chamber motion policy
524 if [ \"$ALIGNMENT_ITERATION\" == \"%(ITERATIONS)s\" ]; then
525 # convert this iteration's geometry into detailed xml
526 ./Alignment/MuonAlignmentAlgorithms/scripts/convertSQLiteXML.py %(directory)s%(director)s.db %(directory)s%(director)s_extra.xml --gprcdconnect $ALIGNMENT_GPRCDCONNECT --gprcd $ALIGNMENT_GPRCD
527 # perform motion policy
528 ./Alignment/MuonAlignmentAlgorithms/scripts/motionPolicyChamber.py \
529 %(INITIALXML)s %(directory)s%(director)s_extra.xml \
530 %(directory)s%(director)s_report.py \
531 %(directory)s%(director)s_final.xml \
532 --nsigma %(theNSigma)s
533 # convert the resulting xml into the final sqlite geometry
534 ./Alignment/MuonAlignmentAlgorithms/scripts/convertSQLiteXML.py %(directory)s%(director)s_final.xml %(directory)s%(director)s_final.db --gprcdconnect $ALIGNMENT_GPRCDCONNECT --gprcd $ALIGNMENT_GPRCD
545 export ALIGNMENT_CAFDIR=`pwd`
550 eval `scramv1 run -sh`
551 ALIGNMENT_AFSDIR=`pwd`
552 ALIGNMENT_ITERATION=%(iteration)d
553 ALIGNMENT_MAPPLOTS=None
554 ALIGNMENT_SEGDIFFPLOTS=None
555 ALIGNMENT_CURVATUREPLOTS=None
556 ALIGNMENT_EXTRAPLOTS=%(extraPlots)s
557 export ALIGNMENT_GPRCDCONNECT=%(gprcdconnect)s
558 export ALIGNMENT_GPRCD=%(gprcd)s
559 export ALIGNMENT_DO_DT=%(doDT)s
560 export ALIGNMENT_DO_CSC=%(doCSC)s
563 # copy the scripts to CAFDIR
564 cd Alignment/MuonAlignmentAlgorithms/scripts/
565 cp -f plotscripts.py $ALIGNMENT_CAFDIR/
566 cp -f mutypes.py $ALIGNMENT_CAFDIR/
567 cp -f alignmentValidation.py $ALIGNMENT_CAFDIR/
568 cp -f phiedges_fitfunctions.C $ALIGNMENT_CAFDIR/
569 cp -f createTree.py $ALIGNMENT_CAFDIR/
570 cp -f signConventions.py $ALIGNMENT_CAFDIR/
571 cp -f convertSQLiteXML.py $ALIGNMENT_CAFDIR/
572 cp -f wrapperExtraPlots.sh $ALIGNMENT_CAFDIR/
574 cp Alignment/MuonAlignmentAlgorithms/test/browser/tree* $ALIGNMENT_CAFDIR/out/
576 # copy the results to CAFDIR
577 cp -f %(directory1)s%(director1)s_report.py $ALIGNMENT_CAFDIR/files/
578 cp -f %(directory)s%(director)s_report.py $ALIGNMENT_CAFDIR/files/
579 cp -f %(directory1)s%(director1)s.root $ALIGNMENT_CAFDIR/files/
580 cp -f %(directory)s%(director)s.root $ALIGNMENT_CAFDIR/files/
581 if [ -e %(directory1)s%(director1)s_plotting.root ] && [ -e %(directory)s%(director)s_plotting.root ]; then
582 cp -f %(directory1)s%(director1)s_plotting.root $ALIGNMENT_CAFDIR/files/
583 cp -f %(directory)s%(director)s_plotting.root $ALIGNMENT_CAFDIR/files/
584 ALIGNMENT_MAPPLOTS=%(mapplots)s
585 ALIGNMENT_SEGDIFFPLOTS=%(segdiffplots)s
586 ALIGNMENT_CURVATUREPLOTS=%(curvatureplots)s
590 if [ $ALIGNMENT_DO_DT == \"True\" ]; then
593 if [ $ALIGNMENT_DO_CSC == \"True\" ]; then
594 dtcsc="${dtcsc} --csc"
598 cd $ALIGNMENT_CAFDIR/
599 echo \" ### Start running ###\"
602 # do fits and median plots first
603 ./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
605 if [ $ALIGNMENT_MAPPLOTS == \"True\" ]; then
606 ./alignmentValidation.py -l %(validationLabel)s -i $ALIGNMENT_CAFDIR --i1 files --iN files --i1prefix %(director1)s --iNprefix %(director)s -o $ALIGNMENT_CAFDIR/out $dtcsc --map
609 if [ $ALIGNMENT_SEGDIFFPLOTS == \"True\" ]; then
610 ./alignmentValidation.py -l %(validationLabel)s -i $ALIGNMENT_CAFDIR --i1 files --iN files --i1prefix %(director1)s --iNprefix %(director)s -o $ALIGNMENT_CAFDIR/out $dtcsc --segdiff
613 if [ $ALIGNMENT_CURVATUREPLOTS == \"True\" ]; then
614 ./alignmentValidation.py -l %(validationLabel)s -i $ALIGNMENT_CAFDIR --i1 files --iN files --i1prefix %(director1)s --iNprefix %(director)s -o $ALIGNMENT_CAFDIR/out $dtcsc --curvature
617 if [ $ALIGNMENT_EXTRAPLOTS == \"True\" ]; then
618 if [ \"zzz%(copytrackerdb)s\" != \"zzz\" ]; then
619 cp -f $ALIGNMENT_AFSDIR/%(copytrackerdb)s $ALIGNMENT_CAFDIR/
621 cp $ALIGNMENT_AFSDIR/inertGlobalPositionRcd.db .
622 ./convertSQLiteXML.py $ALIGNMENT_AFSDIR/%(INITIALGEOM)s g0.xml --noLayers --gprcdconnect $ALIGNMENT_GPRCDCONNECT --gprcd $ALIGNMENT_GPRCD
623 ./wrapperExtraPlots.sh -n $ALIGNMENT_ITERATION -i $ALIGNMENT_AFSDIR -0 g0.xml -z -w %(station123params)s %(dir_no_)s
631 # run simple diagnostic
632 ./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
634 # fill the tree browser structure:
635 ./createTree.py -i $ALIGNMENT_CAFDIR/out
637 timestamp=`date \"+%%y-%%m-%%d %%H:%%M:%%S\"`
638 echo \"%(validationLabel)s.plots (${timestamp})\" > out/label.txt
641 timestamp=`date +%%Y%%m%%d%%H%%M%%S`
642 tar czf %(validationLabel)s_${timestamp}.tgz out
643 cp -f %(validationLabel)s_${timestamp}.tgz $ALIGNMENT_AFSDIR/
651 SUPER_SPECIAL_XY_AND_DXDZ_ITERATIONS =
False
653 bsubfile = [
"#!/bin/sh",
""]
658 for iteration
in range(1, ITERATIONS+1):
660 inputdb = INITIALGEOM
661 inputdbdir = directory[:]
663 inputdb = director +
".db"
664 inputdbdir = directory[:]
666 directory =
"%s%02d/" % (DIRNAME, iteration)
667 director = directory[:-1]
670 if DIRNAME[-1]==
'_': dir_no_ = DIRNAME[:-1]
672 os.system(
"rm -rf %s; mkdir %s" % (directory, directory))
673 os.system(
"cp Alignment/MuonAlignmentAlgorithms/python/gather_cfg.py %s" % directory)
674 os.system(
"cp Alignment/MuonAlignmentAlgorithms/python/align_cfg.py %s" % directory)
676 bsubfile.append(
"cd %s" % directory)
679 if mapplots_ingeneral
and (iteration == 1
or iteration == 3
or iteration == 5
or iteration == 7
or iteration == 9
or iteration == ITERATIONS): mapplots =
True
681 if segdiffplots_ingeneral
and (iteration == 1
or iteration == ITERATIONS): segdiffplots =
True
682 curvatureplots =
False
683 if curvatureplots_ingeneral
and (iteration == 1
or iteration == ITERATIONS): curvatureplots =
True
686 for jobnumber
in range(njobs):
687 if not options.inputInBlocks:
688 inputfiles =
" ".
join(fileNames[jobnumber*stepsize:(jobnumber+1)*stepsize])
690 inputfiles =
" ".
join(fileNamesBlocks[jobnumber])
692 if mapplots
or segdiffplots
or curvatureplots: copyplots =
"plotting*.root"
695 if len(inputfiles) > 0:
696 gather_fileName =
"%sgather%03d.sh" % (directory, jobnumber)
698 os.system(
"chmod +x %s" % gather_fileName)
699 bsubfile.append(
"echo %sgather%03d.sh" % (directory, jobnumber))
701 if last_align
is None: waiter =
""
702 else: waiter =
"-w \"ended(%s)\"" % last_align
703 if options.big: queue =
"cmscaf1nd"
704 else: queue =
"cmscaf1nh"
706 if user_mail: bsubfile.append(
"bsub -R \"type==SLC5_64\" -q %s -J \"%s_gather%03d\" -u %s %s gather%03d.sh" % (queue, director, jobnumber, user_mail, waiter, jobnumber))
707 else: bsubfile.append(
"bsub -R \"type==SLC5_64\" -q %s -J \"%s_gather%03d\" %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==SLC5_64\" -q cmscaf1nd -J \"%s_align\" -u %s -w \"%s\" align.sh" % (director, user_mail,
" && ".
join(bsubnames)))
731 else: bsubfile.append(
"bsub -R \"type==SLC5_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==SLC5_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==SLC5_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)
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
static std::string join(char **cmd)