Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Dec 14, 2023
1 parent 728b69e commit 477feb9
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 26 deletions.
4 changes: 3 additions & 1 deletion inc/TRestAxionField.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,9 @@ class TRestAxionField : public TObject {

Double_t GammaTransmissionFWHM(Double_t step = 0.00001);

std::vector<std::pair<Double_t, Double_t>> GetMassDensityScanning(std::string gasName = "He", Double_t maMax = 0.15, Double_t rampDown = 5.0);
std::vector<std::pair<Double_t, Double_t>> GetMassDensityScanning(std::string gasName = "He",
Double_t maMax = 0.15,
Double_t rampDown = 5.0);

TRestAxionField();
~TRestAxionField();
Expand Down
51 changes: 26 additions & 25 deletions src/TRestAxionField.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -483,41 +483,42 @@ Double_t TRestAxionField::GammaTransmissionFWHM(Double_t step) {
///
/// For additional info see PR: https://github.com/rest-for-physics/axionlib/pull/78
///
std::vector<std::pair<Double_t, Double_t>> TRestAxionField::GetMassDensityScanning(std::string gasName, double maMax, double rampDown) {
std::vector<std::pair<Double_t, Double_t>> TRestAxionField::GetMassDensityScanning(std::string gasName,
double maMax,
double rampDown) {
std::vector<std::pair<Double_t, Double_t>> massDensityPairs;

// Storing the gas pointer, if there was one
TRestAxionBufferGas *previousGas = nullptr;
if( fBufferGas )
{
previousGas = fBufferGas;
fBufferGas = nullptr;
}
// Storing the gas pointer, if there was one
TRestAxionBufferGas* previousGas = nullptr;
if (fBufferGas) {
previousGas = fBufferGas;
fBufferGas = nullptr;
}

// We are in vacuum now
double firstMass = GammaTransmissionFWHM()/2;
// We are in vacuum now
double firstMass = GammaTransmissionFWHM() / 2;

TRestAxionBufferGas gas;
gas.SetGasDensity(gasName, 0);
AssignBufferGas(&gas); // We are in gas now
gas.SetGasDensity(gasName, 0);
AssignBufferGas(&gas); // We are in gas now

Double_t ma = firstMass;
Double_t density = gas.GetDensityForMass(firstMass);
Double_t ma = firstMass;
Double_t density = gas.GetDensityForMass(firstMass);

/// Setting mass-density pair for the first step
massDensityPairs.push_back(std::make_pair(ma, density ) );
/// Setting mass-density pair for the first step
massDensityPairs.push_back(std::make_pair(ma, density));

while (ma < maMax)
{
Double_t factor = TMath::Exp( - ma*rampDown ) + 1;
gas.SetGasDensity(gasName, density);
while (ma < maMax) {
Double_t factor = TMath::Exp(-ma * rampDown) + 1;
gas.SetGasDensity(gasName, density);

ma += GammaTransmissionFWHM()/factor;
std::cout << "Mass : " << ma << " Factor : " << factor << " FWHM: " << GammaTransmissionFWHM()/factor << std::endl;
density = gas.GetDensityForMass(ma);
ma += GammaTransmissionFWHM() / factor;
std::cout << "Mass : " << ma << " Factor : " << factor
<< " FWHM: " << GammaTransmissionFWHM() / factor << std::endl;
density = gas.GetDensityForMass(ma);

massDensityPairs.push_back(std::make_pair(ma, density ));
}
massDensityPairs.push_back(std::make_pair(ma, density));
}

// Recovering back the gas that was defined before calling this method
fBufferGas = previousGas;
Expand Down

0 comments on commit 477feb9

Please sign in to comment.