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