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