Skip to content

Commit

Permalink
style: qualifier alignment to east const
Browse files Browse the repository at this point in the history
  • Loading branch information
c-dilks committed Mar 23, 2024
1 parent e3a59bc commit 88a6a3b
Show file tree
Hide file tree
Showing 27 changed files with 84 additions and 83 deletions.
1 change: 1 addition & 0 deletions .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ BraceWrapping:
# alignment
PointerAlignment: Left
ReferenceAlignment: Left
QualifierAlignment: Right
NamespaceIndentation: All
AlignConsecutiveAssignments: true
AlignTrailingComments: false
Expand Down
4 changes: 2 additions & 2 deletions examples/iguana-example-00-basic.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ int main(int argc, char** argv)

// parse arguments
int argi = 1;
const char* inFileName = argc > argi ? argv[argi++] : "data.hipo";
const int numEvents = argc > argi ? std::stoi(argv[argi++]) : 1;
char const* inFileName = argc > argi ? argv[argi++] : "data.hipo";
int const numEvents = argc > argi ? std::stoi(argv[argi++]) : 1;

// read input file
hipo::reader reader(inFileName);
Expand Down
4 changes: 2 additions & 2 deletions examples/iguana-example-01-bank-rows.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ int main(int argc, char** argv)

// parse arguments
int argi = 1;
const char* inFileName = argc > argi ? argv[argi++] : "data.hipo";
const int numEvents = argc > argi ? std::stoi(argv[argi++]) : 1;
char const* inFileName = argc > argi ? argv[argi++] : "data.hipo";
int const numEvents = argc > argi ? std::stoi(argv[argi++]) : 1;

