Bartender LYSO
Digitizer simulation for the LYSO calorimeter prototype
Loading...
Searching...
No Matches
configure.cc
Go to the documentation of this file.
1
5#include "configure.hh"
6
7using namespace std;
8
9
10string extract_value(const string& line, const string& keyword)
11{
12 // Find the position of the keyword in the line
13 size_t start = line.find(keyword);
14
15 // If the keyword is found, extract the value following it
16 if(start != string::npos)
17 {
18 start += keyword.length();
19 string value = line.substr(start);
20
21 // Remove spaces before string
22 size_t first_not_space = value.find_first_not_of(" \t");
23 if(first_not_space != string::npos)
24 {
25 value = value.substr(first_not_space);
26 }
27
28 // Remove spaces after string
29 size_t last_not_space = value.find_last_not_of(" \t");
30 if(last_not_space != string::npos)
31 {
32 value = value.substr(0, last_not_space + 1);
33 }
34
35 return value;
36 }
37
38 // Return an empty string if the keyword is not found
39 return "";
40}
41
42
43
44void Bartender_Configure(const char* filename, BarLYSO* bar, SiPM* sipm)
45{
46 ifstream file(filename);
47 if(!file.is_open())
48 {
49 cerr << "Can't open the sipm file!" << endl;
50 return;
51 }
52
53 string line;
54 while(getline(file, line))
55 {
56 if(line.find("Brand:") != string::npos)
57 {
58 sipm->fBrand = extract_value(line, "Brand:");
59 }
60 else if(line.find("TypeNo:") != string::npos)
61 {
62 sipm->fTypeNo = extract_value(line, "TypeNo:");
63 }
64 else if(line.find("V =") != string::npos)
65 {
66 sipm->fV = stof(extract_value(line, "V ="));
67 }
68 else if(line.find("T =") != string::npos)
69 {
70 sipm->fT = stof(extract_value(line, "T ="));
71 }
72 else if(line.find("Sampling speed =") != string::npos)
73 {
74 bar->GetDAQ()->fSamplingSpeed_Template = stof(extract_value(line, "Sampling speed ="));
75 }
76 else if(line.find("R_shaper =") != string::npos)
77 {
78 bar->GetDAQ()->fR_shaper_Template = stod(extract_value(line, "R_shaper ="));
79 }
80 else if(line.find("Gain =") != string::npos)
81 {
82 bar->GetDAQ()->fGain_Template = stof(extract_value(line, "Gain ="));
83 }
84 else if(line.find("Constant Bins =") != string::npos)
85 {
86 bar->GetDAQ()->fIsBinSizeConstant = (extract_value(line, "Constant Bins =") == "true");
87 }
88 else if(line.find("Sampling speed_sim =") != string::npos)
89 {
90 bar->GetDAQ()->fSamplingSpeed = stof(extract_value(line, "Sampling speed_sim ="));
91 }
92 else if(line.find("BinSize sigma =") != string::npos && !bar->GetDAQ()->fIsBinSizeConstant)
93 {
94 bar->GetDAQ()->fSigmaBinSize = stod(extract_value(line, "BinSize sigma ="));
95 }
96 else if(line.find("Use shaping =") != string::npos)
97 {
98 bar->GetDAQ()->fIsShaping = (extract_value(line, "Use shaping =") == "true");
99 }
100 else if(line.find("Tau_shaping =") != string::npos && bar->GetDAQ()->fIsShaping)
101 {
102 bar->GetDAQ()->fTau_shaping = stod(extract_value(line, "Tau_shaping ="));
103 }
104 else if(line.find("Gain_sim =") != string::npos)
105 {
106 bar->GetDAQ()->fGain = stof(extract_value(line, "Gain_sim ="));
107 }
108 else if(line.find("Noise (sigma) =") != string::npos)
109 {
110 bar->GetDAQ()->fSigmaNoise = stof(extract_value(line, "Noise (sigma) ="));
111 }
112 else if(line.find("PathToFile:") != string::npos)
113 {
114 bar->SetInputFilename(extract_value(line, "PathToFile:"));
115 }
116 else if(line.find("Charge cuts:") != string::npos)
117 {
118 string data = extract_value(line, "Charge cuts:");
119 istringstream iss(data);
120 Double_t charge_min, charge_max;
121 if(iss >> charge_min >> charge_max)
122 {
123 bar->SetChargeCuts(charge_min, charge_max);
124 }
125 }
126 else if(line.find("A histo:") != string::npos)
127 {
128 string data = extract_value(line, "A histo:");
129 istringstream iss(data);
130 Double_t nbins, hist_min, hist_max;
131 if(iss >> nbins >> hist_min >> hist_max)
132 {
133 bar->SetHisto_A(nbins, hist_min, hist_max);
134 }
135 }
136 else if(line.find("Tau_rise histo:") != string::npos)
137 {
138 string data = extract_value(line, "Tau_rise histo:");
139 istringstream iss(data);
140 Double_t nbins, hist_min, hist_max;
141 if(iss >> nbins >> hist_min >> hist_max)
142 {
143 bar->SetHisto_Tau_rise(nbins, hist_min, hist_max);
144 }
145 }
146 else if(line.find("Tau_dec histo:") != string::npos)
147 {
148 string data = extract_value(line, "Tau_dec histo:");
149 istringstream iss(data);
150 Double_t nbins, hist_min, hist_max;
151 if(iss >> nbins >> hist_min >> hist_max)
152 {
153 bar->SetHisto_Tau_dec(nbins, hist_min, hist_max);
154 }
155 }
156 }
157
158 file.close();
159}
Class for managing waveform construction for all events and channels.
Definition bar.hh:28
void SetInputFilename(std::string newInputFilename)
Set the name of the text file of the best fit parameters data.
Definition bar.hh:112
void SetHisto_Tau_rise(Double_t nbins, Double_t min, Double_t max)
Set the number of bins, the lower and the upper limit related to parameter Tau_rise for the histogram...
Definition bar.hh:136
void SetHisto_A(Double_t nbins, Double_t min, Double_t max)
Set the number of bins, the lower and the upper limit related to parameter A for the histogram hPars.
Definition bar.hh:126
void SetHisto_Tau_dec(Double_t nbins, Double_t min, Double_t max)
Set the number of bins, the lower and the upper limit related to parameter Tau_dec for the histogram ...
Definition bar.hh:146
void SetChargeCuts(Double_t min, Double_t max)
Set the cuts in the charge spectrum of input best fit parameters data.
Definition bar.hh:117
Float_t fSamplingSpeed
Sampling speed [GSPS] of the DAQ.
Definition daq.hh:18
Double_t fSigmaNoise
Noise of the DAQ, evaluated as the stDev of the pedestal distribution.
Definition daq.hh:33
Float_t fGain
Gain of the amplification stage.
Definition daq.hh:25
Double_t fR_shaper_Template
Value [Ohm] of the resistance of the shaper.
Definition daq.hh:32
void Bartender_Configure(const char *filename, BarLYSO *bar, SiPM *sipm)
Reads and processes a specific file to populate members of the BarLYSO class and SiPM struct.
Definition configure.cc:44
Declaration of the function Bartender_Configure() (and the auxiliary function extract_value())
Struct for storing MPPC/SiPM settings for waveform generation.
Definition SiPM.hh:14
Float_t fV
Supply Voltage [V] for the environment working point.
Definition SiPM.hh:18
std::string fBrand
Manufacturer's brand of SiPM.
Definition SiPM.hh:15
Float_t fT
Temperature [°C] for the environment working point.
Definition SiPM.hh:19
std::string fTypeNo
Type number of the SiPM.
Definition SiPM.hh:16