31 string outputFilename = GenerateOutputFilename(inputFilename);
34 fOutFile = TFile::Open(outputFilename.c_str(),
"RECREATE");
36 fOutTree =
new TTree(
"lyso_wfs",
"lyso_wfs");
37 fOutTree->Branch(
"Event", &
fEvent);
38 fOutTree->Branch(
"Front", &
fFront);
39 fOutTree->Branch(
"Back", &
fBack);
41 fTimesTree =
new TTree(
"lyso_wfs_times",
"lyso_wfs_times");
42 fTimesTree->Branch(
"Time_F", &fTimes_F);
43 fTimesTree->Branch(
"Time_B", &fTimes_B);
59 fOutTree->ResetBranchAddresses();
64 fTimesTree->ResetBranchAddresses();
76string BarLYSO::GenerateOutputFilename(
const char* inputFilename)
79 regex regex(
"\\bMCID_(\\d+)");
85 string filename = inputFilename;
88 if(regex_search(filename, match, regex))
91 string runID = match[1].str();
101 string outputFilename;
107 outputFilename =
"./RootFiles/BarID_" + to_string(
fID) +
".root";
111 outputFilename =
"./RootFiles/BarID_" + to_string(
fID) +
"_t" + to_string(fThreadID) +
".root";
116 outputFilename =
"./RootFiles/output.root";
119 return outputFilename;
124void BarLYSO::SetSamplingTimes()
129 if(fDAQ->fIsBinSizeConstant)
133 fTimes_F[j][i] = (Float_t) i / fDAQ->fSamplingSpeed;
134 fTimes_B[j][i] = (Float_t) i / fDAQ->fSamplingSpeed;
140 fTimes_F[j][0] = 0.0;
141 fTimes_B[j][0] = 0.0;
145 Float_t bin_F, bin_B;
148 bin_F = fDAQ->binRand->Gaus(1.0 / fDAQ->fSamplingSpeed, fDAQ->fSigmaBinSize);
149 }
while (bin_F < 0.5 * (1.0 / fDAQ->fSamplingSpeed) || bin_F > 1.5 * (1.0 / fDAQ->fSamplingSpeed));
153 bin_B = fDAQ->binRand->Gaus(1.0 / fDAQ->fSamplingSpeed, fDAQ->fSigmaBinSize);
154 }
while (bin_B < 0.5 * (1.0 / fDAQ->fSamplingSpeed) || bin_B > 1.5 * (1.0 / fDAQ->fSamplingSpeed));
156 fTimes_F[j][i+1] = fTimes_F[j][i] + bin_F;
157 fTimes_B[j][i+1] = fTimes_B[j][i] + bin_B;
170 Double_t charge, A, tau_rise, tau_dec;
173 TTree *tree =
new TTree(
"tree",
"mytree");
176 tree->SetBranchAddress(
"Status", &status);
177 tree->SetBranchAddress(
"Charge", &charge);
178 tree->SetBranchAddress(
"A", &A);
179 tree->SetBranchAddress(
"Tau_rise", &tau_rise);
180 tree->SetBranchAddress(
"Tau_fall", &tau_dec);
183 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]);
186 for(Int_t i = 0; i < tree->GetEntries(); i++)
193 hPars->Fill(A, tau_rise, tau_dec);
206 Double_t expRise = Exp(-(t-timePhel)/tau_rise);
207 Double_t expDec = Exp(-(t-timePhel)/tau_dec);
210 funcVal =
static_cast<Float_t
>(A*(expRise-expDec)*((t > timePhel) ? 1:0));
213 if(funcVal > 0 || IsNaN(funcVal)) funcVal = 0;
231 for(Int_t ch = 0; ch <
CHANNELS; ch++)
243void BarLYSO::SetFrontWaveform(Int_t channel, Double_t start)
246 Double_t A, tau_rise, tau_dec;
250 for(Int_t bin = 0; bin <
SAMPLINGS; bin++)
261 Double_t A, tau_rise, tau_dec;
265 for(Int_t bin = 0; bin <
SAMPLINGS; bin++)
276 Float_t k = fDAQ->ComputeFactorOfGainConversion();
277 for(Int_t ch = 0; ch <
CHANNELS; ch++)
279 for(Int_t bin = 0; bin <
SAMPLINGS; bin++)
292void BarLYSO::SaveBar()
295 fOutTree->Write(
"lyso_wfs");
296 fTimesTree->Write(
"lyso_wfs_times");
Declaration of the class BarLYSO.
std::vector< std::vector< Float_t > > fBack
Container for Back-Detector waveforms: a 3-dimensional matrix with indices for event,...
Float_t Wave_OnePhel(Float_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.
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...
Double_t fChargeCuts[2]
Cuts in the charge spectrum of input best fit parameters data; [0] represents the minimum,...
Float_t Add_Noise()
Returns the value of the noise.
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.
std::vector< std::vector< Float_t > > fFront
Container for Front-Detector waveforms: a 3-dimensional matrix with indices for event,...
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.
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.
constexpr Int_t SAMPLINGS
Number of samplings for one waveform.
constexpr Float_t ZERO_TIME_BIN
Delay of all waveforms in the [0, 1023] bins window.
constexpr Int_t CHANNELS
Number of channels of the detectors.