]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/CALO/macros/run_tests.py
44b9086e853fb343b6fb50a58318fe2634f55f54
[u/mrichter/AliRoot.git] / HLT / CALO / macros / run_tests.py
1 #!/usr/bin/env python
2 # -*- coding: utf-8 -*-
3
4 import os
5
6 class Simulator():
7    
8    def __init__(self):
9       self.pwd = os.getenv("PWD")
10       print "SIMULATOR"
11       
12    def mkDirStructure(self):
13          os.system("mkdir -p simulations/single")
14          os.system("mkdir -p simulations/pi0")
15    
16    def copyFiles(self):
17          os.system("cp ConfigSingle.C simulations/single/Config.C")
18          os.system("cp ConfigPi0.C simulations/pi0/Config.C")
19          os.system("cp sim.C simulations/single/sim.C")
20          os.system("cp sim.C simulations/pi0/sim.C")
21    
22    def cleanFiles(self):
23          os.system("rm simulations/single/ -rf")
24          os.system("rm simulations/pi0/ -rf")
25    
26    def initSimulation(self):
27       self.cleanFiles()
28       self.mkDirStructure()
29       self.copyFiles()
30
31    def runSimulation(self, nevents, dophos, doemcal, dotm):
32       simargs = str(nevents) + ", " + str(int(dophos)) + ", " + str(int(doemcal)) + ", " + str(int(dotm))
33       command = "cd simulations/single/ && aliroot -b -q sim.C\'(" + simargs + ")\'"
34       os.system(command)
35       os.system("cd " + self.pwd)
36
37 class Tester():
38    def __init__(self):
39       print "TESTER"
40
41    def initTest(self):
42       self.pwd = os.getenv("PWD")
43       os.system("rm -rf tests/all/")
44       os.system("mkdir -p tests/all/single")
45       os.system("cp rec_hlt_calo.C tests/all/single/.")
46       os.system("cp runAll.C tests/all/single/.")
47       os.system("cp read_HLT_ESDs.C tests/all/single/.")
48
49    def run(self, dophos, doemcal, dotm):
50       
51       runargs = "\"./\", \"./\", " + str(int(dophos)) + ", " + str(int(doemcal)) + ", " + str(int(dotm))
52       path = self.pwd + "/simulations/single/."
53       command = "cd tests/all/single/;  ln -s " + path + "/raw* .; ln -s " + path + "/GRP . ; aliroot runAll.C\'(" + runargs + ")\'"
54       os.system(command)
55       os.system("cd " + self.pwd)
56
57 from optparse import OptionParser
58
59 parser = OptionParser()
60
61 parser.add_option("-s", "--simulatedata", action="store_true", dest="simulatedata",
62                                  default=False, help="Simulate data for the tests")
63 parser.add_option("-n", "--nevents", dest="nevents",
64                                  default=100, help="Specify the number of events to simulate. If you change this the reference histograms will be useless")
65 parser.add_option("", "--no-phos", action="store_false", dest="runphos", 
66                                  default=True, help="Testing: Don't run PHOS tests. Simulation: Don't simulate for PHOS")
67 parser.add_option("", "--no-emcal", action="store_false", dest="runemcal",
68                                  default=True, help="Testing: Don't run EMCAL tests. Simulation: Don't simulate for EMCAL")
69 parser.add_option("", "--no-trackmatching", action="store_false", dest="runtm",
70                                  default=True, help="Testing: Don't run the track matcher, Simulation: Don't simulate TPC")
71
72 (options, args) = parser.parse_args()
73
74 if options.simulatedata:
75    simulator = Simulator()
76    simulator.initSimulation()
77    simulator.runSimulation(options.nevents, options.runphos, options.runemcal, options.runtm)
78    exit(0)
79
80 else:
81    tester = Tester()
82    tester.initTest()
83    tester.run(options.runphos, options.runemcal, options.runtm)
84    exit(0)
85     
86