6 from ROOT
import Belle2
17 Overloaded harvester, that stores its data into a pandas data frame instead of a numpy array,
18 because they are more flexible when it comes to changing columns and value types to be stored.
22 """Coroutine that receives the dictionaries of names and values from peel and store them into a pandas df."""
26 if isinstance(crop, numbers.Number):
29 crops.append({
"value": crop})
35 elif isinstance(crop, collections.MutableMapping):
44 msg =
"Unrecognised crop {} of type {}".format(
54 """Receive the gathered crops and saves them into a ROOT file."""
61 Read in the trigger results stored in the data store and write them out into a ROOT file after all events have
65 def __init__(self, root_file_name="save_results.pkl", store_object_name="SoftwareTriggerResult"):
67 Create a new module to get the stored trigger decisions from the data store and save them to a root file.
68 :param root_file_name: The file name where to store the results.
69 :param store_object_name: The store object name where the trigger results an be found in the data store.
71 super().
__init__(foreach=store_object_name, output_file_name=root_file_name)
75 For each result ( = event), get the list of all trigger decisions and also add the total decision.
76 Write them back into the internal storage ( = pandas.DataFrame) of all events.
78 return_dict = {identifier: result
for identifier, result
in result.getResults()}
81 getFinalTriggerDecision = Belle2.SoftwareTrigger.FinalTriggerDecisionCalculator.getFinalTriggerDecision
82 return_dict[
"final_decision"] = getFinalTriggerDecision(result)
88 Read in the trigger variables stored in the data store and write them out into a ROOT file after all events have
92 def __init__(self, root_file_name="save_vars.pkl", store_object_name="SoftwareTriggerVariables"):
94 Create a new module to get the stored trigger variables from the data store and save them to a root file.
95 :param root_file_name: The file name where to store the variables.
96 :param store_object_name: The store object name where the trigger variables an be found in the data store.
98 super().
__init__(foreach=store_object_name, output_file_name=root_file_name)
102 For each collection of variables ( = event), get the list of all variables.
103 Write them back into the internal storage ( = pandas.DataFrame) of all events.
105 yield {identifier: value
for identifier, value
in variables.get()}
108 if __name__ ==
"__main__":
109 path = basf2.create_path()
112 path.add_module(
"SeqRootInput", inputFileName=
"raw.sroot")