CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/src/Alignment/MuonAlignmentAlgorithms/scripts/createJobs.py

Go to the documentation of this file.
00001 #! /usr/bin/env python
00002 
00003 import os, sys, optparse, math
00004 
00005 copyargs = sys.argv[:]
00006 for i in range(len(copyargs)):
00007     if copyargs[i] == "":
00008         copyargs[i] = "\"\""
00009     if copyargs[i].find(" ") != -1:
00010         copyargs[i] = "\"%s\"" % copyargs[i]
00011 commandline = " ".join(copyargs)
00012 
00013 usage = """./%prog DIRNAME ITERATIONS INITIALGEOM INPUTFILES [options]
00014 
00015 Creates (overwrites) a directory for each of the iterations and creates (overwrites)
00016 submitJobs.sh with the submission sequence and dependencies.
00017 
00018 DIRNAME        directories will be named DIRNAME01, DIRNAME02, etc.
00019 ITERATIONS     number of iterations
00020 INITIALGEOM    SQLite file containing muon geometry with tag names
00021                DTAlignmentRcd, DTAlignmentErrorRcd, CSCAlignmentRcd, CSCAlignmentErrorRcd
00022 INPUTFILES     Python file defining 'fileNames', a list of input files as
00023                strings (create with findQualityFiles.py)"""
00024 
00025 parser = optparse.OptionParser(usage)
00026 parser.add_option("-j", "--jobs",
00027                    help="approximate number of \"gather\" subjobs",
00028                    type="int",
00029                    default=50,
00030                    dest="subjobs")
00031 parser.add_option("-s", "--submitJobs",
00032                    help="alternate name of submitJobs.sh script (please include .sh extension); a file with this name will be OVERWRITTEN",
00033                    type="string",
00034                    default="submitJobs.sh",
00035                    dest="submitJobs")
00036 parser.add_option("-b", "--big",
00037                   help="if invoked, subjobs will also be run on cmscaf1nd",
00038                   action="store_true",
00039                   dest="big")
00040 parser.add_option("--mapplots",
00041                   help="if invoked, draw \"map plots\"",
00042                   action="store_true",
00043                   dest="mapplots")
00044 parser.add_option("--segdiffplots",
00045                   help="if invoked, draw \"segment-difference plots\"",
00046                   action="store_true",
00047                   dest="segdiffplots")
00048 parser.add_option("--curvatureplots",
00049                   help="if invoked, draw \"curvature plots\"",
00050                   action="store_true",
00051                   dest="curvatureplots")
00052 parser.add_option("--globalTag",
00053                   help="GlobalTag for alignment/calibration conditions (typically all conditions except muon and tracker alignment)",
00054                   type="string",
00055                   default="CRAFT0831X_V1::All",
00056                   dest="globaltag")
00057 parser.add_option("--trackerconnect",
00058                   help="connect string for tracker alignment (frontier://... or sqlite_file:...)",
00059                   type="string",
00060                   default="",
00061                   dest="trackerconnect")
00062 parser.add_option("--trackeralignment",
00063                   help="name of TrackerAlignmentRcd tag",
00064                   type="string",
00065                   default="Alignments",
00066                   dest="trackeralignment")
00067 parser.add_option("--trackerAPEconnect",
00068                   help="connect string for tracker APEs (frontier://... or sqlite_file:...)",
00069                   type="string",
00070                   default="",
00071                   dest="trackerAPEconnect")
00072 parser.add_option("--trackerAPE",
00073                   help="name of TrackerAlignmentErrorRcd tag (tracker APEs)",
00074                   type="string",
00075                   default="AlignmentErrors",
00076                   dest="trackerAPE")
00077 parser.add_option("--gprcdconnect",
00078                   help="connect string for GlobalPositionRcd (frontier://... or sqlite_file:...)",
00079                   type="string",
00080                   default="",
00081                   dest="gprcdconnect")
00082 parser.add_option("--gprcd",
00083                   help="name of GlobalPositionRcd tag",
00084                   type="string",
00085                   default="SurveyGeometry",
00086                   dest="gprcd")
00087 parser.add_option("--iscosmics",
00088                   help="if invoked, use cosmic track refitter instead of the standard one",
00089                   action="store_true",
00090                   dest="iscosmics")
00091 parser.add_option("--station123params",
00092                   help="alignable parameters for DT stations 1, 2, 3 (see SWGuideAlignmentAlgorithms#Selection_of_what_to_align)",
00093                   type="string",
00094                   default="111111",
00095                   dest="station123params")
00096 parser.add_option("--station4params",
00097                   help="alignable parameters for DT station 4",
00098                   type="string",
00099                   default="100011",
00100                   dest="station4params")
00101 parser.add_option("--cscparams",
00102                   help="alignable parameters for CSC chambers",
00103                   type="string",
00104                   default="100011",
00105                   dest="cscparams")
00106 parser.add_option("--minTrackPt",
00107                   help="minimum allowed track transverse momentum (in GeV)",
00108                   type="string",
00109                   default="100",
00110                   dest="minTrackPt")
00111 parser.add_option("--maxTrackPt",
00112                   help="maximum allowed track transverse momentum (in GeV)",
00113                   type="string",
00114                   default="200",
00115                   dest="maxTrackPt")
00116 parser.add_option("--minTrackerHits",
00117                   help="minimum number of tracker hits",
00118                   type="int",
00119                   default=15,
00120                   dest="minTrackerHits")
00121 parser.add_option("--maxTrackerRedChi2",
00122                   help="maximum tracker chi^2 per degrees of freedom",
00123                   type="string",
00124                   default="10",
00125                   dest="maxTrackerRedChi2")
00126 parser.add_option("--allowTIDTEC",
00127                   help="if invoked, allow tracks that pass through the tracker's !TID/!TEC region (recommended)",
00128                   action="store_true",
00129                   dest="allowTIDTEC")
00130 parser.add_option("--twoBin",
00131                   help="if invoked, apply the \"two-bin method\" to control charge-antisymmetric errors",
00132                   action="store_true",
00133                   dest="twoBin")
00134 parser.add_option("--weightAlignment",
00135                   help="if invoked, segments will be weighted by ndf/chi^2 in the alignment",
00136                   action="store_true",
00137                   dest="weightAlignment")
00138 parser.add_option("--minAlignmentSegments",
00139                   help="minimum number of segments required to align a chamber",
00140                   type="int",
00141                   default=5,
00142                   dest="minAlignmentHits")
00143 parser.add_option("--combineME11",
00144                   help="treat ME1/1a and ME1/1b as the same objects",
00145                   action="store_true",
00146                   dest="combineME11")
00147 parser.add_option("--maxEvents",
00148                   help="maximum number of events",
00149                   type="string",
00150                   default="-1",
00151                   dest="maxEvents")
00152 parser.add_option("--skipEvents",
00153                   help="number of events to be skipped",
00154                   type="string",
00155                   default="0",
00156                   dest="skipEvents")
00157 parser.add_option("--validationLabel",
00158                   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",
00159                   type="string",
00160                   default="",
00161                   dest="validationLabel")
00162 parser.add_option("--maxResSlopeY",
00163                   help="maximum residual slope y component",
00164                   type="string",
00165                   default="10",
00166                   dest="maxResSlopeY")
00167 parser.add_option("--motionPolicyNSigma",
00168                   help="minimum nsigma(deltax) position displacement in order to move a chamber for the final alignment result; default NSIGMA=3",
00169                   type="int",
00170                   default=3,
00171                   dest="motionPolicyNSigma")
00172 
00173 if len(sys.argv) < 5:
00174     raise SystemError, "Too few arguments.\n\n"+parser.format_help()
00175 
00176 DIRNAME = sys.argv[1]
00177 ITERATIONS = int(sys.argv[2])
00178 INITIALGEOM = sys.argv[3]
00179 INPUTFILES = sys.argv[4]
00180 
00181 options, args = parser.parse_args(sys.argv[5:])
00182 mapplots_ingeneral = options.mapplots
00183 segdiffplots_ingeneral = options.segdiffplots
00184 curvatureplots_ingeneral = options.curvatureplots
00185 globaltag = options.globaltag
00186 trackerconnect = options.trackerconnect
00187 trackeralignment = options.trackeralignment
00188 trackerAPEconnect = options.trackerAPEconnect
00189 trackerAPE = options.trackerAPE
00190 gprcdconnect = options.gprcdconnect
00191 gprcd = options.gprcd
00192 iscosmics = str(options.iscosmics)
00193 station123params = options.station123params
00194 station4params = options.station4params
00195 cscparams = options.cscparams
00196 minTrackPt = options.minTrackPt
00197 maxTrackPt = options.maxTrackPt
00198 minTrackerHits = str(options.minTrackerHits)
00199 maxTrackerRedChi2 = options.maxTrackerRedChi2
00200 allowTIDTEC = str(options.allowTIDTEC)
00201 twoBin = str(options.twoBin)
00202 weightAlignment = str(options.weightAlignment)
00203 minAlignmentHits = str(options.minAlignmentHits)
00204 combineME11 = str(options.combineME11)
00205 maxEvents = options.maxEvents
00206 skipEvents = options.skipEvents
00207 validationLabel = options.validationLabel
00208 maxResSlopeY = options.maxResSlopeY
00209 theNSigma = options.motionPolicyNSigma
00210 
00211 execfile(INPUTFILES)
00212 stepsize = int(math.ceil(1.*len(fileNames)/options.subjobs))
00213 pwd = str(os.getcwdu())
00214 
00215 bsubfile = ["#!/bin/sh", ""]
00216 bsubnames = []
00217 last_align = None
00218 
00219 #####################################################################
00220 # step 0: convert initial geometry to xml
00221 INITIALXML = INITIALGEOM + '.xml'
00222 if INITIALGEOM[-3:]=='.db':
00223   INITIALXML = INITIALGEOM[:-3] + '.xml'
00224 print "Converting",INITIALGEOM,"to",INITIALXML," ...will be done in several seconds..."
00225 exit_code = os.system("./Alignment/MuonAlignmentAlgorithms/scripts/convertSQLiteXML.py  %s %s" % (INITIALGEOM,INITIALXML))
00226 if exit_code>0:
00227   print "problem: conversion exited with code:", exit_code
00228   sys.exit()
00229 
00230 #####################################################################
00231 
00232 directory = ""
00233 for iteration in range(1, ITERATIONS+1):
00234     if iteration == 1:
00235         inputdb = INITIALGEOM
00236         inputdbdir = directory[:]
00237     else:
00238         inputdb = director + ".db"
00239         inputdbdir = directory[:]
00240 
00241     directory = "%s%02d/" % (DIRNAME, iteration)
00242     director = directory[:-1]
00243     os.system("rm -rf %s; mkdir %s" % (directory, directory))
00244     os.system("cp gather_cfg.py %s" % directory)
00245     os.system("cp align_cfg.py %s" % directory)
00246 
00247     bsubfile.append("cd %s" % directory)
00248 
00249     mapplots = False
00250     if mapplots_ingeneral and (iteration == 1 or iteration == ITERATIONS): mapplots = True
00251     segdiffplots = False
00252     if segdiffplots_ingeneral and (iteration == 1 or iteration == ITERATIONS): segdiffplots = True
00253     curvatureplots = False
00254     if curvatureplots_ingeneral and (iteration == 1 or iteration == ITERATIONS): curvatureplots = True
00255 
00256     for jobnumber in range(options.subjobs):
00257         gather_fileName = "%sgather%03d.sh" % (directory, jobnumber)
00258         inputfiles = " ".join(fileNames[jobnumber*stepsize:(jobnumber+1)*stepsize])
00259 
00260         if mapplots or segdiffplots or curvatureplots: copyplots = "plotting*.root"
00261         else: copyplots = ""
00262 
00263         copytrackerdb = ""
00264         if trackerconnect[0:12] == "sqlite_file:": copytrackerdb += "%s " % trackerconnect[12:]
00265         if trackerAPEconnect[0:12] == "sqlite_file:": copytrackerdb += "%s " % trackerAPEconnect[12:]
00266         if gprcdconnect[0:12] == "sqlite_file:": copytrackerdb += "%s " % gprcdconnect[12:]
00267 
00268         if len(inputfiles) > 0:
00269             file(gather_fileName, "w").write("""#/bin/sh
00270 # %(commandline)s
00271 
00272 export ALIGNMENT_CAFDIR=`pwd`
00273 
00274 cd %(pwd)s
00275 eval `scramv1 run -sh`
00276 export ALIGNMENT_AFSDIR=`pwd`
00277 
00278 export ALIGNMENT_INPUTFILES='%(inputfiles)s'
00279 export ALIGNMENT_ITERATION=%(iteration)d
00280 export ALIGNMENT_JOBNUMBER=%(jobnumber)d
00281 export ALIGNMENT_MAPPLOTS=%(mapplots)s
00282 export ALIGNMENT_SEGDIFFPLOTS=%(segdiffplots)s
00283 export ALIGNMENT_CURVATUREPLOTS=%(curvatureplots)s
00284 export ALIGNMENT_GLOBALTAG=%(globaltag)s
00285 export ALIGNMENT_INPUTDB=%(inputdb)s
00286 export ALIGNMENT_TRACKERCONNECT=%(trackerconnect)s
00287 export ALIGNMENT_TRACKERALIGNMENT=%(trackeralignment)s
00288 export ALIGNMENT_TRACKERAPECONNECT=%(trackerAPEconnect)s
00289 export ALIGNMENT_TRACKERAPE=%(trackerAPE)s
00290 export ALIGNMENT_GPRCDCONNECT=%(gprcdconnect)s
00291 export ALIGNMENT_GPRCD=%(gprcd)s
00292 export ALIGNMENT_ISCOSMICS=%(iscosmics)s
00293 export ALIGNMENT_STATION123PARAMS=%(station123params)s
00294 export ALIGNMENT_STATION4PARAMS=%(station4params)s
00295 export ALIGNMENT_CSCPARAMS=%(cscparams)s
00296 export ALIGNMENT_MINTRACKPT=%(minTrackPt)s
00297 export ALIGNMENT_MAXTRACKPT=%(maxTrackPt)s
00298 export ALIGNMENT_MINTRACKERHITS=%(minTrackerHits)s
00299 export ALIGNMENT_MAXTRACKERREDCHI2=%(maxTrackerRedChi2)s
00300 export ALIGNMENT_ALLOWTIDTEC=%(allowTIDTEC)s
00301 export ALIGNMENT_TWOBIN=%(twoBin)s
00302 export ALIGNMENT_WEIGHTALIGNMENT=%(weightAlignment)s
00303 export ALIGNMENT_MINALIGNMENTHITS=%(minAlignmentHits)s
00304 export ALIGNMENT_COMBINEME11=%(combineME11)s
00305 export ALIGNMENT_MAXEVENTS=%(maxEvents)s
00306 export ALIGNMENT_SKIPEVENTS=%(skipEvents)s
00307 export ALIGNMENT_MAXRESSLOPEY=%(maxResSlopeY)s
00308 
00309 cp -f %(directory)sgather_cfg.py %(inputdbdir)s%(inputdb)s %(copytrackerdb)s $ALIGNMENT_CAFDIR/
00310 cd $ALIGNMENT_CAFDIR/
00311 ls -l
00312 cmsRun gather_cfg.py
00313 ls -l
00314 cp -f *.tmp %(copyplots)s $ALIGNMENT_AFSDIR/%(directory)s
00315 """ % vars())
00316             os.system("chmod +x %s" % gather_fileName)
00317             bsubfile.append("echo %sgather%03d.sh" % (directory, jobnumber))
00318 
00319             if last_align is None: waiter = ""
00320             else: waiter = "-w \"ended(%s)\"" % last_align            
00321             if options.big: queue = "cmscaf1nd"
00322             else: queue = "cmscaf1nh"
00323 
00324             bsubfile.append("bsub -R \"type==SLC5_64\" -q %s -J \"%s_gather%03d\" %s gather%03d.sh" % (queue, director, jobnumber, waiter, jobnumber))
00325 
00326             bsubnames.append("ended(%s_gather%03d)" % (director, jobnumber))
00327 
00328     file("%sconvert-db-to-xml_cfg.py" % directory, "w").write("""from Alignment.MuonAlignment.convertSQLitetoXML_cfg import *
00329 process.PoolDBESSource.connect = \"sqlite_file:%(directory)s%(director)s.db\"
00330 process.MuonGeometryDBConverter.outputXML.fileName = \"%(directory)s%(director)s.xml\"
00331 process.MuonGeometryDBConverter.outputXML.relativeto = \"ideal\"
00332 process.MuonGeometryDBConverter.outputXML.suppressDTChambers = False
00333 process.MuonGeometryDBConverter.outputXML.suppressDTSuperLayers = True
00334 process.MuonGeometryDBConverter.outputXML.suppressDTLayers = True
00335 process.MuonGeometryDBConverter.outputXML.suppressCSCChambers = False
00336 process.MuonGeometryDBConverter.outputXML.suppressCSCLayers = True
00337 
00338 process.MuonGeometryDBConverter.getAPEs = True
00339 process.PoolDBESSource.toGet = cms.VPSet(
00340     cms.PSet(record = cms.string(\"DTAlignmentRcd\"), tag = cms.string(\"DTAlignmentRcd\")),
00341     cms.PSet(record = cms.string(\"DTAlignmentErrorRcd\"), tag = cms.string(\"DTAlignmentErrorRcd\")),
00342     cms.PSet(record = cms.string(\"CSCAlignmentRcd\"), tag = cms.string(\"CSCAlignmentRcd\")),
00343     cms.PSet(record = cms.string(\"CSCAlignmentErrorRcd\"), tag = cms.string(\"CSCAlignmentErrorRcd\")),
00344       )
00345 """ % vars())
00346 
00347     copytrackerdb = ""
00348     if trackerconnect[0:12] == "sqlite_file:": copytrackerdb += "%s " % trackerconnect[12:]
00349     if trackerAPEconnect[0:12] == "sqlite_file:": copytrackerdb += "%s " % trackerAPEconnect[12:]
00350     if gprcdconnect[0:12] == "sqlite_file:": copytrackerdb += "%s " % gprcdconnect[12:]
00351 
00352     file("%salign.sh" % directory, "w").write("""#!/bin/sh
00353 # %(commandline)s
00354 
00355 export ALIGNMENT_CAFDIR=`pwd`
00356 
00357 cd %(pwd)s
00358 eval `scramv1 run -sh`
00359 export ALIGNMENT_AFSDIR=`pwd`
00360 export ALIGNMENT_INPUTDB=%(inputdb)s
00361 export ALIGNMENT_ITERATION=%(iteration)d
00362 export ALIGNMENT_GLOBALTAG=%(globaltag)s
00363 export ALIGNMENT_TRACKERCONNECT=%(trackerconnect)s
00364 export ALIGNMENT_TRACKERALIGNMENT=%(trackeralignment)s
00365 export ALIGNMENT_TRACKERAPECONNECT=%(trackerAPEconnect)s
00366 export ALIGNMENT_TRACKERAPE=%(trackerAPE)s
00367 export ALIGNMENT_GPRCDCONNECT=%(gprcdconnect)s
00368 export ALIGNMENT_GPRCD=%(gprcd)s
00369 export ALIGNMENT_ISCOSMICS=%(iscosmics)s
00370 export ALIGNMENT_STATION123PARAMS=%(station123params)s
00371 export ALIGNMENT_STATION4PARAMS=%(station4params)s
00372 export ALIGNMENT_CSCPARAMS=%(cscparams)s
00373 export ALIGNMENT_MINTRACKPT=%(minTrackPt)s
00374 export ALIGNMENT_MAXTRACKPT=%(maxTrackPt)s
00375 export ALIGNMENT_MINTRACKERHITS=%(minTrackerHits)s
00376 export ALIGNMENT_MAXTRACKERREDCHI2=%(maxTrackerRedChi2)s
00377 export ALIGNMENT_ALLOWTIDTEC=%(allowTIDTEC)s
00378 export ALIGNMENT_TWOBIN=%(twoBin)s
00379 export ALIGNMENT_WEIGHTALIGNMENT=%(weightAlignment)s
00380 export ALIGNMENT_MINALIGNMENTHITS=%(minAlignmentHits)s
00381 export ALIGNMENT_COMBINEME11=%(combineME11)s
00382 export ALIGNMENT_MAXRESSLOPEY=%(maxResSlopeY)s
00383 
00384 cp -f %(directory)salign_cfg.py %(directory)sconvert-db-to-xml_cfg.py %(inputdbdir)s%(inputdb)s %(directory)s*.tmp  %(copytrackerdb)s $ALIGNMENT_CAFDIR/
00385 cd $ALIGNMENT_CAFDIR/
00386 export ALIGNMENT_ALIGNMENTTMP=`ls alignment*.tmp`
00387 
00388 ls -l
00389 cmsRun align_cfg.py
00390 cp -f MuonAlignmentFromReference_report.py $ALIGNMENT_AFSDIR/%(directory)s%(director)s_report.py
00391 cp -f MuonAlignmentFromReference_outputdb.db $ALIGNMENT_AFSDIR/%(directory)s%(director)s.db
00392 cp -f MuonAlignmentFromReference_plotting.root $ALIGNMENT_AFSDIR/%(directory)s%(director)s.root
00393 
00394 cd $ALIGNMENT_AFSDIR
00395 cmsRun %(directory)sconvert-db-to-xml_cfg.py
00396 
00397 # if it's 1st or last iteration, combine _plotting.root files into one:
00398 if [ \"$ALIGNMENT_ITERATION\" == \"1\" ] || [ \"$ALIGNMENT_ITERATION\" == \"%(ITERATIONS)s\" ]; then
00399   nfiles=$(ls %(directory)splotting0*.root 2> /dev/null | wc -l)
00400   if [ \"$nfiles\" != \"0\" ]; then
00401     hadd -f1 %(directory)s%(director)s_plotting.root %(directory)splotting0*.root
00402     #if [ $? == 0 ]; then rm %(directory)splotting0*.root; fi
00403   fi
00404 fi
00405 
00406 # if it's last iteration, apply chamber motion policy
00407 if [ \"$ALIGNMENT_ITERATION\" == \"%(ITERATIONS)s\" ]; then
00408   # convert this iteration's geometry into detailed xml
00409   ./Alignment/MuonAlignmentAlgorithms/scripts/convertSQLiteXML.py %(directory)s%(director)s.db %(directory)s%(director)s_extra.xml
00410   # perform motion policy 
00411   ./Alignment/MuonAlignmentAlgorithms/scripts/motionPolicyChamber.py \
00412       %(INITIALXML)s  %(directory)s%(director)s_extra.xml \
00413       %(directory)s%(director)s_report.py \
00414       %(directory)s%(director)s_final.xml \
00415       --nsigma %(theNSigma)s
00416   # convert the resulting xml into the final sqlite geometry
00417   ./Alignment/MuonAlignmentAlgorithms/scripts/convertSQLiteXML.py %(directory)s%(director)s_final.xml %(directory)s%(director)s_final.db
00418 fi
00419 
00420 """ % vars())
00421     os.system("chmod +x %salign.sh" % directory)
00422 
00423     bsubfile.append("echo %salign.sh" % directory)
00424     bsubfile.append("bsub -R \"type==SLC5_64\" -q cmscaf1nd -J \"%s_align\" -w \"%s\" align.sh" % (director, " && ".join(bsubnames)))
00425     bsubfile.append("cd ..")
00426     bsubnames = []
00427     last_align = "%s_align" % director
00428     
00429     # after the last iteration (optionally) do diagnostics run
00430     if len(validationLabel) and iteration == ITERATIONS:
00431         # do we have plotting files created?
00432         directory1 = "%s01/" % DIRNAME
00433         director1 = directory1[:-1]
00434 
00435         file("%svalidation.sh" % directory, "w").write("""#!/bin/sh
00436 # %(commandline)s
00437 
00438 export ALIGNMENT_CAFDIR=`pwd`
00439 mkdir files
00440 mkdir out
00441 
00442 cd %(pwd)s
00443 eval `scramv1 run -sh`
00444 ALIGNMENT_AFSDIR=`pwd`
00445 ALIGNMENT_ITERATION=%(iteration)d
00446 ALIGNMENT_MAPPLOTS=None
00447 ALIGNMENT_SEGDIFFPLOTS=None
00448 ALIGNMENT_CURVATUREPLOTS=None
00449 
00450 # copy the scripts to CAFDIR
00451 cd Alignment/MuonAlignmentAlgorithms/scripts/
00452 cp -f plotscripts.py $ALIGNMENT_CAFDIR/
00453 cp -f mutypes.py $ALIGNMENT_CAFDIR/
00454 cp -f alignmentValidation.py $ALIGNMENT_CAFDIR/
00455 cp -f phiedges_fitfunctions.C $ALIGNMENT_CAFDIR/
00456 cp -f createTree.py $ALIGNMENT_CAFDIR/
00457 cd -
00458 cp Alignment/MuonAlignmentAlgorithms/test/browser/tree* $ALIGNMENT_CAFDIR/out/
00459 
00460 # copy the results to CAFDIR
00461 cp -f %(directory1)s%(director1)s_report.py $ALIGNMENT_CAFDIR/files/
00462 cp -f %(directory)s%(director)s_report.py $ALIGNMENT_CAFDIR/files/
00463 cp -f %(directory1)s%(director1)s.root $ALIGNMENT_CAFDIR/files/
00464 cp -f %(directory)s%(director)s.root $ALIGNMENT_CAFDIR/files/
00465 if [ -e %(directory1)s%(director1)s_plotting.root ] && [ -e %(directory)s%(director)s_plotting.root ]; then
00466   cp -f %(directory1)s%(director1)s_plotting.root $ALIGNMENT_CAFDIR/files/
00467   cp -f %(directory)s%(director)s_plotting.root $ALIGNMENT_CAFDIR/files/
00468   ALIGNMENT_MAPPLOTS=%(mapplots)s
00469   ALIGNMENT_SEGDIFFPLOTS=%(segdiffplots)s
00470   ALIGNMENT_CURVATUREPLOTS=%(curvatureplots)s
00471 fi
00472 
00473 cd $ALIGNMENT_CAFDIR/
00474 echo \" ### Start running ###\"
00475 date
00476 
00477 # do fits and median plots first 
00478 ./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
00479 
00480 if [ $ALIGNMENT_MAPPLOTS == \"True\" ]; then
00481   ./alignmentValidation.py -l %(validationLabel)s -i $ALIGNMENT_CAFDIR --i1 files --iN files --i1prefix %(director1)s --iNprefix %(director)s -o $ALIGNMENT_CAFDIR/out  --dt --csc --map
00482 fi
00483 
00484 if [ $ALIGNMENT_SEGDIFFPLOTS == \"True\" ]; then
00485   ./alignmentValidation.py -l %(validationLabel)s -i $ALIGNMENT_CAFDIR --i1 files --iN files --i1prefix %(director1)s --iNprefix %(director)s -o $ALIGNMENT_CAFDIR/out  --dt --csc --segdiff
00486 fi                   
00487 
00488 if [ $ALIGNMENT_CURVATUREPLOTS == \"True\" ]; then
00489   ./alignmentValidation.py -l %(validationLabel)s -i $ALIGNMENT_CAFDIR --i1 files --iN files --i1prefix %(director1)s --iNprefix %(director)s -o $ALIGNMENT_CAFDIR/out  --dt --csc --curvature
00490 fi
00491 
00492 # run simple diagnostic
00493 ./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
00494 
00495 # fill the tree browser structure: 
00496 ./createTree.py -i $ALIGNMENT_CAFDIR/out
00497 
00498 timestamp=`date \"+%%y-%%m-%%d %%H:%%M:%%S\"`
00499 echo \"%(validationLabel)s.plots (${timestamp})\" > out/label.txt
00500 
00501 ls -l out/
00502 timestamp=`date +%%Y%%m%%d%%H%%M%%S`
00503 tar czf %(validationLabel)s_${timestamp}.tgz out
00504 cp -f %(validationLabel)s_${timestamp}.tgz $ALIGNMENT_AFSDIR/
00505 
00506 """ % vars())
00507         os.system("chmod +x %svalidation.sh" % directory)
00508         
00509         bsubfile.append("echo %svalidation.sh" % directory)
00510         bsubfile.append("bsub -R \"type==SLC5_64\" -q cmscaf1nd -J \"%s_validation\" -w \"ended(%s)\" validation.sh" % (director, last_align))
00511         bsubfile.append("cd ..")
00512         
00513     bsubfile.append("")
00514 
00515 
00516 file(options.submitJobs, "w").write("\n".join(bsubfile))
00517 os.system("chmod +x %s" % options.submitJobs)
00518