Skip to content

Commit 19cf96f

Browse files
authored
Merge pull request #63 from rest-for-physics/solar_flux_update
TRestAxionSolarFlux now is an abstract class that allows to encapsulate different solar flux types
2 parents f43d8a7 + 2307cd9 commit 19cf96f

File tree

15 files changed

+1013
-770
lines changed

15 files changed

+1013
-770
lines changed

.github/pr-badge.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,5 @@
1313
message: "Ok: $additions"
1414
color: "green"
1515
when: "$additions < 100"
16-
- imageUrl: "https://gitlab.cern.ch/rest-for-physics/axionlib/badges/$branchName/pipeline.svg"
17-
url: "https://gitlab.cern.ch/rest-for-physics/axionlib/-/commits/$branchName"
18-
- imageUrl: "https://github.com/rest-for-physics/axionlib/actions/workflows/validation.yml/badge.svg?branch=$branchName"
16+
- imageUrl: "https://github.com/rest-for-physics/axionlib/actions/workflows/frameworkValidation.yml/badge.svg?branch=$branchName"
1917
url: "https://github.com/rest-for-physics/axionlib/commits/$branchName"

.github/workflows/validation.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ jobs:
187187
wget https://rest-for-physics.github.io/axionlib-data/solarFlux/Primakoff_Gianotti_201904.dat
188188
wget https://rest-for-physics.github.io/axionlib-data/solarFlux/Primakoff_LennertHoof_202203.dat
189189
python solarTests.py
190-
python solarPlot.py
190+
python solarPlotQCD.py
191191
python compare.py
192192
193193
Ray-tracing:

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ cmake_minimum_required(VERSION 3.5 FATAL_ERROR)
44
include(ExternalProject)
55
set(CMAKE_MACOSX_RPATH 1)
66

7-
set(LibraryVersion "1.1")
7+
set(LibraryVersion "1.2")
88
add_definitions(-DLIBRARY_VERSION="${LibraryVersion}")
99

1010
if (${REST_MPFR} MATCHES "ON")

