CMS 3D CMS Logo

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