CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_3/src/Alignment/MuonAlignmentAlgorithms/scripts/createBeamHaloJobs.py

Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 
00003 import os, sys, re, 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 PATTERN INITIALGEOM INPUTFILES [options]
00014 
00015 Creates (overwrites) a directory for each word in PATTERN and creates
00016 (overwrites) submitJobs.sh with the submission sequence and
00017 dependencies.
00018 
00019 DIRNAME        directories will be named DIRNAME01, DIRNAME02, etc.
00020 PATTERN        a quoted combination of "phiy", "phipos", "phiz"
00021 INITIALGEOM    SQLite file containing muon geometry with tag names
00022                CSCAlignmentRcd, CSCAlignmentErrorRcd
00023 INPUTFILES     Python file defining 'fileNames', a list of input files as
00024                strings"""
00025 
00026 parser = optparse.OptionParser(usage)
00027 parser.add_option("-j", "--jobs",
00028                   help="approximate number of \"gather\" subjobs",
00029                   type="int",
00030                   default=50,
00031                   dest="subjobs")
00032 parser.add_option("-s", "--submitJobs",
00033                   help="alternate name of submitJobs.sh script (please include .sh extension); a file with this name will be OVERWRITTEN",
00034                   type="string",
00035                   default="submitJobs.sh",
00036                   dest="submitJobs")
00037 parser.add_option("-b", "--big",
00038                   help="if invoked, subjobs will also be run on cmscaf1nd",
00039                   action="store_true",
00040                   dest="big")
00041 parser.add_option("-u", "--user_mail",
00042                   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",
00043                   type="string",
00044                   dest="user_mail")               
00045 parser.add_option("--globalTag",
00046                   help="GlobalTag for calibration conditions",
00047                   type="string",
00048                   default="GR_R_42_V14::All",
00049                   dest="globaltag")
00050 parser.add_option("--photogrammetry",
00051                   help="if invoked, alignment will be constrained to photogrammetry",
00052                   action="store_true",
00053                   dest="photogrammetry")
00054 parser.add_option("--photogrammetryOnlyholes",
00055                   help="if invoked, only missing data will be constrained to photogrammetry",
00056                   action="store_true",
00057                   dest="photogrammetryOnlyholes")
00058 parser.add_option("--photogrammetryOnlyOnePerRing",
00059                   help="if invoked, only one chamber per ring will be constrained to photogrammetry",
00060                   action="store_true",
00061                   dest="photogrammetryOnlyOnePerRing")
00062 parser.add_option("--photogrammetryScale",
00063                   help="scale factor for photogrammetry constraint: 1 is default and 10 *weakens* the constraint by a factor of 10",
00064                   type="string",
00065                   default="1.",
00066                   dest="photogrammetryScale")
00067 parser.add_option("--slm",
00068                   help="if invoked, apply SLM constraint",
00069                   action="store_true",
00070                   dest="slm")
00071 parser.add_option("--fillME11holes",
00072                   help="use CollisionsOct2010 data to fill holes in ME1/1",
00073                   action="store_true",
00074                   dest="fillME11holes")
00075 parser.add_option("--disks",
00076                   help="align whole disks, rather than individual rings",
00077                   action="store_true",
00078                   dest="disks")
00079 
00080 parser.add_option("--minP",
00081                   help="minimum track momentum (measured via radial component of fringe fields)",
00082                   type="string",
00083                   default="5",
00084                   dest="minP")
00085 parser.add_option("--minHitsPerChamber",
00086                   help="minimum number of hits per chamber",
00087                   type="string",
00088                   default="5",
00089                   dest="minHitsPerChamber")
00090 parser.add_option("--maxdrdz",
00091                   help="maximum dr/dz of tracklets (anti-cosmic cut)",
00092                   type="string",
00093                   default="0.2",
00094                   dest="maxdrdz")
00095 parser.add_option("--maxRedChi2",
00096                   help="maximum reduced chi^2 of tracks",
00097                   type="string",
00098                   default="10",
00099                   dest="maxRedChi2")
00100 parser.add_option("--fiducial",
00101                   help="if invoked, select only segments within the good region of the chamber (for all 6 layers)",
00102                   action="store_true",
00103                   dest="fiducial")
00104 parser.add_option("--useHitWeights",
00105                   help="if invoked, use hit weights in tracklet fits",
00106                   action="store_true",
00107                   dest="useHitWeights")
00108 parser.add_option("--truncateSlopeResid",
00109                   help="maximum allowed slope residual in mrad (like the histograms in a phiy job)",
00110                   type="string",
00111                   default="30.",
00112                   dest="truncateSlopeResid")
00113 parser.add_option("--truncateOffsetResid",
00114                   help="maximum allowed offset residual in mm (like the histograms in a phipos or phiz job)",
00115                   type="string",
00116                   default="15.",
00117                   dest="truncateOffsetResid")
00118 parser.add_option("--combineME11",
00119                   help="if invoked, combine ME1/1a and ME1/1b chambers",
00120                   action="store_true",
00121                   dest="combineME11")
00122 parser.add_option("--useTrackWeights",
00123                   help="if invoked, weight residuals by track uncertainties",
00124                   action="store_true",
00125                   dest="useTrackWeights")
00126 parser.add_option("--errorFromRMS",
00127                   help="if invoked, determine residuals uncertainties from the RMS of the residuals distribution",
00128                   action="store_true",
00129                   dest="errorFromRMS")
00130 parser.add_option("--minTracksPerOverlap",
00131                   help="minimum number of tracks needed for an overlap constraint to be valid",
00132                   type="string",
00133                   default="10",
00134                   dest="minTracksPerOverlap")
00135 parser.add_option("--slopeFromTrackRefit",
00136                   help="if invoked, determine direction of tracklets by refitting track to all other stations",
00137                   action="store_true",
00138                   dest="slopeFromTrackRefit")
00139 parser.add_option("--minStationsInTrackRefits",
00140                   help="minimum number of stations in a full track refit (slopeFromTrackRefit)",
00141                   type="string",
00142                   default="2",
00143                   dest="minStationsInTrackRefits")
00144 parser.add_option("--inputInBlocks",
00145                   help="if invoked, assume that INPUTFILES provides a list of files already groupped into job blocks, -j has no effect in that case",
00146                   action="store_true",
00147                   dest="inputInBlocks")
00148 parser.add_option("--json",
00149                   help="If present with JSON file as argument, use JSON file for good lumi mask. "+\
00150                   "The latest JSON file is available at /afs/cern.ch/cms/CAF/CMSCOMM/COMM_DQM/certification/Collisions10/7TeV/StreamExpress/",
00151                   type="string",
00152                   default="",
00153                   dest="json")
00154 
00155 if len(sys.argv) < 5:
00156     raise SystemError, "Too few arguments.\n\n"+parser.format_help()
00157 
00158 DIRNAME = sys.argv[1]
00159 PATTERN = re.split("\s+", sys.argv[2])
00160 INITIALGEOM = sys.argv[3]
00161 INPUTFILES = sys.argv[4]
00162 
00163 options, args = parser.parse_args(sys.argv[5:])
00164 user_mail = options.user_mail
00165 globaltag = options.globaltag
00166 photogrammetry = options.photogrammetry
00167 photogrammetryOnlyholes = options.photogrammetryOnlyholes
00168 photogrammetryOnlyOnePerRing = options.photogrammetryOnlyOnePerRing
00169 photogrammetryScale = options.photogrammetryScale
00170 slm = options.slm
00171 fillME11holes = options.fillME11holes
00172 disks = options.disks
00173 minP = options.minP
00174 minHitsPerChamber = options.minHitsPerChamber
00175 maxdrdz = options.maxdrdz
00176 maxRedChi2 = options.maxRedChi2
00177 fiducial = options.fiducial
00178 useHitWeights = options.useHitWeights
00179 truncateSlopeResid = options.truncateSlopeResid
00180 truncateOffsetResid = options.truncateOffsetResid
00181 combineME11 = options.combineME11
00182 useTrackWeights = options.useTrackWeights
00183 errorFromRMS = options.errorFromRMS
00184 minTracksPerOverlap = options.minTracksPerOverlap
00185 slopeFromTrackRefit = options.slopeFromTrackRefit
00186 minStationsInTrackRefits = options.minStationsInTrackRefits
00187 
00188 if options.inputInBlocks: inputInBlocks = "--inputInBlocks"
00189 json_file = options.json
00190 
00191 
00192 fileNames=[]
00193 fileNamesBlocks=[]
00194 execfile(INPUTFILES)
00195 njobs = options.subjobs
00196 if (options.inputInBlocks):
00197   njobs = len(fileNamesBlocks)
00198   if njobs==0:
00199     print "while --inputInBlocks is specified, the INPUTFILES has no blocks!"
00200     sys.exit()
00201 
00202 stepsize = int(math.ceil(1.*len(fileNames)/options.subjobs))
00203 pwd = str(os.getcwdu())
00204 
00205 bsubfile = ["#!/bin/sh", ""]
00206 bsubnames = []
00207 last_align = None
00208 
00209 directory = ""
00210 for i, mode in enumerate(PATTERN):
00211     iteration = i+1
00212     if iteration == 1:
00213         inputdb = INITIALGEOM
00214         inputdbdir = directory[:]
00215     else:
00216         inputdb = director + ".db"
00217         inputdbdir = directory[:]
00218 
00219     directory = "%s%02d/" % (DIRNAME, iteration)
00220     director = directory[:-1]
00221     os.system("rm -rf %s; mkdir %s" % (directory, directory))
00222     os.system("cp gatherBH_cfg.py %s" % directory)
00223     os.system("cp alignBH_cfg.py %s" % directory)
00224 
00225     bsubfile.append("cd %s" % directory)
00226 
00227     constraints = """echo \"\" > constraints_cff.py
00228 """
00229     if photogrammetry and (mode == "phipos" or mode == "phiz"):
00230         diskswitch = ""
00231         if disks: diskswitch = "--disks "
00232 
00233         constraints += """export ALIGNMENT_CONVERTXML=%(inputdb)s
00234 cmsRun $ALIGNMENT_AFSDIR/Alignment/MuonAlignmentAlgorithms/python/convertToXML_global_cfg.py 
00235 python $ALIGNMENT_AFSDIR/Alignment/MuonAlignmentAlgorithms/scripts/relativeConstraints.py %(inputdb)s_global.xml $ALIGNMENT_AFSDIR/Alignment/MuonAlignmentAlgorithms/data/Photogrammetry2007.%(mode)s PGFrame --scaleErrors %(photogrammetryScale)s %(diskswitch)s>> constraints_cff.py
00236 """ % vars()
00237 
00238     elif photogrammetryOnlyholes and (mode == "phipos" or mode == "phiz"):
00239         diskswitch = ""
00240         if disks: diskswitch = "--disks "
00241 
00242         constraints += """export ALIGNMENT_CONVERTXML=%(inputdb)s
00243 cmsRun $ALIGNMENT_AFSDIR/Alignment/MuonAlignmentAlgorithms/python/convertToXML_global_cfg.py 
00244 python $ALIGNMENT_AFSDIR/Alignment/MuonAlignmentAlgorithms/scripts/relativeConstraints.py %(inputdb)s_global.xml $ALIGNMENT_AFSDIR/Alignment/MuonAlignmentAlgorithms/data/Photogrammetry2007_onlyOct2010holes.%(mode)s PGFrame --scaleErrors %(photogrammetryScale)s %(diskswitch)s>> constraints_cff.py
00245 """ % vars()
00246 
00247     elif photogrammetryOnlyOnePerRing and (mode == "phipos" or mode == "phiz"):
00248         diskswitch = ""
00249         if disks: diskswitch = "--disks "
00250 
00251         constraints += """export ALIGNMENT_CONVERTXML=%(inputdb)s
00252 cmsRun $ALIGNMENT_AFSDIR/Alignment/MuonAlignmentAlgorithms/python/convertToXML_global_cfg.py 
00253 python $ALIGNMENT_AFSDIR/Alignment/MuonAlignmentAlgorithms/scripts/relativeConstraints.py %(inputdb)s_global.xml $ALIGNMENT_AFSDIR/Alignment/MuonAlignmentAlgorithms/data/Photogrammetry2007_onlyOnePerRing.%(mode)s PGFrame --scaleErrors %(photogrammetryScale)s %(diskswitch)s>> constraints_cff.py
00254 """ % vars()
00255 
00256     if slm and (mode == "phipos" or "phiz"):
00257         diskswitch = ""
00258         if disks: diskswitch = "--disks "
00259 
00260         constraints += """export ALIGNMENT_CONVERTXML=%(inputdb)s
00261 cmsRun $ALIGNMENT_AFSDIR/Alignment/MuonAlignmentAlgorithms/python/convertToXML_global_cfg.py
00262 python $ALIGNMENT_AFSDIR/Alignment/MuonAlignmentAlgorithms/scripts/relativeConstraints.py %(inputdb)s_global.xml $ALIGNMENT_AFSDIR/Alignment/MuonAlignmentAlgorithms/data/SLM_test.%(mode)s SLMFrame --scaleErrors 1.0 %(diskswitch)s>> constraints_cff.py
00263 """ % vars()
00264 
00265     if fillME11holes and (mode == "phipos" or mode == "phiz"):
00266         diskswitch = ""
00267         if disks: diskswitch = "--disks "
00268 
00269         constraints += """export ALIGNMENT_CONVERTXML=%(inputdb)s
00270 cmsRun $ALIGNMENT_AFSDIR/Alignment/MuonAlignmentAlgorithms/python/convertToXML_global_cfg.py 
00271 python $ALIGNMENT_AFSDIR/Alignment/MuonAlignmentAlgorithms/scripts/relativeConstraints.py %(inputdb)s_global.xml $ALIGNMENT_AFSDIR/Alignment/MuonAlignmentAlgorithms/data/CollisionsOct2010_ME11holes.%(mode)s TKFrame --scaleErrors 1. %(diskswitch)s>> constraints_cff.py
00272 """ % vars()
00273 
00274     for jobnumber in range(njobs):
00275         gather_fileName = "%sgather%03d.sh" % (directory, jobnumber)
00276         if not options.inputInBlocks:
00277           inputfiles = " ".join(fileNames[jobnumber*stepsize:(jobnumber+1)*stepsize])
00278         else:
00279           inputfiles = " ".join(fileNamesBlocks[jobnumber])
00280 
00281         if len(inputfiles) > 0:
00282             file(gather_fileName, "w").write("""#/bin/sh
00283 # %(commandline)s
00284 
00285 export ALIGNMENT_CAFDIR=`pwd`
00286 
00287 cd %(pwd)s
00288 
00289 export SCRAM_ARCH=slc5_amd64_gcc434
00290 echo INFO: SCRAM_ARCH $SCRAM_ARCH
00291 
00292 eval `scramv1 run -sh`
00293 
00294 source /afs/cern.ch/cms/caf/setup.sh
00295 echo INFO: CMS_PATH $CMS_PATH
00296 echo INFO: STAGE_SVCCLASS $STAGE_SVCCLASS
00297 echo INFO: STAGER_TRACE $STAGER_TRACE
00298 
00299 export ALIGNMENT_AFSDIR=`pwd`
00300 
00301 export ALIGNMENT_INPUTFILES='%(inputfiles)s'
00302 export ALIGNMENT_ITERATION=%(iteration)d
00303 export ALIGNMENT_MODE=%(mode)s
00304 export ALIGNMENT_JOBNUMBER=%(jobnumber)d
00305 export ALIGNMENT_INPUTDB=%(inputdb)s
00306 export ALIGNMENT_GLOBALTAG=%(globaltag)s
00307 export ALIGNMENT_PHOTOGRAMMETRY='%(photogrammetry)s or %(photogrammetryOnlyholes)s or %(photogrammetryOnlyOnePerRing)s'
00308 export ALIGNMENT_SLM=%(slm)s
00309 export ALIGNMENT_FILLME11HOLES='%(fillME11holes)s'
00310 export ALIGNMENT_DISKS=%(disks)s
00311 export ALIGNMENT_minP=%(minP)s
00312 export ALIGNMENT_minHitsPerChamber=%(minHitsPerChamber)s
00313 export ALIGNMENT_maxdrdz=%(maxdrdz)s
00314 export ALIGNMENT_maxRedChi2=%(maxRedChi2)s
00315 export ALIGNMENT_fiducial=%(fiducial)s
00316 export ALIGNMENT_useHitWeights=%(useHitWeights)s
00317 export ALIGNMENT_truncateSlopeResid=%(truncateSlopeResid)s
00318 export ALIGNMENT_truncateOffsetResid=%(truncateOffsetResid)s
00319 export ALIGNMENT_combineME11=%(combineME11)s
00320 export ALIGNMENT_useTrackWeights=%(useTrackWeights)s
00321 export ALIGNMENT_errorFromRMS=%(errorFromRMS)s
00322 export ALIGNMENT_minTracksPerOverlap=%(minTracksPerOverlap)s
00323 export ALIGNMENT_slopeFromTrackRefit=%(slopeFromTrackRefit)s
00324 export ALIGNMENT_minStationsInTrackRefits=%(minStationsInTrackRefits)s
00325 
00326 cp -f %(directory)sgatherBH_cfg.py %(inputdbdir)s%(inputdb)s inertGlobalPositionRcd.db $ALIGNMENT_CAFDIR/
00327 cd $ALIGNMENT_CAFDIR/
00328 
00329 %(constraints)s
00330 
00331 ls -l
00332 cmsRun gatherBH_cfg.py
00333 ls -l
00334 cp -f *.tmp *.root $ALIGNMENT_AFSDIR/%(directory)s
00335 """ % vars())
00336             os.system("chmod +x %s" % gather_fileName)
00337             bsubfile.append("echo %sgather%03d.sh" % (directory, jobnumber))
00338 
00339             if last_align is None: waiter = ""
00340             else: waiter = "-w \"ended(%s)\"" % last_align
00341             if options.big: queue = "cmscaf1nd"
00342             else: queue = "cmscaf1nh"
00343             
00344             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))
00345             else: bsubfile.append("bsub -R \"type==SLC5_64\" -q %s -J \"%s_gather%03d\" %s gather%03d.sh" % (queue, director, jobnumber, waiter, jobnumber))
00346             
00347             bsubnames.append("ended(%s_gather%03d)" % (director, jobnumber))
00348 
00349     file("%sconvert-db-to-xml_cfg.py" % directory, "w").write("""from Alignment.MuonAlignment.convertSQLitetoXML_cfg import *
00350 process.PoolDBESSource.connect = \"sqlite_file:%(directory)s%(director)s.db\"
00351 process.MuonGeometryDBConverter.outputXML.fileName = \"%(directory)s%(director)s.xml\"
00352 process.MuonGeometryDBConverter.outputXML.relativeto = \"ideal\"
00353 process.MuonGeometryDBConverter.outputXML.suppressDTChambers = True
00354 process.MuonGeometryDBConverter.outputXML.suppressDTSuperLayers = True
00355 process.MuonGeometryDBConverter.outputXML.suppressDTLayers = True
00356 process.MuonGeometryDBConverter.outputXML.suppressCSCChambers = False
00357 process.MuonGeometryDBConverter.outputXML.suppressCSCLayers = True
00358 
00359 process.MuonGeometryDBConverter.getAPEs = True
00360 process.PoolDBESSource.toGet = cms.VPSet(
00361     cms.PSet(record = cms.string(\"DTAlignmentRcd\"), tag = cms.string(\"DTAlignmentRcd\")),
00362     cms.PSet(record = cms.string(\"DTAlignmentErrorRcd\"), tag = cms.string(\"DTAlignmentErrorRcd\")),
00363     cms.PSet(record = cms.string(\"CSCAlignmentRcd\"), tag = cms.string(\"CSCAlignmentRcd\")),
00364     cms.PSet(record = cms.string(\"CSCAlignmentErrorRcd\"), tag = cms.string(\"CSCAlignmentErrorRcd\")),
00365       )
00366 """ % vars())
00367 
00368     constraints += """\ncp -f constraints_cff.py $ALIGNMENT_AFSDIR/%(directory)sconstraints_cff.py""" % vars()
00369 
00370     file("%salign.sh" % directory, "w").write("""#!/bin/sh
00371 # %(commandline)s
00372 
00373 export ALIGNMENT_CAFDIR=`pwd`
00374 
00375 cd %(pwd)s
00376 
00377 export SCRAM_ARCH=slc5_amd64_gcc434
00378 echo INFO: SCRAM_ARCH $SCRAM_ARCH
00379 
00380 eval `scramv1 run -sh`
00381 
00382 source /afs/cern.ch/cms/caf/setup.sh
00383 echo INFO: CMS_PATH $CMS_PATH
00384 echo INFO: STAGE_SVCCLASS $STAGE_SVCCLASS
00385 echo INFO: STAGER_TRACE $STAGER_TRACE
00386 
00387 export ALIGNMENT_AFSDIR=`pwd`
00388 
00389 export ALIGNMENT_ITERATION=%(iteration)d
00390 export ALIGNMENT_MODE=%(mode)s
00391 export ALIGNMENT_INPUTDB=%(inputdb)s
00392 export ALIGNMENT_GLOBALTAG=%(globaltag)s
00393 export ALIGNMENT_PHOTOGRAMMETRY='%(photogrammetry)s or %(photogrammetryOnlyholes)s or %(photogrammetryOnlyOnePerRing)s'
00394 export ALIGNMENT_SLM=%(slm)s
00395 export ALIGNMENT_FILLME11HOLES='%(fillME11holes)s'
00396 export ALIGNMENT_DISKS=%(disks)s
00397 export ALIGNMENT_minP=%(minP)s
00398 export ALIGNMENT_minHitsPerChamber=%(minHitsPerChamber)s
00399 export ALIGNMENT_maxdrdz=%(maxdrdz)s
00400 export ALIGNMENT_maxRedChi2=%(maxRedChi2)s
00401 export ALIGNMENT_fiducial=%(fiducial)s
00402 export ALIGNMENT_useHitWeights=%(useHitWeights)s
00403 export ALIGNMENT_truncateSlopeResid=%(truncateSlopeResid)s
00404 export ALIGNMENT_truncateOffsetResid=%(truncateOffsetResid)s
00405 export ALIGNMENT_combineME11=%(combineME11)s
00406 export ALIGNMENT_useTrackWeights=%(useTrackWeights)s
00407 export ALIGNMENT_errorFromRMS=%(errorFromRMS)s
00408 export ALIGNMENT_minTracksPerOverlap=%(minTracksPerOverlap)s
00409 export ALIGNMENT_slopeFromTrackRefit=%(slopeFromTrackRefit)s
00410 export ALIGNMENT_minStationsInTrackRefits=%(minStationsInTrackRefits)s
00411 
00412 cp -f %(directory)salignBH_cfg.py %(directory)sconvert-db-to-xml_cfg.py %(inputdbdir)s%(inputdb)s %(directory)s*.tmp inertGlobalPositionRcd.db $ALIGNMENT_CAFDIR/
00413 cd $ALIGNMENT_CAFDIR/
00414 export ALIGNMENT_ALIGNMENTTMP=`ls alignment*.tmp`
00415 
00416 %(constraints)s
00417 
00418 ls -l
00419 cmsRun alignBH_cfg.py
00420 cp -f report.py $ALIGNMENT_AFSDIR/%(directory)s%(director)s_report.py
00421 cp -f outputdb.db $ALIGNMENT_AFSDIR/%(directory)s%(director)s.db
00422 cp -f plotting.root $ALIGNMENT_AFSDIR/%(directory)s%(director)s.root
00423 
00424 cd $ALIGNMENT_AFSDIR
00425 cmsRun %(directory)sconvert-db-to-xml_cfg.py
00426 
00427 export ALIGNMENT_PLOTTINGTMP=`ls %(directory)splotting0*.root 2> /dev/null`
00428 if [ \"zzz$ALIGNMENT_PLOTTINGTMP\" != \"zzz\" ]; then
00429   hadd -f1 %(directory)s%(director)s_plotting.root %(directory)splotting0*.root
00430   #if [ $? == 0 ] && [ \"$ALIGNMENT_CLEANUP\" == \"True\" ]; then rm %(directory)splotting0*.root; fi
00431 fi
00432 
00433 """ % vars())
00434     os.system("chmod +x %salign.sh" % directory)
00435 
00436     bsubfile.append("echo %salign.sh" % directory)
00437     
00438     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)))
00439     else: bsubfile.append("bsub -R \"type==SLC5_64\" -q cmscaf1nd -J \"%s_align\" -w \"%s\" align.sh" % (director, " && ".join(bsubnames)))
00440     
00441     bsubfile.append("cd ..")
00442     bsubnames = []
00443     last_align = "%s_align" % director
00444 
00445 bsubfile.append("")
00446 file(options.submitJobs, "w").write("\n".join(bsubfile))
00447 os.system("chmod +x %s" % options.submitJobs)