GRSISort "v4.1.1.0"
An extension of the ROOT analysis Framework
Loading...
Searching...
No Matches
TGRSIMnemonic.cxx
Go to the documentation of this file.
1#include "TGRSIMnemonic.h"
2
3#include <algorithm>
4
5// Detector dependent includes
6#include "TGriffin.h"
7#include "TSceptar.h"
8#include "TTigress.h"
9#include "TTigressBgo.h"
10#include "TTip.h"
11#include "TTAC.h"
12#include "TLaBr.h"
13#include "TSharc.h"
14#include "TCSM.h"
15#include "TTriFoil.h"
16#include "TRF.h"
17#include "TS3.h"
18#include "TPaces.h"
19#include "TDescant.h"
20#include "TZeroDegree.h"
21#include "TSiLi.h"
22#include "TGenericDetector.h"
23#include "TBgo.h"
24#include "TGriffinBgo.h"
25#include "TLaBrBgo.h"
26#include "TEmma.h"
27#include "TTrific.h"
28#include "TSharc2.h"
29#include "TRcmp.h"
30#include "TAries.h"
31#include "TDemand.h"
32
38
40{
41 // Enumerating the fSystemString must come after the total mnemonic has been parsed as the details of other parts of
42 // the mnemonic must be known
43 if(SystemString() == "TI") {
44 if(SubSystem() == EMnemonic::kS) {
46 } else {
48 }
49 } else if(SystemString() == "SH") {
51 } else if(SystemString() == "TR") {
53 } else if(SystemString() == "RF") {
55 } else if(SystemString() == "SP") {
56 if(SubSystem() == EMnemonic::kI) {
58 } else {
60 }
61 } else if(SystemString() == "GD") {
63 } else if(SystemString() == "CS") {
65 } else if(SystemString() == "GR") {
66 if(SubSystem() == EMnemonic::kS) {
68 } else {
70 }
71 } else if(SystemString() == "SE") {
73 } else if(SystemString() == "PA") {
75 } else if(SystemString() == "DS") {
77 } else if((SystemString() == "DA") || (SystemString() == "LB")) {
78 if(SubSystem() == EMnemonic::kS) {
80 } else if(SubSystem() == EMnemonic::kT) {
82 } else {
84 }
85 } else if(SystemString() == "BA") {
87 } else if(SystemString() == "ZD") {
89 } else if(SystemString() == "TP") {
91 } else if(SystemString() == "BG") {
93 } else if((SystemString() == "EM") || (SystemString() == "ET")) {
94 if(SubSystem() == EMnemonic::kE) {
96 } else {
98 }
99 } else if(SystemString() == "TF") {
101 } else if(SystemString() == "SZ") {
103 } else if(SystemString() == "RC") {
105 } else if(SystemString() == "AR") {
107 } else if(SystemString() == "DM") {
109 } else {
111 }
112}
113
115{
116 std::string name = digitizerName.Value();
117 std::transform(name.begin(), name.end(), name.begin(), ::toupper);
119 int tmpUnit = 1;
120 if(name == "GRF16") {
121 tmpType = EDigitizer::kGRF16;
122 tmpUnit = 10;
123 } else if(name == "GRF4G") {
124 tmpType = EDigitizer::kGRF4G;
125 tmpUnit = 10;
126 } else if(name == "TIG10") {
127 tmpType = EDigitizer::kTIG10;
128 tmpUnit = 10;
129 } else if(name == "TIG64") {
130 tmpType = EDigitizer::kTIG64;
131 tmpUnit = 10;
132 } else if(name == "CAEN") {
133 tmpType = EDigitizer::kCaen;
134 tmpUnit = 2;
135 } else if(name == "MADC") {
136 tmpType = EDigitizer::kMadc;
137 tmpUnit = 50;
138 } else if(name == "V1190") {
139 tmpType = EDigitizer::kV1190;
140 tmpUnit = 50;
141 } else if(name == "FMC32") {
142 tmpType = EDigitizer::kFMC32;
143 tmpUnit = 10;
144 } else {
145 std::cout << "Warning, digitizer type '" << name << "' not recognized, options are 'GRF16', 'FMC32', 'GRF4G', 'TIG10', 'TIG64', 'CAEN', 'MADC!' && 'V1190'!" << std::endl;
146 }
147 digitizerType.Set(tmpType, digitizerName.Priority());
148 timeStampUnit.Set(tmpUnit, digitizerName.Priority());
149}
150
151void TGRSIMnemonic::Parse(std::string* name)
152{
153 if((name == nullptr) || name->length() < 9) {
154 if((name->length() < 1) && (name->compare(0, 2, "RF") == 0)) {
155 SetRFMnemonic(name);
156 }
157 return;
158 }
159 TMnemonic::Parse(name);
160 // Enumerating the fSystemString must come last as the details of other parts of
161 // the mnemonic must be known
163
164 if(fSystem == ESystem::kSiLi) {
165 std::string buf;
166 buf.assign(*name, 7, 2);
167 Segment(static_cast<int16_t>(strtol(buf.c_str(), nullptr, 16)));
168 }
169}
170
171void TGRSIMnemonic::Print(Option_t*) const
172{
173 std::ostringstream str;
174 str << "======== GRSIMNEMONIC ========" << std::endl;
175 TMnemonic::Print(str);
176 str << "==============================" << std::endl;
177 std::cout << str.str();
178}
179
181{
182 if(TMnemonic::GetClassType() != nullptr) {
184 }
185
186 switch(System()) {
187 case ESystem::kTigress: SetClassType(TTigress::Class()); break;
188 case ESystem::kTigressBgo: SetClassType(TTigressBgo::Class()); break;
189 case ESystem::kSharc: SetClassType(TSharc::Class()); break;
190 case ESystem::kTriFoil: SetClassType(TTriFoil::Class()); break;
191 case ESystem::kRF: SetClassType(TRF::Class()); break;
192 case ESystem::kSiLi: SetClassType(TSiLi::Class()); break;
193 case ESystem::kS3: SetClassType(TS3::Class()); break;
194 case ESystem::kSiLiS3: SetClassType(TS3::Class()); break;
195 case ESystem::kCSM: SetClassType(TCSM::Class()); break;
196 case ESystem::kGriffin: SetClassType(TGriffin::Class()); break;
197 case ESystem::kSceptar: SetClassType(TSceptar::Class()); break;
198 case ESystem::kPaces: SetClassType(TPaces::Class()); break;
199 case ESystem::kDescant: SetClassType(TDescant::Class()); break;
200 case ESystem::kLaBr: SetClassType(TLaBr::Class()); break;
201 case ESystem::kTAC: SetClassType(TTAC::Class()); break;
202 case ESystem::kZeroDegree: SetClassType(TZeroDegree::Class()); break;
203 case ESystem::kTip: SetClassType(TTip::Class()); break;
204 case ESystem::kGriffinBgo: SetClassType(TGriffinBgo::Class()); break;
205 case ESystem::kLaBrBgo: SetClassType(TLaBrBgo::Class()); break;
206 case ESystem::kGeneric: SetClassType(TGenericDetector::Class()); break;
207 case ESystem::kEmma: SetClassType(TEmma::Class()); break;
208 case ESystem::kEmmaS3: SetClassType(TS3::Class()); break;
209 case ESystem::kTrific: SetClassType(TTrific::Class()); break;
210 case ESystem::kSharc2: SetClassType(TSharc2::Class()); break;
211 case ESystem::kRcmp: SetClassType(TRcmp::Class()); break;
212 case ESystem::kAries: SetClassType(TAries::Class()); break;
213 case ESystem::kDemand: SetClassType(TDemand::Class()); break;
214 default: SetClassType(nullptr);
215 };
217}
218
219double TGRSIMnemonic::GetTime(Long64_t timestamp, Float_t cfd, double energy, const TChannel* channel) const
220{
221 if(channel == nullptr) {
222 Error("GetTime", "No TChannel provided");
223 return static_cast<double>(timestamp) + gRandom->Uniform();
224 }
225
226 Double_t dTime = 0.;
227 switch(static_cast<EDigitizer>(channel->GetDigitizerType())) {
230 // we need to zero the lowest 18 bits of the timestamp as those are included in the CFD value
231 // TODO: what happens close to the wrap-around of those 18 bits??? This only happens every 2^18 * 10e-8 so 2.5 ms so 400 Hz
232 dTime = static_cast<Double_t>((timestamp & (~0x3ffff)) * channel->GetTimeStampUnit()) + channel->CalibrateCFD((cfd + gRandom->Uniform()) / 1.6); // CFD is in 10/16th of a nanosecond
233 return dTime - channel->GetTZero(energy) - static_cast<double>(channel->GetTimeOffset());
235 dTime = static_cast<Double_t>(timestamp * channel->GetTimeStampUnit()) + channel->CalibrateCFD((static_cast<Int_t>(cfd) >> 22) + ((static_cast<Int_t>(cfd) & 0x3fffff) + gRandom->Uniform()) / 256.);
236 return dTime - channel->GetTZero(energy) - static_cast<double>(channel->GetTimeOffset());
238 dTime = static_cast<Double_t>((timestamp & (~0x7fffff)) * channel->GetTimeStampUnit()) + channel->CalibrateCFD((cfd + gRandom->Uniform()) / 1.6); // CFD is in 10/16th of a nanosecond
239 //channel->CalibrateCFD((cfd & (~0xf) + gRandom->Uniform()) / 1.6); // PBender suggests this.
240 return dTime - channel->GetTZero(energy) - static_cast<double>(channel->GetTimeOffset());
242 //10 bit CFD for 0-2ns => divide by 512
243 dTime = static_cast<Double_t>(timestamp * channel->GetTimeStampUnit()) + channel->CalibrateCFD((cfd + gRandom->Uniform()) / 512.);
244 return dTime - channel->GetTZero(energy) - static_cast<double>(channel->GetTimeOffset());
245 default:
246 dTime = (static_cast<Double_t>(timestamp) + gRandom->Uniform()) * channel->GetTimeStampUnit();
247 return dTime - channel->GetTZero(energy) - static_cast<double>(channel->GetTimeOffset());
248 }
249 return 0.;
250}
251
253{
254 /// This function translates the crystal color to an index
255 /// B - Blue - 0, G - Green - 1, R - Red - 2, W - White - 3, default - 5
256 /// Except for the LaBr BGOs which use A - 0, B - 1, C - 2
257 /// and a default of 5
258 if(System() == ESystem::kLaBrBgo) {
259 switch(ArraySubPosition()) {
261 return 0;
263 return 1;
265 return 2;
266 default:
267 return 5;
268 };
269 }
270
271 switch(ArraySubPosition()) {
273 return 0;
275 return 1;
277 return 2;
279 return 3;
280 default:
281 return 5;
282 };
283
284 // return statement here instead of default case
285 // to make sure compiler doesn't warn us about missing return
286 return 5;
287}
EDigitizer
Long64_t GetTimeOffset() const
Definition TChannel.h:173
EDigitizer GetDigitizerType() const
Definition TChannel.h:171
double CalibrateCFD(double) const
Definition TChannel.cxx:727
int GetTimeStampUnit() const
Definition TChannel.h:172
double GetTZero(double tempd) const
Definition TChannel.h:295
TClass * GetClassType() const override
void Print(Option_t *opt="") const override
double GetTime(Long64_t timestamp, Float_t cfd, double energy, const TChannel *channel) const override
void Parse(std::string *name) override
void EnumerateDigitizer(TPriorityValue< std::string > &digitizerName, TPriorityValue< EDigitizer > &digitizerType, TPriorityValue< int > &timeStampUnit) override
ESystem System() const
void Clear(Option_t *opt="") override
int NumericArraySubPosition() const override
virtual std::string SystemString() const
Definition TMnemonic.h:70
virtual EMnemonic ArraySubPosition() const
Definition TMnemonic.h:63
virtual EMnemonic SubSystem() const
Definition TMnemonic.h:62
void Print(Option_t *opt="") const override
virtual void Parse(std::string *name)
Definition TMnemonic.cxx:58
void Clear(Option_t *opt="") override
Definition TMnemonic.cxx:9
virtual int16_t Segment() const
Definition TMnemonic.h:68
virtual TClass * GetClassType() const
virtual void SetClassType(TClass *classType) const
Definition TMnemonic.h:93
virtual void SetRFMnemonic(std::string *name)
Definition TMnemonic.cxx:98
void Set(const T &val, EPriority priority)
EPriority Priority() const
const T & Value() const