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 Feb 12, 2024
1 parent 68f296f commit d8ec95b
Show file tree
Hide file tree
Showing 8 changed files with 56 additions and 55 deletions.
9 changes: 4 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -188,18 +188,17 @@ else ()
set(REST_MPFR OFF)
endif (${REST_MPFR} MATCHES "ON")

#### GSL ####
# Find GSL
# GSL #### Find GSL
find_package(GSL REQUIRED)

# Include GSL directories
set(external_include_dirs ${external_include_dirs} ${GSL_INCLUDE_DIRS})

# Link GSL libraries
set(external_libs ${external_libs};${GSL_LIBRARIES} )
set(external_libs ${external_libs};${GSL_LIBRARIES})

message ( STATUS "Found GSL libraries : ${GSL_LIBRARIES}")
message ( STATUS "GSL headers : ${GSL_INCLUDE_DIRS}")
message(STATUS "Found GSL libraries : ${GSL_LIBRARIES}")
message(STATUS "GSL headers : ${GSL_INCLUDE_DIRS}")

# CURL #####
find_library(CURL_LIB curl)
Expand Down
12 changes: 1 addition & 11 deletions source/framework/core/inc/TRestSystemOfUnits.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,7 @@
namespace REST_Units {

// We use more common physics units instead of SI unit
enum Physical_Unit {
Energy,
Time,
Length,
Mass,
Voltage,
MagneticField,
Pressure,
Angle,
NOT_A_UNIT = -1
};
enum Physical_Unit { Energy, Time, Length, Mass, Voltage, MagneticField, Pressure, Angle, NOT_A_UNIT = -1 };

class TRestSystemOfUnits {
private:
Expand Down
22 changes: 14 additions & 8 deletions source/framework/core/src/TRestMetadata.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -1168,9 +1168,10 @@ void TRestMetadata::ReplaceForLoopVars(TiXmlElement* e, map<string, string> forL
}
}

e->SetAttribute(name, ReplaceMathematicalExpressions(outputBuffer, 0,
"Please, check parameter name: " + parName +
" (ReplaceForLoopVars)").c_str());
e->SetAttribute(name, ReplaceMathematicalExpressions(
outputBuffer, 0,
"Please, check parameter name: " + parName + " (ReplaceForLoopVars)")
.c_str());
}

