Jpp  pmt_effective_area_update_2
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JEllipse.cc
Go to the documentation of this file.
1 #include <string>
2 #include <iostream>
3 
4 #include "TROOT.h"
5 #include "TFile.h"
6 #include "TEllipse.h"
7 
8 #include "Jeep/JParser.hh"
9 #include "Jeep/JMessage.hh"
10 
11 
12 /**
13  * Auxiliary data structure for ellipse.
14  */
15 struct JEllipse {
16 
17  /**
18  * Read ellipse from input stream.
19  *
20  * \param in input stream
21  * \param ellipse ellipse
22  * \return input stream
23  */
24  friend inline std::istream& operator>>(std::istream& in, JEllipse& ellipse)
25  {
26  if (in >> ellipse.x1 >> ellipse.y1 >> ellipse.r1) {
27 
28  if (in >> ellipse.r2) {
29 
30  if (in >> ellipse.phimin >> ellipse.phimax) {
31 
32  } else {
33 
34  ellipse.phimin = 0.0;
35  ellipse.phimax = 360.0;
36  }
37 
38  } else {
39 
40  ellipse.r2 = ellipse.r1;
41  ellipse.phimin = 0.0;
42  ellipse.phimax = 360.0;
43  }
44  }
45 
46  return in;
47  }
48 
49  /**
50  * Write ellipse to output stream.
51  *
52  * \param out output stream
53  * \param ellipse ellipse
54  * \return output stream
55  */
56  friend inline std::ostream& operator<<(std::ostream& out, const JEllipse& ellipse)
57  {
58  out << ellipse.x1 << ' '
59  << ellipse.y1 << ' '
60  << ellipse.r1 << ' '
61  << ellipse.r2 << ' '
62  << ellipse.phimin << ' '
63  << ellipse.phimax;
64 
65  return out;
66  }
67 
68  double x1;
69  double y1;
70  double r1;
71  double r2;
72  double phimin;
73  double phimax;
74 };
75 
76 
77 /**
78  * \file
79  * Auxiliary program to create TEllipse.
80  * \author mdejong
81  */
82 int main(int argc, char **argv)
83 {
84  using namespace std;
85 
86  string outputFile;
88  int debug;
89 
90  try {
91 
92  JParser<> zap("Auxiliary program to create TEllipse");
93 
94  zap['o'] = make_field(outputFile);
95  zap['p'] = make_field(parameters, "x y r1 [r2 [phimin phimax]]");
96  zap['d'] = make_field(debug) = 1;
97 
98  zap(argc, argv);
99  }
100  catch(const exception &error) {
101  FATAL(error.what() << endl);
102  }
103 
104 
105  TFile out(outputFile.c_str(), "recreate");
106 
107  TEllipse* p = new TEllipse(parameters.x1, parameters.y1, parameters.r1, parameters.r2, parameters.phimin, parameters.phimax);
108 
109  p->SetFillStyle(0); // hollow
110 
111  out.WriteTObject(p);
112 
113  out.Write();
114  out.Close();
115 }
Utility class to parse command line options.
Definition: JParser.hh:1500
int main(int argc, char *argv[])
Definition: Main.cc:15
double r2
Definition: JEllipse.cc:71
double x1
Definition: JEllipse.cc:68
*fatal Wrong number of arguments esac JCookie sh typeset Z DETECTOR typeset Z SOURCE_RUN typeset Z TARGET_RUN set_variable PARAMETERS_FILE $WORKDIR parameters
Definition: diff-Tuna.sh:38
friend std::ostream & operator<<(std::ostream &out, const JEllipse &ellipse)
Write ellipse to output stream.
Definition: JEllipse.cc:56
string outputFile
double phimax
Definition: JEllipse.cc:73
friend std::istream & operator>>(std::istream &in, JEllipse &ellipse)
Read ellipse from input stream.
Definition: JEllipse.cc:24
double r1
Definition: JEllipse.cc:70
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1961
double y1
Definition: JEllipse.cc:69
Auxiliary data structure for ellipse.
Definition: JEllipse.cc:15
double phimin
Definition: JEllipse.cc:72
int debug
debug level
Definition: JSirene.cc:63
General purpose messaging.
#define FATAL(A)
Definition: JMessage.hh:67
Utility class to parse command line options.
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 source JAcoustics sh $DETECTOR_ID CHECK_EXIT_CODE typeset A TRIPODS get_tripods $WORKDIR tripod txt TRIPODS for EMITTER in
Definition: JCanberra.sh:40