Skip to content

Commit

Permalink
TRestDetectorHitsSmearingProcess. Seed will now be registered as meta…
Browse files Browse the repository at this point in the history
…data
  • Loading branch information
jgalan committed Mar 3, 2023
1 parent 83c9cdb commit 5c280dc
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
7 changes: 5 additions & 2 deletions inc/TRestDetectorHitsSmearingProcess.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ class TRestDetectorHitsSmearingProcess : public TRestEventProcess {
/// A pointer to the random generator initializes with fSeed
TRandom3* fRandom = nullptr; //!

void InitFromConfigFile() override;
void Initialize() override;
void InitProcess() override;

protected:
/// Reference energy for the FWHM
Expand All @@ -50,6 +50,9 @@ class TRestDetectorHitsSmearingProcess : public TRestEventProcess {
/// FWHM at Energy of reference
Double_t fResolutionAtERef = 15; //<

/// The seed to be used for the random generator
ULong_t fSeed = 0; //<

public:
any GetInputEvent() const override { return fInputEvent; }
any GetOutputEvent() const override { return fOutputEvent; }
Expand Down Expand Up @@ -82,6 +85,6 @@ class TRestDetectorHitsSmearingProcess : public TRestEventProcess {

~TRestDetectorHitsSmearingProcess();

ClassDefOverride(TRestDetectorHitsSmearingProcess, 2);
ClassDefOverride(TRestDetectorHitsSmearingProcess, 3);
};
#endif
12 changes: 5 additions & 7 deletions src/TRestDetectorHitsSmearingProcess.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,12 @@ void TRestDetectorHitsSmearingProcess::Initialize() {

fInputEvent = nullptr;
fOutputEvent = new TRestDetectorHitsEvent();
}

fRandom = nullptr;
void TRestDetectorHitsSmearingProcess::InitProcess() {
if (fRandom != nullptr) delete fRandom;
fRandom = new TRandom3(fSeed);
fSeed = fRandom->TRandom::GetSeed();
}

///////////////////////////////////////////////
Expand All @@ -115,9 +119,3 @@ TRestEvent* TRestDetectorHitsSmearingProcess::ProcessEvent(TRestEvent* inputEven

return fOutputEvent;
}

void TRestDetectorHitsSmearingProcess::InitFromConfigFile() {
fEnergyRef = GetDblParameterWithUnits("energyReference");
fResolutionAtERef = StringToDouble(GetParameter("resolutionReference"));
fRandom = new TRandom3(StringToDouble(GetParameter("seed", "0")));
}

0 comments on commit 5c280dc

Please sign in to comment.