66 #include "TRestAxionGeneratorProcess.h"
85 SetSectionName(this->ClassName());
86 SetLibraryVersion(LIBRARY_VERSION);
91 fSingleThreadOnly =
true;
99 RESTDebug <<
"Entering ... TRestAxionGeneratorProcess::InitProcess" << RESTendl;
101 fAxionFlux = GetMetadata<TRestAxionSolarFlux>();
103 if (fGeneratorType ==
"solarFlux" && fAxionFlux ==
nullptr) {
104 if (!this->GetError()) this->SetError(
"The solar flux definition was not found.");
108 fAxionFlux->Initialize();
110 fTotalFlux = fAxionFlux->IntegrateFluxInRange(fEnergyRange);
118 fRandom =
new TRandom3(fSeed);
119 fSeed = fRandom->TRandom::GetSeed();
126 RESTDebug <<
"TRestAxionGeneratorProcess::ProcessEvent : " << fCounter << RESTendl;
127 fOutputAxionEvent->SetID(fCounter);
131 TVector3 axionDirection = TVector3(0, 0, 1);
138 x = 2 * (fRandom->Rndm() - 0.5);
139 y = 2 * (fRandom->Rndm() - 0.5);
141 }
while (r > 1 || r == 0);
145 std::pair<Double_t, Double_t> p;
146 if (fGeneratorType ==
"solarFlux") {
147 p = fAxionFlux->GetRandomEnergyAndRadius(fEnergyRange);
149 Double_t radius = p.second;
151 axionPosition = TVector3(REST_Physics::solarRadius * radius * x / r,
154 axionDirection = -axionPosition.Unit();
157 if (fGeneratorType ==
"flat" || fGeneratorType ==
"plain") {
158 if (fEnergyRange.X() > 0 && fEnergyRange.Y() > 0)
159 energy = fRandom->Rndm() * (fEnergyRange.Y() - fEnergyRange.X()) + fEnergyRange.X();
160 else if (fEnergyRange.X() > 0)
161 energy = (1. - fEnergyRange.X()) * fRandom->Rndm() + fEnergyRange.X();
163 RESTWarning <<
"Not a valid energy range was defined!" << RESTendl;
177 x = 2 * (fRandom->Rndm() - 0.5);
178 y = 2 * (fRandom->Rndm() - 0.5);
180 }
while (r > 1 || r == 0);
184 axionPosition = axionPosition + TVector3(fTargetRadius * x, fTargetRadius * y, 0) + fTargetPosition;
186 Double_t mass = fRandom->Uniform(fAxionMassRange.X(), fAxionMassRange.Y());
188 fOutputAxionEvent->SetEnergy(energy);
189 fOutputAxionEvent->SetPosition(axionPosition);
190 fOutputAxionEvent->SetDirection(axionDirection);
191 fOutputAxionEvent->SetMass(mass);
194 fOutputAxionEvent->PrintEvent();
196 return fOutputAxionEvent;
205 RESTMetadata <<
"Generator type: " << fGeneratorType << RESTendl;
206 RESTMetadata <<
"Axion mass range: (" << fAxionMassRange.X() *
units(
"eV") <<
", "
207 << fAxionMassRange.Y() *
units(
"eV") <<
") eV" << RESTendl;
208 RESTMetadata <<
"Target radius: " << fTargetRadius *
units(
"cm") <<
" cm" << RESTendl;
209 RESTMetadata <<
"Random seed: " << (UInt_t)fSeed << RESTendl;
210 RESTMetadata <<
"Energy range: (" << fEnergyRange.X() <<
", " << fEnergyRange.Y() <<
") keV" << RESTendl;
211 RESTMetadata <<
"Total flux: " << fTotalFlux <<
" cm-2 s-1" << RESTendl;
213 RESTMetadata <<
"+++++++++++++++++++++++++++++++++++++++++++++++++" << RESTendl;
An event data class to define the parameters related to an axion particle.
A process to initialize the axion event (mainly through TRestAxionSolarFlux)
TRestAxionGeneratorProcess()
Default constructor.
void PrintMetadata() override
Prints out relevant metadata members.
void Initialize() override
Function to initialize input/output event members and define the section name.
void InitProcess() override
Process initialization. Data members that require initialization just before start processing should ...
TRestEvent * ProcessEvent(TRestEvent *eventInput) override
The main processing event function.
~TRestAxionGeneratorProcess()
Default destructor.
A base class for any REST event.
@ REST_Debug
+show the defined debug messages
constexpr double AU
Average Sun-Earth distance in m.