FairShip
Loading...
Searching...
No Matches
strawtubesDetector.strawtubesDetector Class Reference
Inheritance diagram for strawtubesDetector.strawtubesDetector:
Collaboration diagram for strawtubesDetector.strawtubesDetector:

Public Member Functions

None __init__ (self, name, intree, outtree=None)
 
None digitize (self)
 
list[dict[str, int]] withT0Estimate (self)
 
list[dict[str, int]] smearHits (self, no_amb=None)
 
- Public Member Functions inherited from BaseDetector.BaseDetector
None __init__ (self, name, intree, branchName=None, mcBranchType=None, mcBranchName=None, int splitLevel=99, outtree=None)
 
None delete (self)
 
None fill (self)
 
None digitize (self)
 
None process (self)
 

Additional Inherited Members

- Public Attributes inherited from BaseDetector.BaseDetector
 name
 
 intree
 
 outtree
 
 det
 
 MCdet
 
 mcBranch
 
 branch
 

Detailed Description

Definition at line 7 of file strawtubesDetector.py.

Constructor & Destructor Documentation

◆ __init__()

None strawtubesDetector.strawtubesDetector.__init__ (   self,
  name,
  intree,
  branchName = None 
)
Initialize the detector digitizer.

Reimplemented from BaseDetector.BaseDetector.

Definition at line 8 of file strawtubesDetector.py.

8 def __init__(self, name, intree, outtree=None) -> None:
9 super().__init__(name, intree, outtree=outtree)
10

Member Function Documentation

◆ digitize()

None strawtubesDetector.strawtubesDetector.digitize (   self)
Digitize strawtube MC hits.

The earliest hit per straw will be marked valid, all later ones invalid.

Reimplemented from BaseDetector.BaseDetector.

Definition at line 11 of file strawtubesDetector.py.

11 def digitize(self) -> None:
12 """Digitize strawtube MC hits.
13
14 The earliest hit per straw will be marked valid, all later ones invalid.
15 """
16 earliest_per_det_id = {}
17 for index, point in enumerate(self.intree.strawtubesPoint):
18 hit = ROOT.strawtubesHit(point, self.intree.t0)
19 self.det.push_back(hit)
20 if hit.isValid():
21 detector_id = hit.GetDetectorID()
22 if detector_id in earliest_per_det_id:
23 earliest = earliest_per_det_id[detector_id]
24 if self.det[earliest].GetTDC() > hit.GetTDC():
25 # second hit with smaller tdc
26 self.det[earliest].setInvalid()
27 earliest_per_det_id[detector_id] = index
28 else:
29 self.det[index].setInvalid()
30 else:
31 earliest_per_det_id[detector_id] = index
32

◆ smearHits()

list[dict[str, int]] strawtubesDetector.strawtubesDetector.smearHits (   self,
  no_amb = None 
)

Definition at line 72 of file strawtubesDetector.py.

72 def smearHits(self, no_amb=None) -> list[dict[str, int]]:
73 # smear strawtube points
74 SmearedHits = []
75 key = -1
76 stop = ROOT.TVector3()
77 start = ROOT.TVector3()
78 v_drift = global_variables.modules["strawtubes"].StrawVdrift()
79 global_variables.modules["strawtubes"].StrawEndPoints(1002001, start, stop)
80 for aDigi in self.det:
81 key += 1
82 if not aDigi.isValid():
83 continue
84 detID = aDigi.GetDetectorID()
85 global_variables.modules["strawtubes"].StrawEndPoints(detID, start, stop)
86 p = self.intree.strawtubesPoint[key]
87 # use true t0 construction:
88 # fdigi = t0 + p->GetTime() + t_drift + ( stop[0]-p->GetX() )/ speedOfLight;
89 smear = (aDigi.GetDigi() - self.intree.t0 - p.GetTime() - (stop[0] - p.GetX()) / u.speedOfLight) * v_drift
90 if no_amb:
91 smear = p.dist2Wire()
92 SmearedHits.append(
93 {
94 "digiHit": key,
95 "xtop": stop.x(),
96 "ytop": stop.y(),
97 "z": stop.z(),
98 "xbot": start.x(),
99 "ybot": start.y(),
100 "dist": smear,
101 "detID": detID,
102 }
103 )
104 # Note: top.z()==bot.z() unless misaligned, so only add key 'z' to smearedHit
105 if abs(stop.y()) == abs(start.y()):
106 global_variables.h["disty"].Fill(smear)
107 elif abs(stop.y()) > abs(start.y()):
108 global_variables.h["distu"].Fill(smear)
109 elif abs(stop.y()) < abs(start.y()):
110 global_variables.h["distv"].Fill(smear)
111
112 return SmearedHits

◆ withT0Estimate()

list[dict[str, int]] strawtubesDetector.strawtubesDetector.withT0Estimate (   self)

Definition at line 33 of file strawtubesDetector.py.

33 def withT0Estimate(self) -> list[dict[str, int]]:
34 # loop over all straw tdcs and make average, correct for ToF
35 n = 0
36 t0 = 0.0
37 key = -1
38 stop = ROOT.TVector3()
39 start = ROOT.TVector3()
40 SmearedHits = []
41 v_drift = global_variables.modules["strawtubes"].StrawVdrift()
42 global_variables.modules["strawtubes"].StrawEndPoints(1002001, start, stop)
43 z1 = stop.z()
44 for aDigi in self.det:
45 key += 1
46 if not aDigi.isValid():
47 continue
48 detID = aDigi.GetDetectorID()
49 global_variables.modules["strawtubes"].StrawEndPoints(detID, start, stop)
50 delt1 = (start[2] - z1) / u.speedOfLight
51 t0 += aDigi.GetDigi() - delt1
52 SmearedHits.append(
53 {
54 "digiHit": key,
55 "xtop": stop.x(),
56 "ytop": stop.y(),
57 "z": stop.z(),
58 "xbot": start.x(),
59 "ybot": start.y(),
60 "dist": aDigi.GetDigi(),
61 "detID": detID,
62 }
63 )
64 n += 1
65 if n > 0:
66 t0 = t0 / n - 73.2 * u.ns
67 for s in SmearedHits:
68 delt1 = (s["z"] - z1) / u.speedOfLight
69 s["dist"] = (s["dist"] - delt1 - t0) * v_drift
70 return SmearedHits
71

The documentation for this class was generated from the following file: