11 def __init__(self, name, intree, branchName=None, outtree=None) -> None:
12 super().
__init__(name, intree, branchName, outtree=outtree)
15 if intree.GetBranch(
"MTCDetPoint"):
16 lsOfGlobals = ROOT.gROOT.GetListOfGlobals()
17 if not lsOfGlobals.FindObject(
"MTC"):
18 lsOfGlobals.Add(global_variables.modules[
"MTC"])
20 mapping.make_mapping()
24 """Digitize SND/MTC MC hits.
26 Example of fiberID: 123051820, where:
29 - 0: station type (0 for +5 degrees, 1 for -5 degrees, 2 for scint plane)
30 - 5: z-layer number (0-5)
31 - 1820: local fibre ID within the station
32 Example of SiPM global channel (what is seen in the output file): 123001123, where:
35 - 0: station type (0 for +5 degrees, 1 for -5 degrees)
36 - 0: mat number (only 0 by June 2025). In future, if multiple mats per station are used,
37 this number will be 0-N. Currently, this digit is allocated by SiPM channel ID!
38 - 1: SiPM number (automatically assigned based on fibre aggregation settings)
39 - 123: number of the SiPM channel (0-N). The channel number depends on the fibre aggregation setting.
44 for k, mc_point
in enumerate(self.
intree.MTCDetPoint):
45 det_id = mc_point.GetDetectorID()
47 station_type = mc_point.GetLayerType()
48 energy_loss = mc_point.GetEnergyLoss()
53 elif station_type == 1:
56 elif station_type == 2:
59 global_channel = det_id
60 if global_channel
not in hit_container:
61 hit_container[global_channel] = []
62 mc_points[global_channel] = {}
63 norm[global_channel] = 0
66 hit_container[global_channel].append([mc_point, weight])
67 d_e = energy_loss * weight
68 mc_points[global_channel][k] = d_e
69 norm[global_channel] += d_e
75 loc_fibre_id = det_id % 1_000_000
76 if loc_fibre_id
not in fibre_map:
79 f
"MTC digitization: no mapping found for fibre ID {loc_fibre_id} in station type {station_type}. Skipping."
83 for sipm_chan, chan_info
in fibre_map[loc_fibre_id].items():
84 global_channel = (det_id // 1_000_000) * 1_000_000 + sipm_chan
85 if global_channel
not in hit_container:
86 hit_container[global_channel] = []
87 mc_points[global_channel] = {}
88 norm[global_channel] = 0
90 weight = chan_info[
"weight"]
91 hit_container[global_channel].append([mc_point, weight])
92 d_e = energy_loss * weight
93 mc_points[global_channel][k] = d_e
94 norm[global_channel] += d_e
96 for det_id
in hit_container:
97 all_points = ROOT.std.vector(
"MTCDetPoint*")()
98 all_weights = ROOT.std.vector(
"Float_t")()
100 for entry
in hit_container[det_id]:
101 all_points.push_back(entry[0])
102 all_weights.push_back(entry[1])
103 det_hit = ROOT.MTCDetHit(det_id, all_points, all_weights)
104 self.
det.push_back(det_hit)