Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-10-26 10:51:02

0001 #!/usr/bin/env python3
0002 
0003 from __future__ import print_function
0004 import os,sys
0005 import getopt
0006 import time
0007 import ROOT
0008 import urllib
0009 import string
0010 import optparse
0011 import dataCert
0012 
0013 #read arguments to the command line
0014 #configure
0015 usage = 'usage: %prog [options]'
0016 parser = optparse.OptionParser(usage)
0017 parser.add_option('-f', '--firstRun'   ,    dest='firstRun'           , help='first run to process (-1 --> automatic)'  , default='-1')
0018 parser.add_option('-l', '--lastRun'    ,    dest='lastRun'            , help='last run to process (-1 --> automatic)'   , default='-1')
0019 parser.add_option('-P', '--publish'    ,    dest='publish'            , help='publish the results'                      , default='True')
0020 parser.add_option('-p', '--pcl'        ,    dest='usePCL'             , help='use PCL output instead of calibTree'      , default='True')
0021 parser.add_option('-m', '--mode'       ,    dest='calMode'            , help='select the statistics type'      , default='AagBunch')
0022 parser.add_option('-s', '--scriptDir'  ,    dest='scriptDir'          , help='select the scriptDirectory'      , default='')
0023 parser.add_option('-a', '--automatic'  ,    dest='automatic'          , help='set if ran automaticaly'         , default='')
0024 (opt, args) = parser.parse_args()
0025 
0026 scriptDir = os.getcwd()
0027 firstRun = int(opt.firstRun)
0028 lastRun  = int(opt.lastRun)
0029 #calMode  = str(opt.calMode) if not str(opt.calMode)=='' else "StdBunch"
0030 calMode  = str(opt.calMode) if not str(opt.calMode)=='' else "AagBunch" # Set default to AAG
0031 MC=""
0032 publish = (opt.publish=='True')
0033 mail = "martin.delcourt@cern.ch "#dimattia@cern.ch"
0034 
0035 usePCL = (opt.usePCL=='True')
0036 
0037 initEnv='cd ' + os.getcwd() + ';'
0038 initEnv+='source /afs/cern.ch/cms/cmsset_default.sh' + ';'
0039 initEnv+='eval `scramv1 runtime -sh`' + ';'
0040 
0041 name = "Run_"+str(firstRun)+"_to_"+str(lastRun)
0042 if len(calMode)>0:  name = name+"_"+calMode
0043 if(usePCL==True):   name = name+"_PCL"
0044 else:               name = name+"_CalibTree"
0045 print(name)
0046 
0047 automatic = opt.automatic
0048 scriptDir = opt.scriptDir
0049 
0050 
0051 if(os.system(initEnv+"sh sequence.sh \"" + name + "\" \"" + calMode + "\" \"CMS Preliminary  -  Run " + str(firstRun) + " to " + str(lastRun) + "\"")!=0):
0052     os.system('echo "Gain calibration failed" | mail -s "Gain calibration failed ('+name+')" ' + mail)        
0053 else:
0054     if(publish==True):os.system(initEnv+"sh sequence.sh " + name);
0055     os.system('echo "Manual gain calibration done\nhttps://test-stripcalibvalidation.web.cern.ch/test-stripcalibvalidation/CalibrationValidation/ParticleGain/" | mail -s "Gain calibration done ('+name+')" ' + mail)
0056 
0057 if(automatic==True):
0058    #call the script one more time to make sure that we do not have a new run to process
0059    os.chdir(scriptDir); #go back to initial location
0060    os.system('python automatic_RunOnCalibTree.py')