Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 11:56:46

0001 #!/usr/bin/env python3
0002 
0003 from __future__ import print_function
0004 from builtins import range
0005 import os, sys, re, optparse, math
0006 
0007 copyargs = sys.argv[:]
0008 for i in range(len(copyargs)):
0009     if copyargs[i] == "":
0010         copyargs[i] = "\"\""
0011     if copyargs[i].find(" ") != -1:
0012         copyargs[i] = "\"%s\"" % copyargs[i]
0013 commandline = " ".join(copyargs)
0014 
0015 usage = """./%prog DIRNAME PATTERN INITIALGEOM INPUTFILES [options]
0016 
0017 Creates (overwrites) a directory for each word in PATTERN and creates
0018 (overwrites) submitJobs.sh with the submission sequence and
0019 dependencies.
0020 
0021 DIRNAME        directories will be named DIRNAME01, DIRNAME02, etc.
0022 PATTERN        a quoted combination of "phiy", "phipos", "phiz"
0023 INITIALGEOM    SQLite file containing muon geometry with tag names
0024                CSCAlignmentRcd, CSCAlignmentErrorExtendedRcd
0025 INPUTFILES     Python file defining 'fileNames', a list of input files as
0026                strings"""
0027 
0028 parser = optparse.OptionParser(usage)
0029 parser.add_option("-j", "--jobs",
0030                   help="approximate number of \"gather\" subjobs",
0031                   type="int",
0032                   default=50,
0033                   dest="subjobs")
0034 parser.add_option("-s", "--submitJobs",
0035                   help="alternate name of submitJobs.sh script (please include .sh extension); a file with this name will be OVERWRITTEN",
0036                   type="string",
0037                   default="submitJobs.sh",
0038                   dest="submitJobs")
0039 parser.add_option("-b", "--big",
0040                   help="if invoked, subjobs will also be run on cmscaf1nd",
0041                   action="store_true",
0042                   dest="big")
0043 parser.add_option("-u", "--user_mail",
0044                   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",
0045                   type="string",
0046                   dest="user_mail")       
0047 parser.add_option("--globalTag",
0048                   help="GlobalTag for calibration conditions",
0049                   type="string",
0050                   default="GR_R_42_V14::All",
0051                   dest="globaltag")
0052 parser.add_option("--photogrammetry",
0053                   help="if invoked, alignment will be constrained to photogrammetry",
0054                   action="store_true",
0055                   dest="photogrammetry")
0056 parser.add_option("--photogrammetryOnlyholes",
0057                   help="if invoked, only missing data will be constrained to photogrammetry",
0058                   action="store_true",
0059                   dest="photogrammetryOnlyholes")
0060 parser.add_option("--photogrammetryOnlyOnePerRing",
0061                   help="if invoked, only one chamber per ring will be constrained to photogrammetry",
0062                   action="store_true",
0063                   dest="photogrammetryOnlyOnePerRing")
0064 parser.add_option("--photogrammetryScale",
0065                   help="scale factor for photogrammetry constraint: 1 is default and 10 *weakens* the constraint by a factor of 10",
0066                   type="string",
0067                   default="1.",
0068                   dest="photogrammetryScale")
0069 parser.add_option("--slm",
0070                   help="if invoked, apply SLM constraint",
0071                   action="store_true",
0072                   dest="slm")
0073 parser.add_option("--fillME11holes",
0074                   help="use CollisionsOct2010 data to fill holes in ME1/1",
0075                   action="store_true",
0076                   dest="fillME11holes")
0077 parser.add_option("--disks",
0078                   help="align whole disks, rather than individual rings",
0079                   action="store_true",
0080                   dest="disks")
0081 
0082 parser.add_option("--minP",
0083                   help="minimum track momentum (measured via radial component of fringe fields)",
0084                   type="string",
0085                   default="5",
0086                   dest="minP")
0087 parser.add_option("--minHitsPerChamber",
0088                   help="minimum number of hits per chamber",
0089                   type="string",
0090                   default="5",
0091                   dest="minHitsPerChamber")
0092 parser.add_option("--maxdrdz",
0093                   help="maximum dr/dz of tracklets (anti-cosmic cut)",
0094                   type="string",
0095                   default="0.2",
0096                   dest="maxdrdz")
0097 parser.add_option("--maxRedChi2",
0098                   help="maximum reduced chi^2 of tracks",
0099                   type="string",
0100                   default="10",
0101                   dest="maxRedChi2")
0102 parser.add_option("--fiducial",
0103                   help="if invoked, select only segments within the good region of the chamber (for all 6 layers)",
0104                   action="store_true",
0105                   dest="fiducial")
0106 parser.add_option("--useHitWeights",
0107                   help="if invoked, use hit weights in tracklet fits",
0108                   action="store_true",
0109                   dest="useHitWeights")
0110 parser.add_option("--truncateSlopeResid",
0111                   help="maximum allowed slope residual in mrad (like the histograms in a phiy job)",
0112                   type="string",
0113                   default="30.",
0114                   dest="truncateSlopeResid")
0115 parser.add_option("--truncateOffsetResid",
0116                   help="maximum allowed offset residual in mm (like the histograms in a phipos or phiz job)",
0117                   type="string",
0118                   default="15.",
0119                   dest="truncateOffsetResid")
0120 parser.add_option("--combineME11",
0121                   help="if invoked, combine ME1/1a and ME1/1b chambers",
0122                   action="store_true",
0123                   dest="combineME11")
0124 parser.add_option("--useTrackWeights",
0125                   help="if invoked, weight residuals by track uncertainties",
0126                   action="store_true",
0127                   dest="useTrackWeights")
0128 parser.add_option("--errorFromRMS",
0129                   help="if invoked, determine residuals uncertainties from the RMS of the residuals distribution",
0130                   action="store_true",
0131                   dest="errorFromRMS")
0132 parser.add_option("--minTracksPerOverlap",
0133                   help="minimum number of tracks needed for an overlap constraint to be valid",
0134                   type="string",
0135                   default="10",
0136                   dest="minTracksPerOverlap")
0137 parser.add_option("--slopeFromTrackRefit",
0138                   help="if invoked, determine direction of tracklets by refitting track to all other stations",
0139                   action="store_true",
0140                   dest="slopeFromTrackRefit")
0141 parser.add_option("--minStationsInTrackRefits",
0142                   help="minimum number of stations in a full track refit (slopeFromTrackRefit)",
0143                   type="string",
0144                   default="2",
0145                   dest="minStationsInTrackRefits")
0146 parser.add_option("--inputInBlocks",
0147                   help="if invoked, assume that INPUTFILES provides a list of files already groupped into job blocks, -j has no effect in that case",
0148                   action="store_true",
0149                   dest="inputInBlocks")
0150 parser.add_option("--json",
0151                   help="If present with JSON file as argument, use JSON file for good lumi mask. "+\
0152                   "The latest JSON file is available at /afs/cern.ch/cms/CAF/CMSCOMM/COMM_DQM/certification/Collisions10/7TeV/StreamExpress/",
0153                   type="string",
0154                   default="",
0155                   dest="json")
0156 
0157 if len(sys.argv) < 5:
0158     raise SystemError("Too few arguments.\n\n"+parser.format_help())
0159 
0160 DIRNAME = sys.argv[1]
0161 PATTERN = re.split("\s+", sys.argv[2])
0162 INITIALGEOM = sys.argv[3]
0163 INPUTFILES = sys.argv[4]
0164 
0165 options, args = parser.parse_args(sys.argv[5:])
0166 user_mail = options.user_mail
0167 globaltag = options.globaltag
0168 photogrammetry = options.photogrammetry
0169 photogrammetryOnlyholes = options.photogrammetryOnlyholes
0170 photogrammetryOnlyOnePerRing = options.photogrammetryOnlyOnePerRing
0171 photogrammetryScale = options.photogrammetryScale
0172 slm = options.slm
0173 fillME11holes = options.fillME11holes
0174 disks = options.disks
0175 minP = options.minP
0176 minHitsPerChamber = options.minHitsPerChamber
0177 maxdrdz = options.maxdrdz
0178 maxRedChi2 = options.maxRedChi2
0179 fiducial = options.fiducial
0180 useHitWeights = options.useHitWeights
0181 truncateSlopeResid = options.truncateSlopeResid
0182 truncateOffsetResid = options.truncateOffsetResid
0183 combineME11 = options.combineME11
0184 useTrackWeights = options.useTrackWeights
0185 errorFromRMS = options.errorFromRMS
0186 minTracksPerOverlap = options.minTracksPerOverlap
0187 slopeFromTrackRefit = options.slopeFromTrackRefit
0188 minStationsInTrackRefits = options.minStationsInTrackRefits
0189 
0190 if options.inputInBlocks: inputInBlocks = "--inputInBlocks"
0191 json_file = options.json
0192 
0193 
0194 fileNames=[]
0195 fileNamesBlocks=[]
0196 execfile(INPUTFILES)
0197 njobs = options.subjobs
0198 if (options.inputInBlocks):
0199     njobs = len(fileNamesBlocks)
0200     if njobs==0:
0201         print("while --inputInBlocks is specified, the INPUTFILES has no blocks!")
0202         sys.exit()
0203 
0204 stepsize = int(math.ceil(1.*len(fileNames)/options.subjobs))
0205 pwd = str(os.getcwd())
0206 
0207 bsubfile = ["#!/bin/sh", ""]
0208 bsubnames = []
0209 last_align = None
0210 
0211 directory = ""
0212 for i, mode in enumerate(PATTERN):
0213     iteration = i+1
0214     if iteration == 1:
0215         inputdb = INITIALGEOM
0216         inputdbdir = directory[:]
0217     else:
0218         inputdb = director + ".db"
0219         inputdbdir = directory[:]
0220 
0221     directory = "%s%02d/" % (DIRNAME, iteration)
0222     director = directory[:-1]
0223     os.system("rm -rf %s; mkdir %s" % (directory, directory))
0224     os.system("cp gatherBH_cfg.py %s" % directory)
0225     os.system("cp alignBH_cfg.py %s" % directory)
0226 
0227     bsubfile.append("cd %s" % directory)
0228 
0229     constraints = """echo \"\" > constraints_cff.py
0230 """
0231     if photogrammetry and (mode == "phipos" or mode == "phiz"):
0232         diskswitch = ""
0233         if disks: diskswitch = "--disks "
0234 
0235         constraints += """export ALIGNMENT_CONVERTXML=%(inputdb)s
0236 cmsRun $ALIGNMENT_AFSDIR/Alignment/MuonAlignmentAlgorithms/python/convertToXML_global_cfg.py 
0237 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
0238 """ % vars()
0239 
0240     elif photogrammetryOnlyholes and (mode == "phipos" or mode == "phiz"):
0241         diskswitch = ""
0242         if disks: diskswitch = "--disks "
0243 
0244         constraints += """export ALIGNMENT_CONVERTXML=%(inputdb)s
0245 cmsRun $ALIGNMENT_AFSDIR/Alignment/MuonAlignmentAlgorithms/python/convertToXML_global_cfg.py 
0246 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
0247 """ % vars()
0248 
0249     elif photogrammetryOnlyOnePerRing and (mode == "phipos" or mode == "phiz"):
0250         diskswitch = ""
0251         if disks: diskswitch = "--disks "
0252 
0253         constraints += """export ALIGNMENT_CONVERTXML=%(inputdb)s
0254 cmsRun $ALIGNMENT_AFSDIR/Alignment/MuonAlignmentAlgorithms/python/convertToXML_global_cfg.py 
0255 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
0256 """ % vars()
0257 
0258     if slm and (mode == "phipos" or "phiz"):
0259         diskswitch = ""
0260         if disks: diskswitch = "--disks "
0261 
0262         constraints += """export ALIGNMENT_CONVERTXML=%(inputdb)s
0263 cmsRun $ALIGNMENT_AFSDIR/Alignment/MuonAlignmentAlgorithms/python/convertToXML_global_cfg.py
0264 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
0265 """ % vars()
0266 
0267     if fillME11holes and (mode == "phipos" or mode == "phiz"):
0268         diskswitch = ""
0269         if disks: diskswitch = "--disks "
0270 
0271         constraints += """export ALIGNMENT_CONVERTXML=%(inputdb)s
0272 cmsRun $ALIGNMENT_AFSDIR/Alignment/MuonAlignmentAlgorithms/python/convertToXML_global_cfg.py 
0273 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
0274 """ % vars()
0275 
0276     for jobnumber in range(njobs):
0277         gather_fileName = "%sgather%03d.sh" % (directory, jobnumber)
0278         if not options.inputInBlocks:
0279             inputfiles = " ".join(fileNames[jobnumber*stepsize:(jobnumber+1)*stepsize])
0280         else:
0281             inputfiles = " ".join(fileNamesBlocks[jobnumber])
0282 
0283         if len(inputfiles) > 0:
0284             file(gather_fileName, "w").write("""#/bin/sh
0285 # %(commandline)s
0286 
0287 export ALIGNMENT_CAFDIR=`pwd`
0288 
0289 cd %(pwd)s
0290 
0291 export SCRAM_ARCH=slc5_amd64_gcc434
0292 echo INFO: SCRAM_ARCH $SCRAM_ARCH
0293 
0294 eval `scramv1 run -sh`
0295 
0296 source /afs/cern.ch/cms/caf/setup.sh
0297 echo INFO: CMS_PATH $CMS_PATH
0298 echo INFO: STAGE_SVCCLASS $STAGE_SVCCLASS
0299 echo INFO: STAGER_TRACE $STAGER_TRACE
0300 
0301 export ALIGNMENT_AFSDIR=`pwd`
0302 
0303 export ALIGNMENT_INPUTFILES='%(inputfiles)s'
0304 export ALIGNMENT_ITERATION=%(iteration)d
0305 export ALIGNMENT_MODE=%(mode)s
0306 export ALIGNMENT_JOBNUMBER=%(jobnumber)d
0307 export ALIGNMENT_INPUTDB=%(inputdb)s
0308 export ALIGNMENT_GLOBALTAG=%(globaltag)s
0309 export ALIGNMENT_PHOTOGRAMMETRY='%(photogrammetry)s or %(photogrammetryOnlyholes)s or %(photogrammetryOnlyOnePerRing)s'
0310 export ALIGNMENT_SLM=%(slm)s
0311 export ALIGNMENT_FILLME11HOLES='%(fillME11holes)s'
0312 export ALIGNMENT_DISKS=%(disks)s
0313 export ALIGNMENT_minP=%(minP)s
0314 export ALIGNMENT_minHitsPerChamber=%(minHitsPerChamber)s
0315 export ALIGNMENT_maxdrdz=%(maxdrdz)s
0316 export ALIGNMENT_maxRedChi2=%(maxRedChi2)s
0317 export ALIGNMENT_fiducial=%(fiducial)s
0318 export ALIGNMENT_useHitWeights=%(useHitWeights)s
0319 export ALIGNMENT_truncateSlopeResid=%(truncateSlopeResid)s
0320 export ALIGNMENT_truncateOffsetResid=%(truncateOffsetResid)s
0321 export ALIGNMENT_combineME11=%(combineME11)s
0322 export ALIGNMENT_useTrackWeights=%(useTrackWeights)s
0323 export ALIGNMENT_errorFromRMS=%(errorFromRMS)s
0324 export ALIGNMENT_minTracksPerOverlap=%(minTracksPerOverlap)s
0325 export ALIGNMENT_slopeFromTrackRefit=%(slopeFromTrackRefit)s
0326 export ALIGNMENT_minStationsInTrackRefits=%(minStationsInTrackRefits)s
0327 
0328 cp -f %(directory)sgatherBH_cfg.py %(inputdbdir)s%(inputdb)s inertGlobalPositionRcd.db $ALIGNMENT_CAFDIR/
0329 cd $ALIGNMENT_CAFDIR/
0330 
0331 %(constraints)s
0332 
0333 ls -l
0334 cmsRun gatherBH_cfg.py
0335 ls -l
0336 cp -f *.tmp *.root $ALIGNMENT_AFSDIR/%(directory)s
0337 """ % vars())
0338             os.system("chmod +x %s" % gather_fileName)
0339             bsubfile.append("echo %sgather%03d.sh" % (directory, jobnumber))
0340 
0341             if last_align is None: waiter = ""
0342             else: waiter = "-w \"ended(%s)\"" % last_align
0343             if options.big: queue = "cmscaf1nd"
0344             else: queue = "cmscaf1nh"
0345 
0346             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))
0347             else: bsubfile.append("bsub -R \"type==SLC5_64\" -q %s -J \"%s_gather%03d\" %s gather%03d.sh" % (queue, director, jobnumber, waiter, jobnumber))
0348 
0349             bsubnames.append("ended(%s_gather%03d)" % (director, jobnumber))
0350 
0351     file("%sconvert-db-to-xml_cfg.py" % directory, "w").write("""from Alignment.MuonAlignment.convertSQLitetoXML_cfg import *
0352 process.PoolDBESSource.connect = \"sqlite_file:%(directory)s%(director)s.db\"
0353 process.MuonGeometryDBConverter.outputXML.fileName = \"%(directory)s%(director)s.xml\"
0354 process.MuonGeometryDBConverter.outputXML.relativeto = \"ideal\"
0355 process.MuonGeometryDBConverter.outputXML.suppressDTChambers = True
0356 process.MuonGeometryDBConverter.outputXML.suppressDTSuperLayers = True
0357 process.MuonGeometryDBConverter.outputXML.suppressDTLayers = True
0358 process.MuonGeometryDBConverter.outputXML.suppressCSCChambers = False
0359 process.MuonGeometryDBConverter.outputXML.suppressCSCLayers = True
0360 
0361 process.MuonGeometryDBConverter.getAPEs = True
0362 process.PoolDBESSource.toGet = cms.VPSet(
0363     cms.PSet(record = cms.string(\"DTAlignmentRcd\"), tag = cms.string(\"DTAlignmentRcd\")),
0364     cms.PSet(record = cms.string(\"DTAlignmentErrorExtendedRcd\"), tag = cms.string(\"DTAlignmentErrorExtendedRcd\")),
0365     cms.PSet(record = cms.string(\"CSCAlignmentRcd\"), tag = cms.string(\"CSCAlignmentRcd\")),
0366     cms.PSet(record = cms.string(\"CSCAlignmentErrorExtendedRcd\"), tag = cms.string(\"CSCAlignmentErrorExtendedRcd\")),
0367       )
0368 """ % vars())
0369 
0370     constraints += """\ncp -f constraints_cff.py $ALIGNMENT_AFSDIR/%(directory)sconstraints_cff.py""" % vars()
0371 
0372     file("%salign.sh" % directory, "w").write("""#!/bin/sh
0373 # %(commandline)s
0374 
0375 export ALIGNMENT_CAFDIR=`pwd`
0376 
0377 cd %(pwd)s
0378 
0379 export SCRAM_ARCH=slc5_amd64_gcc434
0380 echo INFO: SCRAM_ARCH $SCRAM_ARCH
0381 
0382 eval `scramv1 run -sh`
0383 
0384 source /afs/cern.ch/cms/caf/setup.sh
0385 echo INFO: CMS_PATH $CMS_PATH
0386 echo INFO: STAGE_SVCCLASS $STAGE_SVCCLASS
0387 echo INFO: STAGER_TRACE $STAGER_TRACE
0388 
0389 export ALIGNMENT_AFSDIR=`pwd`
0390 
0391 export ALIGNMENT_ITERATION=%(iteration)d
0392 export ALIGNMENT_MODE=%(mode)s
0393 export ALIGNMENT_INPUTDB=%(inputdb)s
0394 export ALIGNMENT_GLOBALTAG=%(globaltag)s
0395 export ALIGNMENT_PHOTOGRAMMETRY='%(photogrammetry)s or %(photogrammetryOnlyholes)s or %(photogrammetryOnlyOnePerRing)s'
0396 export ALIGNMENT_SLM=%(slm)s
0397 export ALIGNMENT_FILLME11HOLES='%(fillME11holes)s'
0398 export ALIGNMENT_DISKS=%(disks)s
0399 export ALIGNMENT_minP=%(minP)s
0400 export ALIGNMENT_minHitsPerChamber=%(minHitsPerChamber)s
0401 export ALIGNMENT_maxdrdz=%(maxdrdz)s
0402 export ALIGNMENT_maxRedChi2=%(maxRedChi2)s
0403 export ALIGNMENT_fiducial=%(fiducial)s
0404 export ALIGNMENT_useHitWeights=%(useHitWeights)s
0405 export ALIGNMENT_truncateSlopeResid=%(truncateSlopeResid)s
0406 export ALIGNMENT_truncateOffsetResid=%(truncateOffsetResid)s
0407 export ALIGNMENT_combineME11=%(combineME11)s
0408 export ALIGNMENT_useTrackWeights=%(useTrackWeights)s
0409 export ALIGNMENT_errorFromRMS=%(errorFromRMS)s
0410 export ALIGNMENT_minTracksPerOverlap=%(minTracksPerOverlap)s
0411 export ALIGNMENT_slopeFromTrackRefit=%(slopeFromTrackRefit)s
0412 export ALIGNMENT_minStationsInTrackRefits=%(minStationsInTrackRefits)s
0413 
0414 cp -f %(directory)salignBH_cfg.py %(directory)sconvert-db-to-xml_cfg.py %(inputdbdir)s%(inputdb)s %(directory)s*.tmp inertGlobalPositionRcd.db $ALIGNMENT_CAFDIR/
0415 cd $ALIGNMENT_CAFDIR/
0416 export ALIGNMENT_ALIGNMENTTMP=`ls alignment*.tmp`
0417 
0418 %(constraints)s
0419 
0420 ls -l
0421 cmsRun alignBH_cfg.py
0422 cp -f report.py $ALIGNMENT_AFSDIR/%(directory)s%(director)s_report.py
0423 cp -f outputdb.db $ALIGNMENT_AFSDIR/%(directory)s%(director)s.db
0424 cp -f plotting.root $ALIGNMENT_AFSDIR/%(directory)s%(director)s.root
0425 
0426 cd $ALIGNMENT_AFSDIR
0427 cmsRun %(directory)sconvert-db-to-xml_cfg.py
0428 
0429 export ALIGNMENT_PLOTTINGTMP=`ls %(directory)splotting0*.root 2> /dev/null`
0430 if [ \"zzz$ALIGNMENT_PLOTTINGTMP\" != \"zzz\" ]; then
0431   hadd -f1 %(directory)s%(director)s_plotting.root %(directory)splotting0*.root
0432   #if [ $? == 0 ] && [ \"$ALIGNMENT_CLEANUP\" == \"True\" ]; then rm %(directory)splotting0*.root; fi
0433 fi
0434 
0435 """ % vars())
0436     os.system("chmod +x %salign.sh" % directory)
0437 
0438     bsubfile.append("echo %salign.sh" % directory)
0439 
0440     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)))
0441     else: bsubfile.append("bsub -R \"type==SLC5_64\" -q cmscaf1nd -J \"%s_align\" -w \"%s\" align.sh" % (director, " && ".join(bsubnames)))
0442 
0443     bsubfile.append("cd ..")
0444     bsubnames = []
0445     last_align = "%s_align" % director
0446 
0447 bsubfile.append("")
0448 file(options.submitJobs, "w").write("\n".join(bsubfile))
0449 os.system("chmod +x %s" % options.submitJobs)