96
97
Test the main method of the batch script
99
def __check_sim_file(self):
101
Make some simple data integrity checks on the simulation file
103
root_file = ROOT.TFile(RUN_NUMBER+'_sim.root', # pylint: disable = E1101
105
data = ROOT.MAUS.Data() # pylint: disable = E1101
106
tree = root_file.Get("Spill")
107
tree.SetBranchAddress("data", data)
108
self.assertGreater(tree.GetEntries(), 0)
110
self.assertGreater(data.GetSpill().GetMCEventSize(), 1)
113
def __check_recon_file(self):
115
Make some simple data integrity checks on the simulation file
117
root_file = ROOT.TFile(RUN_NUMBER+'_recon.root', # pylint: disable=E1101
119
data = ROOT.MAUS.Data() # pylint: disable = E1101
120
tree = root_file.Get("Spill")
121
tree.SetBranchAddress("data", data)
122
self.assertGreater(tree.GetEntries(), 0)
124
self.assertEqual(data.GetSpill().GetDaqEventType(), "physics_event")
125
self.assertGreater(data.GetSpill().GetReconEventSize(), 0)
126
self.assertGreater(data.GetSpill().GetAReconEvent(0).GetTOFEvent().\
127
GetTOFEventDigit().GetTOF1DigitArraySize(), 0)
98
131
# want to test also each of the return codes is okay
99
132
def test_main_success(self):
121
154
tar_out = tarfile.open(TEST_OUT, 'r:*')
122
155
tar_out.extractall()
123
156
for file_name in [TEST_OUT, TEST_FILE, 'batch.log', 'download.log', \
124
'reco.log', 'sim.log', RUN_NUMBER+'_recon.json', \
125
RUN_NUMBER+'_sim.json']:
157
'reco.log', 'sim.log', RUN_NUMBER+'_recon.root', \
158
RUN_NUMBER+'_sim.root']:
126
159
self.assertTrue(os.path.isfile(file_name), file_name)
127
sim_first_line = open(RUN_NUMBER+'_sim.json').readline()
128
sim_first_spill = json.loads(sim_first_line)
129
self.assertGreater(len(sim_first_spill['mc']), 1)
130
rec_in = open(RUN_NUMBER+'_recon.json')
131
# start of run twice (?), start of burst
132
for i in range(3): # pylint: disable = W0612
134
rec_first_spill = json.loads(rec_in.readline())
135
self.assertTrue('mc' not in rec_first_spill.keys())
136
self.assertGreater(len(rec_first_spill['digits']['tof1']), 0)
160
self.__check_sim_file()
161
self.__check_recon_file()
139
164
if __name__ == "__main__":