// read input file
hipo::reader reader(inFileName);
Expand Down
24 changes: 12 additions & 12 deletions src/iguana/algorithms/Algorithm.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ namespace iguana {
}
return val;
}
catch(const std::runtime_error& ex) {
catch(std::runtime_error const& ex) {
m_log->Error("Failed to `GetOptionScalar` for key '{}'", key);
throw std::runtime_error("config file parsing issue");
}
Expand All @@ -50,7 +50,7 @@ namespace iguana {
}
return val;
}
catch(const std::runtime_error& ex) {
catch(std::runtime_error const& ex) {
m_log->Error("Failed to `GetOptionVector` for key '{}'", key);
throw std::runtime_error("config file parsing issue");
}
Expand Down Expand Up @@ -158,19 +158,19 @@ namespace iguana {
{
if(auto it{m_option_cache.find(key)}; it != m_option_cache.end()) {
auto val = it->second;
if(const auto valPtr(std::get_if<int>(&val)); valPtr)
if(auto const valPtr(std::get_if<int>(&val)); valPtr)
return fmt::format("{} [{}]", *valPtr, "int");
else if(const auto valPtr(std::get_if<double>(&val)); valPtr)
else if(auto const valPtr(std::get_if<double>(&val)); valPtr)
return fmt::format("{} [{}]", *valPtr, "double");
else if(const auto valPtr(std::get_if<std::string>(&val)); valPtr)
else if(auto const valPtr(std::get_if<std::string>(&val)); valPtr)
return fmt::format("{:?} [{}]", *valPtr, "string");
else if(const auto valPtr(std::get_if<std::vector<int>>(&val)); valPtr)
else if(auto const valPtr(std::get_if<std::vector<int>>(&val)); valPtr)
return fmt::format("({}) [{}]", fmt::join(*valPtr, ", "), "vector<int>");
else if(const auto valPtr(std::get_if<std::vector<double>>(&val)); valPtr)
else if(auto const valPtr(std::get_if<std::vector<double>>(&val)); valPtr)
return fmt::format("({}) [{}]", fmt::join(*valPtr, ", "), "vector<double>");
else if(const auto valPtr(std::get_if<std::vector<std::string>>(&val)); valPtr) {
else if(auto const valPtr(std::get_if<std::vector<std::string>>(&val)); valPtr) {
std::vector<std::string> valQuoted;
for(const auto& s : *valPtr)
for(auto const& s : *valPtr)
valQuoted.push_back(fmt::format("{:?}", s));
return fmt::format("({}) [{}]", fmt::join(valQuoted, ", "), "vector<string>");
}
Expand Down Expand Up @@ -199,7 +199,7 @@ namespace iguana {
else
return result;
}
catch(const std::out_of_range& o) {
catch(std::out_of_range const& o) {
m_log->Error("required input bank '{}' not found; cannot `Run` algorithm '{}'", expected_bank_name, m_class_name);
auto creators = AlgorithmFactory::QueryNewBank(expected_bank_name);
if(creators)
Expand All @@ -211,7 +211,7 @@ namespace iguana {

///////////////////////////////////////////////////////////////////////////////

void Algorithm::MaskRow(hipo::bank& bank, const int row) const
void Algorithm::MaskRow(hipo::bank& bank, int const row) const
{
// TODO: need https://github.com/gavalian/hipo/issues/35
// until then, just set the PID to -1
Expand Down Expand Up @@ -282,7 +282,7 @@ namespace iguana {
try { // get the expected type
return std::get<OPTION_TYPE>(it->second);
}
catch(const std::bad_variant_access& ex) {
catch(std::bad_variant_access const& ex) {
m_log->Warn("user called SetOption for option '{}' and set it to '{}', which is the wrong type; IGNORING", key, PrintOptionValue(key));
}
}
Expand Down
10 changes: 5 additions & 5 deletions src/iguana/algorithms/Algorithm.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ namespace iguana {
if(key == "log") {
if constexpr(std::disjunction<
std::is_same<OPTION_TYPE, std::string>,
std::is_same<OPTION_TYPE, const char*>,
std::is_same<OPTION_TYPE, char const*>,
std::is_same<OPTION_TYPE, Logger::Level>>::value)
m_log->SetLevel(val);
else
Expand Down Expand Up @@ -162,7 +162,7 @@ namespace iguana {
/// Mask a row, setting all items to zero
/// @param bank the bank to modify
/// @param row the row to mask
void MaskRow(hipo::bank& bank, const int row) const;
void MaskRow(hipo::bank& bank, int const row) const;

/// Create a new bank and push it to the bank list
/// @param [out] banks the `hipo::banklist` onto which the new bank will be pushed
Expand Down Expand Up @@ -254,17 +254,17 @@ namespace iguana {
/// @param creator the creator function
/// @param new_banks if this algorithm creates *new* banks, list them here
/// @returns true if the algorithm has not yet been registered
static bool Register(const std::string& name, algo_creator_t creator, const std::vector<std::string> new_banks = {}) noexcept;
static bool Register(std::string const& name, algo_creator_t creator, const std::vector<std::string> new_banks = {}) noexcept;

/// Create an algorithm. Throws an exception if the algorithm cannot be created
/// @param name the name of the algorithm, which was used as an argument in the `AlgorithmFactory::Register` call
/// @returns the algorithm instance
static algo_t Create(const std::string& name) noexcept(false);
static algo_t Create(std::string const& name) noexcept(false);

/// Check if a bank is created by an algorithm
/// @param bank_name the name of the bank
/// @returns the list of algorithms which create it, if any
static std::optional<std::vector<std::string>> QueryNewBank(const std::string& bank_name) noexcept;
static std::optional<std::vector<std::string>> QueryNewBank(std::string const& bank_name) noexcept;

private:

Expand Down
8 changes: 4 additions & 4 deletions src/iguana/algorithms/AlgorithmFactory.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ namespace iguana {
std::unordered_map<std::string, AlgorithmFactory::algo_creator_t> AlgorithmFactory::s_creators;
std::unordered_map<std::string, std::vector<std::string>> AlgorithmFactory::s_created_banks;

bool AlgorithmFactory::Register(const std::string& name, algo_creator_t creator, const std::vector<std::string> new_banks) noexcept
bool AlgorithmFactory::Register(std::string const& name, algo_creator_t creator, const std::vector<std::string> new_banks) noexcept
{
if(auto it = s_creators.find(name); it == s_creators.end()) {
s_creators.insert({name, creator});
for(const auto& new_bank : new_banks) {
for(auto const& new_bank : new_banks) {
if(auto it = s_created_banks.find(new_bank); it == s_created_banks.end())
s_created_banks.insert({new_bank, {}});
s_created_banks.at(new_bank).push_back(name);
Expand All @@ -19,14 +19,14 @@ namespace iguana {
return false;
}

algo_t AlgorithmFactory::Create(const std::string& name)
algo_t AlgorithmFactory::Create(std::string const& name)
{
if(auto it = s_creators.find(name); it != s_creators.end())
return it->second();
throw std::runtime_error(fmt::format("AlgorithmFactory: algorithm with name {:?} does not exist", name));
}

std::optional<std::vector<std::string>> AlgorithmFactory::QueryNewBank(const std::string& bank_name) noexcept
std::optional<std::vector<std::string>> AlgorithmFactory::QueryNewBank(std::string const& bank_name) noexcept
{
if(auto it = s_created_banks.find(bank_name); it != s_created_banks.end())
return it->second;
Expand Down
10 changes: 5 additions & 5 deletions src/iguana/algorithms/AlgorithmSequence.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@ namespace iguana {

void AlgorithmSequence::Start(hipo::banklist& banks)
{
for(const auto& algo : m_sequence)
for(auto const& algo : m_sequence)
algo->Start(banks);
}
void AlgorithmSequence::Run(hipo::banklist& banks) const
{
for(const auto& algo : m_sequence)
for(auto const& algo : m_sequence)
algo->Run(banks);
}
void AlgorithmSequence::Stop()
{
for(const auto& algo : m_sequence)
for(auto const& algo : m_sequence)
algo->Stop();
}

Expand Down Expand Up @@ -49,7 +49,7 @@ namespace iguana {
void AlgorithmSequence::SetName(const std::string name)
{
// change the `m_name+"|"` prefix of each algorithm
for(const auto& algo : m_sequence) {
for(auto const& algo : m_sequence) {
auto algoName = algo->GetName();
if(auto pos{algoName.find("|")}; pos != algoName.npos)
algo->SetName(name + algoName.substr(pos));
Expand All @@ -63,7 +63,7 @@ namespace iguana {
void AlgorithmSequence::PrintSequence(Logger::Level level) const
{
m_log->Print(level, "algorithms in this sequence:");
for(const auto& algo : m_sequence)
for(auto const& algo : m_sequence)
m_log->Print(level, " - {}", algo->GetName());
}

Expand Down
2 changes: 1 addition & 1 deletion src/iguana/algorithms/clas12/EventBuilderFilter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ namespace iguana::clas12 {
}


bool EventBuilderFilter::Filter(const int pid) const
bool EventBuilderFilter::Filter(int const pid) const
{
return o_pids.find(pid) != o_pids.end();
}
Expand Down
2 changes: 1 addition & 1 deletion src/iguana/algorithms/clas12/EventBuilderFilter.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ namespace iguana::clas12 {
/// **Action function**: checks if the PDG `pid` is a part of the list of user-specified PDGs
/// @param pid the particle PDG to check
/// @returns `true` if `pid` is one the user wants
bool Filter(const int pid) const;
bool Filter(int const pid) const;

private:

Expand Down
8 changes: 4 additions & 4 deletions src/iguana/algorithms/clas12/MomentumCorrection.cc
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ namespace iguana::clas12 {
}


double MomentumCorrection::CorrectionInbending(const vector_element_t Px, const vector_element_t Py, const vector_element_t Pz, const int sec, const int pid) const
double MomentumCorrection::CorrectionInbending(const vector_element_t Px, const vector_element_t Py, const vector_element_t Pz, int const sec, int const pid) const
{

// skip the correction if it's not defined
Expand Down Expand Up @@ -241,7 +241,7 @@ namespace iguana::clas12 {
}


double MomentumCorrection::CorrectionOutbending(const vector_element_t Px, const vector_element_t Py, const vector_element_t Pz, const int sec, const int pid) const
double MomentumCorrection::CorrectionOutbending(const vector_element_t Px, const vector_element_t Py, const vector_element_t Pz, int const sec, int const pid) const
{

// skip the correction if it's not defined
Expand Down Expand Up @@ -356,7 +356,7 @@ namespace iguana::clas12 {
}


double MomentumCorrection::EnergyLossInbending(const vector_element_t Px, const vector_element_t Py, const vector_element_t Pz, const int pid) const
double MomentumCorrection::EnergyLossInbending(const vector_element_t Px, const vector_element_t Py, const vector_element_t Pz, int const pid) const
{

// The following code is for the Energy Loss Corrections for the proton
Expand All @@ -378,7 +378,7 @@ namespace iguana::clas12 {
}


double MomentumCorrection::EnergyLossOutbending(const vector_element_t Px, const vector_element_t Py, const vector_element_t Pz, const int pid) const
double MomentumCorrection::EnergyLossOutbending(const vector_element_t Px, const vector_element_t Py, const vector_element_t Pz, int const pid) const
{

// The following code is for the Energy Loss Corrections for the proton
Expand Down
8 changes: 4 additions & 4 deletions src/iguana/algorithms/clas12/MomentumCorrection.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ namespace iguana::clas12 {
/// @param sec the sector
/// @param pid the particle PDG
/// @returns the correction factor
double CorrectionInbending(const vector_element_t Px, const vector_element_t Py, const vector_element_t Pz, const int sec, const int pid) const;
double CorrectionInbending(const vector_element_t Px, const vector_element_t Py, const vector_element_t Pz, int const sec, int const pid) const;

/// Calculate the correction factor for outbending data
/// @param Px @f$p_x@f$
Expand All @@ -46,23 +46,23 @@ namespace iguana::clas12 {
/// @param sec the sector
/// @param pid the particle PDG
/// @returns the correction factor
double CorrectionOutbending(const vector_element_t Px, const vector_element_t Py, const vector_element_t Pz, const int sec, const int pid) const;
double CorrectionOutbending(const vector_element_t Px, const vector_element_t Py, const vector_element_t Pz, int const sec, int const pid) const;

/// Energy loss correction for inbending data
/// @param Px @f$p_x@f$
/// @param Py @f$p_y@f$
/// @param Pz @f$p_z@f$
/// @param pid the particle PDG
/// @returns the correction factor
double EnergyLossInbending(const vector_element_t Px, const vector_element_t Py, const vector_element_t Pz, const int pid) const;
double EnergyLossInbending(const vector_element_t Px, const vector_element_t Py, const vector_element_t Pz, int const pid) const;

/// Energy loss correction for outbending data
/// @param Px @f$p_x@f$
/// @param Py @f$p_y@f$
/// @param Pz @f$p_z@f$
/// @param pid the particle PDG
/// @returns the correction factor
double EnergyLossOutbending(const vector_element_t Px, const vector_element_t Py, const vector_element_t Pz, const int pid) const;
double EnergyLossOutbending(const vector_element_t Px, const vector_element_t Py, const vector_element_t Pz, int const pid) const;

private:

Expand Down
6 changes: 3 additions & 3 deletions src/iguana/algorithms/clas12/MomentumCorrectionValidator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ namespace iguana::clas12 {

// define plots
gStyle->SetOptStat(0);
for(const auto& pdg : u_pdg_list) {
for(auto const& pdg : u_pdg_list) {
std::vector<TH2D*> deltaPvsP;
TString particle_name = particle::name.at(particle::PDG(pdg));
TString particle_title = particle::title.at(particle::PDG(pdg));
Expand Down Expand Up @@ -96,14 +96,14 @@ namespace iguana::clas12 {
void MomentumCorrectionValidator::Stop()
{
if(GetOutputDirectory()) {
for(const auto& [pdg, plots] : u_deltaPvsP) {
for(auto const& [pdg, plots] : u_deltaPvsP) {
int n_cols = 3;
int n_rows = 2;
TString canv_name = Form("canv%d", pdg);
auto canv = new TCanvas(canv_name, canv_name, n_cols * 800, n_rows * 600);
canv->Divide(n_cols, n_rows);
int pad_num = 0;
for(const auto& plot : plots) {
for(auto const& plot : plots) {
auto pad = canv->GetPad(++pad_num);
pad->cd();
pad->SetGrid(1, 1);
Expand Down
6 changes: 3 additions & 3 deletions src/iguana/algorithms/clas12/MomentumCorrectionValidator.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ namespace iguana::clas12 {

std::unique_ptr<SectorFinder> m_sector_finder;

const double m_p_max = 12.0;
const double m_deltaP_max = 1.0;
const double m_deltaP_zoom = 0.2;
double const m_p_max = 12.0;
double const m_deltaP_max = 1.0;
double const m_deltaP_zoom = 0.2;

const std::vector<int> u_pdg_list = {
particle::PDG::electron,
Expand Down
12 changes: 6 additions & 6 deletions src/iguana/algorithms/clas12/SectorFinder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ namespace iguana::clas12 {
{
}

int SectorFinder::GetSector(const hipo::bank& bank, const int pindex) const
int SectorFinder::GetSector(hipo::bank const& bank, int const pindex) const
{
int sector = 0;
for(int row = 0; row < bank.getRows(); row++) {
Expand All @@ -46,11 +46,11 @@ namespace iguana::clas12 {
std::vector<int> SectorFinder::Find(hipo::banklist& banks) const
{
std::vector<int> sectors;
const auto& particleBank = GetBank(banks, b_particle, "REC::Particle");
auto const& particleBank = GetBank(banks, b_particle, "REC::Particle");

// filter the input bank for requested PDG code(s)
if(userSpecifiedBank) { // if user specified a specific bank
const auto& userBank = GetBank(banks, b_user);
auto const& userBank = GetBank(banks, b_user);
for(int row = 0; row < particleBank.getRows(); row++) {
if(userBank.getRows() > 0) {
sectors.push_back(GetSector(userBank, row));
Expand All @@ -62,9 +62,9 @@ namespace iguana::clas12 {
}
}
else { // use the standard method
const auto& calBank = GetBank(banks, b_calorimeter);
const auto& scintBank = GetBank(banks, b_scint);
const auto& trackBank = GetBank(banks, b_track);
auto const& calBank = GetBank(banks, b_calorimeter);
auto const& scintBank = GetBank(banks, b_scint);
auto const& trackBank = GetBank(banks, b_track);
for(int row = 0; row < particleBank.getRows(); row++) {
int trackSector = 0;
if(trackBank.getRows() > 0) {
Expand Down
2 changes: 1 addition & 1 deletion src/iguana/algorithms/clas12/SectorFinder.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ namespace iguana::clas12 {
/// @param bank bank to get sector from
/// @param pindex index in bank for which to get sector
/// @returns sector for pindex in bank
int GetSector(const hipo::bank& bank, const int pindex) const;
int GetSector(hipo::bank const& bank, int const pindex) const;

private:

Expand Down
2 changes: 1 addition & 1 deletion src/iguana/algorithms/clas12/ZVertexFilter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ namespace iguana::clas12 {
ShowBank(particleBank, Logger::Header("OUTPUT PARTICLES"));
}

bool ZVertexFilter::Filter(const double zvertex) const
bool ZVertexFilter::Filter(double const zvertex) const
{
return zvertex > GetZcutLower() && zvertex < GetZcutUpper();
}
Expand Down
Loading

0 comments on commit 88a6a3b

Please sign in to comment.