Jpp  17.2.1-pre0
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 "TH1D.h"
9 #include "JROOT/JGraph.hh"
10 #include "JROOT/JManager.hh"
11 #include "JMath/JMath.hh"
12 #include "JPhysics/JConstants.hh"
13 #include "JDetector/JDetector.hh"
15 #include "Jeep/JParser.hh"
16 #include "Jeep/JMessage.hh"
17 
18 
19 /**
20  * \file
21  * Auxiliary program to draw the string of detector.
22  * \author mdejong
23  */
24 int main(int argc, char**argv)
25 {
26  using namespace std;
27  using namespace JPP;
28 
29  string detectorFile;
30  string outputFile;
31  double step;
32  int debug;
33 
34  try {
35 
36  JParser<> zap("Auxiliary program to draw the strigs of detector.");
37 
38  zap['a'] = make_field(detectorFile, "detector file") = JPARSER::initialised();
39  zap['o'] = make_field(outputFile, "graphics output") = "detector.root";
40  zap['z'] = make_field(step) = 0.0;
41  zap['d'] = make_field(debug) = 1;
42 
43  zap(argc, argv);
44  }
45  catch(const exception &error) {
46  FATAL(error.what() << endl);
47  }
48 
49 
51 
52  try {
53  load(detectorFile, detector);
54  }
55  catch(const JException& error) {
56  FATAL(error);
57  }
58 
59  const double V = 0.61 * C;
60 
61  JManager<int, TH1D> H1(new TH1D("H[%].s", NULL, 500, -1.0e3, 1.0e+3));
63 
66 
67  for (JDetector::const_iterator module = detector.begin(); module != detector.end(); ++module) {
68 
69  if (module->getFloor() == 1) {
70 
71  if (step != 0.0)
72  z0[module->getString()] = module->getZ();
73  else
74  z0[module->getString()] = 0.0;
75 
76  z1[module->getString()] = module->getZ() - getAverage(make_array(module->begin(), module->end(), &JPMT::getT0)) * V;
77  }
78  }
79 
80  for (JDetector::const_iterator module = detector.begin(); module != detector.end(); ++module) {
81 
82  if (module->getFloor() != 0) {
83 
84  const double dz = module->getZ() - (module->getFloor() - 1) * step - z0[module->getString()];
85  const double ds = module->getZ() - getAverage(make_array(module->begin(), module->end(), &JPMT::getT0)) * V - z1[module->getString()];
86 
87  H0[module->getString()].put((Double_t) module->getFloor(), dz);
88  H1[module->getString()]->Fill(ds);
89 
90  DEBUG(module->getLocation() << ' ' << FIXED(7,3) << ds << endl);
91  }
92  }
93 
94  TFile out(outputFile.c_str(), "recreate");
95 
96  out << H1;
97 
98  for (map<int, JGraph_t>::const_iterator i = H0.begin(); i != H0.end(); ++i) {
99  out << JGraph(i->second, MAKE_CSTRING("G[" << i->first << "].string"));
100  }
101 
102  out.Write();
103  out.Close();
104 
105 }
Utility class to parse command line options.
Definition: JParser.hh:1517
General exception.
Definition: JException.hh:23
int main(int argc, char *argv[])
Definition: Main.cc:15
Detector data structure.
Definition: JDetector.hh:89
std::iterator_traits< T >::value_type getAverage(T __begin, T __end)
Get average.
Definition: JMath.hh:494
#define MAKE_CSTRING(A)
Make C-string.
Definition: JPrint.hh:136
Empty structure for specification of parser element that is initialised (i.e. does not require input)...
Definition: JParser.hh:83
Dynamic ROOT object management.
Auxiliary data structure for floating point format specification.
Definition: JManip.hh:446
Auxiliary data structure to build TGraph.
Definition: JGraph.hh:42
V(JDAQEvent-JTriggerReprocessor)*1.0/(JDAQEvent+1.0e-10)
string outputFile
Data structure for detector geometry and calibration.
static const double C
Physics constants.
Auxiliary class to manage set of compatible ROOT objects (e.g. histograms) using unique keys...
Definition: JManager.hh:43
Detector file.
Definition: JHead.hh:226
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1993
const array_type< JValue_t > & make_array(const JValue_t(&array)[N])
Method to create array of values.
Definition: JVectorize.hh:54
Physics constants.
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.
Base class for data structures with artithmetic capabilities.
do set_variable DETECTOR_TXT $WORKDIR detector
int debug
debug level
#define DEBUG(A)
Message macros.
Definition: JMessage.hh:62