59template<
class>
struct InvalidTupleType;
79template<
class DataType,
class Tuple>
82 InvalidTupleType<Tuple> typeChecker;
84 if (delimiter ==
'\r' || delimiter ==
'\n') {
85 ::Error(
"FillNtupleFromStream",
"invalid delimiter - newline character");
89 if (delimiter ==
'#') {
90 ::Error(
"FillNtuplesFromStream",
"invalid delimiter, '#' symbols can only start a comment");
94 const Int_t nVars = tuple.GetNvar();
96 ::Error(
"FillNtupleFromStream",
"invalid number of elements");
100 DataType *args = tuple.GetArgs();
101 assert(args != 0 &&
"FillNtupleFromStream, args buffer is a null");
111 if (!inputStream.good()) {
113 ::Error(
"FillNtupleFromStream",
"no data read");
118 for (
Int_t i = 0; i < nVars; ++i) {
120 if (!inputStream.good()) {
121 ::Error(
"FillNtupleFromStream",
"failed to read a tuple (not enough values found)");
125 if (i > 0 && !std::isspace(delimiter)) {
126 const char test = inputStream.peek();
127 if (!inputStream.good() ||
test != delimiter) {
128 ::Error(
"FillNtupleFromStream",
"delimiter expected");
138 ::Error(
"FillNtupleFromStream",
"unexpected character or eof found");
142 inputStream>>args[i];
144 if (!(inputStream.eof() && i + 1 == nVars) && !inputStream.good()){
145 ::Error(
"FillNtupleFromStream",
"error while reading a value");
152 ::Error(
"FillNtupleFromStream",
153 "only whitespace and new line can follow the last number on the line");
159 static_cast<TTree &
>(tuple).Fill();
170 if (!inputStream.good()) {
173 ::Error(
"FillNtupleFromStream",
"no data read");
175 ::Error(
"FillNtupleFromStream",
"unexpected character or eof found");
179 if (i > 0 && !std::isspace(delimiter)) {
181 const char test = inputStream.peek();
182 if (!inputStream.good() ||
test != delimiter) {
183 ::Error(
"FillNtupleFromStream",
"delimiter expected (non-strict mode)");
192 inputStream>>args[i];
194 if (!(inputStream.eof() && i + 1 == nVars) && !inputStream.good()){
195 ::Error(
"FillNtupleFromStream",
"error while reading a value");
199 if (i + 1 == nVars) {
201 static_cast<TTree &
>(tuple).Fill();
242 while (input.good()) {
243 const char next = input.peek();
246 if (next ==
'\r' || next ==
'\n')
261 while (input.good()) {
262 const char c = input.peek();
268 else if (!std::isspace(
c))
282 while (input.good()) {
283 const char next = input.peek();
285 if (std::isspace(next) && next !=
'\n' && next !=
'\r')
303 const char next = input.peek();
307 return next ==
'\r' || next ==
'\n';
void Error(const char *location, const char *msgfmt,...)
A simple TTree restricted to a list of double variables only.
A simple TTree restricted to a list of float variables only.
A TTree represents a columnar dataset.
template Long64_t FillNtupleFromStream< Float_t, TNtuple >(std::istream &, TNtuple &, char, bool)
Long64_t FillNtupleFromStream(std::istream &inputStream, Tuple &tuple, char delimiter, bool strictMode)
void SkipEmptyLines(std::istream &input)
Skips empty lines (newline-characters), ws-lines (consisting only of whitespace characters + newline-...
void SkipWSCharacters(std::istream &input)
Skip whitespace characters, but not newline-characters we support ('\r' or '\n').
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)