CbmRoot
Loading...
Searching...
No Matches
DigiRec.cxx
Go to the documentation of this file.
1/* Copyright (C) 2018-2020 Horia Hulubei National Institute of Physics and Nuclear Engineering, Bucharest
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Alexandru Bercuci[committer] */
4
5#include "DigiRec.h"
6
7#include <cstring>
8
9namespace cbm::algo::trd
10{
11
13 float DigiRec::fgBaseline = 0.25; //[V] AB : match HW on mCBM22
14 float DigiRec::fgOutGain = 2.025; // [V/ 4095 ADC chs]
15
16 //_____________________________________________________________________________
17 DigiRec::DigiRec() : CbmTrdDigi(), fStatus(0)
18 {
19 fG[0] = 1.;
20 fG[1] = 1.;
21 memset(fT, 0, 3 * sizeof(double));
22 }
23
24 //_____________________________________________________________________________
25 DigiRec::DigiRec(const CbmTrdDigi& d, double* G, double* T) : CbmTrdDigi(d), fStatus(0)
26 {
27 if (G) {
28 fG[0] = G[0];
29 fG[1] = G[1];
30 }
31 else {
32 fG[0] = 1.;
33 fG[1] = 1.;
34 }
35 if (T)
36 memcpy(fT, T, 3 * sizeof(double));
37 else
38 memset(fT, 0, 3 * sizeof(double));
39
40 int dt;
41 double t, r = CbmTrdDigi::GetCharge(t, dt);
42 if (t > 4094) SETBIT(fStatus, 0);
43 if (r > 4094) SETBIT(fStatus, 1);
44 }
45
46 //_____________________________________________________________________________
47 DigiRec::DigiRec(const CbmTrdDigi& d, const CbmTrdDigi& dr, double* G, double* T) : CbmTrdDigi(d), fStatus(0)
48 {
51 if (G) {
52 fG[0] = G[0];
53 fG[1] = G[1];
54 }
55 else {
56 fG[0] = 1.;
57 fG[1] = 1.;
58 }
59 if (T)
60 memcpy(fT, T, 3 * sizeof(double));
61 else
62 memset(fT, 0, 3 * sizeof(double));
63
64 int dt;
65 double t, r = dr.GetCharge(t, dt);
66 if (r > 4094) SETBIT(fStatus, 1);
68 if (t > 4094) SETBIT(fStatus, 0);
69 dt = dr.GetTimeDAQ() - GetTimeDAQ();
70 SetCharge(t, r, dt);
71 int rtrg(dr.GetTriggerType() & 2), ttrg(GetTriggerType() & 1);
72 SetTriggerType(rtrg | ttrg); //merge the triggers
73 }
74
75 //_____________________________________________________________________________
76 double DigiRec::GetCharge(int typ, bool& on) const
77 {
78 int dT;
79 double T, R = CbmTrdDigi::GetCharge(T, dT);
80 on = true;
81 if (typ) { // rectangular pairing
82 if (R > 0) {
83 R -= GetBaselineCorr();
84 return fG[1] * R;
85 }
86 else
87 on = false;
88 }
89 else { // tilt pairing
90 if (T > 0) {
91 T -= GetBaselineCorr();
92 return fG[0] * T;
93 }
94 else
95 on = false;
96 }
97 return 0.;
98 }
99
100 //_____________________________________________________________________________
101 double DigiRec::GetTime(int typ) const
102 {
103 int dT;
104 double T, R = CbmTrdDigi::GetCharge(T, dT);
105 if (typ) { // rectangular pairing
106 double R0 = R - fT[2];
107 return GetTimeDAQ() + dT + fT[0] * R0 * R0 + fT[1] * R0;
108 }
109 else { // tilt pairing
110 double T0 = T - fT[2];
111 return GetTimeDAQ() + fT[0] * T0 * T0 + fT[1] * T0;
112 }
113 }
114
115 //_____________________________________________________________________________
116 void DigiRec::Init(double g[2], double t[3])
117 {
118 fG[0] = g[0];
119 fG[1] = g[1];
120 memcpy(fT, t, 3 * sizeof(double));
121 }
122
123} // namespace cbm::algo::trd
#define SETBIT(n, i)
Definition RTypes.h:15
void SetTriggerType(const eTriggerType triggerType)
Set digi trigger type.
int32_t GetTriggerType() const
Channel trigger type. SPADIC specific see CbmTrdTriggerType.
Definition CbmTrdDigi.h:163
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
double GetTime() const
Getter for physical time [ns]. Accounts for clock representation of each ASIC. In SPADIC case physica...
Definition CbmTrdDigi.h:153
double GetCharge() const
Common purpose charge getter.
void SetCharge(float c)
Charge setter for SPADIC ASIC.
static float fgOutGain
FASP -> ADC gain [V/4095 ADC].
Definition DigiRec.h:71
static float fgBaseline
FASP baseline [V].
Definition DigiRec.h:70
DigiRec()
Default constructor.
Definition DigiRec.cxx:17
static float GetBaselineCorr()
Definition DigiRec.h:63
unsigned char fStatus
Definition DigiRec.h:66
void Init(double g[2], double t[3])
Init FEE gain and time walk corrections.
Definition DigiRec.cxx:116