attr = attr->Next();
Expand Down Expand Up @@ -1327,7 +1328,8 @@ void TRestMetadata::ExpandIncludeFile(TiXmlElement* e) {
TiXmlElement* ele = GetElementFromFile(filename);
if (ele == nullptr) {
RESTError << "TRestMetadata::ExpandIncludeFile. No xml elements contained in the include "
"file \"" << filename << "\"" << RESTendl;
"file \""
<< filename << "\"" << RESTendl;
exit(1);
}
while (ele != nullptr) {
Expand Down Expand Up @@ -1409,7 +1411,8 @@ void TRestMetadata::ExpandIncludeFile(TiXmlElement* e) {

if (remoteele == nullptr) {
RESTWarning << "Cannot find the needed xml section in "
"include file!" << RESTendl;
"include file!"
<< RESTendl;
RESTWarning << "type: \"" << type << "\" , name: \"" << name << "\" . Skipping"
<< RESTendl;
RESTWarning << RESTendl;
Expand Down Expand Up @@ -2292,7 +2295,8 @@ TString TRestMetadata::GetLibraryVersion() { return fLibraryVersion; }
void TRestMetadata::ReSetVersion() {
if (!this->InheritsFrom("TRestRun"))
RESTError << "version is a static value, you cannot set version "
"for a class!" << RESTendl;
"for a class!"
<< RESTendl;
else {
fVersion = REST_RELEASE;
}
Expand All @@ -2304,7 +2308,8 @@ void TRestMetadata::ReSetVersion() {
void TRestMetadata::UnSetVersion() {
if (!this->InheritsFrom("TRestRun"))
RESTError << "version is a static value, you cannot set version "
"for a class!" << RESTendl;
"for a class!"
<< RESTendl;
else {
fVersion = -1;
fCommit = -1;
Expand Down Expand Up @@ -2571,7 +2576,8 @@ void TRestMetadata::ReadOneParameter(string name, string value) {
} else {
RESTWarning << this->ClassName() << " find unit definition in parameter: " << name
<< ", but the corresponding data member doesn't support it. Data "
"member type: " << datamember.type << RESTendl;
"member type: "
<< datamember.type << RESTendl;
datamember.ParseString(value);
}
} else {
Expand Down
18 changes: 11 additions & 7 deletions source/framework/sensitivity/src/TRestComponent.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,8 @@ ROOT::RVecD TRestComponent::GetRandom() {
if (!GetDensity()) {
for (size_t n = 0; n < GetDimensions(); n++) result.push_back(0);
RESTWarning << "TRestComponent::GetRandom. Component might not be initialized! Use "
"TRestComponent::Initialize()." << RESTendl;
"TRestComponent::Initialize()."
<< RESTendl;
return result;
}

Expand Down Expand Up @@ -346,10 +347,11 @@ ROOT::RDF::RNode TRestComponent::GetMonteCarloDataFrame(Int_t N) {
/* Excluding Rndm from df */
std::vector<std::string> columns = df.GetColumnNames();
std::vector<std::string> excludeColumns = {"Rndm"};
columns.erase(std::remove_if(columns.begin(), columns.end(), [&excludeColumns](std::string elem) {
return std::find(excludeColumns.begin(), excludeColumns.end(), elem) !=
excludeColumns.end();
}),
columns.erase(std::remove_if(columns.begin(), columns.end(),
[&excludeColumns](std::string elem) {
return std::find(excludeColumns.begin(), excludeColumns.end(), elem) !=
excludeColumns.end();
}),
columns.end());

std::string user = getenv("USER");
Expand All @@ -375,13 +377,15 @@ TCanvas* TRestComponent::DrawComponent(std::vector<std::string> drawVariables,
TString drawOption) {
if (drawVariables.size() > 2 || drawVariables.size() == 0) {
RESTError << "TRestComponent::DrawComponent. The number of variables to be drawn must "
"be 1 or 2!" << RESTendl;
"be 1 or 2!"
<< RESTendl;
return fCanvas;
}

if (scanVariables.size() > 2 || scanVariables.size() == 0) {
RESTError << "TRestComponent::DrawComponent. The number of variables to be scanned must "
"be 1 or 2!" << RESTendl;
"be 1 or 2!"
<< RESTendl;
return fCanvas;
}

Expand Down
3 changes: 1 addition & 2 deletions source/framework/sensitivity/src/TRestComponentDataSet.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,6 @@ void TRestComponentDataSet::FillHistograms() {
/// different random sample.
///
void TRestComponentDataSet::RegenerateActiveNodeDensity() {

if (fActiveNode >= 0 && fNodeDensity[fActiveNode]) {
delete fNodeDensity[fActiveNode];
} else {
Expand Down Expand Up @@ -434,7 +433,7 @@ std::vector<Int_t> TRestComponentDataSet::ExtractNodeStatistics() {
nEv = fDataSet.GetDataFrame().Filter(filter).Range(fSamples).Count();
}

if ((Int_t) * nEv < fSamples) {
if ((Int_t)*nEv < fSamples) {
RESTWarning << "The number of requested samples (" << fSamples
<< ") is higher than the number of dataset entries (" << *nEv << ")" << RESTendl;
}
Expand Down
12 changes: 7 additions & 5 deletions source/framework/sensitivity/src/TRestExperiment.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,8 @@ void TRestExperiment::SetExperimentalDataSet(const std::string& filename) {

if (!fSignal || !fBackground) {
RESTWarning << "TRestExperiment::SetExperimentalDataSet. Signal and background components must "
"be available before atempt to load experimental data" << RESTendl;
"be available before atempt to load experimental data"
<< RESTendl;
fDataReady = false;
return;
}
Expand All @@ -133,7 +134,8 @@ void TRestExperiment::SetExperimentalDataSet(const std::string& filename) {
for (const auto& v : fSignal->GetVariables()) {
if (std::find(columns.begin(), columns.end(), v) == columns.end()) {
RESTError << "TRestExperiment::SetExperimentalDataSetFile a component variable was not found in "
"the dataset!" << RESTendl;
"the dataset!"
<< RESTendl;
fDataReady = false;
return;
}
Expand Down Expand Up @@ -261,9 +263,9 @@ void TRestExperiment::PrintMetadata() {
RESTMetadata << "Random seed : " << fSeed << RESTendl;
RESTMetadata << " " << RESTendl;
if (fExposureTime > 0) {
RESTMetadata << " - Exposure time : " << fExposureTime* units("s") << " seconds" << RESTendl;
RESTMetadata << " - Exposure time : " << fExposureTime* units("hr") << " hours" << RESTendl;
RESTMetadata << " - Exposure time : " << fExposureTime* units("day") << " days" << RESTendl;
RESTMetadata << " - Exposure time : " << fExposureTime * units("s") << " seconds" << RESTendl;
RESTMetadata << " - Exposure time : " << fExposureTime * units("hr") << " hours" << RESTendl;
RESTMetadata << " - Exposure time : " << fExposureTime * units("day") << " days" << RESTendl;
}

if (fSignal) RESTMetadata << " - Signal component : " << fSignal->GetName() << RESTendl;
Expand Down
6 changes: 4 additions & 2 deletions source/framework/sensitivity/src/TRestExperimentList.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,8 @@ void TRestExperimentList::InitFromConfigFile() {

if (nExpectedColumns == 0) {
RESTError << "TRestExperimentList::InitFromConfigFile. At least one free parameter required! "
"(Exposure/Background/Signal)" << RESTendl;
"(Exposure/Background/Signal)"
<< RESTendl;
return;
}

Expand All @@ -134,7 +135,8 @@ void TRestExperimentList::InitFromConfigFile() {
}

RESTError << "TRestExperimentList::InitFromConfigFile. Number of expected columns does not match "
"the number of table columns" << RESTendl;
"the number of table columns"
<< RESTendl;
RESTError << "Number of table columns : " << nTableColumns << RESTendl;
RESTError << "Number of expected columns : " << nExpectedColumns << RESTendl;
RESTError << "Expected columns : " << expectedColumns << RESTendl;
Expand Down
29 changes: 14 additions & 15 deletions source/framework/sensitivity/src/TRestSensitivity.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ TRestSensitivity::~TRestSensitivity() {}
/// \param name The name of the specific metadata. It will be used to find the
/// corresponding TRestAxionMagneticField section inside the RML.
///
TRestSensitivity::TRestSensitivity(const char *cfgFileName, const std::string &name)
TRestSensitivity::TRestSensitivity(const char* cfgFileName, const std::string& name)
: TRestMetadata(cfgFileName) {
LoadConfigFromFile(fConfigFileName, name);
}
Expand All @@ -92,7 +92,7 @@ Double_t TRestSensitivity::ApproachByFactor(Double_t g4, Double_t chi0, Double_t
Double_t Chi2 = 0;
do {
Chi2 = 0;
for (const auto &exp : fExperiments) Chi2 += -2 * UnbinnedLogLikelihood(exp, g4);
for (const auto& exp : fExperiments) Chi2 += -2 * UnbinnedLogLikelihood(exp, g4);

g4 = factor * g4;
} while (Chi2 - chi0 < target);
Expand All @@ -101,7 +101,7 @@ Double_t TRestSensitivity::ApproachByFactor(Double_t g4, Double_t chi0, Double_t
/// Coarse movement to get to Chi2 below target (/2)
do {
Chi2 = 0;
for (const auto &exp : fExperiments) Chi2 += -2 * UnbinnedLogLikelihood(exp, g4);
for (const auto& exp : fExperiments) Chi2 += -2 * UnbinnedLogLikelihood(exp, g4);

g4 = g4 / factor;
} while (Chi2 - chi0 > target);
Expand All @@ -114,7 +114,7 @@ Double_t TRestSensitivity::ApproachByFactor(Double_t g4, Double_t chi0, Double_t
///
Double_t TRestSensitivity::GetCoupling(Double_t sigma, Double_t precision) {
Double_t Chi2_0 = 0;
for (const auto &exp : fExperiments) Chi2_0 += -2 * UnbinnedLogLikelihood(exp, 0);
for (const auto& exp : fExperiments) Chi2_0 += -2 * UnbinnedLogLikelihood(exp, 0);

Double_t target = sigma * sigma;

Expand All @@ -131,7 +131,7 @@ Double_t TRestSensitivity::GetCoupling(Double_t sigma, Double_t precision) {
///////////////////////////////////////////////
/// \brief It returns the Log(L) for the experiment and coupling given by argument.
///
Double_t TRestSensitivity::UnbinnedLogLikelihood(const TRestExperiment *experiment, Double_t g4) {
Double_t TRestSensitivity::UnbinnedLogLikelihood(const TRestExperiment* experiment, Double_t g4) {
Double_t lhood = 0;
if (!experiment->IsDataReady()) {
RESTError << "TRestSensitivity::UnbinnedLogLikelihood. Experiment " << experiment->GetName()
Expand All @@ -146,7 +146,7 @@ Double_t TRestSensitivity::UnbinnedLogLikelihood(const TRestExperiment *experime
if (ROOT::IsImplicitMTEnabled()) ROOT::DisableImplicitMT();

std::vector<std::vector<Double_t>> trackingData;
for (const auto &var : experiment->GetSignal()->GetVariables()) {
for (const auto& var : experiment->GetSignal()->GetVariables()) {
auto values = experiment->GetExperimentalDataFrame().Take<Double_t>(var);
std::vector<Double_t> vDbl = std::move(*values);
trackingData.push_back(vDbl);
Expand All @@ -169,11 +169,10 @@ Double_t TRestSensitivity::UnbinnedLogLikelihood(const TRestExperiment *experime
///////////////////////////////////////////////
/// \brief
///
TH1D *TRestSensitivity::SignalStatisticalTest(Int_t N) {

TH1D* TRestSensitivity::SignalStatisticalTest(Int_t N) {
std::vector<Double_t> couplings;
for (int n = 0; n < N; n++) {
for (const auto &exp : fExperiments) exp->GetSignal()->RegenerateActiveNodeDensity();
for (const auto& exp : fExperiments) exp->GetSignal()->RegenerateActiveNodeDensity();

Double_t coupling = TMath::Sqrt(TMath::Sqrt(GetCoupling()));
couplings.push_back(coupling);
Expand All @@ -185,7 +184,7 @@ TH1D *TRestSensitivity::SignalStatisticalTest(Int_t N) {

if (fSignalTest) delete fSignalTest;
fSignalTest = new TH1D("SignalTest", "A signal test", 100, 0.9 * min_value, 1.1 * max_value);
for (const auto &coup : couplings) fSignalTest->Fill(coup);
for (const auto& coup : couplings) fSignalTest->Fill(coup);

return fSignalTest;
}
Expand All @@ -197,18 +196,18 @@ void TRestSensitivity::InitFromConfigFile() {
TRestMetadata::InitFromConfigFile();

int cont = 0;
TRestMetadata *metadata = (TRestMetadata *)this->InstantiateChildMetadata(cont, "Experiment");
TRestMetadata* metadata = (TRestMetadata*)this->InstantiateChildMetadata(cont, "Experiment");
while (metadata != nullptr) {
cont++;
if (metadata->InheritsFrom("TRestExperimentList")) {
TRestExperimentList *experimentsList = (TRestExperimentList *)metadata;
std::vector<TRestExperiment *> exList = experimentsList->GetExperiments();
TRestExperimentList* experimentsList = (TRestExperimentList*)metadata;
std::vector<TRestExperiment*> exList = experimentsList->GetExperiments();
fExperiments.insert(fExperiments.end(), exList.begin(), exList.end());
} else if (metadata->InheritsFrom("TRestExperiment")) {
fExperiments.push_back((TRestExperiment *)metadata);
fExperiments.push_back((TRestExperiment*)metadata);
}

metadata = (TRestMetadata *)this->InstantiateChildMetadata(cont, "Experiment");
metadata = (TRestMetadata*)this->InstantiateChildMetadata(cont, "Experiment");
}

Initialize();
Expand Down

0 comments on commit d8ec95b

Please sign in to comment.