DAS  3.0
Das Analysis System
UserInfo

Description

Generic meta-information for n-tuple (can be used out of Darwin).

Generic class to read the meta-information contained in a list. The original goal is to read and write information to store in the list TTree::GetUserInfo(), but it can be used in general.

The elements of the list may simply be reached with UserInfo::Get() and written with UserInfo::Set(). The list may contain simple types such as arithmetic types or literals as well as other lists. To reach a list, the Get and Set function simply need the list of keys to navigate through the tree structure, provided with additional arguments. Examples:

ui.Set<bool>("one", "two", "myBool", true);
cout << ui.Get<bool>("one", "two", "myBool") << endl; // will print true
cout << ui.Get<string>("this", "will", "fail") << endl;

The whole information may be extracted in JSON, INFO, or XML format with Darwin::Tools::UserInfo::Write().

This class is as generic as can be. In certain cases, one may want to use inherit from this class to enforce a more rigid structure. One example is Darwin::Tools::MetaInfo.

#include <UserInfo.h>

+ Inheritance diagram for UserInfo:

Public Types

enum  Format {
  INFO, JSON, XML, INFO,
  JSON, XML
}
 
enum  Format {
  INFO, JSON, XML, INFO,
  JSON, XML
}
 

Public Member Functions

template<typename... Args>
TList * List (const char *key, Args... args) const
 
TList * List () const
 
template<class T , typename... Args>
Get (const char *key, Args... args) const
 
template<typename... Args>
bool Find (const char *key, Args... args) const
 
template<class T , typename... Args>
void Set (const char *key, Args... args) const
 
 UserInfo (const char *="UserInfo")
 
 UserInfo (const boost::property_tree::ptree &)
 
 UserInfo (TList *)
 
 UserInfo (TTree *)
 
 UserInfo (TTree *, const boost::property_tree::ptree &)
 
 ~UserInfo ()
 
void Write () const
 
bool Empty () const
 
boost::property_tree::ptree Write (std::ostream &, Format=INFO) const
 
boost::property_tree::ptree Write (const std::filesystem::path &) const
 
boost::property_tree::ptree MkPtree (Format format=INFO) const
 
void ls () const
 
template<typename... Args>
TList * List (const char *key, Args... args) const
 
TList * List () const
 
template<class T , typename... Args>
Get (const char *key, Args... args) const
 
template<typename... Args>
bool Find (const char *key, Args... args) const
 
template<class T , typename... Args>
void Set (const char *key, Args... args) const
 
 UserInfo (const char *="UserInfo")
 
 UserInfo (const boost::property_tree::ptree &)
 
 UserInfo (TList *)
 
 UserInfo (TTree *)
 
 UserInfo (TTree *, const boost::property_tree::ptree &)
 
 ~UserInfo ()
 
void Write () const
 
bool Empty () const
 
boost::property_tree::ptree Write (std::ostream &, Format=INFO) const
 
boost::property_tree::ptree Write (const std::filesystem::path &) const
 
boost::property_tree::ptree MkPtree (Format format=INFO) const
 
void ls () const
 

Protected Member Functions

boost::property_tree::ptree MkPtree (TList *, Format=INFO) const
 
boost::property_tree::ptree MkPtree (TList *, Format=INFO) const
 

Private Member Functions

TList * List (TList *mother, const char *key) const
 
template<class T >
Get (TList *mother, const char *key) const
 
template<class T , typename... Args>
Get (TList *mother, const char *key, Args... args) const
 
bool Find (TList *mother, const char *key) const
 
template<typename... Args>
bool Find (TList *mother, const char *key, Args... args) const
 
template<class T >
void Set (TList *mother, const char *key, T value) const
 
template<class T , typename... Args>
void Set (TList *mother, const char *key, Args... args) const
 
template<typename... Args>
TList * List (TList *mother, const char *key, Args... args) const
 
template<class T >
Get (TList *mother, std::string key) const
 
bool Find (TList *mother, std::string key) const
 
TList * List (TList *mother, std::string key) const
 
void ConvertPtree (const boost::property_tree::ptree &, const std::string &, TList *)
 
TList * List (TList *mother, const char *key) const
 
template<class T >
Get (TList *mother, const char *key) const
 
