Belle II Software development
SegmentPairFitValidationRun Class Reference
Inheritance diagram for SegmentPairFitValidationRun:
HarvestingRun HarvestingRunMixin StandardEventGenerationRun BrowseTFileOnTerminateRunMixin PostProcessingRunMixin ReadOrGenerateEventsRun PostProcessingRunMixin EmptyRun MinimalRun EmptyRun EmptyRun

Public Member Functions

def output_file_name (self)
 
def harvesting_module (self, path=None)
 
def create_argument_parser (self, **kwds)
 
def get_fit_method (self)
 
def create_path (self)
 

Public Attributes

 monte_carlo
 Degree of refinement of the segment generation.
 

Static Public Attributes

int n_events = 10000
 number of events to generate
 
str generator_module = "simple_gun"
 use the low-momentum particle gun event generator
 
str monte_carlo = "no"
 do not generate new events
 
str segment_orientation = "outwards"
 ordering of the segments in the pair
 
str fit_method_name = "fuse-sz"
 use the Kalmanesk fuse of the two trajectory fits
 

Detailed Description

Harvester to generate, postprocess and inspect MC events for track-segment-pair fit validation

Definition at line 36 of file record.py.

Member Function Documentation

◆ create_argument_parser()

def create_argument_parser (   self,
**  kwds 
)
Convert command-line arguments to basf2 argument list

Reimplemented from HarvestingRunMixin.

Definition at line 71 of file record.py.

71 def create_argument_parser(self, **kwds):
72 """Convert command-line arguments to basf2 argument list"""
73 argument_parser = super().create_argument_parser(**kwds)
74
75 argument_parser.add_argument(
76 '-m',
77 '--monte-carlo',
78 choices=["no", "medium", "full"],
79 default=self.monte_carlo,
80 dest='monte_carlo',
81 help='Amount of monte carlo information to be used in the segment generation.',
82 )
83
84 argument_parser.add_argument(
85 "--fit",
86 choices=["zreco", "fuse-pre", "fuse-sz", "fuse-sz-re"],
87 default=self.fit_method_name,
88 dest="fit_method_name",
89 help=("Choose which fit positional information of the segment should be used. \n"
90 "* 'zreco' means the z coordinate is reconstructed and a linear sz fit is made. "
91 "No covariance between the circle and the linear sz part can be made.\n"
92 "* 'fuse-sz' means the Kalmanesk fuse of the two trajectory fits.\n"
93 "* 'fuse-sz-re' means the Kalmanesk fuse of the two trajectory fits but reestimate the drift length."
94 )
95 )
96
97 return argument_parser
98

◆ create_path()

def create_path (   self)
Sets up a path that plays back pregenerated events or generates events
based on the properties in the base class.

Reimplemented from ReadOrGenerateEventsRun.

Definition at line 164 of file record.py.

164 def create_path(self):
165 """
166 Sets up a path that plays back pregenerated events or generates events
167 based on the properties in the base class.
168 """
169 path = super().create_path()
170
171 path.add_module("TFCDC_WireHitPreparer",
172 flightTimeEstimation="outwards",
173 UseNLoops=0.5
174 )
175
176 path.add_module("TFCDC_ClusterPreparer")
177
178
179 if self.monte_carlo == "no":
180 # MC free - default
181 path.add_module("TFCDC_SegmentFinderFacetAutomaton",
182 SegmentOrientation="outwards"
183 )
184
185 path.add_module("TFCDC_SegmentFitter",
186 inputSegments="CDCSegment2DVector",
187 updateDriftLength=True,
188 useAlphaInDriftLength=True,
189 )
190
191 elif self.monte_carlo == "medium":
192 # Medium MC - proper generation logic, but true facets and facet relations
193 path.add_module("TFCDC_SegmentFinderFacetAutomaton",
194 FacetFilter="truth",
195 FacetRelationFilter="truth",
196 SegmentOrientation="outwards"
197 )
198
199 path.add_module("TFCDC_SegmentFitter",
200 inputSegments="CDCSegment2DVector",
201 updateDriftLength=True,
202 useAlphaInDriftLength=True,
203 )
204
205 elif self.monte_carlo == "full":
206 # Only true monte carlo segments
207 # make the positions realistic but keep the true drift length
208 path.add_module("TFCDC_SegmentCreatorMCTruth",
209 reconstructedDriftLength=False,
210 reconstructedPositions=True,
211 # segments="MCSegments"
212 )
213
214 path.add_module("TFCDC_SegmentFitter",
215 inputSegments="CDCSegment2DVector",
216 updateDriftLength=False,
217 # useAlphaInDriftLength=True,
218 )
219
220 else:
221 raise ValueError("Invalid degree of Monte Carlo information")
222
223 path.add_module("TFCDC_SegmentOrienter",
224 SegmentOrientation="outwards",
225 # SegmentOrientation="none",
226 inputSegments="CDCSegment2DVector",
227 segments="CDCSegment2DVectorOriented"
228 )
229
230 path.add_module("TFCDC_TrackFinderSegmentPairAutomaton",
231 inputSegments="CDCSegment2DVectorOriented",
232 WriteSegmentPairs=True,
233 SegmentPairFilter="truth",
234 SegmentPairFilterParameters={"allowReverse": True},
235 SegmentPairRelationFilter="none"
236 )
237
238 path.add_module(AxialStereoPairFitterModule(fit_method=self.get_fit_method()))
239 return path
240
241

