Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions examples/programs/D3piTest.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,10 @@ int main( int argc, char** argv)

// std::cout << "\nHelicity angle symmetrizations with " << M.helicityAngles()->maxSymmetrizationIndex() + 1 << " indices \n";

D->printDecayChain();
std::cout << "\n";
LOG(INFO) << D->decayChainAsString();

std::cout << *M.spinAmplitudeCache() << std::endl;
M.printDataAccessors(false);
LOG(INFO) << *M.spinAmplitudeCache() << std::endl;
LOG(INFO) << data_accessors_as_string(M, false);

// get default Dalitz axes
auto massAxes = M.massAxes();
Expand All @@ -136,8 +135,7 @@ int main( int argc, char** argv)
data.push_back(P);
}

LOG(INFO) << "AFTER";
M.fourMomenta()->printMasses(data[0]);
LOG(INFO) << masses_as_string(*M.fourMomenta(), data[0]);

for (auto p : M.fourMomenta()->finalStateMomenta(data[0]))
LOG(INFO) << p;
Expand Down Expand Up @@ -174,7 +172,7 @@ int main( int argc, char** argv)
[](const std::string & s, const std::complex<double>& c)
{ return s + "\t" + std::to_string(real(c)) + " + " + std::to_string(imag(c));}).erase(0, 1);

LOG(INFO) << M.initialStateParticle()->printDecayTrees();
LOG(INFO) << to_string(M.initialStateParticle()->decayTrees());

LOG(INFO) << "alright!";
}
10 changes: 5 additions & 5 deletions examples/programs/D4piTest.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "DataPoint.h"
#include "DataSet.h"
#include "DecayChannel.h"
#include "DecayTree.h"
#include "FinalStateParticle.h"
#include "FourMomenta.h"
#include "FourVector.h"
Expand Down Expand Up @@ -112,11 +113,10 @@ int main( int argc, char** argv)
for (auto& pc_i : M.helicityAngles()->symmetrizationIndices())
std::cout << *pc_i.first << ": " << pc_i.second << "\n";

D->printDecayChain();
std::cout << "\n";
LOG(INFO) << D->decayChainAsString();

std::cout << *M.spinAmplitudeCache() << std::endl;
M.printDataAccessors(false);
LOG(INFO) << *M.spinAmplitudeCache() << std::endl;
LOG(INFO) << data_accessors_as_string(M, false);

LOG(INFO) << "create dataPoints";

Expand Down Expand Up @@ -231,7 +231,7 @@ int main( int argc, char** argv)
*/


LOG(INFO) << D->printDecayTrees();
LOG(INFO) << to_string(M.initialStateParticle()->decayTrees());

std::cout << "alright! \n";
}
11 changes: 5 additions & 6 deletions examples/programs/DKKpiTest.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,10 @@ int main( int argc, char** argv)

std::cout << "\nHelicity angle symmetrizations with " << M.helicityAngles()->nSymmetrizationIndices() << " indices \n";

D->printDecayChain();
std::cout << "\n";
LOG(INFO) << D->decayChainAsString();

std::cout << *M.spinAmplitudeCache() << std::endl;
M.printDataAccessors(false);
LOG(INFO) << *M.spinAmplitudeCache() << std::endl;
LOG(INFO) << data_accessors_as_string(M, false);

// choose default Dalitz coordinates
const yap::MassAxes massAxes = M.massAxes();
Expand All @@ -79,7 +78,7 @@ int main( int argc, char** argv)
auto data = M.createDataSet(1);

DEBUG("BEFORE");
M.fourMomenta()->printMasses(data[0]);
DEBUG(masses_as_string(*M.fourMomenta(), data[0]));

LOG(INFO) << "setting squared mass ...";
auto P = M.calculateFourMomenta(massAxes, m2, D);
Expand All @@ -91,7 +90,7 @@ int main( int argc, char** argv)
}

DEBUG("AFTER");
M.fourMomenta()->printMasses(data[0]);
DEBUG(masses_as_string(*M.fourMomenta(), data[0]));

