#include #include #include "TROOT.h" #include "TFile.h" #include "TEllipse.h" #include "Jeep/JContainer.hh" #include "Jeep/JProperties.hh" #include "Jeep/JParser.hh" #include "Jeep/JMessage.hh" /** * Auxiliary data structure for ellipse. */ struct JEllipse { /** * Read ellipse from input stream. * * \param in input stream * \param ellipse ellipse * \return input stream */ friend inline std::istream& operator>>(std::istream& in, JEllipse& ellipse) { if (in >> ellipse.x1 >> ellipse.y1 >> ellipse.r1) { if (in >> ellipse.r2) { if (in >> ellipse.phimin >> ellipse.phimax) { } else { ellipse.phimin = 0.0; ellipse.phimax = 360.0; } } else { ellipse.r2 = ellipse.r1; ellipse.phimin = 0.0; ellipse.phimax = 360.0; } in.clear(); } return in; } /** * Write ellipse to output stream. * * \param out output stream * \param ellipse ellipse * \return output stream */ friend inline std::ostream& operator<<(std::ostream& out, const JEllipse& ellipse) { out << ellipse.x1 << ' ' << ellipse.y1 << ' ' << ellipse.r1 << ' ' << ellipse.r2 << ' ' << ellipse.phimin << ' ' << ellipse.phimax; return out; } double x1; double y1; double r1; double r2; double phimin; double phimax; }; /** * \file * Auxiliary program to create TEllipse. * \author mdejong */ int main(int argc, char **argv) { using namespace std; using namespace JPP; typedef JContainer< vector > JParameters_t; string outputFile; JParameters_t parameters; struct { Color_t color = kBlack; Style_t style = 0; // hollow } fill; struct { Color_t color = kBlack; Style_t style = kSolid; } line; int debug; try { JProperties properties(JEquationParameters("=", "\n", "", "#")); properties.insert(zmake_property(fill.color)); properties.insert(zmake_property(fill.style)); properties.insert(zmake_property(line.color)); properties.insert(zmake_property(line.style)); JParser<> zap("Auxiliary program to create TEllipse"); zap['o'] = make_field(outputFile); zap['p'] = make_field(parameters, "x y r1 [r2 [phimin phimax]]"); zap['@'] = make_field(properties, "ellipse attributes") = JPARSER::initialised(); zap['d'] = make_field(debug) = 1; zap(argc, argv); } catch(const exception &error) { FATAL(error.what() << endl); } TFile out(outputFile.c_str(), "recreate"); for (size_t i = 0; i != parameters.size(); ++i) { TEllipse* p = new TEllipse(parameters[i].x1, parameters[i].y1, parameters[i].r1, parameters[i].r2, parameters[i].phimin, parameters[i].phimax); p->SetFillColor(fill.color); p->SetFillStyle(fill.style); p->SetLineColor(line.color); p->SetLineStyle(line.style); out.WriteTObject(p); } out.Write(); out.Close(); }