13 from ROOT
import Belle2
14 from ROOT.Belle2
import TrackFindingCDC
as TFCDC
31 return logging.getLogger(__name__)
34 CONTACT =
"oliver.frost@desy.de"
38 """Harvester to generate, postprocess and inspect MC events for track-segment evaluation"""
42 generator_module =
"generic"
46 """Get the output ROOT filename"""
47 return 'legendre_binning.root'
50 """Harvest and post-process the generated events"""
53 path.add_module(harvesting_module)
54 return harvesting_module
57 """Convert command-line arguments to basf2 argument list"""
59 return argument_parser
63 Sets up a path that plays back pregenerated events or generates events
64 based on the properties in the base class.
68 path.add_module(
"TFCDC_WireHitPreparer",
70 flightTimeEstimation=
"outwards",
73 path.add_module(
'TFCDC_AxialTrackCreatorMCTruth',
75 useOnlyBeforeTOP=
True,
77 reconstructedDriftLength=
True,
78 reconstructedPositions=
True)
85 """Module to collect information about the generated segments and
86 compose validation plots on terminate."""
90 super().
__init__(foreach=
'CDCTrackVector',
91 output_file_name=output_file_name)
96 origin_track_fitter = TFCDC.CDCRiemannFitter()
97 origin_track_fitter.setOriginConstrained()
102 with open(
'fine_curv_bounds.txt')
as curv_bounds_file:
103 for curv_bound_line
in curv_bounds_file:
104 curv_bounds.append(float(curv_bound_line))
106 bin_bounds = list(zip(curv_bounds[0::2], curv_bounds[1::2]))
107 bin_bounds = sorted(bin_bounds)
117 """Receive signal at the start of event processing"""
120 self.
mc_track_lookupmc_track_lookup = TFCDC.CDCMCTrackLookUp.getInstance()
125 """Initialize the MC-hit lookup method"""
126 TFCDC.CDCMCHitLookUp.getInstance().fill()
129 """Select tracks with at least 4 segments and associated primary MC particle"""
131 mc_particle = mc_track_lookup.getMCParticle(track)
134 return mc_particle
and is_primary(mc_particle)
and track.size() > 3
137 """Aggregate the track and MC information for track-segment analysis"""
142 observations2D = TFCDC.CDCObservations2D(rl_drift_circle, unit_variance)
144 for recoHit3D
in track:
145 observations2D.append(recoHit3D)
147 trajectory2D = track_fitter.fit(observations2D)
148 trajectory2D.setLocalOrigin(TFCDC.Vector2D(0, 0))
150 n_hits = track.size()
151 pt = trajectory2D.getAbsMom2D()
152 curv = trajectory2D.getCurvature()
154 bin_curv = curv
if abs(curv) < curl_curv
else abs(curv)
155 curv_var = trajectory2D.getLocalVariance(0)
156 impact = trajectory2D.getGlobalImpact()
157 phi0 = trajectory2D.getLocalCircle().phi0()
159 circle = trajectory2D.getLocalCircle()
163 for recoHit3D
in track:
164 wire_ref_pos = recoHit3D.getRefPos2D()
165 drift_length = recoHit3D.getSignedRecoDriftLength()
166 r = wire_ref_pos.norm()
167 cross_curv = -2 * (n12.dot(wire_ref_pos) - drift_length) / (r * r - drift_length * drift_length)
168 cross_curvs.append(cross_curv)
170 cross_curvs = np.array(cross_curvs)
171 cross_curv = np.median(cross_curvs)
172 cross_curv_var = np.median(np.abs(cross_curvs - cross_curv))
174 basic_curv_precision = TFCDC.PrecisionUtil.getBasicCurvPrecision(cross_curv)
175 origin_curv_precision = TFCDC.PrecisionUtil.getOriginCurvPrecision(cross_curv)
176 non_origin_curv_precision = TFCDC.PrecisionUtil.getNonOriginCurvPrecision(cross_curv)
180 max_curv_precision = 0.00007
187 curv_dense = random.uniform(random_lower_curv_bound, random_upper_curv_bound)
188 curv_width = random_upper_curv_bound - random_lower_curv_bound
192 curvature_estimate=curv,
193 curvature_variance=curv_var,
194 abs_curvature_estimate=abs(curv),
195 inv_curv=1.0 / abs(curv),
196 cross_curv=cross_curv,
197 cross_curv_var=cross_curv_var,
198 basic_curv_precision=basic_curv_precision,
199 origin_curv_precision=origin_curv_precision,
200 non_origin_curv_precision=non_origin_curv_precision,
201 max_curv_precision=max_curv_precision,
204 curv_dense=curv_dense,
205 curv_width=curv_width,
206 impact_estimate=impact,
212 save_tree = refiners.save_tree()
214 save_histograms = refiners.save_histograms(outlier_z_score=5.0, allow_discrete=
True)
217 save_profiles = refiners.save_profiles(x=[
'curvature_estimate',
'phi0'],
218 y=
'curvature_variance',
222 save_cross_curv_profile = refiners.save_profiles(x=[
'cross_curv'],
224 'curvature_estimate',
225 'basic_curv_precision',
226 'origin_curv_precision',
227 'non_origin_curv_precision',
228 'max_curv_precision',
233 save_scatter = refiners.save_scatters(x=[
'curvature_estimate'], y=
'n_hits')
238 run.configure_and_execute_from_commandline()
241 if __name__ ==
"__main__":
242 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)
output_file_name
Disable the writing of an output ROOT file.
output_file_name
There is no default for the name of the output TFile.
int main(int argc, char **argv)
Run all tests.