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
JLine.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 "TLine.h"
7 
8 #include "Jeep/JParser.hh"
9 #include "Jeep/JMessage.hh"
10 
11 
12 /**
13  * Auxiliary data structure for line.
14  */
15 struct JLine {
16 
17  /**
18  * Read line from input stream.
19  *
20  * \param in input stream
21  * \param line line
22  * \return input stream
23  */
24  friend inline std::istream& operator>>(std::istream& in, JLine& line)
25  {
26  return in >> line.x1 >> line.y1 >> line.x2 >> line.y2;
27  }
28 
29  /**
30  * Write line to output stream.
31  *
32  * \param out output stream
33  * \param line line
34  * \return output stream
35  */
36  friend inline std::ostream& operator<<(std::ostream& out, const JLine& line)
37  {
38  return out << line.x1 << ' ' << line.y1 << ' ' << line.x2 << ' ' << line.y2;
39  }
40 
41  double x1;
42  double y1;
43  double x2;
44  double y2;
45 };
46 
47 
48 /**
49  * \file
50  * Auxiliary program to create TLine.
51  * \author mdejong
52  */
53 int main(int argc, char **argv)
54 {
55  using namespace std;
56 
57  string outputFile;
59  int debug;
60 
61  try {
62 
63  JParser<> zap("Auxiliary program to create TLine.");
64 
65  zap['o'] = make_field(outputFile);
66  zap['p'] = make_field(parameters, "x1 y1 x2 y2");
67  zap['d'] = make_field(debug) = 1;
68 
69  zap(argc, argv);
70  }
71  catch(const exception &error) {
72  FATAL(error.what() << endl);
73  }
74 
75 
76  TFile out(outputFile.c_str(), "recreate");
77 
78  TLine* p = new TLine(parameters.x1, parameters.y1, parameters.x2, parameters.y2);
79 
80  out.WriteTObject(p);
81 
82  out.Write();
83  out.Close();
84 }
Utility class to parse command line options.
Definition: JParser.hh:1500
int main(int argc, char *argv[])
Definition: Main.cc:15
double y1
Definition: JLine.cc:42
double y2
Definition: JLine.cc:44
*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
double x2
Definition: JLine.cc:43
string outputFile
friend std::istream & operator>>(std::istream &in, JLine &line)
Read line from input stream.
Definition: JLine.cc:24
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1961
int debug
debug level
Definition: JSirene.cc:63
double x1
Definition: JLine.cc:41
General purpose messaging.
friend std::ostream & operator<<(std::ostream &out, const JLine &line)
Write line to output stream.
Definition: JLine.cc:36
#define FATAL(A)
Definition: JMessage.hh:67
Auxiliary data structure for line.
Definition: JLine.cc:15
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