22 #include "TRestDetectorAvalancheProcess.h"
30 TRestDetectorAvalancheProcess::TRestDetectorAvalancheProcess() { Initialize(); }
32 TRestDetectorAvalancheProcess::TRestDetectorAvalancheProcess(
const char* configFilename) {
35 if (LoadConfigFromFile(configFilename)) {
43 TRestDetectorAvalancheProcess::~TRestDetectorAvalancheProcess() {
45 delete fHitsOutputEvent;
48 void TRestDetectorAvalancheProcess::LoadDefaultConfig() {
49 SetTitle(
"Default config");
52 fResolutionAtEref = 15.0;
53 fDetectorGain = 8000.0;
57 SetSectionName(this->ClassName());
58 SetLibraryVersion(LIBRARY_VERSION);
63 fResolutionAtEref = 15.0;
64 fDetectorGain = 8000.0;
66 fHitsInputEvent =
nullptr;
70 void TRestDetectorAvalancheProcess::LoadConfig(
string configFilename) {
71 if (LoadConfigFromFile(configFilename)) LoadDefaultConfig();
75 fGas->PrintMetadata();
86 if (fGas ==
nullptr) cout <<
"REST ERROR: Gas has not been initialized" << endl;
92 Double_t fW = fGas->GetWvalue();
93 Double_t gain, totelectrons = 0;
95 Double_t eDep = fHitsInputEvent->GetTotalEnergy() * fW / 1000.0;
96 Double_t eRes = fResolutionAtEref * TMath::Sqrt(fEnergyRef / eDep) / 2.35 / 100.0;
98 cout <<
"Initial electrons " << fHitsInputEvent->GetTotalEnergy() <<
" ; eDep " << eDep
99 <<
" keV; resolution " << eRes * 2.35 * 100 <<
" fwhm" << endl;
101 TRandom3* rnd =
new TRandom3(0);
103 for (
unsigned int hit = 0; hit < fHitsInputEvent->GetNumberOfHits(); hit++) {
104 gain = fDetectorGain * rnd->Gaus(1.0, eRes);
109 totelectrons += gain;
111 fHitsOutputEvent->AddHit(fHitsInputEvent->GetX(hit), fHitsInputEvent->GetY(hit),
112 fHitsInputEvent->GetZ(hit), fHitsInputEvent->GetEnergy(hit) * gain);
117 if (fHitsOutputEvent->GetNumberOfHits() == 0)
return nullptr;
119 cout <<
"Initial: " << fHitsInputEvent->GetNumberOfHits() <<
"e-s, and amplified: " << totelectrons
120 <<
" e-s : " << endl;
121 return fHitsOutputEvent;
134 fEnergyRef = GetDblParameterWithUnits(
"energyReference");
135 fResolutionAtEref =
StringToDouble(GetParameter(
"resolutionReference"));
void InitFromConfigFile() override
To make settings from rml file. This method must be implemented in the derived class.
void InitProcess() override
To be executed at the beginning of the run (outside event loop)
void EndProcess() override
To be executed at the end of the run (outside event loop)
TRestEvent * ProcessEvent(TRestEvent *inputEvent) override
Process one event.
void Initialize() override
Making default settings.
A base class for any REST event.
Double_t StringToDouble(std::string in)
Gets a double from a string.