template<class T , typename... Args>
Get (TList *mother, const char *key, Args... args) const
 
bool Find (TList *mother, const char *key) const
 
template<typename... Args>
bool Find (TList *mother, const char *key, Args... args) const
 
template<class T >
void Set (TList *mother, const char *key, T value) const
 
template<class T , typename... Args>
void Set (TList *mother, const char *key, Args... args) const
 
template<typename... Args>
TList * List (TList *mother, const char *key, Args... args) const
 
template<class T >
Get (TList *mother, std::string key) const
 
bool Find (TList *mother, std::string key) const
 
TList * List (TList *mother, std::string key) const
 
void ConvertPtree (const boost::property_tree::ptree &, const std::string &, TList *)
 

Private Attributes

bool own
 
TList * l
 

Member Enumeration Documentation

◆ Format [1/2]

enum Format

Supported serialization formats.

Enumerator
INFO 

INFO format, proper to Boost Property Trees (default)

JSON 

JSON format, rather common and nearly as powerful.

XML 

XML format, another universal format.

INFO 

INFO format, proper to Boost Property Trees (default)

JSON 

JSON format, rather common and nearly as powerful.

XML 

XML format, another universal format.

56  {
57  INFO,
58  JSON,
59  XML
60  };

◆ Format [2/2]

enum Format

Supported serialization formats.

Enumerator
INFO 

INFO format, proper to Boost Property Trees (default)

JSON 

JSON format, rather common and nearly as powerful.

XML 

XML format, another universal format.

INFO 

INFO format, proper to Boost Property Trees (default)

JSON 

JSON format, rather common and nearly as powerful.

XML 

XML format, another universal format.

56  {
57  INFO,
58  JSON,
59  XML
60  };

Constructor & Destructor Documentation

◆ UserInfo() [1/10]

UserInfo ( const char *  name = "UserInfo")

Constructor (starting from scratch)

162  : own(true), l(new TList)
163 {
164  l->SetName(name);
165 }

◆ UserInfo() [2/10]

UserInfo ( const boost::property_tree::ptree &  ptree)

Constructor (starting from existing ptree)

213  : own(true), l(new TList)
214 {
215  for (const auto& [name, pt]: ptree)
216  ConvertPtree(pt, name, l);
217 }

◆ UserInfo() [3/10]

UserInfo ( TList *  L)

Constructor (starting from existing list)

220  : own(false), l(L)
221 {
222  if (L == nullptr)
223  BOOST_THROW_EXCEPTION(invalid_argument("Invalid list given in argument."));
224 }

◆ UserInfo() [4/10]

UserInfo ( TTree *  t)

Constructor (starting from TTree)

227  : own(false), l(t->GetUserInfo())
228 {
229 }

◆ UserInfo() [5/10]

UserInfo ( TTree *  tree,
const boost::property_tree::ptree &  ptree 
)

constructor (inserting existing ptree direcrly in a ttree)

206  : own(false), l(tree->GetUserInfo())
207 {
208  for (const auto& [name, pt]: ptree)
209  ConvertPtree(pt, name, l);
210 }

◆ ~UserInfo() [1/2]

~UserInfo ( )

Destructor.

232 {
233  if (!own) return;
234  delete l;
235 }

◆ UserInfo() [6/10]

UserInfo ( const char *  = "UserInfo")

Constructor (starting from scratch)

◆ UserInfo() [7/10]

UserInfo ( const boost::property_tree::ptree &  )

Constructor (starting from existing ptree)

◆ UserInfo() [8/10]

UserInfo ( TList *  )

Constructor (starting from existing list)

◆ UserInfo() [9/10]

UserInfo ( TTree *  )

Constructor (starting from TTree)

◆ UserInfo() [10/10]

UserInfo ( TTree *  ,
const boost::property_tree::ptree &   
)

constructor (inserting existing ptree direcrly in a ttree)

◆ ~UserInfo() [2/2]

~UserInfo ( )

Destructor.

Member Function Documentation

◆ ConvertPtree() [1/2]

void ConvertPtree ( const boost::property_tree::ptree &  pt,
const std::string &  name,
TList *  mother 
)
private

Helper function to convert a ptree to a TList Supports making strings, bools, ints, and floats.

