Jpp  17.0.0-rc.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/JDetectorAddressMapToolkit.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 24 of file JNTupleToDetector.cc.

25 {
26  using namespace std;
27 
28  string detectorFile;
29  string ntupleFile;
30  string outputFile;
31  int debug;
32 
33  try {
34 
35  JParser<> zap("Program to convert ntuples to detector.");
36 
37  zap['a'] = make_field(detectorFile);
38  zap['f'] = make_field(ntupleFile);
39  zap['o'] = make_field(outputFile) = "";
40  zap['d'] = make_field(debug) = 0;
41 
42  zap(argc, argv);
43  }
44  catch(const exception &error) {
45  FATAL(error.what() << endl);
46  }
47 
48 
49  using namespace JPP;
50 
51 
53 
54  try {
55  load(detectorFile, detector);
56  }
57  catch(const JException& error) {
58  FATAL(error);
59  }
60 
61 
62  const JModuleRouter router(detector);
63  const JDetectorAddressMap& demo = getDetectorAddressMap(detector.getID());
64 
65 
66  JTimer timer("module");
67 
68  JFileStreamReader in(ntupleFile.c_str());
69 
70  for (JModuleGeometry geometry; in.load(geometry); ) {
71 
72  DEBUG(geometry << endl);
73 
74  const int id = geometry.getID();
75 
76  if (router.hasModule(id)) {
77 
78  timer.start();
79 
80  const JEulerMatrix3D R(geometry.getEulerAngle());
81 
82  JModule master = getModule(demo.get(id), id);
83 
84  master.rotate(R);
85  master.add(geometry.getPosition());
86 
87  JModule& module = detector.getModule(router.getAddress(id));
88 
89  if (module.size() == master.size()) {
90 
91  for (int pmt = 0; pmt != (int) master.size(); ++pmt) {
92  module.getPMT(pmt).setAxis(master.getPMT(pmt).getAxis());
93  }
94 
95  module.compile();
96 
97  } else {
98 
99  ERROR("Module sizes inconsistent " << module.size() << " != " << master.size() << endl);
100  }
101 
102  timer.stop();
103 
104  } else {
105 
106  ERROR("Missing module " << geometry.getID() << endl);
107  }
108  }
109 
110  in.close();
111 
112  timer.print(cout);
113 
114  if (outputFile != "") {
115 
116  if (outputFile == "%") {
117  outputFile = detectorFile;
118  }
119 
120  try {
122  }
123  catch(const JException& error) {
124  FATAL(error);
125  }
126  }
127 }
Utility class to parse command line options.
Definition: JParser.hh:1500
General exception.
Definition: JException.hh:23
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:68
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
Lookup table for PMT addresses in detector.
string outputFile
Detector file.
Definition: JHead.hh:224
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1961
void compile()
Compile module data.
Definition: JModule.hh:282
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
int debug
debug level
Definition: JSirene.cc:66
JDetectorAddressMap & getDetectorAddressMap()
Get detector address map.
const JPMT & getPMT(const int index) const
Get PMT.
Definition: JModule.hh:173
void rotate(const JRotation3D &R)
Rotate module.
Definition: JModule.hh:315
then usage $script[distance] fi case set_variable R
Definition: JDrawLED.sh:43
#define FATAL(A)
Definition: JMessage.hh:67
void load(const std::string &file_name, JDetector &detector)
Load detector from input file.
do set_variable DETECTOR_TXT $WORKDIR detector
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:46
Binary buffered file input.
const JModule & getModule(const JDetector &detector, const JModuleLocation &location)
find module with a given string and floor number
#define DEBUG(A)
Message macros.
Definition: JMessage.hh:62