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
36
38{
39 // Enumerating the fSystemString must come after the total mnemonic has been parsed as the details of other parts of
40 // the mnemonic must be known
41 if(SystemString() == "TI") {
43 } else if(SystemString() == "SH") {
45 } else if(SystemString() == "TR") {
47 } else if(SystemString() == "RF") {
49 } else if(SystemString() == "SP") {
50 if(SubSystem() == EMnemonic::kI) {
52 } else {
54 }
55 } else if(SystemString() == "GD") {
57 } else if(SystemString() == "CS") {
59 } else if(SystemString() == "GR") {
60 if(SubSystem() == EMnemonic::kS) {
62 } else {
64 }
65 } else if(SystemString() == "SE") {
67 } else if(SystemString() == "PA") {
69 } else if(SystemString() == "DS") {
71 } else if((SystemString() == "DA") || (SystemString() == "LB")) {
72 if(SubSystem() == EMnemonic::kS) {
74 } else if(SubSystem() == EMnemonic::kT) {
76 } else {
78 }
79 } else if(SystemString() == "BA") {
81 } else if(SystemString() == "ZD") {
83 } else if(SystemString() == "TP") {
85 } else if(SystemString() == "BG") {
87 } else if((SystemString() == "EM") || (SystemString() == "ET")) {
88 if(SubSystem() == EMnemonic::kE) {
90 } else {
92 }
93 } else if(SystemString() == "TF") {
95 } else if(SystemString() == "SZ") {
97 } else if(SystemString() == "RC") {
99 } else if(SystemString() == "AR") {
101 } else {
103 }
104}
105
107{
108 std::string name = digitizerName.Value();
109 std::transform(name.begin(), name.end(), name.begin(), ::toupper);
111 int tmpUnit = 1;
112 if(name == "GRF16") {
113 tmpType = EDigitizer::kGRF16;
114 tmpUnit = 10;
115 } else if(name == "GRF4G") {
116 tmpType = EDigitizer::kGRF4G;
117 tmpUnit = 10;
118 } else if(name == "TIG10") {
119 tmpType = EDigitizer::kTIG10;
120 tmpUnit = 10;
121 } else if(name == "TIG64") {
122 tmpType = EDigitizer::kTIG64;
123 tmpUnit = 10;
124 } else if(name == "CAEN") {
125 tmpType = EDigitizer::kCaen;
126 tmpUnit = 2;
127 } else if(name == "MADC") {
128 tmpType = EDigitizer::kMadc;
129 tmpUnit = 50;
130 } else if(name == "V1190") {
131 tmpType = EDigitizer::kV1190;
132 tmpUnit = 50;
133 } else if(name == "FMC32") {
134 tmpType = EDigitizer::kFMC32;
135 tmpUnit = 10;
136 } else {
137 std::cout << "Warning, digitizer type '" << name << "' not recognized, options are 'GRF16', 'FMC32', 'GRF4G', 'TIG10', 'TIG64', 'CAEN', 'MADC!' && 'V1190'!" << std::endl;
138 }
139 digitizerType.Set(tmpType, digitizerName.Priority());
140 timeStampUnit.Set(tmpUnit, digitizerName.Priority());
141}
142
143void TGRSIMnemonic::Parse(std::string* name)
144{
145 if((name == nullptr) || name->length() < 9) {
146 if((name->length() < 1) && (name->compare(0, 2, "RF") == 0)) {
147 SetRFMnemonic(name);
148 }
149 return;
150 }
151 TMnemonic::Parse(name);
152 // Enumerating the fSystemString must come last as the details of other parts of
153 // the mnemonic must be known
155
156 if(fSystem == ESystem::kSiLi) {
157 std::string buf;
158 buf.assign(*name, 7, 2);
159 Segment(static_cast<int16_t>(strtol(buf.c_str(), nullptr, 16)));
160 }
161}
162
163void TGRSIMnemonic::Print(Option_t*) const
164{
165 std::ostringstream str;
166 str << "======== GRSIMNEMONIC ========" << std::endl;
167 TMnemonic::Print(str);
168 str << "==============================" << std::endl;
169 std::cout << str.str();
170}
171
173{
174 if(TMnemonic::GetClassType() != nullptr) {
176 }
177
178 switch(System()) {
179 case ESystem::kTigress: SetClassType(TTigress::Class()); break;
180 case ESystem::kSharc: SetClassType(TSharc::Class()); break;
181 case ESystem::kTriFoil: SetClassType(TTriFoil::Class()); break;
182 case ESystem::kRF: SetClassType(TRF::Class()); break;
183 case ESystem::kSiLi: SetClassType(TSiLi::Class()); break;
184 case ESystem::kS3: SetClassType(TS3::Class()); break;
185 case ESystem::kSiLiS3: SetClassType(TS3::Class()); break;
186 case ESystem::kCSM: SetClassType(TCSM::Class()); break;
187 case ESystem::kGriffin: SetClassType(TGriffin::Class()); break;
188 case ESystem::kSceptar: SetClassType(TSceptar::Class()); break;
189 case ESystem::kPaces: SetClassType(TPaces::Class()); break;
190 case ESystem::kDescant: SetClassType(TDescant::Class()); break;
191 case ESystem::kLaBr: SetClassType(TLaBr::Class()); break;
192 case ESystem::kTAC: SetClassType(TTAC::Class()); break;
193 case ESystem::kZeroDegree: SetClassType(TZeroDegree::Class()); break;
194 case ESystem::kTip: SetClassType(TTip::Class()); break;
195 case ESystem::kGriffinBgo: SetClassType(TGriffinBgo::Class()); break;
196 case ESystem::kLaBrBgo: SetClassType(TLaBrBgo::Class()); break;
197 case ESystem::kGeneric: SetClassType(TGenericDetector::Class()); break;
198 case ESystem::kEmma: SetClassType(TEmma::Class()); break;
199 case ESystem::kEmmaS3: SetClassType(TS3::Class()); break;
200 case ESystem::kTrific: SetClassType(TTrific::Class()); break;
201 case ESystem::kSharc2: SetClassType(TSharc2::Class()); break;
202 case ESystem::kRcmp: SetClassType(TRcmp::Class()); break;
203 case ESystem::kAries: SetClassType(TAries::Class()); break;
204 default: SetClassType(nullptr);
205 };
207}
208
209double TGRSIMnemonic::GetTime(Long64_t timestamp, Float_t cfd, double energy, const TChannel* channel) const
210{
211 if(channel == nullptr) {
212 Error("GetTime", "No TChannel provided");
213 return static_cast<double>(timestamp) + gRandom->Uniform();
214 }
215
216 Double_t dTime = 0.;
217 switch(static_cast<EDigitizer>(channel->GetDigitizerType())) {
220 // we need to zero the lowest 18 bits of the timestamp as those are included in the CFD value
221 // 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
222 dTime = static_cast<Double_t>((timestamp & (~0x3ffff)) * channel->GetTimeStampUnit()) + channel->CalibrateCFD((cfd + gRandom->Uniform()) / 1.6); // CFD is in 10/16th of a nanosecond
223 return dTime - channel->GetTZero(energy) - static_cast<double>(channel->GetTimeOffset());
225 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.);
226 return dTime - channel->GetTZero(energy) - static_cast<double>(channel->GetTimeOffset());
228 dTime = static_cast<Double_t>((timestamp & (~0x7fffff)) * channel->GetTimeStampUnit()) + channel->CalibrateCFD((cfd + gRandom->Uniform()) / 1.6); // CFD is in 10/16th of a nanosecond
229 //channel->CalibrateCFD((cfd & (~0xf) + gRandom->Uniform()) / 1.6); // PBender suggests this.
230 return dTime - channel->GetTZero(energy) - static_cast<double>(channel->GetTimeOffset());
232 //10 bit CFD for 0-2ns => divide by 512
233 dTime = static_cast<Double_t>(timestamp * channel->GetTimeStampUnit()) + channel->CalibrateCFD((cfd + gRandom->Uniform()) / 512.);
234 return dTime - channel->GetTZero(energy) - static_cast<double>(channel->GetTimeOffset());
235 default:
236 dTime = (static_cast<Double_t>(timestamp) + gRandom->Uniform()) * channel->GetTimeStampUnit();
237 return dTime - channel->GetTZero(energy) - static_cast<double>(channel->GetTimeOffset());
238 }
239 return 0.;
240}
241
243{
244 /// This function translates the crystal color to an index
245 /// B - Blue - 0, G - Green - 1, R - Red - 2, W - White - 3, default - 5
246 /// Except for the LaBr BGOs which use A - 0, B - 1, C - 2
247 /// and a default of 5
248 if(System() == ESystem::kLaBrBgo) {
249 switch(ArraySubPosition()) {
251 return 0;
253 return 1;
255 return 2;
256 default:
257 return 5;
258 };
259 }
260
261 switch(ArraySubPosition()) {
263 return 0;
265 return 1;
267 return 2;
269 return 3;
270 default:
271 return 5;
272 };
273
274 // return statement here instead of default case
275 // to make sure compiler doesn't warn us about missing return
276 return 5;
277}
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