170 {
171  if (pt.empty()) {
172  // Value - we need to figure out the type
173  auto str = pt.get_value<string>();
174 
175  char * end;
176 
177  // Bools
178  if (str == "true")
179  Set<bool>(mother, name.data(), true);
180  else if (str == "false")
181  Set<bool>(mother, name.data(), false);
182 
183  // Integers
184  else if (int i; from_chars(str.data(), &*str.end(), i).ptr == &*str.end())
185  Set<int>(mother, name.data(), i);
186 
187  // Floats
188  else if (float f = strtof(str.data(), &end); end == &*str.end())
189  Set<float>(mother, name.data(), f);
190 
191  // Everything else is a string
192  else Set<string>(mother, name.data(), str);
193  } else if (pt.count("") == pt.size()) {
194  // List
195  for (const auto& [_, subtree]: pt)
196  ConvertPtree(subtree, name.data(), mother);
197  } else {
198  // Subtree
199  auto child = List(mother, name);
200  for (const auto& [subname, subtree]: pt)
201  ConvertPtree(subtree, subname.c_str(), child);
202  }
203 }

◆ ConvertPtree() [2/2]

void ConvertPtree ( const boost::property_tree::ptree &  ,
const std::string &  ,
TList *   
)
private

Helper function to convert a ptree to a TList Supports making strings, bools, ints, and floats.

◆ Empty() [1/2]

bool Empty ( ) const

Check if list is empty.

157 {
158  return l->GetSize() == 0;
159 }

◆ Empty() [2/2]

bool Empty ( ) const

Check if list is empty.

◆ Find() [1/8]

bool Find ( const char *  key,
Args...  args 
) const
inline

Generic finder.

216  {
217  return Find(l, key, args...);
218  }

◆ Find() [2/8]

bool Find ( const char *  key,
Args...  args 
) const
inline

Generic finder.

216  {
217  return Find(l, key, args...);
218  }

◆ Find() [3/8]

bool Find ( TList *  mother,
const char *  key 
) const
inlineprivate

Recursive finder.

108  {
109  TObject * obj = mother->FindObject(key);
110  return (obj != nullptr);
111  }

◆ Find() [4/8]

bool Find ( TList *  mother,
const char *  key 
) const
inlineprivate

Recursive finder.

108  {
109  TObject * obj = mother->FindObject(key);
110  return (obj != nullptr);
111  }

◆ Find() [5/8]

bool Find ( TList *  mother,
const char *  key,
Args...  args 
) const
inlineprivate

Recursive finder.

116  {
117  if (!Find(mother, key)) return false;
118  TList * daughter = List(mother, key);
119  if (daughter->GetSize() > 0)
120  return Find(daughter, args...);
121  else return false;
122  }

◆ Find() [6/8]

bool Find ( TList *  mother,
const char *  key,
Args...  args 
) const
inlineprivate

Recursive finder.

116  {
117  if (!Find(mother, key)) return false;
118  TList * daughter = List(mother, key);
119  if (daughter->GetSize() > 0)
120  return Find(daughter, args...);
121  else return false;
122  }

◆ Find() [7/8]

bool Find ( TList *  mother,
std::string  key 
) const
inlineprivate

finder with string

◆ Find() [8/8]

bool Find ( TList *  mother,
std::string  key 
) const
inlineprivate

finder with string

◆ Get() [1/8]

T Get ( const char *  key,
Args...  args 
) const
inline

Generic getter.

209  {
210  return Get<T>(l, key, args...);
211  }

◆ Get() [2/8]

T Get ( const char *  key,
Args...  args 
) const
inline

Generic getter.

209  {
210  return Get<T>(l, key, args...);
211  }

◆ Get() [3/8]

T Get ( TList *  mother,
const char *  key 
) const
inlineprivate

Final getter. The behaviour for arithmetic types and for literal (default) is slightly different, since literals don't really have a key. Literals are always contained in a list, and the last element of the list is returned.