inc/TRestAxionEventProcess.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class TRestAxionEventProcess : public TRestEventProcess {
4747
/// The rotation angle around CenterSetup with respect to X-axis
4848
Double_t fExternalPitch = 0; //<
4949

50-
/// If enabled it will skip the end rotation that recovers the original axion trajectory direction
50+
/// If enabled it skips the end rotation that recovers the original axion trajectory direction
5151
Bool_t fLocalAxis = true; //<
5252

5353
protected:

inc/TRestAxionSolarFlux.h

Lines changed: 27 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,11 @@
2727
#include <TH1F.h>
2828
#include <TH2F.h>
2929
#include <TRandom3.h>
30-
#include <TRestAxionSolarModel.h>
3130
#include <TRestMetadata.h>
3231

3332
//! A metadata class to load tabulated solar axion fluxes
3433
class TRestAxionSolarFlux : public TRestMetadata {
3534
private:
36-
/// The filename containning the solar flux table with continuum spectrum
37-
std::string fFluxDataFile = ""; //<
38-
39-
/// The filename containning the solar flux spectra for monochromatic spectrum
40-
std::string fFluxSptFile = ""; //<
41-
4235
/// Axion coupling. Defines coupling type and strength.
4336
std::string fCouplingType = ""; //<
4437

@@ -48,101 +41,55 @@ class TRestAxionSolarFlux : public TRestMetadata {
4841
/// Seed used in random generator
4942
Int_t fSeed = 0; //<
5043

51-
/// It will be used when loading `.flux` files to define the input file energy binsize in eV.
52-
Double_t fBinSize = 0; //<
53-
54-
/// It will be used when loading `.flux` files to define the threshold for peak identification
55-
Double_t fPeakSigma = 0; //<
56-
57-
/// The tabulated solar flux continuum spectra TH1F(200,0,20)keV in cm-2 s-1 keV-1 versus solar radius
58-
std::vector<TH1F*> fFluxTable; //!
59-
60-
/// The tabulated solar flux in cm-2 s-1 for a number of monochromatic energies versus solar radius
61-
std::map<Double_t, TH1F*> fFluxLines; //!
62-
63-
/// Accumulative integrated solar flux for each solar ring for continuum spectrum (renormalized to unity)
64-
std::vector<Double_t> fFluxTableIntegrals; //!
65-
66-
/// Accumulative integrated solar flux for each monochromatic energy (renormalized to unity)
67-
std::vector<Double_t> fFluxLineIntegrals; //!
68-
69-
/// Total solar flux for monochromatic contributions
70-
Double_t fTotalMonochromaticFlux = 0; //!
71-
72-
/// Total solar flux for monochromatic contributions
73-
Double_t fTotalContinuumFlux = 0; //!
74-
75-
/// The ratio between monochromatic and total flux
76-
Double_t fFluxRatio = 0; //!
77-
78-
/// Random number generator
79-
TRandom3* fRandom = nullptr; //!
44+
/// A metadata member to control if this class has been initialized
45+
Bool_t fTablesLoaded = false; //!
8046

47+
protected:
8148
/// A canvas pointer for drawing
8249
TCanvas* fCanvas = nullptr; //!
8350

84-
/// A pointer to the continuum spectrum histogram
85-
TH1F* fContinuumHist = nullptr; //!
86-
87-
/// A pointer to the monochromatic spectrum histogram
88-
TH1F* fMonoHist = nullptr; //!
89-
90-
/// A pointer to the superposed monochromatic and continuum spectrum histogram
91-
TH1F* fTotalHist = nullptr; //!
92-
93-
/// A metadata member to control if the tables have been loaded
94-
Bool_t fTablesLoaded = false; //!
51+
/// Random number generator
52+
TRandom3* fRandom = nullptr; //!
9553

96-
void Initialize();
54+
TRestAxionSolarFlux();
55+
TRestAxionSolarFlux(const char* cfgFileName, std::string name = "");
9756

98-
void ReadFluxFile();
99-
void LoadContinuumFluxTable();
100-
void LoadMonoChromaticFluxTable();
101-
void IntegrateSolarFluxes();
57+
/// It defines how to read the solar tables at the inhereted class
58+
virtual Bool_t LoadTables() = 0;
10259

10360
public:
104-
/// It returns true if continuum flux spectra was loaded
105-
Bool_t isSolarTableLoaded() { return fFluxTable.size() > 0; }
106-
107-
/// It returns true if monochromatic flux spectra was loaded
108-
Bool_t isSolarSpectrumLoaded() { return fFluxLines.size() > 0; }
61+
/// It is required in order to load solar flux tables into memory
62+
void Initialize();
10963

11064
/// It returns the integrated flux at earth in cm-2 s-1 for the given energy range
111-
Double_t IntegrateFluxInRange(TVector2 eRange = TVector2(-1, -1));
65+
virtual Double_t IntegrateFluxInRange(TVector2 eRange = TVector2(-1, -1), Double_t mass = 0) = 0;
11266

11367
/// It returns the total integrated flux at earth in cm-2 s-1
114-
Double_t GetTotalFlux() { return fTotalContinuumFlux + fTotalMonochromaticFlux; }
68+
virtual Double_t GetTotalFlux(Double_t mass = 0) = 0;
11569

116-
std::pair<Double_t, Double_t> GetRandomEnergyAndRadius(TVector2 eRange = TVector2(-1, -1));
70+
/// It defines how to generate Monte Carlo energy and radius values to reproduce the flux
71+
virtual std::pair<Double_t, Double_t> GetRandomEnergyAndRadius(TVector2 eRange = TVector2(-1, -1),
72+
Double_t mass = 0) = 0;
11773

118-
void LoadTables();
74+
/// It returns an energy integrated spectrum in cm-2 s-1 keV-1
75+
virtual TH1F* GetEnergySpectrum(Double_t m = 0) = 0;
11976

120-
TH1F* GetContinuumSpectrum();
121-
TH1F* GetMonochromaticSpectrum();
122-
TH1F* GetTotalSpectrum();
77+
virtual TCanvas* DrawSolarFlux();
12378

124-
TH1F* GetFluxHistogram(std::string fname, Double_t binSize = 0.01);
125-
TCanvas* DrawFluxFile(std::string fname, Double_t binSize = 0.01);
126-
TCanvas* DrawSolarFlux();
127-
128-
/// Tables might be loaded using a solar model description by TRestAxionSolarModel
129-
void InitializeSolarTable(TRestAxionSolarModel* model) {
130-
// TOBE implemented
131-
// This method should initialize the tables fFluxTable and fFluxLines
79+
virtual void ExportTables(Bool_t ascii = false) {
80+
RESTWarning << "TRestAxionSolarFlux::ExportTables must be re-implemented in the inherited class"
81+
<< RESTendl;
13282
}
13383

134-
void ExportTables(Bool_t ascii = false);
84+
Bool_t AreTablesLoaded() { return fTablesLoaded; }
13585

136-
void PrintMetadata();
86+
TH1F* GetFluxHistogram(std::string fname, Double_t binSize = 0.01);
87+
TCanvas* DrawFluxFile(std::string fname, Double_t binSize = 0.01);
13788

138-
void PrintContinuumSolarTable();
139-
void PrintIntegratedRingFlux();
140-
void PrintMonoChromaticFlux();
89+
void PrintMetadata();
14190

142-
TRestAxionSolarFlux();
143-
TRestAxionSolarFlux(const char* cfgFileName, std::string name = "");
14491
~TRestAxionSolarFlux();
14592

146-
ClassDef(TRestAxionSolarFlux, 1);
93+
ClassDef(TRestAxionSolarFlux, 2);
14794
};
14895
#endif

inc/TRestAxionSolarQCDFlux.h

Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
/*************************************************************************
2+
* This file is part of the REST software framework. *
3+
* *
4+
* Copyright (C) 2016 GIFNA/TREX (University of Zaragoza) *
5+
* For more information see http://gifna.unizar.es/trex *
6+
* *
7+
* REST is free software: you can redistribute it and/or modify *
8+
* it under the terms of the GNU General Public License as published by *
9+
* the Free Software Foundation, either version 3 of the License, or *
10+
* (at your option) any later version. *
11+
* *
12+
* REST is distributed in the hope that it will be useful, *
13+
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
14+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15+
* GNU General Public License for more details. *
16+
* *
17+
* You should have a copy of the GNU General Public License along with *
18+
* REST in $REST_PATH/LICENSE. *
19+
* If not, see http://www.gnu.org/licenses/. *
20+
* For the list of contributors see $REST_PATH/CREDITS. *
21+
*************************************************************************/
22+
23+
#ifndef _TRestAxionSolarQCDFlux
24+
#define _TRestAxionSolarQCDFlux
25+
26+
#include <TRestAxionSolarFlux.h>
27+
#include <TRestAxionSolarModel.h>
28+
29+
//! A metadata class to load tabulated solar axion fluxes. Mass independent.
30+
class TRestAxionSolarQCDFlux : public TRestAxionSolarFlux {
31+
private:
32+
/// The filename containning the solar flux table with continuum spectrum
33+
std::string fFluxDataFile = ""; //<
34+
35+
/// The filename containning the solar flux spectra for monochromatic spectrum
36+
std::string fFluxSptFile = ""; //<
37+
38+
/// It will be used when loading `.flux` files to define the input file energy binsize in eV.
39+
Double_t fBinSize = 0; //<
40+
41+
/// It will be used when loading `.flux` files to define the threshold for peak identification
42+
Double_t fPeakSigma = 0; //<
43+
44+
/// The tabulated solar flux continuum spectra TH1F(200,0,20)keV in cm-2 s-1 keV-1 versus solar radius
45+
std::vector<TH1F*> fFluxTable; //!
46+
47+
/// The tabulated solar flux in cm-2 s-1 for a number of monochromatic energies versus solar radius
48+
std::map<Double_t, TH1F*> fFluxLines; //!
49+
50+
/// Accumulative integrated solar flux for each solar ring for continuum spectrum (renormalized to unity)
51+
std::vector<Double_t> fFluxTableIntegrals; //!
52+
53+
/// Accumulative integrated solar flux for each monochromatic energy (renormalized to unity)
54+
std::vector<Double_t> fFluxLineIntegrals; //!
55+
56+
/// Total solar flux for monochromatic contributions
57+
Double_t fTotalMonochromaticFlux = 0; //!
58+
59+
/// Total solar flux for monochromatic contributions
60+
Double_t fTotalContinuumFlux = 0; //!
61+
62+
/// The ratio between monochromatic and total flux
63+
Double_t fFluxRatio = 0; //!
64+
65+
/// A pointer to the continuum spectrum histogram
66+
TH1F* fContinuumHist = nullptr; //!
67+
68+
/// A pointer to the monochromatic spectrum histogram
69+
TH1F* fMonoHist = nullptr; //!
70+
71+
/// A pointer to the superposed monochromatic and continuum spectrum histogram
72+
TH1F* fTotalHist = nullptr; //!
73+
74+
void ReadFluxFile();
75+
void LoadContinuumFluxTable();
76+
void LoadMonoChromaticFluxTable();
77+
void IntegrateSolarFluxes();
78+
79+
public:
80+
/// It returns true if continuum flux spectra was loaded
81+
Bool_t isSolarTableLoaded() { return fFluxTable.size() > 0; }
82+
83+
/// It returns true if monochromatic flux spectra was loaded
84+
Bool_t isSolarSpectrumLoaded() { return fFluxLines.size() > 0; }
85+
86+
/// It returns the integrated flux at earth in cm-2 s-1 for the given energy range
87+
Double_t IntegrateFluxInRange(TVector2 eRange = TVector2(-1, -1), Double_t mass = 0) override;
88+
89+
/// It defines how to generate Monte Carlo energy and radius values to reproduce the flux
90+
std::pair<Double_t, Double_t> GetRandomEnergyAndRadius(TVector2 eRange = TVector2(-1, -1),
91+
Double_t mass = 0) override;
92+
93+
/// It defines how to read the solar tables at the inhereted class
94+
Bool_t LoadTables() override;
95+
96+
/// It returns the total integrated flux at earth in cm-2 s-1
97+
Double_t GetTotalFlux(Double_t mass = 0) override {
98+
return fTotalContinuumFlux + fTotalMonochromaticFlux;
99+
}
100+
101+
/// It returns an energy integrated spectrum in cm-2 s-1 keV-1
102+
TH1F* GetEnergySpectrum(Double_t m = 0) override { return GetTotalSpectrum(); }
103+
104+
TH1F* GetContinuumSpectrum();
105+
TH1F* GetMonochromaticSpectrum();
106+
TH1F* GetTotalSpectrum();
107+
108+
virtual TCanvas* DrawSolarFlux() override;
109+
110+
/// Tables might be loaded using a solar model description by TRestAxionSolarModel
111+
void InitializeSolarTable(TRestAxionSolarModel* model) {
112+
// TOBE implemented
113+
// This method should initialize the tables fFluxTable and fFluxLines
114+
}
115+
116+
void ExportTables(Bool_t ascii = false) override;
117+
118+
void PrintMetadata() override;
119+
120+
void PrintContinuumSolarTable();
121+
void PrintIntegratedRingFlux();
122+
void PrintMonoChromaticFlux();
123+
124+
TRestAxionSolarQCDFlux();
125+
TRestAxionSolarQCDFlux(const char* cfgFileName, std::string name = "");
126+
~TRestAxionSolarQCDFlux();
127+
128+
ClassDefOverride(TRestAxionSolarQCDFlux, 1);
129+
};
130+
#endif

pipeline/metadata/solarFlux/compare.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@
4040
pad1.Divide(2, 1)
4141
pad1.Draw()
4242

43-
primakoffLH = ROOT.TRestAxionSolarFlux("fluxes.rml", "LennertHoofPrimakoff")
44-
primakoffG = ROOT.TRestAxionSolarFlux("fluxes.rml", "Gianotti")
43+
primakoffLH = ROOT.TRestAxionSolarQCDFlux("fluxes.rml", "LennertHoofPrimakoff")
44+
primakoffG = ROOT.TRestAxionSolarQCDFlux("fluxes.rml", "Gianotti")
4545

4646
if primakoffLH.GetError():
4747
print(primakoffLH.GetErrorMessage())

pipeline/metadata/solarFlux/solarPlot.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
if args.samples != None:
6464
samples = args.samples
6565

66-
validation = False
66+
validation = True
6767
if (
6868
rmlfile == "fluxes.rml"
6969
and fluxname == "combined"
@@ -83,8 +83,8 @@
8383
pad1.Divide(2, 2)
8484
pad1.Draw()
8585

86-
combinedFlux = ROOT.TRestAxionSolarFlux(rmlfile, fluxname)
87-
combinedFlux.LoadTables()
86+
combinedFlux = ROOT.TRestAxionSolarQCDFlux(rmlfile, fluxname)
87+
combinedFlux.Initialize()
8888
combinedFlux.PrintMetadata()
8989

9090
if combinedFlux.GetError():
@@ -166,14 +166,14 @@
166166
print("\nMaximum energy bin is " + str(enSpt.GetMaximumBin()))
167167
if validation:
168168
if enSpt.GetMaximumBin() != 8001:
169-
print("\nMaximum Bin is not the expected one! Exit code : 1")
169+
print("\nMaximum Bin is not the expected one (8001)! Exit code : 1")
170170
exit(1)
171171

172172
print("\nMaximum radius bin is " + str(rSpt.GetMaximumBin()))
173173

174174
if validation:
175175
if rSpt.GetMaximumBin() != 25:
176-
print("\nMaximum Bin is not the expected one! Exit code : 2")
176+
print("\nMaximum Bin is not the expected one (25)! Exit code : 2")
177177
exit(2)
178178

179179
exit(0)

pipeline/metadata/solarFlux/solarTests.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@
2929
ROOT.gSystem.Load("libRestFramework.so")
3030
ROOT.gSystem.Load("libRestAxion.so")
3131

32-
monoFlux = ROOT.TRestAxionSolarFlux("fluxes.rml", "mono")
33-
monoFlux.LoadTables()
32+
monoFlux = ROOT.TRestAxionSolarQCDFlux("fluxes.rml", "mono")
33+
monoFlux.Initialize()
3434
monoFlux.PrintMetadata()
3535

3636
if monoFlux.GetError():
@@ -47,7 +47,7 @@
4747

4848
print("[\033[92m OK \x1b[0m]")
4949

50-
continuumFlux = ROOT.TRestAxionSolarFlux("fluxes.rml", "Gianotti")
50+
continuumFlux = ROOT.TRestAxionSolarQCDFlux("fluxes.rml", "Gianotti")
5151
continuumFlux.LoadTables()
5252
continuumFlux.PrintMetadata()
5353

0 commit comments

Comments
 (0)