std::cout << "alright! \n";
}
6 changes: 5 additions & 1 deletion include/CachedDataValue.h
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,12 @@ inline bool operator==(const CachedDataValue::Status& S, const VariableStatus& s
inline bool operator!=(const CachedDataValue::Status& S, const VariableStatus& s)
{ return S.Variable != s; }

/// to_string for CachedDataValue::Status
std::string to_string(const CachedDataValue::Status& S);

/// streaming operator for CachedDataValue::Status
std::ostream& operator<<(std::ostream& str, const CachedDataValue::Status& S);
inline std::ostream& operator<<(std::ostream& str, const CachedDataValue::Status& S)
{ return str << to_string(S); }

/// \class RealCachedDataValue
/// \brief Class for managing a single real cached value inside a #DataPoint
Expand Down
11 changes: 7 additions & 4 deletions include/CalculationStatus.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,21 @@ enum class CalculationStatus : bool {
uncalculated = false
};

inline std::ostream& operator<<(std::ostream& str, const CalculationStatus& c)
inline std::string to_string(const CalculationStatus& c)
{
switch (c) {
case CalculationStatus::calculated:
return str << "calculated";
return "calculated";
case CalculationStatus::uncalculated:
return str << "uncalculated";
return "uncalculated";
default:
return str << (int) c;
return std::to_string(static_cast<int>(c));
}
}

inline std::ostream& operator<<(std::ostream& str, const CalculationStatus& c)
{ return str << to_string(c); }

}

#endif
3 changes: 0 additions & 3 deletions include/DataAccessor.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,6 @@ class DataAccessor
const unsigned nSymmetrizationIndices() const
{ return NIndices_; }

/// print ParticleCombination map
void printParticleCombinations() const;

/// \return CachedDataValueSet
const CachedDataValueSet& cachedDataValues() const
{ return CachedDataValues_; }
Expand Down
3 changes: 3 additions & 0 deletions include/DecayTree.h
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,9 @@ FreeAmplitudeSet freeAmplitudes(const DecayTreeVector& DTV);
/// \param vector of trees to check in
const DecayTreeVector select_changed(const DecayTreeVector& dtv);

/// \return map of spin projections to decayTrees as string
std::string to_string(const std::map<int, DecayTreeVector>& decayTrees);

}

#endif
10 changes: 4 additions & 6 deletions include/DecayingParticle.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,15 +130,13 @@ class DecayingParticle : public Particle

/// @}

/// Print complete decay chain
void printDecayChain() const
{ printDecayChainLevel(0); }
/// \return complete decay chain as (multiline) string
std::string decayChainAsString() const
{ return decayChainLevelAsString(0); }

/// \return raw pointer to Model through first DecayChannel
const Model* model() const override;

std::string printDecayTrees() const;

/// grant friend status to DecayChannel to call fixSolitaryFreeAmplitudes()
/// and storeBlattWeisskopf()
friend DecayChannel;
Expand All @@ -165,7 +163,7 @@ class DecayingParticle : public Particle
/// if only one decay channel is available, fix its free amplitude to the current value
void fixSolitaryFreeAmplitudes();

void printDecayChainLevel(int level) const;
std::string decayChainLevelAsString(int level) const;

/// modify a DecayTree
/// \param dt DecayTree to modify
Expand Down
6 changes: 3 additions & 3 deletions include/FourMomenta.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,6 @@ class FourMomenta : public StaticDataAccessor

/// @}

/// print all masses
std::ostream& printMasses(const DataPoint& d, std::ostream& os = std::cout) const;

/// grant friend status to Model to call addParticleCombination and setFinalStateMomenta
friend class Model;

Expand Down Expand Up @@ -138,6 +135,9 @@ class FourMomenta : public StaticDataAccessor

};

/// \return all masses as (multiline) string
std::string masses_as_string(const FourMomenta& fm, const DataPoint& d);

}
#endif

14 changes: 8 additions & 6 deletions include/Model.h
Original file line number Diff line number Diff line change
Expand Up @@ -209,12 +209,6 @@ class Model
/// Set VariableStatus'es of all Parameter's to unchanged, or leave as fixed
void setParameterFlagsToUnchanged();

/// Print the list of DataAccessor's
void printDataAccessors(bool printParticleCombinations = true) const;

/// Print all VariableStatus'es and CalculationStatus'es
void printFlags(const StatusManager& sm) const;

/// grant friend status to DataAccessor to register itself with this
friend class DataAccessor;