76  {
77  if constexpr (std::is_arithmetic_v<T>) {
78  TObject * obj = mother->FindObject(key);
79  auto parameter = dynamic_cast<TParameter<T>*>(obj);
80  if (parameter == nullptr)
81  BOOST_THROW_EXCEPTION(std::invalid_argument(
82  Form("No `TParameter` with name '%s' could be found in the `TList` '%s'.", key, mother->GetName())));
83  return parameter->GetVal();
84  }
85  else {
86  TList * daughter = List(mother, key);
87  TIter next(daughter->begin());
88  auto objs = dynamic_cast<TObjString*>(daughter->Last());
89  if (daughter->GetSize() == 0 || objs == nullptr)
90  BOOST_THROW_EXCEPTION(std::invalid_argument(
91  Form("No literal with name '%s' was found in the `TList` '%s'.", key, mother->GetName())));
92  T literal = objs->GetString().Data();
93  return literal;
94  }
95  }

◆ Get() [4/8]

T Get ( TList *  mother,
const char *  key 
) const
inlineprivate

Final getter. The behaviour for arithmetic types and for literal (default) is slightly different, since literals don't really have a key. Literals are always contained in a list, and the last element of the list is returned.

76  {
77  if constexpr (std::is_arithmetic_v<T>) {
78  TObject * obj = mother->FindObject(key);
79  auto parameter = dynamic_cast<TParameter<T>*>(obj);
80  if (parameter == nullptr)
81  BOOST_THROW_EXCEPTION(std::invalid_argument(
82  Form("No `TParameter` with name '%s' could be found in the `TList` '%s'.", key, mother->GetName())));
83  return parameter->GetVal();
84  }
85  else {
86  TList * daughter = List(mother, key);
87  TIter next(daughter->begin());
88  auto objs = dynamic_cast<TObjString*>(daughter->Last());
89  if (daughter->GetSize() == 0 || objs == nullptr)
90  BOOST_THROW_EXCEPTION(std::invalid_argument(
91  Form("No literal with name '%s' was found in the `TList` '%s'.", key, mother->GetName())));
92  T literal = objs->GetString().Data();
93  return literal;
94  }
95  }

◆ Get() [5/8]

T Get ( TList *  mother,
const char *  key,
Args...  args 
) const
inlineprivate

Recursive getter.

100  {
101  TList * daughter = List(mother, key);
102  return Get<T>(daughter, args...);
103  }

◆ Get() [6/8]

T Get ( TList *  mother,
const char *  key,
Args...  args 
) const
inlineprivate

Recursive getter.

100  {
101  TList * daughter = List(mother, key);
102  return Get<T>(daughter, args...);
103  }

◆ Get() [7/8]

T Get ( TList *  mother,
std::string  key 
) const
inlineprivate

value getter with string

◆ Get() [8/8]

T Get ( TList *  mother,
std::string  key 
) const
inlineprivate

value getter with string

◆ List() [1/10]

TList* List ( ) const
inline

Access directly to main list.

202  {
203  return l;
204  }

◆ List() [2/10]

TList* List ( ) const
inline

Access directly to main list.

202  {
203  return l;
204  }

◆ List() [3/10]

TList* List ( const char *  key,
Args...  args 
) const
inline

Access directly a sublist.

195  {
196  return List(l, key, args...);
197  }

◆ List() [4/10]

TList* List ( const char *  key,
Args...  args 
) const
inline

Access directly a sublist.

195  {
196  return List(l, key, args...);
197  }

◆ List() [5/10]

TList * List ( TList *  mother,
const char *  key 
) const
private

Accest do daughter list from a mother list.

34 {
35  TObject * obj = mother->FindObject(key);
36  if (obj == nullptr) {
37  auto daughter = static_cast<TList *>(obj);
38  daughter = new TList;
39  daughter->SetName(key);
40  mother->Add(daughter);
41  return daughter;
42  }
43  else {
44  TString classname = obj->ClassName();
45  if (classname != "TList")
46  BOOST_THROW_EXCEPTION(invalid_argument(key));
47  auto daughter = dynamic_cast<TList *>(obj);
48  return daughter;
49  }
50 }

◆ List() [6/10]

TList* List ( TList *  mother,
const char *  key 
) const
private

Accest do daughter list from a mother list.

◆ List() [7/10]

TList* List ( TList *  mother,
const char *  key,
Args...  args 
) const
inlineprivate

Access a sublist.

165  {
166  TList * daughter = List(mother, key);
167  return List(daughter, args...);
168  }

◆ List() [8/10]

