12from ROOT
import Belle2
13from ROOT.Belle2
import TrackFindingCDC
as TFCDC
30 return logging.getLogger(__name__)
33CONTACT =
"oliver.frost@desy.de"
37 """Harvester to generate, postprocess and inspect MC events for track-segment evaluation"""
41 generator_module =
"generic"
45 """Get the output ROOT filename"""
46 return 'legendre_binning.root'
49 """Harvest and post-process the generated events"""
52 path.add_module(harvesting_module)
53 return harvesting_module
56 """Convert command-line arguments to basf2 argument list"""
58 return argument_parser
60 def create_path(self):
62 Sets up a path that plays back pregenerated events or generates events
63 based on the properties
in the base
class.
65 path = super().create_path()
67 path.add_module("TFCDC_WireHitPreparer",
69 flightTimeEstimation=
"outwards",
72 path.add_module(
'TFCDC_AxialTrackCreatorMCTruth',
74 useOnlyBeforeTOP=
True,
76 reconstructedDriftLength=
True,
77 reconstructedPositions=
True)
84 """Module to collect information about the generated segments and
85 compose validation plots on terminate."""
89 super().__init__(foreach='CDCTrackVector',
90 output_file_name=output_file_name)
95 origin_track_fitter = TFCDC.CDCRiemannFitter()
96 origin_track_fitter.setOriginConstrained()
101 with open(
'fine_curv_bounds.txt')
as curv_bounds_file:
102 for curv_bound_line
in curv_bounds_file:
103 curv_bounds.append(float(curv_bound_line))
105 bin_bounds = list(zip(curv_bounds[0::2], curv_bounds[1::2]))
106 bin_bounds = sorted(bin_bounds)
116 """Receive signal at the start of event processing"""
124 """Initialize the MC-hit lookup method"""
125 TFCDC.CDCMCHitLookUp.getInstance().fill()
128 """Select tracks with at least 4 segments and associated primary MC particle"""
130 mc_particle = mc_track_lookup.getMCParticle(track)
133 return mc_particle
and is_primary(mc_particle)
and track.size() > 3
136 """Aggregate the track and MC information for track-segment analysis"""
141 observations2D = TFCDC.CDCObservations2D(rl_drift_circle, unit_variance)
143 for recoHit3D
in track:
144 observations2D.append(recoHit3D)
146 trajectory2D = track_fitter.fit(observations2D)
147 trajectory2D.setLocalOrigin(TFCDC.Vector2D(0, 0))
149 n_hits = track.size()
150 pt = trajectory2D.getAbsMom2D()
151 curv = trajectory2D.getCurvature()
153 bin_curv = curv
if abs(curv) < curl_curv
else abs(curv)
154 curv_var = trajectory2D.getLocalVariance(0)
155 impact = trajectory2D.getGlobalImpact()
156 phi0 = trajectory2D.getLocalCircle().phi0()
158 circle = trajectory2D.getLocalCircle()
162 for recoHit3D
in track:
163 wire_ref_pos = recoHit3D.getRefPos2D()
164 drift_length = recoHit3D.getSignedRecoDriftLength()
165 r = wire_ref_pos.norm()
166 cross_curv = -2 * (n12.dot(wire_ref_pos) - drift_length) / (r * r - drift_length * drift_length)
167 cross_curvs.append(cross_curv)
169 cross_curvs = np.array(cross_curvs)
170 cross_curv = np.median(cross_curvs)
171 cross_curv_var = np.median(np.abs(cross_curvs - cross_curv))
173 basic_curv_precision = TFCDC.PrecisionUtil.getBasicCurvPrecision(cross_curv)
174 origin_curv_precision = TFCDC.PrecisionUtil.getOriginCurvPrecision(cross_curv)
175 non_origin_curv_precision = TFCDC.PrecisionUtil.getNonOriginCurvPrecision(cross_curv)
179 max_curv_precision = 0.00007
186 curv_dense = random.uniform(random_lower_curv_bound, random_upper_curv_bound)
187 curv_width = random_upper_curv_bound - random_lower_curv_bound
191 curvature_estimate=curv,
192 curvature_variance=curv_var,
193 abs_curvature_estimate=abs(curv),
194 inv_curv=1.0 / abs(curv),
195 cross_curv=cross_curv,
196 cross_curv_var=cross_curv_var,
197 basic_curv_precision=basic_curv_precision,
198 origin_curv_precision=origin_curv_precision,
199 non_origin_curv_precision=non_origin_curv_precision,
200 max_curv_precision=max_curv_precision,
203 curv_dense=curv_dense,
204 curv_width=curv_width,
205 impact_estimate=impact,
211 save_tree = refiners.save_tree()
213 save_histograms = refiners.save_histograms(outlier_z_score=5.0, allow_discrete=
True)
216 save_profiles = refiners.save_profiles(x=[
'curvature_estimate',
'phi0'],
217 y=
'curvature_variance',
221 save_cross_curv_profile = refiners.save_profiles(x=[
'cross_curv'],
223 'curvature_estimate',
224 'basic_curv_precision',
225 'origin_curv_precision',
226 'non_origin_curv_precision',
227 'max_curv_precision',
232 save_scatter = refiners.save_scatters(x=[
'curvature_estimate'], y=
'n_hits')
237 run.configure_and_execute_from_commandline()
240if __name__ ==
"__main__":
241 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.