Belle II Software  release-06-01-15
analyzeRawData.py
1 #!/usr/bin/env python
2 # -*- coding: utf-8 -*-
3 
4 
11 
12 
20 
21 
22 
23 import glob
24 import os
25 import basf2
26 
27 # Add a Global Tag
28 basf2.conditions.override_globaltags()
29 basf2.conditions.append_globaltag('data_reprocessing_prompt_bucket7')
30 basf2.conditions.append_globaltag('data_reprocessing_prompt_rel4_patch')
31 
32 # Create the main path
33 main = basf2.create_path()
34 
35 # Add the input files and the progress bar
36 main.add_module('SeqRootInput')
37 main.add_module('Progress')
38 
39 # Add the unpacker
40 main.add_module('KLMUnpacker')
41 
42 # Add the digit analyzer
43 # Note that it must go after the unpacker
44 main.add_module('BKLMDigitAnalyzer',
45  outputRootName='bklmHitmap') # Note that .root is not needed!
46 
47 # Process the main path
48 basf2.process(main)
49 print(basf2.statistics)
50 
51 # Prodce a .pdf file with the hitmap
52 # Here we process only the last file produced
53 # by the BKLMDigitAnalyzer module
54 # The command to be executed is:
55 # root -b 'drawHitmap.cxx("./bklmHitmap_runXXX.root")'
56 allFiles = glob.glob('./bklmHitmap*root') # list all the hitmap .root files
57 latestFile = max(allFiles, key=os.path.getctime) # pick the latest hitmap file
58 bashCommand = "root -b 'drawHitmap.cxx" + '("' + latestFile + '")' + "'"
59 os.system(bashCommand)