Belle II Software development
HarvestingRunMixin Class Reference
Inheritance diagram for HarvestingRunMixin:
BrowseTFileOnTerminateRunMixin PostProcessingRunMixin PostProcessingRunMixin EmptyRun EmptyRun HarvestingRun ElossHarvestingRun LegendreBinningValidationRun SegmentFitValidationRun SegmentPairFitValidationRun

Public Member Functions

def harvesting_module (self, path=None)
 
def create_argument_parser (self, **kwds)
 
def pickle_crops (self, harvesting_module, crops, **kwds)
 
def unpickle_crops (self)
 
def postprocess (self)
 
def adjust_path (self, path)
 

Static Public Attributes

None output_file_name = None
 Disable the writing of an output ROOT file.
 

Detailed Description

Harvester to select crops, postprocess, and inspect

Definition at line 16 of file run.py.

Member Function Documentation

◆ adjust_path()

def adjust_path (   self,
  path 
)
Add the harvester to the basf2 path

Reimplemented from EmptyRun.

Definition at line 66 of file run.py.

66 def adjust_path(self, path):
67 """Add the harvester to the basf2 path"""
68 super().adjust_path(path)
69 harvesting_module = self.harvesting_module()
70 if self.output_file_name:
71 harvesting_module.output_file_name = self.output_file_name
72 harvesting_module.refiners.append(self.pickle_crops)
73 path.add_module(harvesting_module)
74 return path
75
76

◆ create_argument_parser()

def create_argument_parser (   self,
**  kwds 
)
Parse the arguments and append them to the harvester's list

Reimplemented from PostProcessingRunMixin.

Reimplemented in ElossHarvestingRun, LegendreBinningValidationRun, SegmentFitValidationRun, and SegmentPairFitValidationRun.

Definition at line 26 of file run.py.

26 def create_argument_parser(self, **kwds):
27 """Parse the arguments and append them to the harvester's list"""
28 argument_parser = super().create_argument_parser(**kwds)
29 harvesting_argument_group = argument_parser.add_argument_group("Harvest arguments")
30
31 harvesting_argument_group.add_argument(
32 "-o",
33 "--output",
34 dest="output_file_name",
35 default=argparse.SUPPRESS,
36 help="File name for the harvest products"
37 )
38
39 return argument_parser
40

◆ harvesting_module()

def harvesting_module (   self,
  path = None 
)
This virtual method must be overridden by the inheriting class

Reimplemented in ElossHarvestingRun, LegendreBinningValidationRun, SegmentFitValidationRun, and SegmentPairFitValidationRun.

Definition at line 22 of file run.py.

22 def harvesting_module(self, path=None):
23 """This virtual method must be overridden by the inheriting class"""
24 raise RuntimeError("Override the harvesting_module method")
25

◆ pickle_crops()

def pickle_crops (   self,
  harvesting_module,
  crops,
**  kwds 
)
Save the raw crops as a pickle file

Definition at line 41 of file run.py.

41 def pickle_crops(self, harvesting_module, crops, **kwds):
42 """Save the raw crops as a pickle file"""
43 with open(self.output_file_name + ".pickle", "wb") as pickle_file:
44 pickle.dump(crops, pickle_file)
45

◆ postprocess()

def postprocess (   self)
Post-process the crops

Reimplemented from PostProcessingRunMixin.

Definition at line 51 of file run.py.

51 def postprocess(self):
52 """Post-process the crops"""
53 if self.postprocess_only:
54 harvesting_module = self.harvesting_module()
55 if self.output_file_name:
56 harvesting_module.output_file_name = self.output_file_name
57 try:
58 crops = self.unpickle_crops()
59 except FileNotFoundError:
60 print("Crops pickle file not found. Create it now.")
61 else:
62 harvesting_module.refine(crops)
63
64 super().postprocess()
65

◆ unpickle_crops()

def unpickle_crops (   self)
Load the raw crops from a pickle file

Definition at line 46 of file run.py.

46 def unpickle_crops(self):
47 """Load the raw crops from a pickle file"""
48 with open(self.output_file_name + ".pickle", "rb") as pickle_file:
49 return pickle.load(pickle_file)
50

Member Data Documentation

◆ output_file_name

None output_file_name = None
static

Disable the writing of an output ROOT file.

Reimplemented in ElossHarvestingRun, LegendreBinningValidationRun, SegmentFitValidationRun, and SegmentPairFitValidationRun.

Definition at line 20 of file run.py.


The documentation for this class was generated from the following file: