12from ROOT
import Belle2
13from ROOT.Belle2
import TrackFindingCDC
as TFCDC
30 return logging.getLogger(__name__)
34 """Harvester to generate, postprocess and inspect MC events for track-segment evaluation"""
38 generator_module =
"generic"
42 """Get the output ROOT filename"""
43 return 'legendre_binning.root'
46 """Harvest and post-process the generated events"""
49 path.add_module(harvesting_module)
50 return harvesting_module
53 """Convert command-line arguments to basf2 argument list"""
55 return argument_parser
57 def create_path(self):
59 Sets up a path that plays back pregenerated events or generates events
60 based on the properties
in the base
class.
62 path = super().create_path()
64 path.add_module("TFCDC_WireHitPreparer",
66 flightTimeEstimation=
"outwards",
69 path.add_module(
'TFCDC_AxialTrackCreatorMCTruth',
71 useOnlyBeforeTOP=
True,
73 reconstructedDriftLength=
True,
74 reconstructedPositions=
True)
81 """Module to collect information about the generated segments and
82 compose validation plots on terminate."""
86 super().__init__(foreach='CDCTrackVector',
87 output_file_name=output_file_name)
92 origin_track_fitter = TFCDC.CDCRiemannFitter()
93 origin_track_fitter.setOriginConstrained()
98 with open(
'fine_curv_bounds.txt')
as curv_bounds_file:
99 for curv_bound_line
in curv_bounds_file:
100 curv_bounds.append(float(curv_bound_line))
102 bin_bounds = list(zip(curv_bounds[0::2], curv_bounds[1::2]))
103 bin_bounds = sorted(bin_bounds)
113 """Receive signal at the start of event processing"""
121 """Initialize the MC-hit lookup method"""
122 TFCDC.CDCMCHitLookUp.getInstance().fill()
125 """Select tracks with at least 4 segments and associated primary MC particle"""
127 mc_particle = mc_track_lookup.getMCParticle(track)
130 return mc_particle
and is_primary(mc_particle)
and track.size() > 3
133 """Aggregate the track and MC information for track-segment analysis"""
138 observations2D = TFCDC.CDCObservations2D(rl_drift_circle, unit_variance)
140 for recoHit3D
in track:
141 observations2D.append(recoHit3D)
143 trajectory2D = track_fitter.fit(observations2D)
144 trajectory2D.setLocalOrigin(TFCDC.Vector2D(0, 0))
146 n_hits = track.size()
147 pt = trajectory2D.getAbsMom2D()
148 curv = trajectory2D.getCurvature()
150 bin_curv = curv
if abs(curv) < curl_curv
else abs(curv)
151 curv_var = trajectory2D.getLocalVariance(0)
152 impact = trajectory2D.getGlobalImpact()
153 phi0 = trajectory2D.getLocalCircle().phi0()
155 circle = trajectory2D.getLocalCircle()
159 for recoHit3D
in track:
160 wire_ref_pos = recoHit3D.getRefPos2D()
161 drift_length = recoHit3D.getSignedRecoDriftLength()
162 r = wire_ref_pos.norm()
163 cross_curv = -2 * (n12.dot(wire_ref_pos) - drift_length) / (r * r - drift_length * drift_length)
164 cross_curvs.append(cross_curv)
166 cross_curvs = np.array(cross_curvs)
167 cross_curv = np.median(cross_curvs)
168 cross_curv_var = np.median(np.abs(cross_curvs - cross_curv))
170 basic_curv_precision = TFCDC.PrecisionUtil.getBasicCurvPrecision(cross_curv)
171 origin_curv_precision = TFCDC.PrecisionUtil.getOriginCurvPrecision(cross_curv)
172 non_origin_curv_precision = TFCDC.PrecisionUtil.getNonOriginCurvPrecision(cross_curv)
176 max_curv_precision = 0.00007
183 curv_dense = random.uniform(random_lower_curv_bound, random_upper_curv_bound)
184 curv_width = random_upper_curv_bound - random_lower_curv_bound
188 curvature_estimate=curv,
189 curvature_variance=curv_var,
190 abs_curvature_estimate=abs(curv),
191 inv_curv=1.0 / abs(curv),
192 cross_curv=cross_curv,
193 cross_curv_var=cross_curv_var,
194 basic_curv_precision=basic_curv_precision,
195 origin_curv_precision=origin_curv_precision,
196 non_origin_curv_precision=non_origin_curv_precision,
197 max_curv_precision=max_curv_precision,
200 curv_dense=curv_dense,
201 curv_width=curv_width,
202 impact_estimate=impact,
208 save_tree = refiners.save_tree()
210 save_histograms = refiners.save_histograms(outlier_z_score=5.0, allow_discrete=
True)
213 save_profiles = refiners.save_profiles(x=[
'curvature_estimate',
'phi0'],
214 y=
'curvature_variance',
218 save_cross_curv_profile = refiners.save_profiles(x=[
'cross_curv'],
220 'curvature_estimate',
221 'basic_curv_precision',
222 'origin_curv_precision',
223 'non_origin_curv_precision',
224 'max_curv_precision',
229 save_scatter = refiners.save_scatters(x=[
'curvature_estimate'], y=
'n_hits')
234 run.configure_and_execute_from_commandline()
237if __name__ ==
"__main__":
238 logging.basicConfig(stream=sys.stdout, level=logging.INFO, format=
'%(levelname)s:%(message)s')
mc_track_lookup
by default, there is no method to find matching MC tracks
mc_hit_lookup
Method to find matching MC hits.
track_fitter
Use the CDCReimannFitter with a constrained origin for track fitting.
lower_curv_bounds
cached copy of lower bounds
upper_curv_bounds
cached copy of upper bounds
def __init__(self, output_file_name)
def create_argument_parser(self, **kwds)
def harvesting_module(self, path=None)
def output_file_name(self)
None output_file_name
Disable the writing of an output ROOT file.
None output_file_name
There is no default for the name of the output TFile.