CbmRoot
Loading...
Searching...
No Matches
CbmTrdDigi.h
Go to the documentation of this file.
1/* Copyright (C) 2009-2020 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Florian Uhlig [committer] */
4
5#ifndef CBMTRDDIGI_H
6#define CBMTRDDIGI_H
7
8#include "CbmDefs.h" // for kTrd
9
10#ifndef NO_ROOT
11#include <Rtypes.h> // for CLRBIT, SETBIT, TESTBIT, ClassDef
12#endif
13
14#include <boost/serialization/access.hpp>
15
16#include <cstdint>
17#include <string> // for string
18#include <utility> // for pair
19
21public:
22 enum class eCbmTrdAsicType : size_t
23 {
24 kSPADIC = 0,
25 kFASP,
27 };
28 enum class eTriggerType : int32_t
29 {
33 kMulti,
34 kTrg2,
35 kNTrg
36 };
38 {
39 kFlag1 = 0 //<
40 ,
41 kFlag2 //< in case of FASP simulations define pileup
42 ,
43 kFlag3 //< in case of FASP simulations define masked
44 ,
46 };
50 CbmTrdDigi();
58 CbmTrdDigi(int32_t padChNr, float chargeT, float chargeR, uint64_t time);
68 CbmTrdDigi(int32_t padChNr, int32_t uniqueModuleId, float charge, uint64_t time, eTriggerType triggerType,
69 int32_t errClass /*nrSamples*/);
70
75 CbmTrdDigi(int32_t /*address*/, double /*fullTime*/, int32_t /*triggerType*/, int32_t /*infoType*/,
76 int32_t /*stopType*/, int32_t /*nrSamples*/, float* /*samples*/)
77 : fInfo(0)
78 , fCharge(0)
79 , fTime(0)
80 {
81 ;
82 }
83
88 CbmTrdDigi(const CbmTrdDigi&);
89
95 CbmTrdDigi& operator=(const CbmTrdDigi&) = default;
96
97
102 void AddCharge(CbmTrdDigi* sd, double f);
107 void AddCharge(double c, double f = 1);
109 static float Clk(eCbmTrdAsicType ty) { return fgClk[static_cast<size_t>(ty)]; }
112 int32_t GetAddress() const { return (fInfo >> fgkRoOffset) & 0x7fffff; }
116 int32_t GetAddressChannel() const;
120 int32_t GetAddressModule() const;
123 double GetCharge() const;
129 double GetCharge(double& tilt, int32_t& dt) const;
131 double GetChargeError() const;
133 int32_t GetErrorClass() const { return (fInfo >> fgkErrOffset) & 0x7; }
134
139
140
144 static const char* GetClassName() { return "CbmTrdDigi"; }
145
149 static const char* GetBranchName() { return "TrdDigi"; }
150
151
153 double GetTime() const
154 {
155 return (GetType() == eCbmTrdAsicType::kFASP) ? fTime * fgClk[static_cast<size_t>(GetType())] : fTime;
156 }
158 uint64_t GetTimeDAQ() const
159 {
160 return (GetType() == eCbmTrdAsicType::kFASP) ? fTime : fTime / fgClk[static_cast<size_t>(GetType())];
161 }
163 int32_t GetTriggerType() const { return (fInfo >> fgkTrgOffset) & 0x3; }
164
170 static std::pair<eTriggerType, bool> GetTriggerPair(const int32_t triggerValue);
171
177
179 bool IsFASP() const { return GetType() == eCbmTrdAsicType::kFASP; }
180
182 bool IsMasked() const { return (GetType() == eCbmTrdAsicType::kFASP) && IsFlagged(kFlag3); }
184 bool IsPileUp() const { return (GetType() == eCbmTrdAsicType::kFASP) && IsFlagged(kFlag2); }
186 bool IsFlagged(const int32_t iflag) const;
187 int32_t Layer() const { return (fInfo >> fgkLyOffset) & 0xf; }
188 int32_t Module() const { return (fInfo >> fgkModOffset) & 0x7f; }
189
193 void SetAddress(const int32_t a);
195 void SetAddressModule(const int32_t a) { SetAddress(a); }
196
201 void SetCharge(float c);
207 void SetCharge(float cT, float cR, int32_t dt = 0);
209 void SetFlag(const int32_t iflag, bool set = true);
211 void SetMasked(bool set = true)
212 {
214 }
216 void SetPileUp(bool set = true)
217 {
219 }
221 void SetTime(double t);
223 void SetTimeDAQ(uint64_t t) { fTime = t; }
225 void SetTimeOffset(int8_t t);
227 void SetTriggerType(const eTriggerType triggerType);
229 void SetTriggerType(const int32_t triggerValue);
231 void SetErrorClass(const int32_t n)
232 {
233 fInfo &= ~(0x7 << fgkErrOffset);
234 fInfo |= ((n & 0x7) << fgkErrOffset);
235 }
237 std::string ToString() const;
238
239 // TEMPORARY ADDED WITHOUT PROVIDING FUNCTIONALITY ! TODO should be removed
240 // keep backward compatible compilation of CbmTrdSPADIC
241 void SetStopType(int32_t /*stopType*/) { ; }
242 int32_t GetStopType() { return 0; }
243 void SetPulseShape(float /*pulse*/[45]) { ; }
244 // keep backward compatible compilation of fles/reader/tasks [/tools]
245 double GetChargeTR() const { return 0.; }
246 void SetInfoType(int32_t /*infoType*/) { ; }
247 int32_t GetNrSamples() { return 0; }
248 float* GetSamples() { return nullptr; }
249
250protected:
251 void SetChannel(const int32_t a)
252 {
253 fInfo &= ~(0xfff << fgkRoOffset);
254 fInfo |= (a & 0xfff) << fgkRoOffset;
255 }
256 void SetLayer(const int32_t a)
257 {
258 fInfo &= ~(0xf << fgkLyOffset);
259 fInfo |= ((a & 0xf) << fgkLyOffset);
260 }
261 void SetModule(const int32_t a)
262 {
263 fInfo &= ~(0x7f << fgkModOffset);
264 fInfo |= ((a & 0x7f) << fgkModOffset);
265 }
266
267 uint32_t fInfo = 0; //< pad address and extra information
268 uint32_t fCharge = 0; //< measured charge. For SPADIC is int32_t(charge*1eN) where N is the precission while
269 //< for FASP it contains the R and T charges each on 12bits and the time difference between R and T pads in CLK (8 bits).
270 uint64_t fTime = 0; //< global time of the digi: For SPADIC in ns, for FASP in ASIC clock
271
276 static const double fgClk[static_cast<size_t>(eCbmTrdAsicType::kNTypes) + 1];
277
282 static const float fgPrecission[static_cast<size_t>(eCbmTrdAsicType::kNTypes) + 1];
283
284
285private:
286 static const int32_t fgkRoOffset = 0;
287 static const int32_t fgkModOffset = 12;
288 static const int32_t fgkLyOffset = 19;
289 static const int32_t fgkErrOffset = 23;
290 static const int32_t fgkFlgOffset = 26;
291 static const int32_t fgkTrgOffset = 29;
292 static const int32_t fgkTypOffset = 31;
293
296 template<class Archive>
297 void serialize(Archive& ar, const unsigned int /*version*/)
298 {
299 ar& fInfo;
300 ar& fCharge;
301 ar& fTime;
302 }
303
304#ifndef NO_ROOT
305 ClassDefNV(CbmTrdDigi, 4); // Production ready TRD digit
306#endif
307};
308
309#endif
ECbmModuleId
Definition CbmDefs.h:39
@ kTrd
Transition Radiation Detector.
int32_t GetAddressModule() const
Getter module address in the experiment.
static const int32_t fgkTypOffset
Definition CbmTrdDigi.h:292
void SetAsic(eCbmTrdAsicType ty=eCbmTrdAsicType::kSPADIC)
double GetChargeTR() const
Definition CbmTrdDigi.h:245
CbmTrdDigi()
Default constructor.
static const char * GetClassName()
Class name (static)
Definition CbmTrdDigi.h:144
void serialize(Archive &ar, const unsigned int)
Definition CbmTrdDigi.h:297
void SetTriggerType(const eTriggerType triggerType)
Set digi trigger type.
void SetAddress(const int32_t a)
Module address setter for digi.
int32_t GetAddress() const
Address getter for module in the format defined by CbmTrdDigi (format of CbmTrdAddress can be accesse...
Definition CbmTrdDigi.h:112
void SetStopType(int32_t)
Definition CbmTrdDigi.h:241
static std::pair< eTriggerType, bool > GetTriggerPair(const int32_t triggerValue)
Get the trigger combination, i.e. St or Nt and is multihit or not (true/false)
void SetPileUp(bool set=true)
Set digi pile-up (FASP only)
Definition CbmTrdDigi.h:216
int32_t GetTriggerType() const
Channel trigger type. SPADIC specific see CbmTrdTriggerType.
Definition CbmTrdDigi.h:163
bool IsFASP() const
Shortcut to check if FASP digi.
Definition CbmTrdDigi.h:179
static const int32_t fgkTrgOffset
Definition CbmTrdDigi.h:291
static const double fgClk[static_cast< size_t >(eCbmTrdAsicType::kNTypes)+1]
clock length in ns for acquisition
Definition CbmTrdDigi.h:41
static const int32_t fgkRoOffset
Definition CbmTrdDigi.h:286
void SetFlag(const int32_t iflag, bool set=true)
Generic flag status setter.
int32_t Module() const
Definition CbmTrdDigi.h:188
double GetChargeError() const
Charge error parametrisation. SPADIC specific see GetErrorClass()
void SetModule(const int32_t a)
Definition CbmTrdDigi.h:261
bool IsPileUp() const
Query digi pile-up (FASP only)
Definition CbmTrdDigi.h:184
std::string ToString() const
String representation of a TRD digi. Account for digi type and specific information.
int32_t Layer() const
Definition CbmTrdDigi.h:187
void SetChannel(const int32_t a)
Definition CbmTrdDigi.h:251
uint64_t GetTimeDAQ() const
Getter for global DAQ time [clk]. Differs for each ASIC. In FASP case DAQ time is already stored in f...
Definition CbmTrdDigi.h:158
int32_t GetAddressChannel() const
Getter read-out id.
uint32_t fInfo
Definition CbmTrdDigi.h:267
ClassDefNV(CbmTrdDigi, 4)
bool IsFlagged(const int32_t iflag) const
Query flag status (generic)
bool IsMasked() const
Query digi mask (FASP only)
Definition CbmTrdDigi.h:182
static const int32_t fgkLyOffset
Definition CbmTrdDigi.h:288
void SetPulseShape(float[45])
Definition CbmTrdDigi.h:243
static float Clk(eCbmTrdAsicType ty)
DAQ clock accessor for each ASIC.
Definition CbmTrdDigi.h:109
static const int32_t fgkFlgOffset
Definition CbmTrdDigi.h:290
void SetErrorClass(const int32_t n)
Set digi error class (SPADIC only)
Definition CbmTrdDigi.h:231
eCbmTrdAsicType GetType() const
Channel FEE SPADIC/FASP according to CbmTrdAsicType.
Definition CbmTrdDigi.h:173
static const char * GetBranchName()
Get the desired name of the branch for this obj in the cbm output tree (static)
Definition CbmTrdDigi.h:149
void SetInfoType(int32_t)
Definition CbmTrdDigi.h:246
friend class boost::serialization::access
BOOST serialization interface.
Definition CbmTrdDigi.h:295
CbmTrdDigi & operator=(const CbmTrdDigi &)=default
Assignment operator.
void AddCharge(CbmTrdDigi *sd, double f)
Charge addition in case of pile-up (FASP simulation only)
CbmTrdDigi(int32_t, double, int32_t, int32_t, int32_t, int32_t, float *)
Constructor for backward compatibillity. Does not do anything.
Definition CbmTrdDigi.h:75
static ECbmModuleId GetSystem()
Definition CbmTrdDigi.h:138
int32_t GetStopType()
Definition CbmTrdDigi.h:242
void SetAddressModule(const int32_t a)
Alias for SetAddress()
Definition CbmTrdDigi.h:195
int32_t GetErrorClass() const
Channel status. SPADIC specific see LUT.
Definition CbmTrdDigi.h:133
void SetTimeDAQ(uint64_t t)
Set global digi time (clk)
Definition CbmTrdDigi.h:223
uint32_t fCharge
Definition CbmTrdDigi.h:268
static const int32_t fgkErrOffset
Definition CbmTrdDigi.h:289
static const int32_t fgkModOffset
Definition CbmTrdDigi.h:287
void SetTimeOffset(int8_t t)
Set time offset of rectangular to tilt pads for FASP (clk)
int32_t GetNrSamples()
Definition CbmTrdDigi.h:247
double GetTime() const
Getter for physical time [ns]. Accounts for clock representation of each ASIC. In SPADIC case physica...
Definition CbmTrdDigi.h:153
uint64_t fTime
Definition CbmTrdDigi.h:270
void SetMasked(bool set=true)
Set digi mask (FASP only)
Definition CbmTrdDigi.h:211
double GetCharge() const
Common purpose charge getter.
void SetCharge(float c)
Charge setter for SPADIC ASIC.
void SetTime(double t)
Set global digi time (ns)
float * GetSamples()
Definition CbmTrdDigi.h:248
static const float fgPrecission[static_cast< size_t >(eCbmTrdAsicType::kNTypes)+1]
Nr. of digits stored for ASIC.
Definition CbmTrdDigi.h:42
void SetLayer(const int32_t a)
Definition CbmTrdDigi.h:256