Jpp  16.0.0
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 "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 53 of file JPrintDetector.cc.

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