Expand Down Expand Up @@ -294,6 +288,14 @@ const double sumOfLogsOfSquaredAmplitudes(const Model& M, DataPartition& D);
/// \param DP DataPartitionVector of partitions to use
const double sumOfLogsOfSquaredAmplitudes(const Model& M, DataPartitionVector& DP);

/// \return the list of DataAccessor's as (multiline) string
/// \param m Model to print DataAccessor's of
/// \param printParticleCombinations also print ParticleCombination's of each DataAccessor
std::string data_accessors_as_string(const Model& m, bool printParticleCombinations = true);

/// \return all VariableStatus'es and CalculationStatus'es as (multiline) string
std::string flags_as_string(const Model& m, const StatusManager& sm);

}

#endif
13 changes: 12 additions & 1 deletion include/ParticleCombination.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ class ParticleCombination : public std::enable_shared_from_this<ParticleCombinat
ParticleCombination() = default;

/// Final-state-particle constructor, see ParticleCombinationCache::fsp for details
ParticleCombination(unsigned index) : Indices_(1, index) {}
explicit ParticleCombination(unsigned index) : Indices_(1, index) {}

/// Copy constructor is deleted
ParticleCombination(const ParticleCombination&) = delete;
Expand Down Expand Up @@ -236,6 +236,17 @@ std::string to_string(const ParticleCombination& pc);
/// convert ParticleCombination with top-most parent to string
std::string to_string_with_parent(const ParticleCombination& pc);

/// convert ParticleCombinationMap to string
template<typename T>
inline std::string to_string(const ParticleCombinationMap<T>& pcm)
{
std::string s;
using std::to_string;
for (auto& kv : pcm)
s += to_string(kv.second) + " : " + to_string_with_parent(*(kv.first));
return s;
}

/// streamer
inline std::ostream& operator<<(std::ostream& os, const ParticleCombination& PC)
{ os << to_string(PC); return os; }
Expand Down
13 changes: 8 additions & 5 deletions include/VariableStatus.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,20 +30,23 @@ enum class VariableStatus : int {
unchanged = +1, ///< Parameter is free but has not been changed
};

inline std::ostream& operator<<(std::ostream& str, const VariableStatus& s)
inline std::string to_string(const VariableStatus& s)
{
switch (s) {
case VariableStatus::changed:
return str << "changed";
return "changed";
case VariableStatus::fixed:
return str << "fixed";
return "fixed";
case VariableStatus::unchanged:
return str << "unchanged";
return "unchanged";
default:
return str << (int) s;
return std::to_string(static_cast<int>(s));
}
}

inline std::ostream& operator<<(std::ostream& str, const VariableStatus& c)
{ return str << to_string(c); }

}

#endif
4 changes: 2 additions & 2 deletions src/CachedDataValue.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ CachedDataValue::Status& CachedDataValue::Status::operator=(const VariableStatus
}

//-------------------------
std::ostream& operator<<(std::ostream& str, const CachedDataValue::Status& S)
std::string to_string(const CachedDataValue::Status& S)
{
return str << S.Calculation << ", " << S.Variable;
return to_string(S.Calculation) + ", " + to_string(S.Variable);
}

//-------------------------
Expand Down
7 changes: 0 additions & 7 deletions src/DataAccessor.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,6 @@ DataAccessor::DataAccessor(const ParticleCombination::Equal& equal) :
{
}

//-------------------------
void DataAccessor::printParticleCombinations() const
{
for (auto& kv : SymmetrizationIndices_)
LOG(INFO) << kv.second << " : " << to_string_with_parent(*(kv.first));
}

//-------------------------
bool DataAccessor::consistent() const
{
Expand Down
11 changes: 11 additions & 0 deletions src/DecayTree.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -176,4 +176,15 @@ const DecayTreeVector select_changed(const DecayTreeVector& dtv)
return C;
}

//-------------------------
std::string to_string(const std::map<int, DecayTreeVector>& decayTrees)
{
std::string s;
for (const auto& m_dtv : decayTrees) {
for (const auto& dt : m_dtv.second)
s += "\ndepth = " + std::to_string(depth(*dt)) + "\n" + dt->asString() + "\n";
}
return s;
}

}
Loading