◆ get_fit_method()

def get_fit_method (   self)
Determine which track-segment-pair fitter to use

Definition at line 99 of file record.py.

99 def get_fit_method(self):
100 """Determine which track-segment-pair fitter to use"""
101 fit_method_name = self.fit_method_name
102
103 if fit_method_name == 'zreco':
105
106 def z_reconstruction_fit(pair):
107 return sz_fitter.update(pair)
108 return z_reconstruction_fit
109
110 elif fit_method_name.startswith('fuse-pre'):
113 fusionFit = CDCAxialStereoFusion()
114
115 def sz_segment_pair_preliminary_fit(pair):
116 fusionFit.fusePreliminary(pair)
117 return sz_segment_pair_preliminary_fit
118
119 elif fit_method_name.startswith('fuse-sz'):
122 reestimateDriftLength = fit_method_name.endswith("re")
123 fusionFit = CDCAxialStereoFusion(reestimateDriftLength)
124
125 def sz_segment_pair_fusion_fit(pair):
126 fusionFit.reconstructFuseTrajectories(pair)
127 return
128
129 trajectory3D = pair.getTrajectory3D()
130 revFromSegment = pair.getFromSegment().reversed()
131 revToSegment = pair.getToSegment().reversed()
132 revPair = CDCSegmentPair(revToSegment, revFromSegment)
133
134 CDCAxialStereoFusion.reconstructFuseTrajectories(revPair)
135 revTrajectory3D = revPair.getTrajectory3D().reversed()
136
137 # print("One origin x", trajectory3D.getLocalOrigin().x())
138 # print("One origin y", trajectory3D.getLocalOrigin().y())
139 # print("One origin z", trajectory3D.getLocalOrigin().z())
140
141 # print("Rev origin x", revTrajectory3D.getLocalOrigin().x())
142 # print("Rev origin y", revTrajectory3D.getLocalOrigin().y())
143 # print("Rev origin z", revTrajectory3D.getLocalOrigin().z())
144
145 print("One parameters", [trajectory3D.getLocalHelix().parameters()[i] for i in range(5)])
146 print("Rev parameters", [revTrajectory3D.getLocalHelix().parameters()[i] for i in range(5)])
147
148 print("One covariance")
149 for j in range(5):
150 print([trajectory3D.getLocalHelix().helixCovariance()(i, j) for i in range(5)])
151
152 print("Rev covariance")
153 for j in range(5):
154 print([revTrajectory3D.getLocalHelix().helixCovariance()(i, j) for i in range(5)])
155
156 # return revTrajectory3D
157 # return trajectory3D
158
159 return sz_segment_pair_fusion_fit
160
161 else:
162 raise ValueError(f"Unexpected fit_positions {fit_method_name}")
163
Utility class implementing the Kalmanesk combination of to two dimensional trajectories to one three ...
static const CDCSZFitter & getFitter()
Getter for a standard sz line fitter instance.
Definition: CDCSZFitter.cc:36
Class representing a pair of one reconstructed axial segement and one stereo segment in adjacent supe...

◆ harvesting_module()

def harvesting_module (   self,
  path = None 
)
Harvest and post-process the MC events

Reimplemented from HarvestingRunMixin.

Definition at line 64 of file record.py.

64 def harvesting_module(self, path=None):
65 """Harvest and post-process the MC events"""
66 harvesting_module = SegmentPairFitValidationModule(self.output_file_name)
67 if path:
68 path.add_module(harvesting_module)
69 return harvesting_module
70

◆ output_file_name()

def output_file_name (   self)
Get the output ROOT filename

Reimplemented from HarvestingRunMixin.

Definition at line 52 of file record.py.

52 def output_file_name(self):
53 """Get the output ROOT filename"""
54 file_name = self.fit_method_name
55 file_name += "-mc-" + self.monte_carlo
56
57 if self.root_input_file:
58 file_name += "-" + os.path.split(self.root_input_file)[1]
59 else:
60 file_name += ".root"
61
62 return file_name
63

Member Data Documentation

◆ fit_method_name

str fit_method_name = "fuse-sz"
static

use the Kalmanesk fuse of the two trajectory fits

Definition at line 49 of file record.py.

◆ generator_module

str generator_module = "simple_gun"
static

use the low-momentum particle gun event generator

Definition at line 41 of file record.py.

◆ monte_carlo [1/2]

str monte_carlo = "no"
static

do not generate new events

Definition at line 44 of file record.py.

◆ monte_carlo [2/2]

monte_carlo

Degree of refinement of the segment generation.

Definition at line 179 of file record.py.

◆ n_events

int n_events = 10000
static

number of events to generate

Definition at line 39 of file record.py.

◆ segment_orientation

str segment_orientation = "outwards"
static

ordering of the segments in the pair

Definition at line 46 of file record.py.


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