TList* List ( TList *  mother,
const char *  key,
Args...  args 
) const
inlineprivate

Access a sublist.

165  {
166  TList * daughter = List(mother, key);
167  return List(daughter, args...);
168  }

◆ List() [9/10]

TList* List ( TList *  mother,
std::string  key 
) const
inlineprivate

list getter with string

◆ List() [10/10]

TList* List ( TList *  mother,
std::string  key 
) const
inlineprivate

list getter with string

◆ ls() [1/2]

void ls ( ) const
inline

Prints the content of the TList

263 { if (l != nullptr) l->ls(); }

◆ ls() [2/2]

void ls ( ) const
inline

Prints the content of the TList

263 { if (l != nullptr) l->ls(); }

◆ MkPtree() [1/4]

boost::property_tree::ptree MkPtree ( Format  format = INFO) const
inline

Write main TList to Boost Property Tree.

Returns
content of full TList in Property Tree format
Parameters
formatformat of output file
259  { return MkPtree(l, format); }

◆ MkPtree() [2/4]

boost::property_tree::ptree MkPtree ( Format  format = INFO) const
inline

Write main TList to Boost Property Tree.

Returns
content of full TList in Property Tree format
Parameters
formatformat of output file
259  { return MkPtree(l, format); }

◆ MkPtree() [3/4]

boost::property_tree::ptree MkPtree ( TList *  ,
Format  = INFO 
) const
protected

Write TList to Boost Property Tree. Calls itself recursively. Internally, it uses Boost Preprocessor macros to loop over types.

Returns
content of TList given in argument in Property Tree format

◆ MkPtree() [4/4]

pt::ptree MkPtree ( TList *  list,
Format  format = INFO 
) const
protected

Write TList to Boost Property Tree. Calls itself recursively. Internally, it uses Boost Preprocessor macros to loop over types.

Returns
content of TList given in argument in Property Tree format
Parameters
listlist to write to `ptree`
formatformat of output file (e.g. XML cannot handle empty keys)
53 {
54  assert(list);
55  pt::ptree tree; // this tree will contain the list
56  for (const auto& obj: *list) {
57  const char * key = obj->GetName();
58  const TString classname = obj->ClassName();
59  if (classname == "TList") {
60  auto sublist = dynamic_cast<TList *>(obj);
61  pt::ptree child = MkPtree(sublist, format);
62  tree.add_child(key, child);
63  }
64  else if (classname == "TObjString") {
65  auto objs = dynamic_cast<TObjString *>(obj);
66  const char * value = objs->GetString().Data();
67  if (list->GetSize() == 1)
68  tree.put<const char *>("", value);
69  else switch (format) {
70  case XML: tree.add("item", value);
71  break;
72  case INFO:
73  case JSON:
74  {
75  pt::ptree node;
76  node.put("", value);
77  tree.push_back(make_pair("", node));
78  }
79  }
80  }
81 #define ARITHMETIC_TYPES (bool)(char)(signed char)(short)(short int)(int)(long int)(long long int)(unsigned char)(unsigned short)(unsigned short int)(unsigned)(unsigned int)(unsigned long)(unsigned long int)(unsigned long long)(unsigned long long int)(float)(double)(long double)
82 #define ELSE_IF_TPARAM(r, data, TYPE) \
83  else if (classname == "TParameter<" BOOST_PP_STRINGIZE(TYPE) ">") { \
84  auto param = dynamic_cast<TParameter<TYPE>*>(obj); \
85  tree.add<TYPE>(key, param->GetVal()); \
86  }
87  BOOST_PP_SEQ_FOR_EACH(ELSE_IF_TPARAM, _, ARITHMETIC_TYPES)
88 #undef ARITHMETIC_TYPES
89 #undef ELSE_IF_TPARAM
90  else
91  cerr << orange << "Warning: " << classname << " is not handled by " << __func__ << ", therefore `" << key << "` will ignored.\n" << def;
92  }
93  return tree;
94 }

◆ Set() [1/6]

void Set ( const char *  key,
Args...  args 
) const
inline

Generic setter. The key is the name of the first sublist (if any), or to the element directly. An extra argument (implicitly in the variadic argument) contains the value.

225  {
226  Set<T>(l, key, args...);
227  }

