CbmRoot
Loading...
Searching...
No Matches
detectors/trd/Hit.h
Go to the documentation of this file.
1/* Copyright (C) 2024 Facility for Antiproton and Ion Research in Europe, Darmstadt
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Dominik Smith [committer], Matus Kalisky, Florian Uhlig, Andrey Lebedev */
4
12#pragma once
13
14#include "CbmTrdAddress.h" // for CbmTrdAddress
15#include "Math/Rotation3D.h"
16#include "Math/Vector3Dfwd.h"
17
18#include <Rtypes.h> // for CLRBIT, SETBIT, TESTBIT, ClassDef
19#include <RtypesCore.h> // for Double32_t
20
21#include <boost/serialization/access.hpp>
22
23#include <cstdint>
24#include <string> // for string
25
26namespace cbm::algo::trd
27{
28
33 class Hit {
34 public:
35 enum HitDef
36 {
37 kType = 0
38 ,
40 ,
42 ,
43 kOvfl
44 };
45
46
50 Hit();
51
61 Hit(int32_t address, const ROOT::Math::XYZVector& pos, const ROOT::Math::XYZVector& dpos, double dxy, int32_t refId,
62 double eLoss, double time = 0., double timeError = 0.);
63
78 Hit(int32_t address, double x, double y, double z, double dx, double dy, double dz, double dxy, int32_t refId,
79 double time = -1., double timeError = -1.);
80
81
83 ~Hit(){};
84
85 /* Accessors */
86 int32_t GetPlaneId() const { return CbmTrdAddress::GetLayerId(Address()); }
87 double GetELoss() const { return fELoss; }
88 bool GetClassType() const { return TESTBIT(fDefine, kType); }
89 bool GetMaxType() const { return TESTBIT(fDefine, kMaxType); }
90 bool HasOverFlow() const { return TESTBIT(fDefine, kOvfl); }
91 bool IsRowCross() const { return TESTBIT(fDefine, kRowCross); }
92 bool IsUsed() const { return (GetRefId() < 0); }
93 double X() const { return fX; }
94 double Y() const { return fY; }
95 double Z() const { return fZ; }
96 double Dx() const { return fDx; }
97 double Dy() const { return fDy; }
98 double Dz() const { return fDz; }
99 double Dxy() const { return fDxy; }
100 int32_t GetRefId() const { return fRefId; }
101 int32_t Address() const { return fAddress; }
102 double Time() const { return fTime; }
103 double TimeError() const { return fTimeError; }
104
109 void Position(ROOT::Math::XYZVector& pos) const;
110
115 void PositionError(ROOT::Math::XYZVector& dpos) const;
116
117 /* Setters */
118 void SetELoss(double loss) { fELoss = loss; }
120 void SetOverFlow(bool set = true) { set ? SETBIT(fDefine, kOvfl) : CLRBIT(fDefine, kOvfl); }
122 void SetRowCross(bool set = true) { set ? SETBIT(fDefine, kRowCross) : CLRBIT(fDefine, kRowCross); }
124 void SetClassType(bool set = true) { set ? SETBIT(fDefine, kType) : CLRBIT(fDefine, kType); }
126 void SetMaxType(bool set = true) { set ? SETBIT(fDefine, kMaxType) : CLRBIT(fDefine, kMaxType); }
127 void SetX(double x) { fX = x; }
128 void SetY(double y) { fY = y; }
129 void SetZ(double z) { fZ = z; }
130 void SetDx(double dx) { fDx = dx; }
131 void SetDy(double dy) { fDy = dy; }
132 void SetDz(double dz) { fDz = dz; }
133 void SetDxy(double dxy) { fDxy = dxy; }
134 void SetRefId(int32_t refId) { fRefId = refId; }
135 void SetAddress(int32_t address) { fAddress = address; }
136 void SetTime(double time) { fTime = time; }
137 void SetTime(double time, double error)
138 {
139 fTime = time;
140 fTimeError = error;
141 }
142 void SetTimeError(double error) { fTimeError = error; }
143
148 void SetPosition(const ROOT::Math::XYZVector& pos);
149
154 void SetPositionError(const ROOT::Math::XYZVector& dpos);
155
156
157 private:
158 double fX, fY, fZ;
159 double fDx, fDy, fDz;
160 double fDxy;
161 int32_t fRefId;
162 int32_t fAddress;
163 double fTime;
164 double fTimeError;
165
166 uint8_t fDefine; // hit extra info
167 int32_t fNeighborId; // refId in case of row cross clusters
168 Double32_t fELoss; // Energy deposit due to TR + dEdx
169
170 private:
172
173 template<class Archive>
174 void serialize(Archive& ar, unsigned int /*version*/)
175 {
176 ar& fX;
177 ar& fY;
178 ar& fZ;
179 ar& fDx;
180 ar& fDy;
181 ar& fDz;
182 ar& fDxy;
183 ar& fRefId;
184 ar& fAddress;
185 ar& fTime;
186 ar& fTimeError;
187 ar& fDefine;
188 ar& fNeighborId;
189 ar& fELoss;
190 }
191 };
192
193
194} // namespace cbm::algo::trd
TVector3 dpos
Helper class to convert unique channel ID back and forth.
#define SETBIT(n, i)
Definition RTypes.h:15
#define TESTBIT(n, i)
Definition RTypes.h:17
#define CLRBIT(n, i)
Definition RTypes.h:16
static uint32_t GetLayerId(uint32_t address)
Return layer ID from address.
A light-weight TRD hit class for online reconstruction, based on CbmTrdHit. .
int32_t GetRefId() const
void PositionError(ROOT::Math::XYZVector &dpos) const
Copies hit position error to pos.
Definition Hit.cxx:45
@ kType
set type of pad layout
@ kMaxType
set type of pad on which the maximum charge is found
@ kOvfl
mark over-flow in the data
@ kRowCross
mark hit defined by 2 clusters
double fDxy
X-Y covariance of the hit [cm**2].
Hit()
Default constructor.
Definition Hit.cxx:15
void SetTime(double time)
void SetELoss(double loss)
int32_t fRefId
some reference id (usually to cluster, digi or MC point)
void SetTimeError(double error)
double fDz
X, Y, Z errors [cm].
void SetPositionError(const ROOT::Math::XYZVector &dpos)
Definition Hit.cxx:54
double GetELoss() const
void SetDxy(double dxy)
void SetRowCross(bool set=true)
Mark hit reconstructed between pad rows.
void SetTime(double time, double error)
void SetClassType(bool set=true)
Type of pad layout used in reconstruction R[0], T[1].
void SetOverFlow(bool set=true)
Mark overflow in one or more digits which define the hit.
void SetMaxType(bool set=true)
Extra bool definition for the hit (e.g. the type of maximum for triangular pads).
int32_t fAddress
detector unique identifier
void Position(ROOT::Math::XYZVector &pos) const
Copies hit position to pos.
Definition Hit.cxx:43
void SetPosition(const ROOT::Math::XYZVector &pos)
Sets position of the hit.
Definition Hit.cxx:47
void SetRefId(int32_t refId)
void serialize(Archive &ar, unsigned int)
int32_t Address() const
void SetAddress(int32_t address)
double fZ
X, Y, Z positions of hit [cm].
friend class boost::serialization::access
double fTimeError
Error of hit time [ns].
double fTime
Hit time [ns].
int32_t GetPlaneId() const