Jpp  18.2.0-rc.1
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 "JMath/JConstants.hh"
#include "JTools/JRange.hh"
#include "JSystem/JDateAndTime.hh"
#include "JGeometry3D/JGeometry3DToolkit.hh"
#include "JGeometry3D/JCylinder3D.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 54 of file JPrintDetector.cc.

55 {
56  using namespace std;
57 
58  string detectorFile;
59  string option;
60  int debug;
61 
62  try {
63 
64  JParser<> zap("Auxiliary program to print detector file in human friendly format.");
65 
66  zap['a'] = make_field(detectorFile);
67  zap['O'] = make_field(option) =
68 
69  default_t,
70 
71  pmts_t,
72  modules_t,
73  geometry_t,
74 
75  comment_t,
76  header_t,
77  version_t,
78  identifier_t,
79  can_t,
80  center_t,
81  summary_t,
82 
83  HEADER_t,
84  VERSION_t,
85  IDENTIFIER_t,
86  CAN_t,
87  CENTER_t,
88  SUMMARY_t;
89 
90  zap['d'] = make_field(debug) = 1;
91 
92  zap(argc, argv);
93  }
94  catch(const exception &error) {
95  FATAL(error.what() << endl);
96  }
97 
98  using namespace JPP;
99 
100  JDetector detector;
101 
102  try {
103  load(detectorFile, detector);
104  }
105  catch(const JException& error) {
106  FATAL(error);
107  }
108 
109 
110  if (option == default_t) {
111 
112  cout << detector << endl;
113 
114  } else if (option == modules_t) {
115 
116  for (JDetector::const_iterator module = detector.begin(); module != detector.end(); ++module) {
117 
118  cout << "Module";
119  cout << ' ' << noshowpos << setw(8) << right << module->getID();
120  cout << ' ' << noshowpos << setw(3) << right << module->getString();
121  cout << ' ' << noshowpos << setw(2) << right << module->getFloor();
122  cout << ' ' << FIXED(7,2) << module->getX();
123  cout << ' ' << FIXED(7,2) << module->getY();
124  cout << ' ' << FIXED(7,2) << module->getZ();
125  cout << ' ' << FIXED(8,2) << module->getT0();
126  cout << endl;
127  }
128 
129  } else if (option == pmts_t) {
130 
131  for (JDetector::const_iterator module = detector.begin(); module != detector.end(); ++module) {
132  for (JModule::const_iterator pmt = module->begin(); pmt != module->end(); ++pmt) {
133 
134  cout << "PMT";
135  cout << ' ' << noshowpos << setw(8) << right << pmt->getID();
136  cout << ' ' << FIXED(7,2) << pmt->getX();
137  cout << ' ' << FIXED(7,2) << pmt->getY();
138  cout << ' ' << FIXED(7,2) << pmt->getZ();
139  cout << ' ' << FIXED(6,3) << pmt->getDX();
140  cout << ' ' << FIXED(6,3) << pmt->getDY();
141  cout << ' ' << FIXED(6,3) << pmt->getDZ();
142  cout << ' ' << FIXED(8,2) << pmt->getT0();
143  cout << ' ' << noshowpos << setw(8) << right << pmt->getStatus();
144  cout << endl;
145  }
146  }
147 
148  } else if (option == geometry_t) {
149 
150  cout << "Maximal distance [m] = " << FIXED(6,1) << getMaximalDistance(detector) << endl;
151  cout << "Maximal time [ns] = " << FIXED(6,1) << getMaximalTime (detector) << endl;
152 
153  } else if (option == comment_t) {
154 
155  cout << detector.comment << endl;
156 
157  } else if (option == header_t ||
158  option == HEADER_t) {
159 
160  if (option == header_t) {
161 
162  cout << detector.getProperties() << endl;
163  cout << "name = " << (isARCADetector(detector) ? "ARCA" :
164  isORCADetector(detector) ? "ORCA" :
165  "unknown") << endl;
166  cout << "validity = "
167  << JDateAndTime(detector.getLowerLimit(), true).toString() << ' '
168  << JDateAndTime(detector.getUpperLimit(), true).toString() << endl;
169 
170  } else {
171 
172  cout << "set_variable UTM_EAST " << FIXED(12,2) << detector.getUTMEast() << ";" << endl;
173  cout << "set_variable UTM_NORTH " << FIXED(12,2) << detector.getUTMNorth() << ";" << endl;
174  cout << "set_variable UTM_Z " << FIXED(12,2) << detector.getUTMZ() << ";" << endl;
175  cout << "set_variable UTM_ZONE " << FIXED(12,2) << detector.getUTMZone() << ";" << endl;
176  cout << "set_variable UTM_WGS " << FIXED(12,2) << detector.getWGS() << ";" << endl;
177  }
178 
179  } else if (option == version_t ||
180  option == VERSION_t) {
181 
182  if (option == version_t) {
183 
184  cout << detector.getVersion() << endl;
185 
186  } else {
187 
188  cout << "set_variable DETECTOR_VERSION " << detector.getVersion() << ";" << endl;
189  }
190 
191  } else if (option == identifier_t ||
192  option == IDENTIFIER_t) {
193 
194  if (option == identifier_t) {
195 
196  cout << "Detector " << detector.getID() << endl;
197 
198  } else {
199 
200  cout << "set_variable DETECTOR_ID " << detector.getID() << ";" << endl;
201  }
202 
203  } else if (option == can_t ||
204  option == CAN_t) {
205 
206  const JCylinder3D cylinder(detector.begin(), detector.end());
207 
208  const double V = (cylinder.getZmax() - cylinder.getZmin()) * PI * cylinder.getRadius() * cylinder.getRadius();
209  const double D = getMaximalDistance(detector);
210 
211  if (option == can_t) {
212 
213  cout << "X = " << FIXED(7,1) << cylinder.getX() << endl;
214  cout << "Y = " << FIXED(7,1) << cylinder.getY() << endl;
215  cout << "Zmin = " << FIXED(7,1) << cylinder.getZmin() << endl;
216  cout << "Zmax = " << FIXED(7,1) << cylinder.getZmax() << endl;
217  cout << "Radius = " << FIXED(7,1) << cylinder.getRadius() << endl;
218  cout << "Depth = " << FIXED(7,1) << detector.getUTMZ() << endl;
219  cout << "Volume = " << SCIENTIFIC(12,3) << V << endl;
220  cout << "Distance = " << FIXED(9,3) << D << endl;
221 
222  } else {
223 
224  cout << "set_variable CAN_X_M " << FIXED(7,1) << cylinder.getX() << ";" << endl;
225  cout << "set_variable CAN_Y_M " << FIXED(7,1) << cylinder.getY() << ";" << endl;
226  cout << "set_variable CAN_ZMIN_M " << FIXED(7,1) << cylinder.getZmin() << ";" << endl;
227  cout << "set_variable CAN_ZMAX_M " << FIXED(7,1) << cylinder.getZmax() << ";" << endl;
228  cout << "set_variable CAN_RADIUS_M " << FIXED(7,1) << cylinder.getRadius() << ";" << endl;
229  cout << "set_variable CAN_DEPTH_M " << FIXED(7,1) << detector.getUTMZ() << ";" << endl;
230  cout << "set_variable CAN_VOLUME_M3 " << SCIENTIFIC(12,3) << V << ";" << endl;
231  cout << "set_variable CAN_DISTANCE_M " << FIXED(9,3) << D << ";" << endl;
232  }
233 
234  } else if (option == center_t ||
235  option == CENTER_t) {
236 
237  const JCenter3D center(detector.begin(), detector.end());
238 
239  if (option == center_t) {
240 
241  cout << "center = ";
242  cout << showpos << FIXED(8,3) << center.getX() << ' ';
243  cout << showpos << FIXED(8,3) << center.getY() << ' ';
244  cout << showpos << FIXED(8,3) << center.getZ() << endl;
245 
246  } else {
247 
248  cout << "set_variable CENTER_X_M " << FIXED(7,1) << center.getX() << ";" << endl;
249  cout << "set_variable CENTER_Y_M " << FIXED(7,1) << center.getY() << ";" << endl;
250  cout << "set_variable CENTER_Z_M " << FIXED(7,1) << center.getZ() << ";" << endl;
251  }
252 
253  } else if (option == summary_t ||
254  option == SUMMARY_t) {
255 
256  const int numberOfStrings = getNumberOfStrings(detector);
257  const int numberOfFloors = getNumberOfFloors (detector);
258  const int numberOfModules = getNumberOfModules(detector);
259  const int numberOfPMTs = getNumberOfPMTs (detector);
260 
261  typedef JTOOLS::JRange<int> JRange_t;
262 
263  const JRange_t string(make_array(detector.begin(), detector.end(), &JModule::getString));
264  const JRange_t floor (make_array(detector.begin(), detector.end(), &JModule::getFloor));
265 
267 
268  for (JDetector::const_iterator module = detector.begin(); module != detector.end(); ++module) {
269  strings.insert(module->getString());
270  }
271 
272  if (option == summary_t) {
273 
274  cout << "Number of strings = " << setw(4) << numberOfStrings << endl;
275  cout << "Number of floors = " << setw(4) << numberOfFloors << endl;
276  cout << "Number of modules = " << setw(4) << numberOfModules << endl;
277  cout << "Number of PMTs = " << setw(4) << numberOfPMTs << endl;
278  cout << "First string = " << setw(4) << string.first << endl;
279  cout << "Last string = " << setw(4) << string.second << endl;
280  cout << "First floor = " << setw(4) << floor .first << endl;
281  cout << "Last floor = " << setw(4) << floor .second << endl;
282 
283  } else {
284 
285  cout << "set_variable NUMBER_OF_STRINGS " << setw(4) << numberOfStrings << ";" << endl;
286  cout << "set_variable NUMBER_OF_FLOORS " << setw(4) << numberOfFloors << ";" << endl;
287  cout << "set_variable NUMBER_OF_MODULES " << setw(4) << numberOfModules << ";" << endl;
288  cout << "set_variable NUMBER_OF_PMTS " << setw(4) << numberOfPMTs << ";" << endl;
289  cout << "set_variable FIRST_STRING " << setw(4) << string.first << ";" << endl;
290  cout << "set_variable LAST_STRING " << setw(4) << string.second << ";" << endl;
291  cout << "set_variable FIRST_FLOOR " << setw(4) << floor .first << ";" << endl;
292  cout << "set_variable LAST_FLOOR " << setw(4) << floor .second << ";" << endl;
293  cout << "set_array STRINGS ";
294  copy(strings.begin(), strings.end(), ostream_iterator<int>(cout, " "));
295  cout << endl;
296  }
297  }
298 }
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
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.
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.
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.
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.
do set_variable DETECTOR_TXT $WORKDIR detector
Auxiliary data structure for floating point format specification.
Definition: JManip.hh:484
do echo Generating $dir eval D
Definition: JDrawLED.sh:53
int debug
debug level