Jpp  17.1.0
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JDrawDetector1D.cc
Go to the documentation of this file.
1 #include <string>
2 #include <iostream>
3 #include <limits>
4 #include <map>
5 
6 #include "TROOT.h"
7 #include "TGraph.h"
8 #include "JROOT/JGraph.hh"
9 #include "JROOT/JManager.hh"
10 #include "JDetector/JDetector.hh"
12 #include "Jeep/JParser.hh"
13 #include "Jeep/JMessage.hh"
14 
15 
16 /**
17  * \file
18  * Auxiliary program to draw the string of detector.
19  * \author mdejong
20  */
21 int main(int argc, char**argv)
22 {
23  using namespace std;
24  using namespace JPP;
25 
26  string detectorFile;
27  string outputFile;
28  double step;
29  int debug;
30 
31  try {
32 
33  JParser<> zap("Auxiliary program to draw the strigs of detector.");
34 
35  zap['a'] = make_field(detectorFile, "detector file") = JPARSER::initialised();
36  zap['o'] = make_field(outputFile, "graphics output") = "detector.root";
37  zap['z'] = make_field(step) = 0.0;
38  zap['d'] = make_field(debug) = 1;
39 
40  zap(argc, argv);
41  }
42  catch(const exception &error) {
43  FATAL(error.what() << endl);
44  }
45 
46 
48 
49  try {
50  load(detectorFile, detector);
51  }
52  catch(const JException& error) {
53  FATAL(error);
54  }
55 
58 
59  for (JDetector::const_iterator module = detector.begin(); module != detector.end(); ++module) {
60  if (module->getFloor() == 1) {
61  if (step != 0.0)
62  z0[module->getString()] = module->getZ();
63  else
64  z0[module->getString()] = 0.0;
65  }
66  }
67 
68  for (JDetector::const_iterator module = detector.begin(); module != detector.end(); ++module) {
69  if (module->getFloor() != 0) {
70  H0[module->getString()].put((Double_t) module->getFloor(), module->getZ() - (module->getFloor() - 1) * step - z0[module->getString()]);
71  }
72  }
73 
74  TFile out(outputFile.c_str(), "recreate");
75 
76  for (map<int, JGraph_t>::const_iterator i = H0.begin(); i != H0.end(); ++i) {
77  out << JGraph(i->second, MAKE_CSTRING("G[" << i->first << "].string"));
78  }
79 
80  out.Write();
81  out.Close();
82 
83 }
Utility class to parse command line options.
Definition: JParser.hh:1500
General exception.
Definition: JException.hh:23
int main(int argc, char *argv[])
Definition: Main.cc:15
Detector data structure.
Definition: JDetector.hh:89
#define MAKE_CSTRING(A)
Make C-string.
Definition: JPrint.hh:151
Empty structure for specification of parser element that is initialised (i.e. does not require input)...
Definition: JParser.hh:66
Dynamic ROOT object management.
Auxiliary data structure to build TGraph.
Definition: JGraph.hh:42
string outputFile
Data structure for detector geometry and calibration.
Detector file.
Definition: JHead.hh:226
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1961
int debug
debug level
Definition: JSirene.cc:67
General purpose messaging.
#define FATAL(A)
Definition: JMessage.hh:67
void load(const std::string &file_name, JDetector &detector)
Load detector from input file.
Utility class to parse command line options.
do set_variable DETECTOR_TXT $WORKDIR detector