Belle II Software development
ConstraintsGenerator Class Reference
Inheritance diagram for ConstraintsGenerator:

Public Member Functions

def __init__ (self, generator)
 
def event (self)
 
def terminate (self)
 

Public Attributes

 generator
 The generator: alignment.Constraints.
 
 consts
 Generated constraints (key is constraint checksum)
 

Detailed Description

basf2 python module to generate a file with a single set of constraints

(Needed especially for time-dependent constraints)

Definition at line 19 of file constraints_generator.py.

Constructor & Destructor Documentation

◆ __init__()

def __init__ (   self,
  generator 
)
Constructor

Parameters
----------
generator : alignment.Constraints
  Set of constraints to be generated (defines also filename)

Definition at line 26 of file constraints_generator.py.

26 def __init__(self, generator):
27 """
28 Constructor
29
30 Parameters
31 ----------
32 generator : alignment.Constraints
33 Set of constraints to be generated (defines also filename)
34
35 """
36
37 super().__init__()
38
39 self.generator = generator
40
41 self.consts = dict()
42 super().set_name(super().name() + ":" + generator.filename)
43

Member Function Documentation

◆ event()

def event (   self)
 Event: attempt to add constraints
At each event, attempt to generate the constraints and add them
to the dict (same cheksum - using only labels - means it gets overriden!)
Thus is only works if the time-dependence is set (otherwise you always get the same labels and
only the last constraint coefficients will be stored)

Definition at line 44 of file constraints_generator.py.

44 def event(self):
45 """ Event: attempt to add constraints
46 At each event, attempt to generate the constraints and add them
47 to the dict (same cheksum - using only labels - means it gets overriden!)
48 Thus is only works if the time-dependence is set (otherwise you always get the same labels and
49 only the last constraint coefficients will be stored)
50 """
51 consts = self.generator.generate()
52 for const in consts:
53 self.consts[const.get_checksum()] = const.data
54

◆ terminate()

def terminate (   self)
 Terminate: write-down collect constraint data to file

Definition at line 55 of file constraints_generator.py.

55 def terminate(self):
56 """ Terminate: write-down collect constraint data to file
57 """
58 if len(self.consts):
59 with open(self.generator.filename, 'w') as f:
60 for checksum, data in self.consts.items():
61 f.write('Constraint 0.\n')
62 for label, coef in data:
63 f.write('{} {}\n'.format(label, coef))
64 print("Finished file: ", self.generator.filename)
65 print("Done: ", self.generator.filename)
66
67

Member Data Documentation

◆ consts

consts

Generated constraints (key is constraint checksum)

Definition at line 41 of file constraints_generator.py.

◆ generator

generator

The generator: alignment.Constraints.

Definition at line 39 of file constraints_generator.py.


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