◆ Set() [2/6]

void Set ( const char *  key,
Args...  args 
) const
inline

Generic setter. The key is the name of the first sublist (if any), or to the element directly. An extra argument (implicitly in the variadic argument) contains the value.

225  {
226  Set<T>(l, key, args...);
227  }

◆ Set() [3/6]

void Set ( TList *  mother,
const char *  key,
Args...  args 
) const
inlineprivate

Recursive setter.

157  {
158  TList * daughter = List(mother, key);
159  Set<T>(daughter, args...);
160  }

◆ Set() [4/6]

void Set ( TList *  mother,
const char *  key,
Args...  args 
) const
inlineprivate

Recursive setter.

157  {
158  TList * daughter = List(mother, key);
159  Set<T>(daughter, args...);
160  }

◆ Set() [5/6]

void Set ( TList *  mother,
const char *  key,
value 
) const
inlineprivate

(Re)sets elements of a given list.

Only arithmetic types have a key and a value. Literals only have identical key and value.

130  {
131  if constexpr (std::is_arithmetic_v<T>) {
132  TObject * obj = mother->FindObject(key);
133  if (obj) {
134  auto parameter = dynamic_cast<TParameter<T>*>(obj);
135  if (parameter == nullptr)
136  BOOST_THROW_EXCEPTION(std::invalid_argument(
137  Form("No `TParameter` with name '%s' and typeid '%s' was found in the `TList` '%s'.",
138  key, typeid(T).name(), mother->GetName())));
139  parameter->SetVal(value);
140  }
141  else {
142  auto parameter = new TParameter<T>(key, value, 'l');
143  mother->Add(parameter);
144  }
145  }
146  else {
147  TList * daughter = List(mother, key);
148  TString str(value);
149  auto objs = new TObjString(str);
150  daughter->Add(objs);
151  }
152  }

◆ Set() [6/6]

void Set ( TList *  mother,
const char *  key,
value 
) const
inlineprivate

(Re)sets elements of a given list.

Only arithmetic types have a key and a value. Literals only have identical key and value.

130  {
131  if constexpr (std::is_arithmetic_v<T>) {
132  TObject * obj = mother->FindObject(key);
133  if (obj) {
134  auto parameter = dynamic_cast<TParameter<T>*>(obj);
135  if (parameter == nullptr)
136  BOOST_THROW_EXCEPTION(std::invalid_argument(
137  Form("No `TParameter` with name '%s' and typeid '%s' was found in the `TList` '%s'.",
138  key, typeid(T).name(), mother->GetName())));
139  parameter->SetVal(value);
140  }
141  else {
142  auto parameter = new TParameter<T>(key, value, 'l');
143  mother->Add(parameter);
144  }
145  }
146  else {
147  TList * daughter = List(mother, key);
148  TString str(value);
149  auto objs = new TObjString(str);
150  daughter->Add(objs);
151  }
152  }

◆ Write() [1/6]

void Write ( ) const

Write TList to TFile in ROOT format.

◆ Write() [2/6]

void Write ( ) const

Write TList to TFile in ROOT format.

150 {
151  TString name = l->GetName();
152  if (name.IsNull()) name = "UserInfo";
153  l->Write(name, TList::kSingleKey);
154 }

◆ Write() [3/6]

pt::ptree Write ( const std::filesystem::path &  p) const

Write to file with Boost. Calls MkPtree to write sublists.

Returns
content of full TList in Property Tree format
Parameters
ppath to output
138 {
139  auto type = INFO;
140  if (p.extension() == ".json")
141  type = JSON;
142  else if (p.extension() == ".xml")
143  type = XML;
144 
145  ofstream stream(p);
146  return Write(stream, type);
147 }

◆ Write() [4/6]

boost::property_tree::ptree Write ( const std::filesystem::path &  ) const

Write to file with Boost. Calls MkPtree to write sublists.

Returns
content of full TList in Property Tree format

◆ Write() [5/6]

boost::property_tree::ptree Write ( std::ostream &  ,
Format  = INFO 
) const

Write to stream with Boost. Calls MkPtree to write sublists.

Returns
content of full TList in Property Tree format

◆ Write() [6/6]

pt::ptree Write ( std::ostream &  out,
Format  format = INFO 
) const

