CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
runonSM.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 import os,string,sys,commands,time
3 
4 # template file to be used
5 MODFILE="reco_skim_cfg_mod.py"
6 
7 # the output file is PREFIX_date.root
8 PREFIX="SkimSM"
9 
10 # it produces a file every NUEVENTS events
11 NUMEVENTS="-1"
12 
13 # here starts the main
14 
15 if len(sys.argv)!=2 :
16  print "Usage = runonSM.py <type>"
17  print "where type is either \"tunnel\" or \"revproxy\" or \"playback\" "
18  sys.exit(1)
19 
20 TYPE=sys.argv[1]
21 
22 if TYPE=="tunnel" :
23  SOURCE="cms.string('http://localhost:22100/urn:xdaq-application:lid=30')"
24  SELECTHLT= "cms.untracked.string('hltOutputDQM')"
25 elif TYPE=="revproxy":
26  SOURCE="cms.string('http://cmsdaq0.cern.ch/event-server/urn:xdaq-application:lid=30')"
27  SELECTHLT= "cms.untracked.string('hltOutputDQM')"
28 elif TYPE=="playback":
29  SOURCE="cms.string('http://localhost:50082/urn:xdaq-application:lid=29')"
30  SELECTHLT= "cms.untracked.string('hltOutputDQM')"
31 else:
32  print "wrong type value."
33  sys.exit(1)
34 
35 while True:
36  DATE=str(int(time.time()))
37  print "Suffix:"+DATE
38  FILENAME=PREFIX+"_"+DATE+"_cfg.py"
39  FILELOG=PREFIX+"_"+DATE+".log"
40  # read mod file
41  modfile=open(MODFILE,"r")
42  text=modfile.read()
43  modfile.close()
44  text=text.replace("SUFFIX",DATE)
45  text=text.replace("SOURCE",SOURCE)
46  text=text.replace("NUMEVENTS",NUMEVENTS)
47  text=text.replace("SELECTHLT",SELECTHLT)
48  newfile=open(FILENAME,"w")
49  newfile.write(text)
50  newfile.close()
51 
52  print "Created: "+FILENAME+" . Running cmsRun now and logging in "+FILELOG
53  os.system("cmsRun "+FILENAME+" 2>&1 | tee "+FILELOG+" | grep --line-buffered -e \"Begin processing\" -e \"BeamSplash\" -e \"PhysDecl\"")