Jpp  18.3.1
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Functions
JNTupleToDetector.cc File Reference

Program to convert ntuples to detector. More...

#include <string>
#include <iostream>
#include <iomanip>
#include "JDetector/JDetector.hh"
#include "JDetector/JDetectorToolkit.hh"
#include "JDetector/JModuleRouter.hh"
#include "JDetector/JDetectorAddressMap.hh"
#include "JDetector/JDetectorSupportkit.hh"
#include "JDetector/JModuleGeometry.hh"
#include "JIO/JFileStreamIO.hh"
#include "Jeep/JParser.hh"
#include "Jeep/JMessage.hh"
#include "Jeep/JTimer.hh"

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Detailed Description

Program to convert ntuples to detector.

Author
mdejong

Definition in file JNTupleToDetector.cc.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 25 of file JNTupleToDetector.cc.

26 {
27  using namespace std;
28 
29  string detectorFile;
30  string ntupleFile;
31  string outputFile;
32  int debug;
33 
34  try {
35 
36  JParser<> zap("Program to convert ntuples to detector.");
37 
38  zap['a'] = make_field(detectorFile);
39  zap['f'] = make_field(ntupleFile);
40  zap['o'] = make_field(outputFile) = "";
41  zap['d'] = make_field(debug) = 0;
42 
43  zap(argc, argv);
44  }
45  catch(const exception &error) {
46  FATAL(error.what() << endl);
47  }
48 
49 
50  using namespace JPP;
51 
52 
54 
55  try {
56  load(detectorFile, detector);
57  }
58  catch(const JException& error) {
59  FATAL(error);
60  }
61 
62 
63  const JModuleRouter router(detector);
64  const JDetectorBuilder& demo = getDetectorBuilder(detector.getID());
65 
66 
67  JTimer timer("module");
68 
69  JFileStreamReader in(ntupleFile.c_str());
70 
71  for (JModuleGeometry geometry; in.load(geometry); ) {
72 
73  DEBUG(geometry << endl);
74 
75  const int id = geometry.getID();
76 
77  if (router.hasModule(id)) {
78 
79  timer.start();
80 
81  const JEulerMatrix3D R(geometry.getEulerAngle());
82 
83  JModule master = demo.getModule(id);
84 
85  master.rotate(R);
86  master.add(geometry.getPosition());
87 
88  JModule& module = detector.getModule(router.getAddress(id));
89 
90  if (module.size() == master.size()) {
91 
92  for (int pmt = 0; pmt != (int) master.size(); ++pmt) {
93  module.getPMT(pmt).setAxis(master.getPMT(pmt).getAxis());
94  }
95 
96  module.compile();
97 
98  } else {
99 
100  ERROR("Module sizes inconsistent " << module.size() << " != " << master.size() << endl);
101  }
102 
103  timer.stop();
104 
105  } else {
106 
107  ERROR("Missing module " << geometry.getID() << endl);
108  }
109  }
110 
111  in.close();
112 
113  timer.print(cout);
114 
115  if (outputFile != "") {
116 
117  if (outputFile == "%") {
118  outputFile = detectorFile;
119  }
120 
121  try {
123  }
124  catch(const JException& error) {
125  FATAL(error);
126  }
127  }
128 }
Utility class to parse command line options.
Definition: JParser.hh:1514
General exception.
Definition: JException.hh:24
then echo Test string reversed by master(hit< return > to continue)." $DIR/JProcess -c "$DIR/JEcho" -rC fi if (( 1 ))
Data structure for a composite optical module.
Definition: JModule.hh:67
Detector data structure.
Definition: JDetector.hh:89
Router for direct addressing of module data in detector data structure.
void setAxis(const JAxis3D &axis)
Set axis.
Definition: JAxis3D.hh:109
string outputFile
Detector file.
Definition: JHead.hh:226
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1989
void compile()
Compile module data.
Definition: JModule.hh:281
void store(const std::string &file_name, const JDetector &detector)
Store detector to output file.
Auxiliary class for CPU timing and usage.
Definition: JTimer.hh:32
#define ERROR(A)
Definition: JMessage.hh:66
const JPMT & getPMT(const int index) const
Get PMT.
Definition: JModule.hh:172
#define FATAL(A)
Definition: JMessage.hh:67
then JCookie sh JDataQuality D $DETECTOR_ID R
Definition: JDataQuality.sh:41
void load(const std::string &file_name, JDetector &detector)
Load detector from input file.
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 JAcoustics sh $DETECTOR_ID source JAcousticsToolkit sh CHECK_EXIT_CODE typeset A EMITTERS get_tripods $WORKDIR tripod txt EMITTERS get_transmitters $WORKDIR transmitter txt EMITTERS for EMITTER in
Definition: JCanberra.sh:48
do set_variable DETECTOR_TXT $WORKDIR detector
JDetectorBuilder & getDetectorBuilder()
Get detector builder.
Auxiliary interface for building detector.
Binary buffered file input.
int debug
debug level
#define DEBUG(A)
Message macros.
Definition: JMessage.hh:62