Belle II Software  release-05-01-25
perfect_match.py
1 #!/usr/bin/env python3
2 # -*- coding: utf-8 -*-
3 
4 
10 
11 from basf2 import *
12 from ROOT import Belle2
13 
14 from interactive import embed
15 # Set the log level to show only error and fatal messages
16 set_log_level(LogLevel.INFO)
17 
18 # Set Database
19 use_database_chain()
20 use_local_database(Belle2.FileSystem.findFile("data/framework/database.txt"))
21 
22 # Input file
23 # Get type of input file to decide, which input module we want to use
24 input_files = Belle2.Environment.Instance().getInputFilesOverride()
25 if input_files.empty():
26  print('Please specify input file(s). Example usage:',
27  'basf2 perfect_match.py -i input.sroot')
28  exit(1)
29 if input_files.front().endswith(".sroot"):
30  root_input = register_module('SeqRootInput')
31 else:
32  root_input = register_module('RootInput')
33 
34 unpacker = register_module('CDCUnpacker')
35 unpacker.param('enableStoreCDCRawHit', True)
36 # unpacker.param('enablePrintOut', True)
37 output = register_module('RootOutput')
38 output.param('outputFileName', 'UnpackerOutput.root')
39 output.param('branchNames', ['CDCHits', 'CDCRawHits'])
40 
41 
42 class PrintTRGTime(Module):
43  """
44  Print TRG time
45  """
46 
47  def initialize(self):
48  """
49  set CDCHits and EventMetaData
50  """
51 
52  self.event_info = Belle2.PyStoreObj('EventMetaData')
53 
54  self.cdc_hit = Belle2.PyStoreArray('CDCHits')
55 
56  def event(self):
57  """
58  Print TRG time of an event
59  """
60  B2INFO('Event {}:'.format(self.event_info.getEvent()))
61  for hit in self.cdc_hit:
62  cdc_raw_hit = hit.getRelatedTo('CDCRawHits')
63  B2INFO('Trigger time: {}'.format(cdc_raw_hit.getTriggerTime()))
64 
65 
66 # Create main path
67 main = create_path()
68 
69 # Add modules to main path
70 main.add_module(root_input)
71 main.add_module(unpacker)
72 main.add_module(PrintTRGTime())
73 # main.add_module(output)
74 
75 # Process all events
76 print_path(main)
77 process(main)
78 
79 print(statistics)
perfect_match.PrintTRGTime.initialize
def initialize(self)
Definition: perfect_match.py:47
Belle2::PyStoreObj
a (simplified) python wrapper for StoreObjPtr.
Definition: PyStoreObj.h:69
perfect_match.PrintTRGTime.event_info
event_info
EventMetaData.
Definition: perfect_match.py:52
perfect_match.PrintTRGTime
Definition: perfect_match.py:42
perfect_match.PrintTRGTime.event
def event(self)
Definition: perfect_match.py:56
Belle2::PyStoreArray
a (simplified) python wrapper for StoreArray.
Definition: PyStoreArray.h:58
Belle2::Environment::Instance
static Environment & Instance()
Static method to get a reference to the Environment instance.
Definition: Environment.cc:31
Belle2::FileSystem::findFile
static std::string findFile(const std::string &path, bool silent=false)
Search for given file or directory in local or central release directory, and return absolute path if...
Definition: FileSystem.cc:147
perfect_match.PrintTRGTime.cdc_hit
cdc_hit
CDCHits.
Definition: perfect_match.py:54