31 string outputFilename = GenerateOutputFilename(inputFilename);
34 fOutFile = TFile::Open(outputFilename.c_str(),
"RECREATE");
35 fOutTree =
new TTree(
"lyso_wfs",
"lyso_wfs");
36 fOutTree->Branch(
"Event", &
fEvent);
37 fOutTree->Branch(
"Time_F", &fTimes_F);
38 fOutTree->Branch(
"Time_B", &fTimes_B);
39 fOutTree->Branch(
"Front", &
fFront);
40 fOutTree->Branch(
"Back", &
fBack);
56 fOutTree->ResetBranchAddresses();
68string BarLYSO::GenerateOutputFilename(
const char* inputFilename)
71 regex regex(
"\\bMCID_(\\d+)");
77 string filename = inputFilename;
80 if(regex_search(filename, match, regex))
83 string runID = match[1].str();
93 string outputFilename;
99 outputFilename =
"BarID_" + to_string(
fID) +
".root";
103 outputFilename =
"BarID_" + to_string(
fID) +
"_t" + to_string(fThreadID) +
".root";
108 outputFilename =
"output.root";
111 return outputFilename;
116void BarLYSO::SetSamplingTimes()
121 if(fDAQ->fIsBinSizeConstant)
132 fTimes_F[j][0] = 0.0;
133 fTimes_B[j][0] = 0.0;
137 Double_t bin_F, bin_B;
140 bin_F = fDAQ->binRand->Gaus(1.0 / fDAQ->
fSamplingSpeed, fDAQ->fSigmaBinSize);
145 bin_B = fDAQ->binRand->Gaus(1.0 / fDAQ->
fSamplingSpeed, fDAQ->fSigmaBinSize);
148 fTimes_F[j][i+1] = fTimes_F[j][i] + bin_F;
149 fTimes_B[j][i+1] = fTimes_B[j][i] + bin_B;
160 Double_t my_charge, A, tau_rise, tau_dec;
163 TTree *tree =
new TTree(
"tree",
"mytree");
166 tree->SetBranchAddress(
"Status", &status);
167 tree->SetBranchAddress(
"my_charge", &my_charge);
168 tree->SetBranchAddress(
"A", &A);
169 tree->SetBranchAddress(
"Tau_rise", &tau_rise);
170 tree->SetBranchAddress(
"Tau_dec", &tau_dec);
173 hPars =
new TH3D(
"hPars",
"Fitted All",
fHisto_A[0],
fHisto_A[1],
fHisto_A[2],
fHisto_Tau_rise[0],
fHisto_Tau_rise[1],
fHisto_Tau_rise[2],
fHisto_Tau_dec[0],
fHisto_Tau_dec[1],
fHisto_Tau_dec[2]);
176 for(Int_t i = 0; i < tree->GetEntries(); i++)
183 hPars->Fill(A, tau_rise, tau_dec);
196 Double_t expRise = Exp(-(t-timePhel)/tau_rise);
197 Double_t expDec = Exp(-(t-timePhel)/tau_dec);
200 if(expRise > DBL_MAX || expRise < DBL_MIN) expRise = 0;
201 if(expDec > DBL_MAX || expDec < DBL_MIN) expDec = 0;
204 funcVal = A*(expRise-expDec)*((t > timePhel) ? 1:0);
221 for(Int_t ch = 0; ch <
CHANNELS; ch++)
233void BarLYSO::SetFrontWaveform(Int_t channel, Double_t start)
236 Double_t A, tau_rise, tau_dec;
240 for(Int_t bin = 0; bin <
SAMPLINGS; bin++)
251 Double_t A, tau_rise, tau_dec;
255 for(Int_t bin = 0; bin <
SAMPLINGS; bin++)
266 Double_t k = fDAQ->ComputeFactorOfGainConversion();
267 for(Int_t ch = 0; ch <
CHANNELS; ch++)
269 for(Int_t bin = 0; bin <
SAMPLINGS; bin++)
282void BarLYSO::SaveBar()
285 fOutTree->Write(
"lyso_wfs");
Declaration of the class BarLYSO.
Double_t fHisto_Tau_dec[3]
Settings for histogram hPars related to parameter Tau_dec: [0] for number of bins,...
TRandom3 * fRandNoise
Random generator for Add_Noise()
Int_t fEvent
Number of events in the run.
std::string fInputFilename
Name of the txt file of the best fit parameters data. See the introduction for more details about the...
std::vector< std::vector< Double_t > > fBack
Container for Back-Detector waveforms: a 3-dimensional matrix with indices for event,...
Double_t fChargeCuts[2]
Cuts in the charge spectrum of input best fit parameters data; [0] represents the minimum,...
void SaveEvent()
Saves all the samples from fFront and fBack into a text file.
void InitializeBaselines(Int_t event)
Method to initialize the entire fFront and fBack with a noise baseline.
void SetParsDistro()
Sets the 3D histogram hPars.
Double_t Add_Noise()
Returns the value of the noise.
BarLYSO(const char *inputFilename, Int_t threadID)
Constructor of the class.
void SetBackWaveform(Int_t channel, Double_t start)
Method to add a I-Phel waveform to the corresponding event and channel of the Back-Detector.
TH3D * hPars
3D Histogram of One-Phel waveform parameters from which sampling will occur
Double_t fHisto_A[3]
Settings for histogram hPars related to parameter A: [0] for number of bins, [1] for the lower limit,...
void ClearContainers()
Method to add a I-Phel waveform to the corresponding event and channel of the Front-Detector.
~BarLYSO()
Destructor of the class.
Double_t Wave_OnePhel(Double_t t, Double_t A, Double_t tau_rise, Double_t tau_dec, Double_t timePhel)
Returns the value at t of the analytical form of the One Photo-Electron waveform.
TRandom3 * fRandPars
Random generator for SetFrontWaveform() and SetBackWaveform()
Double_t fHisto_Tau_rise[3]
Settings for histogram hPars related to parameter Tau_rise: [0] for number of bins,...
Int_t fID
Run ID of the Monte Carlo.
std::vector< std::vector< Double_t > > fFront
Container for Front-Detector waveforms: a 3-dimensional matrix with indices for event,...
Float_t fSamplingSpeed
Sampling speed [GSPS] of the DAQ.
constexpr Int_t SAMPLINGS
Number of samplings for one waveform.
constexpr Int_t ZERO_TIME_BIN
Delay of all waveforms in the [0, 1023] bins window.
constexpr Int_t CHANNELS
Number of channels of the detectors.