71{
74
75 string detectorFile;
77 double precision;
79
80 try {
81
82 JParser<> zap(
"Auxiliary program to print detector file in human friendly format.");
83
85 zap[
'O'] =
make_field(option,
"possible options "
86
87 << default_t << ' '
88
89 << pmts_t << ' '
90 << modules_t << ' '
91 << geometry_t << ' '
92
93 << comment_t << ' '
94 << header_t << ' '
95 << version_t << ' '
96 << identifier_t << ' '
97 << can_t << ' '
98 << center_t << ' '
99 << summary_t << ' '
100
101 << GEOMETRY_t << ' '
102 << HEADER_t << ' '
103 << VERSION_t << ' '
104 << IDENTIFIER_t << ' '
105 << CAN_t << ' '
106 << CENTER_t << ' '
108
109 zap[
'p'] =
make_field(precision,
"precision for match with reference module") = 1.0e-5;
111
112 zap(argc, argv);
113 }
114 catch(const exception &error) {
115 FATAL(error.what() << endl);
116 }
117
118
120
121 try {
123 }
126 }
127
128 if (option.count(default_t)) {
129
131
132 }
133
134 if (option.count(modules_t)) {
135
137
138 for (JDetector::const_iterator module =
detector.begin(); module !=
detector.end(); ++module) {
139
140 cout << "Module";
141 cout << ' ' << noshowpos << setw(8) << right << module->getID();
142 cout << ' ' << noshowpos << setw(3) << right << module->getString();
143 cout << ' ' << noshowpos << setw(2) << right << module->getFloor();
144 cout <<
' ' <<
FIXED(7,2) << module->getX();
145 cout <<
' ' <<
FIXED(7,2) << module->getY();
146 cout <<
' ' <<
FIXED(7,2) << module->getZ();
147 cout <<
' ' <<
FIXED(8,2) << module->getT0();
148
149 if (module->getFloor() != 0) {
150 {
152
155
156 const double phi = (JVector3Z_t.getDot(q1.twist) >= 0.0 ? +1.0 : -1.0) * q1.twist.getAngle();
157
158 cout <<
' ' <<
FIXED(7,2) << phi;
159 }
160 {
163
164 const double phi = (JVector3Z_t.getDot(q1.twist) >= 0.0 ? +1.0 : -1.0) * q1.twist.getAngle();
165
166 cout <<
' ' <<
FIXED(7,2) << phi;
167 }
168 {
170
171 const JRotation3D R = getRotation(buffer, *module);
172
174
175 cout << ' ' << (JModule::compare(buffer, *module, precision) ? "==" : "!=")
177 }
178 }
179
180 cout << endl;
181 }
182
183 }
184
185 if (option.count(pmts_t)) {
186
188
189 for (JDetector::const_iterator module =
detector.begin(); module !=
detector.end(); ++module) {
190
192
193 for (size_t i = 0; i != module->size(); ++i) {
194
195 const JPMT& pmt =
module->getPMT(i);
197
198 cout <<
"PMT[" <<
FILL(2,
'0') << i <<
FILL() <<
"]";
199 cout << ' ' << address;
200 cout <<
' ' << noshowpos << setw(8) << right << pmt.
getID();
208 cout <<
' ' << noshowpos << setw(8) << right << pmt.
getStatus();
209 cout << endl;
210 }
211 }
212
213 }
214
215 if (option.count(geometry_t) ||
216 option.count(GEOMETRY_t)) {
217
218 if (option.count(geometry_t)) {
219
223
224 } else {
225
228 }
229
230 }
231
232 if (option.count(comment_t)) {
233
235
236 }
237
238 if (option.count(header_t) ||
239 option.count(HEADER_t)) {
240
241 if (option.count(header_t)) {
242
243 cout <<
detector.getProperties() << endl;
246 "unknown") << endl;
247 cout << "validity = "
250
251 } else {
252
253 cout <<
"set_variable UTM_EAST " <<
FIXED(12,2) <<
detector.getUTMEast() <<
";" << endl;
254 cout <<
"set_variable UTM_NORTH " <<
FIXED(12,2) <<
detector.getUTMNorth() <<
";" << endl;
255 cout <<
"set_variable UTM_Z " <<
FIXED(12,2) <<
detector.getUTMZ() <<
";" << endl;
256 cout <<
"set_variable UTM_ZONE " <<
FIXED(12,2) <<
detector.getUTMZone() <<
";" << endl;
257 cout <<
"set_variable UTM_WGS " <<
FIXED(12,2) <<
detector.getWGS() <<
";" << endl;
258 }
259
260 }
261
262 if (option.count(version_t) ||
263 option.count(VERSION_t)) {
264
265 if (option.count(version_t)) {
266
267 cout <<
detector.getVersion() << endl;
268
269 } else {
270
271 cout <<
"set_variable DETECTOR_VERSION " <<
detector.getVersion() <<
";" << endl;
272 }
273
274 }
275
276 if (option.count(identifier_t) ||
277 option.count(IDENTIFIER_t)) {
278
279 if (option.count(identifier_t)) {
280
281 cout <<
"Detector " <<
detector.getID() << endl;
282
283 } else {
284
285 cout <<
"set_variable DETECTOR_ID " <<
detector.getID() <<
";" << endl;
286 }
287
288 }
289
290 if (option.count(can_t) ||
291 option.count(CAN_t)) {
292
294
295 const double V = (cylinder.getZmax() - cylinder.getZmin()) * PI * cylinder.getRadius() * cylinder.getRadius();
297
298 if (option.count(can_t)) {
299
300 cout <<
"X = " <<
FIXED(7,1) << cylinder.getX() << endl;
301 cout <<
"Y = " <<
FIXED(7,1) << cylinder.getY() << endl;
302 cout <<
"Zmin = " <<
FIXED(7,1) << cylinder.getZmin() << endl;
303 cout <<
"Zmax = " <<
FIXED(7,1) << cylinder.getZmax() << endl;
304 cout <<
"Radius = " <<
FIXED(7,1) << cylinder.getRadius() << endl;
305 cout <<
"Depth = " <<
FIXED(7,1) <<
detector.getUTMZ() << endl;
306 cout <<
"Volume = " <<
SCIENTIFIC(12,3) << V << endl;
307 cout <<
"Distance = " <<
FIXED(9,3) << D << endl;
308
309 } else {
310
311 cout <<
"set_variable CAN_X_M " <<
FIXED(7,1) << cylinder.getX() <<
";" << endl;
312 cout <<
"set_variable CAN_Y_M " <<
FIXED(7,1) << cylinder.getY() <<
";" << endl;
313 cout <<
"set_variable CAN_ZMIN_M " <<
FIXED(7,1) << cylinder.getZmin() <<
";" << endl;
314 cout <<
"set_variable CAN_ZMAX_M " <<
FIXED(7,1) << cylinder.getZmax() <<
";" << endl;
315 cout <<
"set_variable CAN_RADIUS_M " <<
FIXED(7,1) << cylinder.getRadius() <<
";" << endl;
316 cout <<
"set_variable CAN_DEPTH_M " <<
FIXED(7,1) <<
detector.getUTMZ() <<
";" << endl;
317 cout <<
"set_variable CAN_VOLUME_M3 " <<
SCIENTIFIC(12,3) << V <<
";" << endl;
318 cout <<
"set_variable CAN_DISTANCE_M " <<
FIXED(9,3) << D <<
";" << endl;
319 }
320
321 }
322
323 if (option.count(center_t) ||
324 option.count(CENTER_t)) {
325
327
328 if (option.count(center_t)) {
329
330 cout << "center = ";
331 cout << showpos <<
FIXED(8,3) << center.getX() <<
' ';
332 cout << showpos <<
FIXED(8,3) << center.getY() <<
' ';
333 cout << showpos <<
FIXED(8,3) << center.getZ() << endl;
334
335 } else {
336
337 cout <<
"set_variable CENTER_X_M " <<
FIXED(7,1) << center.getX() <<
";" << endl;
338 cout <<
"set_variable CENTER_Y_M " <<
FIXED(7,1) << center.getY() <<
";" << endl;
339 cout <<
"set_variable CENTER_Z_M " <<
FIXED(7,1) << center.getZ() <<
";" << endl;
340 }
341
342 }
343
344 if (option.count(summary_t) ||
345 option.count(SUMMARY_t)) {
346
347 const int numberOfStrings = getNumberOfStrings(
detector);
351
353
355 const JRange_t floor_t (make_array(
detector.begin(),
detector.end(), &JModule::getFloor));
356
359
360 for (JDetector::const_iterator module =
detector.begin(); module !=
detector.end(); ++module) {
361 strings.insert(module->getString());
362 modules.insert(module->getID());
363 }
364
365 if (option.count(summary_t)) {
366
367 cout << "Number of strings = " << setw(4) << numberOfStrings << endl;
368 cout << "Number of floors = " << setw(4) << numberOfFloors << endl;
369 cout << "Number of modules = " << setw(4) << numberOfModules << endl;
370 cout << "Number of PMTs = " << setw(4) << numberOfPMTs << endl;
371 cout <<
"First string = " << setw(4) <<
string_t.first << endl;
372 cout <<
"Last string = " << setw(4) <<
string_t.second << endl;
373 cout << "First floor = " << setw(4) << floor_t .first << endl;
374 cout << "Last floor = " << setw(4) << floor_t .second << endl;
375
376 } else {
377
378 cout << "let \"NUMBER_OF_STRINGS = " << setw(5) << numberOfStrings << "\";" << endl;
379 cout << "let \"NUMBER_OF_FLOORS = " << setw(5) << numberOfFloors << "\";" << endl;
380 cout << "let \"NUMBER_OF_MODULES = " << setw(5) << numberOfModules << "\";" << endl;
381 cout << "let \"NUMBER_OF_PMTS = " << setw(5) << numberOfPMTs << "\";" << endl;
382 cout <<
"let \"FIRST_STRING = " << setw(5) <<
string_t.first <<
"\";" << endl;
383 cout <<
"let \"LAST_STRING = " << setw(5) <<
string_t.second <<
"\";" << endl;
384 cout << "let \"FIRST_FLOOR = " << setw(5) << floor_t .first << "\";" << endl;
385 cout << "let \"LAST_FLOOR = " << setw(5) << floor_t .second << "\";" << endl;
386 cout << "STRINGS=(";
387 copy(strings.begin(), strings.end(), ostream_iterator<int>(cout,
" "));
388 cout << ");" << endl;
389 cout << "MODULES=(";
390 copy(modules.begin(), modules.end(), ostream_iterator<int>(cout,
" "));
391 cout << ");" << endl;
392
393
394
395 for (const auto i : strings) {
396 cout <<
"typeset -A " <<
getString(i) <<
";" << endl;
397 }
399 cout <<
getString(i.getString()) <<
"[" << i.getFloor() <<
"]=" << i.getID() <<
";" << endl;
400 }
401 }
402 }
403}
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
double getT0() const
Get time offset.
Lookup table for PMT addresses in detector.
const JModuleAddressMap & get(const int id) const
Get module address map.
virtual const JModuleAddressMap & getDefaultModuleAddressMap() const =0
Get default module address map.
Lookup table for PMT addresses in optical module.
const JPMTPhysicalAddress & getPMTPhysicalAddress(const int tdc) const
Get PMT physical address.
Data structure for a composite optical module.
void rotate(const JRotation3D &R)
Rotate module.
Data structure for PMT physical address.
Data structure for PMT geometry, calibration and status.
Data structure for unit quaternion in three dimensions.
double getY() const
Get y position.
double getZ() const
Get z position.
double getX() const
Get x position.
double getDY() const
Get y direction.
double getDX() const
Get x direction.
double getDZ() const
Get z direction.
int getID() const
Get identifier.
Utility class to parse command line options.
void copy(const Head &from, JHead &to)
Copy header from from to to.
JMODEL::JString getString(const JFit &fit)
Get model parameters of string.
const char *const string_t
routing by string
int getNumberOfPMTs(const JModule &module)
Get number of PMTs.
int getNumberOfFloors(const JDetector &detector)
Get number of floors.
JDetectorBuilder & getDetectorBuilder()
Get detector builder.
void load(const std::string &file_name, JDetector &detector)
Load detector from input file.
bool isORCADetector(const JDetectorHeader &header)
Check if given detector header is compatible with that of ORCA.
bool isARCADetector(const JDetectorHeader &header)
Check if given detector header is compatible with tat of ARCA.
JDetectorAddressMap & getDetectorAddressMap()
Get detector address map.
int getNumberOfModules(const JDetector &detector, const bool option=false)
Get number of modules.
double getMinimalDistance(const JDetector &detector)
Get minimal distance between modules in detector.
double getMaximalDistance(const JDetector &detector, const bool option=false)
Get maximal distance between modules in detector.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
double getMaximalTime(const double R_Hz)
Get maximal time for given rate.
Auxiliary data structure for sequence of same character.
Auxiliary data structure for floating point format specification.
Auxiliary interface for building detector.
const JModule & getModule(const int id=-1, const JLocation &location=JLocation()) const
Get module.
Auxiliary data structure for decomposition of quaternion in twist and swing quaternions.
status_type getStatus(const JType< status_type > &type) const
Get status.
Empty structure for specification of parser element that is initialised (i.e. does not require input)...
Auxiliary class for date and time.
std::string toString() const
Get ASCII formatted date and time.
Auxiliary data structure for floating point format specification.