Write to stream with Boost. Calls MkPtree to write sublists.

Returns
content of full TList in Property Tree format
Parameters
outoutput stream
formatformat of output
97 {
98  pt::ptree tree = MkPtree(format);
99 
100  switch (format) {
101  case JSON:
102  {
103  stringstream ss;
104  write_json(ss, tree);
105  string str = ss.str();
106  // by default, everything is a string
107  // -> we remove quotation marks for numerics and booleans
108  regex numbers("\\\"([0-9]+\\.{0,1}[0-9]*)\\\""), // note: no support for hex
109  booleans("\\\"(true|false)\\\"");
110  str = regex_replace(str, numbers, "$1");
111  str = regex_replace(str, booleans, "$1");
112  al::replace_all(str, "\\/", "/");
113  out << str;
114  break;
115  }
116  case XML :
117  {
118  pt::ptree userinfo;
119  userinfo.put_child("userinfo", tree); // there must be exactly one global key
120  pt::xml_writer_settings<string> settings(' ', 2); // indentation with 2 spaces
121  write_xml(out, userinfo, settings);
122  break;
123  }
124  case INFO:
125  {
126  stringstream ss;
127  write_info(ss, tree);
128  string str = ss.str();
129  al::erase_all(str, "\"\"");
130  out << str;
131  }
132  }
133 
134  return tree;
135 }

Member Data Documentation

◆ l

TList * l
private

main list (typically from TTree::GetUserInfo())

◆ own

bool own
private

The documentation for this class was generated from the following files:
DYToLL_M-50_13TeV_pythia8_cff_GEN_SIM_RECOBEFMIX_DIGI_L1_DIGI2RAW_L1Reco_RECO.name
name
Definition: DYToLL_M-50_13TeV_pythia8_cff_GEN_SIM_RECOBEFMIX_DIGI_L1_DIGI2RAW_L1Reco_RECO.py:48
Ntupliser_cfg.cerr
cerr
Definition: Ntupliser_cfg.py:93
Darwin::Tools::UserInfo::List
TList * List() const
Access directly to main list.
Definition: UserInfo.h:201
Darwin::Tools::UserInfo::l
TList * l
main list (typically from TTree::GetUserInfo())
Definition: UserInfo.h:64
jmarExample.pt
pt
Definition: jmarExample.py:19
Darwin::Tools::UserInfo::XML
@ XML
XML format, another universal format.
Definition: UserInfo.h:59
Step::def
static const char * def
Definition: Step.h:36
Ntupliser_cfg.args
args
Definition: Ntupliser_cfg.py:11
ELSE_IF_TPARAM
#define ELSE_IF_TPARAM(r, data, TYPE)
Darwin::Tools::UserInfo::JSON
@ JSON
JSON format, rather common and nearly as powerful.
Definition: UserInfo.h:58
Ntupliser_cfg.p
p
Definition: Ntupliser_cfg.py:361
Ntupliser_cfg.f
f
Definition: Ntupliser_cfg.py:255
jercExample.key
string key
Definition: jercExample.py:109
Darwin::Tools::UserInfo::ConvertPtree
void ConvertPtree(const boost::property_tree::ptree &, const std::string &, TList *)
Definition: UserInfo.cc:167
orange
static const char * orange
Definition: colours.h:6
Darwin::Tools::UserInfo::Write
void Write() const
Write TList to TFile in ROOT format.
Definition: UserInfo.cc:149
Darwin::Tools::UserInfo::Find
bool Find(TList *mother, const char *key) const
Recursive finder.
Definition: UserInfo.h:107
Darwin::Tools::UserInfo::own
bool own
Definition: UserInfo.h:63
Darwin::Tools::UserInfo::INFO
@ INFO
INFO format, proper to Boost Property Trees (default)
Definition: UserInfo.h:57
Darwin::Tools::UserInfo::MkPtree
boost::property_tree::ptree MkPtree(TList *, Format=INFO) const
Definition: UserInfo.cc:52
ARITHMETIC_TYPES
#define ARITHMETIC_TYPES
Darwin::Tools::UserInfo::UserInfo
UserInfo(const char *="UserInfo")
Constructor (starting from scratch)
Definition: UserInfo.cc:161