57 template<
class>
struct InvalidTupleType;
60 struct InvalidTupleType<
TNtuple>
77 template<
class DataType,
class Tuple>
80 InvalidTupleType<Tuple> typeChecker;
82 if (delimiter ==
'\r' || delimiter ==
'\n') {
83 ::Error(
"FillNtupleFromStream",
"invalid delimiter - newline character");
87 if (delimiter ==
'#') {
88 ::Error(
"FillNtuplesFromStream",
"invalid delimiter, '#' symbols can only start a comment");
92 const Int_t nVars = tuple.GetNvar();
94 ::Error(
"FillNtupleFromStream",
"invalid number of elements");
98 DataType *args = tuple.GetArgs();
99 assert(args != 0 &&
"FillNtupleFromStream, args buffer is a null");
109 if (!inputStream.good()) {
111 ::Error(
"FillNtupleFromStream",
"no data read");
116 for (
Int_t i = 0; i < nVars; ++i) {
118 if (!inputStream.good()) {
119 ::Error(
"FillNtupleFromStream",
"failed to read a tuple (not enough values found)");
123 if (i > 0 && !std::isspace(delimiter)) {
124 const char test = inputStream.peek();
125 if (!inputStream.good() || test != delimiter) {
126 ::Error(
"FillNtupleFromStream",
"delimiter expected");
136 ::Error(
"FillNtupleFromStream",
"unexpected character or eof found");
140 inputStream>>args[i];
142 if (!(inputStream.eof() && i + 1 == nVars) && !inputStream.good()){
143 ::Error(
"FillNtupleFromStream",
"error while reading a value");
150 ::Error(
"FillNtupleFromStream",
151 "only whitespace and new line can follow the last number on the line");
157 static_cast<TTree &
>(tuple).Fill();
168 if (!inputStream.good()) {
171 ::Error(
"FillNtupleFromStream",
"no data read");
173 ::Error(
"FillNtupleFromStream",
"unexpected character or eof found");
177 if (i > 0 && !std::isspace(delimiter)) {
179 const char test = inputStream.peek();
180 if (!inputStream.good() || test != delimiter) {
181 ::Error(
"FillNtupleFromStream",
"delimiter expected (non-strict mode)");
190 inputStream>>args[i];
192 if (!(inputStream.eof() && i + 1 == nVars) && !inputStream.good()){
193 ::Error(
"FillNtupleFromStream",
"error while reading a value");
197 if (i + 1 == nVars) {
199 static_cast<TTree &
>(tuple).Fill();
240 while (input.good()) {
241 const char next = input.peek();
244 if (next ==
'\r' || next ==
'\n')
259 while (input.good()) {
260 const char c = input.peek();
266 else if (!std::isspace(c))
280 while (input.good()) {
281 const char next = input.peek();
283 if (std::isspace(next) && next !=
'\n' && next !=
'\r')
301 const char next = input.peek();
305 return next ==
'\r' || next ==
'\n';
Namespace for new ROOT classes and functions.
A simple TTree restricted to a list of double variables only.
ClassImp(TSeqCollection) Int_t TSeqCollection TIter next(this)
Return index of object in collection.
template Long64_t FillNtupleFromStream< Float_t, TNtuple >(std::istream &, TNtuple &, char, bool)
void SkipEmptyLines(std::istream &input)
Skips empty lines (newline-characters), ws-lines (consisting only of whitespace characters + newline-...
A simple TTree restricted to a list of float variables only.
Long64_t FillNtupleFromStream(std::istream &inputStream, Tuple &tuple, char delimiter, bool strictMode)
bool NextCharacterIsEOL(std::istream &input)
Either '\r' | '\n' or eof of some problem.
void SkipComment(std::istream &input)
Skips everything from '#' to (including) '\r' or '\n'.
template Long64_t FillNtupleFromStream< Double_t, TNtupleD >(std::istream &, TNtupleD &, char, bool)
A TTree object has a header with a name and a title.
void SkipWSCharacters(std::istream &input)
Skip whitespace characters, but not newline-characters we support ('\r' or '\n'). ...
void Error(ErrorHandler_t func, int code, const char *va_(fmt),...)
Write error message and call a handler, if required.