Jpp  18.2.1-ARCA-DF-PATCH
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Functions
JPrintDetector.cc File Reference

Auxiliary program to print detector file in human friendly format. More...

#include <string>
#include <iostream>
#include <iomanip>
#include <set>
#include <iterator>
#include "JDetector/JDetector.hh"
#include "JDetector/JDetectorToolkit.hh"
#include "JDetector/JDetectorAddressMapToolkit.hh"
#include "JDetector/JModule.hh"
#include "JMath/JConstants.hh"
#include "JTools/JRange.hh"
#include "JSystem/JDateAndTime.hh"
#include "JGeometry3D/JGeometry3DToolkit.hh"
#include "JGeometry3D/JCylinder3D.hh"
#include "JGeometry3D/JQuaternion3D.hh"
#include "Jeep/JPrint.hh"
#include "Jeep/JParser.hh"
#include "Jeep/JMessage.hh"

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Detailed Description

Auxiliary program to print detector file in human friendly format.

Author
mdejong

Definition in file JPrintDetector.cc.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 57 of file JPrintDetector.cc.

58 {
59  using namespace std;
60  using namespace JPP;
61 
62  string detectorFile;
63  string option;
64  int debug;
65 
66  try {
67 
68  JParser<> zap("Auxiliary program to print detector file in human friendly format.");
69 
70  zap['a'] = make_field(detectorFile);
71  zap['O'] = make_field(option) =
72 
73  default_t,
74 
75  pmts_t,
76  modules_t,
77  geometry_t,
78 
79  comment_t,
80  header_t,
81  version_t,
82  identifier_t,
83  can_t,
84  center_t,
85  summary_t,
86 
87  HEADER_t,
88  VERSION_t,
89  IDENTIFIER_t,
90  CAN_t,
91  CENTER_t,
92  SUMMARY_t;
93 
94  zap['d'] = make_field(debug) = 1;
95 
96  zap(argc, argv);
97  }
98  catch(const exception &error) {
99  FATAL(error.what() << endl);
100  }
101 
102 
103  JDetector detector;
104 
105  try {
106  load(detectorFile, detector);
107  }
108  catch(const JException& error) {
109  FATAL(error);
110  }
111 
112  if (option == default_t) {
113 
114  cout << detector << endl;
115 
116  } else if (option == modules_t) {
117 
118  const JDetectorAddressMap& demo = getDetectorAddressMap(detector.getID());
119 
120  for (JDetector::const_iterator module = detector.begin(); module != detector.end(); ++module) {
121 
122  cout << "Module";
123  cout << ' ' << noshowpos << setw(8) << right << module->getID();
124  cout << ' ' << noshowpos << setw(3) << right << module->getString();
125  cout << ' ' << noshowpos << setw(2) << right << module->getFloor();
126  cout << ' ' << FIXED(7,2) << module->getX();
127  cout << ' ' << FIXED(7,2) << module->getY();
128  cout << ' ' << FIXED(7,2) << module->getZ();
129  cout << ' ' << FIXED(8,2) << module->getT0();
130 
131  if (module->getFloor() != 0) {
132  {
133  JModule buffer = getModule(demo.get(module->getID()), module->getID(), module->getLocation());
134 
135  const JQuaternion3D Q = getRotation(buffer, *module);
137 
138  const double phi = (JVector3Z_t.getDot(q1.twist) >= 0.0 ? +1.0 : -1.0) * q1.twist.getAngle();
139 
140  cout << ' ' << FIXED(7,2) << phi;
141  }
142  {
143  const JQuaternion3D Q = module->getQuaternion();
145 
146  const double phi = (JVector3Z_t.getDot(q1.twist) >= 0.0 ? +1.0 : -1.0) * q1.twist.getAngle();
147 
148  cout << ' ' << FIXED(7,2) << phi;
149  }
150  }
151 
152  cout << endl;
153  }
154 
155  } else if (option == pmts_t) {
156 
157  for (JDetector::const_iterator module = detector.begin(); module != detector.end(); ++module) {
158  for (JModule::const_iterator pmt = module->begin(); pmt != module->end(); ++pmt) {
159  cout << "PMT";
160  cout << ' ' << noshowpos << setw(8) << right << pmt->getID();
161  cout << ' ' << FIXED(7,2) << pmt->getX();
162  cout << ' ' << FIXED(7,2) << pmt->getY();
163  cout << ' ' << FIXED(7,2) << pmt->getZ();
164  cout << ' ' << FIXED(6,3) << pmt->getDX();
165  cout << ' ' << FIXED(6,3) << pmt->getDY();
166  cout << ' ' << FIXED(6,3) << pmt->getDZ();
167  cout << ' ' << FIXED(8,2) << pmt->getT0();
168  cout << ' ' << noshowpos << setw(8) << right << pmt->getStatus();
169  cout << endl;
170  }
171  }
172 
173  } else if (option == geometry_t) {
174 
175  cout << "Maximal distance [m] = " << FIXED(6,1) << getMaximalDistance(detector) << endl;
176  cout << "Maximal time [ns] = " << FIXED(6,1) << getMaximalTime (detector) << endl;
177 
178  } else if (option == comment_t) {
179 
180  cout << detector.comment << endl;
181 
182  } else if (option == header_t ||
183  option == HEADER_t) {
184 
185  if (option == header_t) {
186 
187  cout << detector.getProperties() << endl;
188  cout << "name = " << (isARCADetector(detector) ? "ARCA" :
189  isORCADetector(detector) ? "ORCA" :
190  "unknown") << endl;
191  cout << "validity = "
192  << JDateAndTime(detector.getLowerLimit(), true).toString() << ' '
193  << JDateAndTime(detector.getUpperLimit(), true).toString() << endl;
194 
195  } else {
196 
197  cout << "set_variable UTM_EAST " << FIXED(12,2) << detector.getUTMEast() << ";" << endl;
198  cout << "set_variable UTM_NORTH " << FIXED(12,2) << detector.getUTMNorth() << ";" << endl;
199  cout << "set_variable UTM_Z " << FIXED(12,2) << detector.getUTMZ() << ";" << endl;
200  cout << "set_variable UTM_ZONE " << FIXED(12,2) << detector.getUTMZone() << ";" << endl;
201  cout << "set_variable UTM_WGS " << FIXED(12,2) << detector.getWGS() << ";" << endl;
202  }
203 
204  } else if (option == version_t ||
205  option == VERSION_t) {
206 
207  if (option == version_t) {
208 
209  cout << detector.getVersion() << endl;
210 
211  } else {
212 
213  cout << "set_variable DETECTOR_VERSION " << detector.getVersion() << ";" << endl;
214  }
215 
216  } else if (option == identifier_t ||
217  option == IDENTIFIER_t) {
218 
219  if (option == identifier_t) {
220 
221  cout << "Detector " << detector.getID() << endl;
222 
223  } else {
224 
225  cout << "set_variable DETECTOR_ID " << detector.getID() << ";" << endl;
226  }
227 
228  } else if (option == can_t ||
229  option == CAN_t) {
230 
231  const JCylinder3D cylinder(detector.begin(), detector.end());
232 
233  const double V = (cylinder.getZmax() - cylinder.getZmin()) * PI * cylinder.getRadius() * cylinder.getRadius();
234  const double D = getMaximalDistance(detector);
235 
236  if (option == can_t) {
237 
238  cout << "X = " << FIXED(7,1) << cylinder.getX() << endl;
239  cout << "Y = " << FIXED(7,1) << cylinder.getY() << endl;
240  cout << "Zmin = " << FIXED(7,1) << cylinder.getZmin() << endl;
241  cout << "Zmax = " << FIXED(7,1) << cylinder.getZmax() << endl;
242  cout << "Radius = " << FIXED(7,1) << cylinder.getRadius() << endl;
243  cout << "Depth = " << FIXED(7,1) << detector.getUTMZ() << endl;
244  cout << "Volume = " << SCIENTIFIC(12,3) << V << endl;
245  cout << "Distance = " << FIXED(9,3) << D << endl;
246 
247  } else {
248 
249  cout << "set_variable CAN_X_M " << FIXED(7,1) << cylinder.getX() << ";" << endl;
250  cout << "set_variable CAN_Y_M " << FIXED(7,1) << cylinder.getY() << ";" << endl;
251  cout << "set_variable CAN_ZMIN_M " << FIXED(7,1) << cylinder.getZmin() << ";" << endl;
252  cout << "set_variable CAN_ZMAX_M " << FIXED(7,1) << cylinder.getZmax() << ";" << endl;
253  cout << "set_variable CAN_RADIUS_M " << FIXED(7,1) << cylinder.getRadius() << ";" << endl;
254  cout << "set_variable CAN_DEPTH_M " << FIXED(7,1) << detector.getUTMZ() << ";" << endl;
255  cout << "set_variable CAN_VOLUME_M3 " << SCIENTIFIC(12,3) << V << ";" << endl;
256  cout << "set_variable CAN_DISTANCE_M " << FIXED(9,3) << D << ";" << endl;
257  }
258 
259  } else if (option == center_t ||
260  option == CENTER_t) {
261 
262  const JCenter3D center(detector.begin(), detector.end());
263 
264  if (option == center_t) {
265 
266  cout << "center = ";
267  cout << showpos << FIXED(8,3) << center.getX() << ' ';
268  cout << showpos << FIXED(8,3) << center.getY() << ' ';
269  cout << showpos << FIXED(8,3) << center.getZ() << endl;
270 
271  } else {
272 
273  cout << "set_variable CENTER_X_M " << FIXED(7,1) << center.getX() << ";" << endl;
274  cout << "set_variable CENTER_Y_M " << FIXED(7,1) << center.getY() << ";" << endl;
275  cout << "set_variable CENTER_Z_M " << FIXED(7,1) << center.getZ() << ";" << endl;
276  }
277 
278  } else if (option == summary_t ||
279  option == SUMMARY_t) {
280 
281  const int numberOfStrings = getNumberOfStrings(detector);
282  const int numberOfFloors = getNumberOfFloors (detector);
283  const int numberOfModules = getNumberOfModules(detector);
284  const int numberOfPMTs = getNumberOfPMTs (detector);
285 
286  typedef JTOOLS::JRange<int> JRange_t;
287 
288  const JRange_t string(make_array(detector.begin(), detector.end(), &JModule::getString));
289  const JRange_t floor (make_array(detector.begin(), detector.end(), &JModule::getFloor));
290 
292 
293  for (JDetector::const_iterator module = detector.begin(); module != detector.end(); ++module) {
294  strings.insert(module->getString());
295  }
296 
297  if (option == summary_t) {
298 
299  cout << "Number of strings = " << setw(4) << numberOfStrings << endl;
300  cout << "Number of floors = " << setw(4) << numberOfFloors << endl;
301  cout << "Number of modules = " << setw(4) << numberOfModules << endl;
302  cout << "Number of PMTs = " << setw(4) << numberOfPMTs << endl;
303  cout << "First string = " << setw(4) << string.first << endl;
304  cout << "Last string = " << setw(4) << string.second << endl;
305  cout << "First floor = " << setw(4) << floor .first << endl;
306  cout << "Last floor = " << setw(4) << floor .second << endl;
307 
308  } else {
309 
310  cout << "set_variable NUMBER_OF_STRINGS " << setw(4) << numberOfStrings << ";" << endl;
311  cout << "set_variable NUMBER_OF_FLOORS " << setw(4) << numberOfFloors << ";" << endl;
312  cout << "set_variable NUMBER_OF_MODULES " << setw(4) << numberOfModules << ";" << endl;
313  cout << "set_variable NUMBER_OF_PMTS " << setw(4) << numberOfPMTs << ";" << endl;
314  cout << "set_variable FIRST_STRING " << setw(4) << string.first << ";" << endl;
315  cout << "set_variable LAST_STRING " << setw(4) << string.second << ";" << endl;
316  cout << "set_variable FIRST_FLOOR " << setw(4) << floor .first << ";" << endl;
317  cout << "set_variable LAST_FLOOR " << setw(4) << floor .second << ";" << endl;
318  cout << "set_array STRINGS ";
319  copy(strings.begin(), strings.end(), ostream_iterator<int>(cout, " "));
320  cout << endl;
321  }
322  }
323 }
bool isORCADetector(const JDetectorHeader &header)
Check if given detector header is compatible with that of ORCA.
Utility class to parse command line options.
Definition: JParser.hh:1514
Q(UTCMax_s-UTCMin_s)-livetime_s
bool isARCADetector(const JDetectorHeader &header)
Check if given detector header is compatible with tat of ARCA.
int getNumberOfPMTs(const JModule &module)
Get number of PMTs.
static JRotation getRotation
Function object to get rotation matrix to go from first to second module.
then usage $script< detector specific pre-calibration script >< option > nAuxiliary script to make scan of pre stretching of detector strings(see JEditDetector)." "\nPossible options
Auxiliary data structure for floating point format specification.
Definition: JManip.hh:446
static const JModuleCounter getNumberOfModules
Function object to count unique modules.
V(JDAQEvent-JTriggerReprocessor)*1.0/(JDAQEvent+1.0e-10)
JMODEL::JString getString(const JFit &fit)
Get model parameters of string.
#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
int getNumberOfFloors(const JDetector &detector)
Get number of floors.
then awk string
static const double PI
Mathematical constants.
double getMaximalTime(const double R_Hz)
Get maximal time for given rate.
JDetectorAddressMap & getDetectorAddressMap()
Get detector address map.
static const JStringCounter getNumberOfStrings
Function object to count unique strings.
#define FATAL(A)
Definition: JMessage.hh:67
void load(const std::string &file_name, JDetector &detector)
Load detector from input file.
static const JVector3D JVector3Z_t(0, 0, 1)
unit z-vector
void copy(const Head &from, JHead &to)
Copy header from from to to.
Definition: JHead.cc:162
double getMaximalDistance(const JDetector &detector, const bool option=false)
Get maximal distance between modules in detector.
double getDot(const JVector3D &vector) const
Get dot product.
Definition: JVector3D.hh:282
do set_variable DETECTOR_TXT $WORKDIR detector
Auxiliary data structure for decomposition of quaternion in twist and swing quaternions.
Auxiliary data structure for floating point format specification.
Definition: JManip.hh:484
do echo Generating $dir eval D
Definition: JDrawLED.sh:53
const JModule & getModule(const JDetector &detector, const JModuleLocation &location)
find module with a given string and floor number
int debug
debug level