10 #include "TGraphErrors.h"
38 int main(
int argc,
char **argv)
51 JParser<> zap(
"Auxiliary program to create TGraph from input file with ASCII data.");
62 catch(
const exception &error) {
63 FATAL(error.what() << endl);
73 const string gname = (title !=
"" ? title :
getFilename(*file_name));
75 ifstream
in(file_name->c_str());
77 while (
in.peek() ==
'#') {
78 in.ignore(numeric_limits<streamsize>::max(),
'\n');
91 istringstream
is(buffer);
93 for (
string key; is >> key; ) {
94 column.push_back(key);
100 in.ignore(numeric_limits<streamsize>::max(),
'\n');
105 Double_t
x,
y, ex, ey;
114 for (
string buffer;
getline(
in,buffer); ) {
116 istringstream
is(buffer);
118 if (is >> x) X .push_back(x);
119 if (is >> y) Y .push_back(y);
120 if (is >> ex) EX.push_back(ex);
121 if (is >> ey) EY.push_back(ey);
124 if (X.size() != Y.size()) {
125 FATAL(
"Number of points " << X.size() <<
' ' << Y.size() << endl);
129 TGraph* graph = NULL;
133 graph =
new TGraph(X.size(), X.data(), Y.data());
137 if (X.size() != EX.size()) {
138 FATAL(
"Number of x points " << X.size() <<
' ' << EX.size() << endl);
143 EX.resize(X.size(), 0.0);
146 if (Y.size() != EY.size()) {
147 FATAL(
"Number of y points " << Y.size() <<
' ' << EY.size() << endl);
150 graph =
new TGraphErrors(X.size(), X.data(), Y.data(), EX.data(), EY.data());
155 graph->SetName(gname.c_str());
159 DEBUG(
"TGraph " << graph->GetName() << endl);
169 for (
string buffer;
getline(
in,buffer); ) {
171 istringstream
is(buffer);
179 for ( ; is >>
y; ++
i) {
188 if (i+1 != column.size()) {
189 FATAL(
"Number of colums " << i+1 <<
' ' << column.size() << endl);
194 for (
size_t i = 0;
i != Y.size(); ++
i) {
196 TGraph* graph =
new TGraph(X.size(), X.data(), Y[
i].data());
200 os << gname <<
"[" << column[
i+1] <<
"]";
202 graph->SetName(os.str().c_str());
206 DEBUG(
"TGraph " << graph->GetName() << endl);
Utility class to parse command line options.
int main(int argc, char *argv[])
void setLimits(TGraph &g1)
Set limits of TGraph.
then fatal Wrong number of arguments fi set_variable STRING $argv[1] set_variable DETECTORXY_TXT $WORKDIR $DETECTORXY_TXT tail read X Y CHI2 RMS printf optimum n $X $Y $CHI2 $RMS awk v Y
#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.
no fit printf nominal n $STRING awk v X
std::string getFilename(const std::string &file_name)
Get file name part, i.e. part after last JEEP::PATHNAME_SEPARATOR if any.
then fatal Wrong number of arguments fi set_variable DETECTOR $argv[1] set_variable INPUT_FILE $argv[2] eval JPrintDetector a $DETECTOR O IDENTIFIER eval JPrintDetector a $DETECTOR O SUMMARY JAcoustics sh $DETECTOR_ID source JAcousticsToolkit sh CHECK_EXIT_CODE typeset A EMITTERS get_tripods $WORKDIR tripod txt EMITTERS get_transmitters $WORKDIR transmitter txt EMITTERS for EMITTER in
#define DEBUG(A)
Message macros.