FairShip
Loading...
Searching...
No Matches
timeDetector.py
Go to the documentation of this file.
1# SPDX-License-Identifier: LGPL-3.0-or-later
2# SPDX-FileCopyrightText: Copyright CERN for the benefit of the SHiP Collaboration
3
4import ROOT
5from BaseDetector import BaseDetector
6
7
9 def __init__(self, name, intree, outtree=None) -> None:
10 super().__init__(name, intree, outtree=outtree)
11
12 def digitize(self) -> None:
13 """Digitize timing detector MC hits.
14
15 One hit is created per TimeDetPoint, at the same index. Per bar, the hit
16 from the point with the earliest true (unsmeared) time is marked valid,
17 all others invalid.
18
19 The selection uses the MC time rather than the smeared TDC values:
20 points in the same bar (e.g. a muon and its delta electrons) belong to
21 the same light pulse, so comparing independently smeared TDCs would pick
22 a random point and often invalidate the primary's hit.
23 """
24 earliest_per_det_id = {}
25 points = self.intree.TimeDetPoint
26 for index, point in enumerate(points):
27 self.det.push_back(ROOT.TimeDetHit(point, self.intree.t0))
28 detector_id = point.GetDetectorID()
29 earliest = earliest_per_det_id.get(detector_id)
30 if earliest is None:
31 earliest_per_det_id[detector_id] = index
32 elif point.GetTime() < points[earliest].GetTime():
33 self.det[earliest].setInvalid()
34 earliest_per_det_id[detector_id] = index
35 else:
36 self.det[index].setInvalid()
None __init__(self, name, intree, outtree=None)