10 #include "TGraphErrors.h"
38 int main(
int argc,
char **argv)
50 JParser<> zap(
"Auxiliary program to create TGraph from input file with ASCII data.");
60 catch(
const exception &error) {
61 FATAL(error.what() << endl);
73 ifstream
in(file_name->c_str());
75 while (
in.peek() ==
'#') {
76 in.ignore(numeric_limits<streamsize>::max(),
'\n');
89 istringstream
is(buffer);
91 for (
string key; is >> key; ) {
92 column.push_back(key);
98 in.ignore(numeric_limits<streamsize>::max(),
'\n');
103 Double_t x, y, ex, ey;
112 for (
string buffer;
getline(
in,buffer); ) {
114 istringstream
is(buffer);
116 if (is >> x) X .push_back(x);
117 if (is >> y) Y .push_back(y);
118 if (is >> ex) EX.push_back(ex);
119 if (is >> ey) EY.push_back(ey);
122 if (X.size() != Y.size()) {
123 FATAL(
"Number of points " << X.size() <<
' ' << Y.size() << endl);
127 TGraph* graph = NULL;
131 graph =
new TGraph(X.size(), X.data(), Y.data());
135 if (X.size() != EX.size()) {
136 FATAL(
"Number of x points " << X.size() <<
' ' << EX.size() << endl);
141 EX.resize(X.size(), 0.0);
144 if (Y.size() != EY.size()) {
145 FATAL(
"Number of y points " << Y.size() <<
' ' << EY.size() << endl);
148 graph =
new TGraphErrors(X.size(), X.data(), Y.data(), EX.data(), EY.data());
153 graph->SetName(title.c_str());
157 DEBUG(
"TGraph " << graph->GetName() << endl);
167 for (
string buffer;
getline(
in,buffer); ) {
169 istringstream
is(buffer);
177 for ( ; is >> y; ++i) {
186 if (i+1 != column.size()) {
187 FATAL(
"Number of colums " << i+1 <<
' ' << column.size() << endl);
192 for (
size_t i = 0; i != Y.size(); ++i) {
194 TGraph* graph =
new TGraph(X.size(), X.data(), Y[i].data());
198 os << title <<
"[" << column[i+1] <<
"]";
200 graph->SetName(os.str().c_str());
204 DEBUG(
"TGraph " << graph->GetName() << endl);
Utility class to parse command line options.
esac print_variable DETECTOR INPUT_FILE OUTPUT_FILE CDF for TYPE in
void setLimits(TGraph &g1)
Set limits of TGraph.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
std::istream & getline(std::istream &in, JString &object)
Read string from input stream until end of line.
General purpose messaging.
Utility class to parse command line options.
std::string getFilename(const std::string &file_name)
Get file name part, i.e. part after last JEEP::PATHNAME_SEPARATOR if any.
#define DEBUG(A)
Message macros.
int main(int argc, char *argv[])