Skip to content

Commit 13c9d15

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 6e94816 commit 13c9d15

6 files changed

+79
-65
lines changed

Diff for: inc/TRestAxionSolarFlux.h

+6-3
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,13 @@ class TRestAxionSolarFlux : public TRestMetadata {
6565
void Initialize();
6666

6767
/// It is required in order to load solar flux tables into memory for specific mass
68-
void InitializeMass( Double_t mass ) { SetMass(mass); Initialize(); }
69-
68+
void InitializeMass(Double_t mass) {
69+
SetMass(mass);
70+
Initialize();
71+
}
72+
7073
/// Set mass and reinitialise
71-
void SetMass( Double_t m ) { fMass = m; } //Initialize(); }
74+
void SetMass(Double_t m) { fMass = m; } // Initialize(); }
7275

7376
/// It returns the integrated flux at earth in cm-2 s-1 for the given energy range
7477
virtual Double_t IntegrateFluxInRange(TVector2 eRange = TVector2(-1, -1)) = 0;

Diff for: inc/TRestAxionSolarHiddenPhotonFlux.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ class TRestAxionSolarHiddenPhotonFlux : public TRestAxionSolarFlux {
7373
void LoadMonoChromaticFluxTable();
7474
void IntegrateSolarFluxes();
7575

76-
public:
76+
public:
7777
/// It returns true if continuum flux spectra was loaded
7878
Bool_t isSolarTableLoaded() { return fFluxTable.size() > 0; }
7979

Diff for: inc/TRestAxionSolarQCDFlux.h

+1-3
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,7 @@ class TRestAxionSolarQCDFlux : public TRestAxionSolarFlux {
9393
Bool_t LoadTables() override;
9494

9595
/// It returns the total integrated flux at earth in cm-2 s-1
96-
Double_t GetTotalFlux() override {
97-
return fTotalContinuumFlux + fTotalMonochromaticFlux;
98-
}
96+
Double_t GetTotalFlux() override { return fTotalContinuumFlux + fTotalMonochromaticFlux; }
9997

10098
/// It returns an energy integrated spectrum in cm-2 s-1 keV-1
10199
TH1D* GetEnergySpectrum() override { return GetTotalSpectrum(); }

Diff for: pipeline/metadata/solarFlux/solarPlotHiddenPhoton.py

+4-6
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,10 @@
4444
parser.add_argument(
4545
"--N", dest="samples", type=int, help="The number of generated particles"
4646
)
47-
parser.add_argument(
48-
"--m", dest="mass", type=float, help="Hidden photon mass [eV]"
49-
)
47+
parser.add_argument("--m", dest="mass", type=float, help="Hidden photon mass [eV]")
5048
args = parser.parse_args()
5149

52-
mass = 10. # eV
50+
mass = 10.0 # eV
5351
if args.mass != None:
5452
mass = args.mass
5553

@@ -96,7 +94,7 @@
9694
comb_spt = TH2D("comb_spt", "Energy versus solar radius", 20000, 0, 20, 100, 0, 1)
9795
for i in range(samples):
9896
x = combinedFlux.GetRandomEnergyAndRadius((-1, -1))
99-
#print(x)
97+
# print(x)
10098
comb_spt.Fill(x[0], x[1])
10199

102100
rnd = TRandom3(0)
@@ -164,4 +162,4 @@
164162
c1.Print(outfname)
165163
print("Generated file : " + outfname)
166164

167-
#exit(0)
165+
# exit(0)

Diff for: src/TRestAxionSolarFlux.cxx

+2-3
Original file line numberDiff line numberDiff line change
@@ -134,12 +134,11 @@ void TRestAxionSolarFlux::Initialize() {
134134
fSeed = fRandom->TRandom::GetSeed();
135135
}
136136

137-
138137
///////////////////////////////////////////////
139138
/// \brief Initialization of TRestAxionSolarFlux members with specific mass
140139
///
141-
//void TRestAxionSolarFlux::InitializeMass( Double_t mass ) { SetMass(mass); RESTMetadata << GetMass() << RESTendl; } // SetMass calls Initialize
142-
140+
// void TRestAxionSolarFlux::InitializeMass( Double_t mass ) { SetMass(mass); RESTMetadata << GetMass() <<
141+
// RESTendl; } // SetMass calls Initialize
143142

144143
///////////////////////////////////////////////
145144
/// \brief It builds a histogram using the contents of the .flux file given

Diff for: src/TRestAxionSolarHiddenPhotonFlux.cxx

+65-49
Original file line numberDiff line numberDiff line change
@@ -184,23 +184,28 @@ TRestAxionSolarHiddenPhotonFlux::~TRestAxionSolarHiddenPhotonFlux() {}
184184
/// inside the metadata members, and calculate the solar flux for a given m.
185185
///
186186
Bool_t TRestAxionSolarHiddenPhotonFlux::LoadTables() {
187-
188-
if (GetMass() <= 0 ) {
189-
RESTWarning << "TRestAxionSolarHiddenPhotonFlux::LoadTables - hidden photon mass not yet defined" << RESTendl;
190-
RESTWarning << "TRestAxionSolarHiddenPhotonFlux::LoadTables - mass given as " << GetMass() << " eV" << RESTendl;
191-
return false;
187+
if (GetMass() <= 0) {
188+
RESTWarning << "TRestAxionSolarHiddenPhotonFlux::LoadTables - hidden photon mass not yet defined"
189+
<< RESTendl;
190+
RESTWarning << "TRestAxionSolarHiddenPhotonFlux::LoadTables - mass given as " << GetMass() << " eV"
191+
<< RESTendl;
192+
return false;
193+
}
194+
if (fFluxDataFile == "") {
195+
RESTWarning << "TRestAxionSolarHiddenPhotonFlux::LoadTables - flux table not found!!\n "
196+
<< fFluxDataFile << RESTendl;
197+
return false;
192198
}
193-
if ( fFluxDataFile == "" ){
194-
RESTWarning << "TRestAxionSolarHiddenPhotonFlux::LoadTables - flux table not found!!\n " << fFluxDataFile << RESTendl;
195-
return false;
199+
if (fWidthDataFile == "") {
200+
RESTWarning << "TRestAxionSolarHiddenPhotonFlux::LoadTables - width table not found!!\n "
201+
<< fWidthDataFile << RESTendl;
202+
return false;
196203
}
197-
if ( fWidthDataFile == "") {
198-
RESTWarning << "TRestAxionSolarHiddenPhotonFlux::LoadTables - width table not found!!\n " << fWidthDataFile << RESTendl;
199-
return false;
200-
}
201-
if ( fPlasmaFreqDataFile == "" ) {
202-
RESTWarning << "TRestAxionSolarHiddenPhotonFlux::LoadTables - plasma frequency table not found!!\n " << fPlasmaFreqDataFile << RESTendl;
203-
return false;
204+
if (fPlasmaFreqDataFile == "") {
205+
RESTWarning
206+
<< "TRestAxionSolarHiddenPhotonFlux::LoadTables - plasma frequency table not found!!\n "
207+
<< fPlasmaFreqDataFile << RESTendl;
208+
return false;
204209
}
205210

206211
LoadContinuumFluxTable();
@@ -248,7 +253,9 @@ void TRestAxionSolarHiddenPhotonFlux::LoadContinuumFluxTable() {
248253

249254
for (unsigned int n = 0; n < fluxTable.size(); n++) {
250255
TH1D* h = new TH1D(Form("%s_ContinuumFluxAtRadius%d", GetName(), n), "", 200, 0, 20);
251-
for (unsigned int m = 0; m < fluxTable[n].size(); m++) { h->SetBinContent(m + 1, fluxTable[n][m]); }
256+
for (unsigned int m = 0; m < fluxTable[n].size(); m++) {
257+
h->SetBinContent(m + 1, fluxTable[n][m]);
258+
}
252259
fContinuumTable.push_back(h);
253260
}
254261
}
@@ -277,8 +284,9 @@ void TRestAxionSolarHiddenPhotonFlux::LoadWidthTable() {
277284
}
278285

279286
TRestTools::ReadBinaryTable(fullPathName, fluxTable);
280-
//RESTMetadata << "Width table rows / columns: " << fluxTable.size() << " " << fluxTable[0].size() << RESTendl;
281-
287+
// RESTMetadata << "Width table rows / columns: " << fluxTable.size() << " " << fluxTable[0].size() <<
288+
// RESTendl;
289+
282290
if (fluxTable.size() != 1000 || fluxTable[0].size() != 200) {
283291
fluxTable.clear();
284292
RESTError << "LoadWidthTable. The table does not contain the right number of rows or columns"
@@ -288,7 +296,9 @@ void TRestAxionSolarHiddenPhotonFlux::LoadWidthTable() {
288296

289297
for (unsigned int n = 0; n < fluxTable.size(); n++) {
290298
TH1D* h = new TH1D(Form("%s_ResonanceWidthAtRadius%d", GetName(), n), "", 200, 0, 20);
291-
for (unsigned int m = 0; m < fluxTable[n].size(); m++) { h->SetBinContent(m + 1, fluxTable[n][m]); }
299+
for (unsigned int m = 0; m < fluxTable[n].size(); m++) {
300+
h->SetBinContent(m + 1, fluxTable[n][m]);
301+
}
292302
fWidthTable.push_back(h);
293303
}
294304
}
@@ -318,7 +328,7 @@ void TRestAxionSolarHiddenPhotonFlux::LoadPlasmaFreqTable() {
318328
}
319329

320330
TRestTools::ReadBinaryTable(fullPathName, fluxTable);
321-
331+
322332
if (fluxTable.size() != 1000 || fluxTable[0].size() != 1) {
323333
fluxTable.clear();
324334
RESTError << "LoadPlasmaFreqTable. The table does not contain the right number of rows or columns"
@@ -328,7 +338,9 @@ void TRestAxionSolarHiddenPhotonFlux::LoadPlasmaFreqTable() {
328338

329339
for (unsigned int n = 0; n < fluxTable.size(); n++) {
330340
TH1D* h = new TH1D(Form("%s_PlasmaFreqAtRadius%d", GetName(), n), "", 1, 0, 20);
331-
for (unsigned int m = 0; m < fluxTable[n].size(); m++) { h->SetBinContent(m + 1, fluxTable[n][m]); }
341+
for (unsigned int m = 0; m < fluxTable[n].size(); m++) {
342+
h->SetBinContent(m + 1, fluxTable[n][m]);
343+
}
332344
fPlasmaFreqTable.push_back(h);
333345
}
334346
}
@@ -341,20 +353,21 @@ void TRestAxionSolarHiddenPhotonFlux::CalculateSolarFlux() {
341353
if (GetMass() == 0) {
342354
RESTError << "CalculateSolarFlux. The hidden photon mass is set to zero!" << RESTendl;
343355
return;
344-
}
345-
if (fContinuumTable.size() == 0 ) {
346-
RESTError << "TRestAxionSolarHiddenPhotonFlux::CalculateSolarFlux - empty flux table!" << RESTendl;
347-
return;
348356
}
349-
if (fPlasmaFreqTable.size() == 0 ) {
350-
RESTError << "TRestAxionSolarHiddenPhotonFlux::CalculateSolarFlux - empty plasma freq table!" << RESTendl;
351-
return;
357+
if (fContinuumTable.size() == 0) {
358+
RESTError << "TRestAxionSolarHiddenPhotonFlux::CalculateSolarFlux - empty flux table!" << RESTendl;
359+
return;
352360
}
353-
if (fWidthTable.size() == 0 ) {
354-
RESTError << "TRestAxionSolarHiddenPhotonFlux::CalculateSolarFlux - empty width table!" << RESTendl;
355-
return;
361+
if (fPlasmaFreqTable.size() == 0) {
362+
RESTError << "TRestAxionSolarHiddenPhotonFlux::CalculateSolarFlux - empty plasma freq table!"
363+
<< RESTendl;
364+
return;
365+
}
366+
if (fWidthTable.size() == 0) {
367+
RESTError << "TRestAxionSolarHiddenPhotonFlux::CalculateSolarFlux - empty width table!" << RESTendl;
368+
return;
356369
}
357-
370+
358371
Double_t mass = GetMass();
359372
cout << mass << endl;
360373
for (unsigned int n = 0; n < fContinuumTable.size(); n++) {
@@ -363,19 +376,21 @@ void TRestAxionSolarHiddenPhotonFlux::CalculateSolarFlux() {
363376
Double_t wp = fPlasmaFreqTable[n]->GetBinContent(1);
364377
TH1D* hMass = new TH1D(Form("%s_hMass%d", GetName(), n), "hMass", 200, 0, 20);
365378
TH1D* hWg2 = (TH1D*)fWidthTable[n]->Clone();
366-
hWg2->Multiply(hWg2); // (w G)^2
379+
hWg2->Multiply(hWg2); // (w G)^2
367380

368-
for ( unsigned int c = 0; c < 200; c++ ) {
369-
Double_t wG = fWidthTable[n]->GetBinContent(c+1);
370-
hMass->SetBinContent( c+1, pow(mass,-4) * ( pow( pow(mass,2) - pow(wp,2) , 2 )));// + pow(wG,2) ) ); // m2
371-
}
372-
373-
hMass->Add(hWg2); // (m2 - wp2)^2 + (w G)^2
381+
for (unsigned int c = 0; c < 200; c++) {
382+
Double_t wG = fWidthTable[n]->GetBinContent(c + 1);
383+
hMass->SetBinContent(
384+
c + 1, pow(mass, -4) * (pow(pow(mass, 2) - pow(wp, 2), 2))); // + pow(wG,2) ) ); // m2
385+
}
374386

375-
TH1D* h = (TH1D*)fWidthTable[n]->Clone(); // wG
376-
h->Multiply(fContinuumTable[n]); // wG * flux
377-
h->Divide(hMass); // wG * flux / ( (m2 - wp2)^2 + (w G)^2 )
378-
//h->Scale(pow(mass, 4)); // m4 * wG * flux / ( (m2 - wp2)^2 + (w G)^2 )
387+
hMass->Add(hWg2); // (m2 - wp2)^2 + (w G)^2
388+
389+
TH1D* h = (TH1D*)fWidthTable[n]->Clone(); // wG
390+
h->Multiply(fContinuumTable[n]); // wG * flux
391+
h->Divide(hMass); // wG * flux / ( (m2 - wp2)^2 + (w G)^2 )
392+
// h->Scale(pow(mass, 4)); // m4 * wG * flux / ( (m2 - wp2)^2 + (w G)^2
393+
// )
379394

380395
fFluxTable.push_back(h);
381396
}
@@ -477,9 +492,11 @@ Double_t TRestAxionSolarHiddenPhotonFlux::IntegrateFluxInRange(TVector2 eRange)
477492
/// flux distributions defined inside the solar tables loaded in the class
478493
///
479494
std::pair<Double_t, Double_t> TRestAxionSolarHiddenPhotonFlux::GetRandomEnergyAndRadius(TVector2 eRange) {
480-
481495
std::pair<Double_t, Double_t> result = {0, 0};
482-
if (!AreTablesLoaded()) { RESTWarning << "Tables not loaded!!" << RESTendl; return result; }
496+
if (!AreTablesLoaded()) {
497+
RESTWarning << "Tables not loaded!!" << RESTendl;
498+
return result;
499+
}
483500
Double_t rnd = fRandom->Rndm();
484501
for (unsigned int r = 0; r < fFluxTableIntegrals.size(); r++) {
485502
if (rnd < fFluxTableIntegrals[r]) {
@@ -529,9 +546,9 @@ void TRestAxionSolarHiddenPhotonFlux::PrintIntegratedRingFlux() {
529546
void TRestAxionSolarHiddenPhotonFlux::PrintMetadata() {
530547
TRestAxionSolarFlux::PrintMetadata();
531548

532-
RESTMetadata << " - Solar hidden photon datafile (flux) : " << fFluxDataFile << RESTendl;
533-
RESTMetadata << " - Solar hidden photon datafile (width) : " << fWidthDataFile << RESTendl;
534-
RESTMetadata << " - Solar hidden photon datafile (plasma freq) : " << fPlasmaFreqDataFile << RESTendl;
549+
RESTMetadata << " - Solar hidden photon datafile (flux) : " << fFluxDataFile << RESTendl;
550+
RESTMetadata << " - Solar hidden photon datafile (width) : " << fWidthDataFile << RESTendl;
551+
RESTMetadata << " - Solar hidden photon datafile (plasma freq) : " << fPlasmaFreqDataFile << RESTendl;
535552
RESTMetadata << "-------" << RESTendl;
536553
RESTMetadata << " - Total continuum flux : " << fTotalContinuumFlux << " cm-2 s-1" << RESTendl;
537554
RESTMetadata << "++++++++++++++++++" << RESTendl;
@@ -610,4 +627,3 @@ TCanvas* TRestAxionSolarHiddenPhotonFlux::DrawSolarFlux() {
610627

611628
return fCanvas;
612629
}
613-

0 commit comments

Comments
 (0)