71 static int dbg(
int setDbg =-1) {
83 using Map =
typename std::map<Name,Value>;
85 using Entry =
typename Map::value_type;
89 std::ostringstream sout;
90 sout << m_ent.first <<
": " << m_ent.second;
98 using Value =
typename std::vector<T>;
99 using Map =
typename std::map<Name,Value>;
101 using Entry =
typename Map::value_type;
105 std::ostringstream sout;
106 sout << m_ent.first <<
"[" << m_ent.second.size() <<
"]";
138 if ( own && ph !=
nullptr ) {
139 ph->SetDirectory(
nullptr);
144 if ( ph !=
nullptr )
setHist(ph->GetName(), ph, own);
147 m_hsts[ph->GetName()] = ph.get();
151 const std::string myname =
"DataMap::setHistVector: ";
154 for ( TH1* ph : hsts ) {
157 if ( phShared.get() == ph ) {
158 std::cout << myname <<
"Ignoring duplicate attempt to manage a histogram." <<
std::endl;
164 ph->SetDirectory(
nullptr);
165 m_sharedHsts.push_back(std::shared_ptr<TH1>(ph));
171 const std::string myname =
"DataMap::setHistVector: ";
182 if ( pg !=
nullptr )
setGraph(pg->GetName(), pg);
240 for ( HistMap::value_type ihst :
m_hsts ) hsts.push_back(ihst.second);
245 void print(std::ostream* pout)
const {
249 if ( pout ==
nullptr )
return;
250 std::ostream& sout = *pout;
255 for (
typename IntMap::value_type ient :
m_ints ) {
256 sout <<
prefix <<
" " << ient.first <<
": " << ient.second <<
endl;
262 for (
typename IntVectorMap::value_type ient :
m_intvecs ) {
263 unsigned nval = ient.second.size();
264 sout <<
prefix <<
" " << ient.first <<
"[" << nval <<
"]:";
265 for (
unsigned int ival=0; ival<nval; ++ival ) {
266 if ( ival ) sout <<
",";
267 sout <<
" " << ient.second[ival];
268 if ( ival > maxval ) {
278 for (
typename FloatMap::value_type ient :
m_flts ) {
279 sout <<
prefix <<
" " << ient.first <<
": " << ient.second <<
endl;
285 for (
typename FloatVectorMap::value_type ient :
m_fltvecs ) {
286 unsigned nval = ient.second.size();
287 sout <<
prefix <<
" " << ient.first <<
"[" << nval <<
"]:";
288 for (
unsigned int ival=0; ival<nval; ++ival ) {
289 if ( ival ) sout <<
",";
290 sout <<
" " << ient.second[ival];
291 if ( ival > maxval ) {
301 for (
typename StringMap::value_type ient :
m_strs ) {
302 sout <<
prefix <<
" " << ient.first <<
": " << ient.second <<
endl;
307 for (
typename HistMap::value_type ient :
m_hsts ) {
308 TH1* ph = ient.second;
310 sout <<
prefix <<
" " << ient.first <<
": " << ph <<
endl;
314 sout <<
prefix <<
"Histogram vectors:" <<
endl;
315 for (
typename HistVectorMap::value_type ient :
m_hstvecs ) {
316 unsigned nhst = ient.second.size();
317 sout <<
prefix <<
" " << ient.first <<
"[" << nhst <<
"]" <<
endl;
322 for (
typename GraphMap::value_type ient :
m_grfs ) {
325 sout <<
prefix <<
" " << ient.first <<
": " << pg.get() <<
endl;
347 return ival != vals.end();
355 if ( ival == vals.end() ) {
356 if (
dbg() ) std::cout << myname <<
"Unknown entry: " << name <<
std::endl;
370 if ( ival == vals.end() ) {
371 if (
dbg() ) std::cout << myname <<
"Unknown entry: " << name <<
std::endl;
381 void mapextend(std::map<Name,T>& lhs,
const std::map<Name,T>& rhs) {
382 for (
typename std::map<Name,T>::value_type ient : rhs ) {
std::vector< float > FloatVector
typename std::vector< T > Value
std::string toString() const
void setFloat(Name name, float val)
const IntVectorMap & getIntVectorMap() const
std::map< Name, int > IntMap
DataMap & setStatus(int stat)
std::map< Name, GraphPtr > GraphMap
std::map< Name, IntVector > IntVectorMap
std::map< Name, TH1 * > HistMap
bool haveHist(Name name) const
bool haveInt(Name name) const
const IntVector & getIntVector(Name name) const
TGraph * getGraph(Name name) const
void setHist(Name name, TH1 *ph, bool own=false)
bool haveString(Name name) const
const FloatVector & getFloatVector(Name name) const
T mapget(const std::map< Name, T > &vals, Name name, T def) const
static int dbg(int setDbg=-1)
void print(std::ostream *pout) const
void setHistVector(Name name, const SharedHistVector &hsts)
void setGraph(TGraph *pg)
std::string toString() const
std::vector< int > IntVector
const FloatVectorMap & getFloatVectorMap() const
const HistVector & getHistVector(Name name) const
void setIntVector(Name name, const IntVector &val)
const T & mapgetobj(const std::map< Name, T > &vals, Name name) const
void mapextend(std::map< Name, T > &lhs, const std::map< Name, T > &rhs)
void setHistVector(Name name, const HistVector &hsts, bool own=false)
String getString(Name name, String def="") const
void extend(const DataMap &rhs)
void setString(Name name, String val)
const GraphMap & getGraphMap() const
std::shared_ptr< TGraph > GraphPtr
std::map< Name, String > StringMap
std::map< Name, Float > FloatMap
const IntMap & getIntMap() const
void setInt(Name name, int val)
const FloatMap & getFloatMap() const
typename std::map< Name, Value > Map
DataMap & operator+=(const DataMap &rhs)
Float getFloat(Name name, Float def=0.0) const
bool maphas(const std::map< Name, T > &vals, Name name) const
typename std::map< Name, Value > Map
const HistVectorMap & getHistVectorMap() const
typename Map::const_iterator Iterator
HistVector getHists() const
int getInt(Name name, int def=0) const
const StringMap & getStringMap() const
std::map< Name, FloatVector > FloatVectorMap
bool haveFloat(Name name) const
bool haveGraph(Name name) const
void print(std::string prefix="", std::ostream *pout=&std::cout) const
void setGraph(Name name, TGraph *pg)
SharedHistVector m_sharedHsts
TH1 * getHist(Name name, TH1 *def=nullptr) const
bool haveHistVector(Name name) const
void setFloatVector(Name name, const FloatVector &val)
void setHist(TH1 *ph, bool own=false)
const HistMap & getHistMap() const
std::vector< TH1 * > HistVector
void setHist(std::shared_ptr< TH1 > ph)
bool haveFloatVector(Name name) const
std::map< Name, HistVector > HistVectorMap
bool haveIntVector(Name name) const
std::shared_ptr< TH1 > SharedHistPtr
QTextStream & endl(QTextStream &s)
typename Map::const_iterator Iterator
std::vector< SharedHistPtr > SharedHistVector