Jpp  18.0.0-rc.1
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 z-positions of the modules in 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  int debug;
32 
33  try {
34 
35  JParser<> zap("Auxiliary program to draw the z-positions of the modules in detector.");
36 
37  zap['a'] = make_field(detectorFile, "detector file") = JPARSER::initialised();
38  zap['o'] = make_field(outputFile, "graphics output") = "detector.root";
39  zap['d'] = make_field(debug) = 1;
40 
41  zap(argc, argv);
42  }
43  catch(const exception &error) {
44  FATAL(error.what() << endl);
45  }
46 
47 
48  JDetector detector;
49 
50  try {
51  load(detectorFile, detector);
52  }
53  catch(const JException& error) {
54  FATAL(error);
55  }
56 
57  const double V = 0.61 * C;
58 
59  JManager<int, TH1D> H1(new TH1D("H[%].s", NULL, 500, -1.0e3, 1.0e+3));
61 
64 
65  for (JDetector::const_iterator module = detector.begin(); module != detector.end(); ++module) {
66 
67  if (module->getFloor() == 1) {
68  z0[module->getString()] = module->getZ() - getAverage(make_array(module->begin(), module->end(), &JPMT::getT0)) * V;
69  }
70 
71  z1[module->getString()][module->getFloor()] = module->getZ();
72  }
73 
74  for (JDetector::const_iterator module = detector.begin(); module != detector.end(); ++module) {
75 
76  if (module->getFloor() != 0) {
77 
78  const double ds = module->getZ() - getAverage(make_array(module->begin(), module->end(), &JPMT::getT0)) * V - z0[module->getString()];
79 
80  HA[module->getString()].put((Double_t) module->getFloor(), module->getZ());
81  H1[module->getString()]->Fill(ds);
82  }
83  }
84 
85  TFile out(outputFile.c_str(), "recreate");
86 
87  out << H1;
88 
89  for (map<int, JGraph_t>::const_iterator i = HA.begin(); i != HA.end(); ++i) {
90  out << JGraph(i->second, MAKE_CSTRING("G[" << i->first << "].string"));
91  }
92 
93  for (auto& string : z1) {
94 
95  JGraph_t g1;
96 
97  for (auto& module : string.second) {
98  if (module.first > 0 && string.second.count(module.first - 1) != 0) {
99  g1.put((Double_t) module.first, module.second - string.second[module.first - 1]);
100  }
101  }
102 
103  out << JGraph(g1, MAKE_CSTRING("G[" << string.first << "].floor"));
104  }
105 
106  out.Write();
107  out.Close();
108 
109 }
Utility class to parse command line options.
Definition: JParser.hh:1514
int main(int argc, char *argv[])
Definition: Main.cc:15
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.
V(JDAQEvent-JTriggerReprocessor)*1.0/(JDAQEvent+1.0e-10)
string outputFile
Data structure for detector geometry and calibration.
then echo The file $DIR KM3NeT_00000001_00000000 root already please rename or remove it first
static const double C
Physics constants.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1989
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
Double_t g1(const Double_t x)
Function.
Definition: JQuantiles.cc:25