71{
74
75 string detectorFile;
76 string option;
77 double precision;
79
80 try {
81
82 JParser<> zap(
"Auxiliary program to print detector file in human friendly format.");
83
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,
107 SUMMARY_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 == default_t) {
129
131
132 } else if (option == modules_t) {
133
135
136 for (JDetector::const_iterator module =
detector.begin(); module !=
detector.end(); ++module) {
137
138 cout << "Module";
139 cout << ' ' << noshowpos << setw(8) << right << module->getID();
140 cout << ' ' << noshowpos << setw(3) << right << module->getString();
141 cout << ' ' << noshowpos << setw(2) << right << module->getFloor();
142 cout <<
' ' <<
FIXED(7,2) << module->getX();
143 cout <<
' ' <<
FIXED(7,2) << module->getY();
144 cout <<
' ' <<
FIXED(7,2) << module->getZ();
145 cout <<
' ' <<
FIXED(8,2) << module->getT0();
146
147 if (module->getFloor() != 0) {
148 {
150
153
154 const double phi = (JVector3Z_t.getDot(q1.twist) >= 0.0 ? +1.0 : -1.0) * q1.twist.getAngle();
155
156 cout <<
' ' <<
FIXED(7,2) << phi;
157 }
158 {
161
162 const double phi = (JVector3Z_t.getDot(q1.twist) >= 0.0 ? +1.0 : -1.0) * q1.twist.getAngle();
163
164 cout <<
' ' <<
FIXED(7,2) << phi;
165 }
166 {
168
169 const JRotation3D R = getRotation(buffer, *module);
170
172
173 cout << ' ' << (JModule::compare(buffer, *module, precision) ? "==" : "!=")
175 }
176 }
177
178 cout << endl;
179 }
180
181 } else if (option == pmts_t) {
182
183 for (JDetector::const_iterator module =
detector.begin(); module !=
detector.end(); ++module) {
184 for (JModule::const_iterator pmt = module->begin(); pmt != module->end(); ++pmt) {
185 cout << "PMT";
186 cout << ' ' << noshowpos << setw(8) << right << pmt->getID();
187 cout <<
' ' <<
FIXED(7,2) << pmt->getX();
188 cout <<
' ' <<
FIXED(7,2) << pmt->getY();
189 cout <<
' ' <<
FIXED(7,2) << pmt->getZ();
190 cout <<
' ' <<
FIXED(6,3) << pmt->getDX();
191 cout <<
' ' <<
FIXED(6,3) << pmt->getDY();
192 cout <<
' ' <<
FIXED(6,3) << pmt->getDZ();
193 cout <<
' ' <<
FIXED(8,2) << pmt->getT0();
194 cout << ' ' << noshowpos << setw(8) << right << pmt->getStatus();
195 cout << endl;
196 }
197 }
198
199 } else if (option == geometry_t ||
200 option == GEOMETRY_t) {
201
202 if (option == geometry_t) {
203
207
208 } else {
209
212 }
213
214 } else if (option == comment_t) {
215
217
218 } else if (option == header_t ||
219 option == HEADER_t) {
220
221 if (option == header_t) {
222
223 cout <<
detector.getProperties() << endl;
226 "unknown") << endl;
227 cout << "validity = "
230
231 } else {
232
233 cout <<
"set_variable UTM_EAST " <<
FIXED(12,2) <<
detector.getUTMEast() <<
";" << endl;
234 cout <<
"set_variable UTM_NORTH " <<
FIXED(12,2) <<
detector.getUTMNorth() <<
";" << endl;
235 cout <<
"set_variable UTM_Z " <<
FIXED(12,2) <<
detector.getUTMZ() <<
";" << endl;
236 cout <<
"set_variable UTM_ZONE " <<
FIXED(12,2) <<
detector.getUTMZone() <<
";" << endl;
237 cout <<
"set_variable UTM_WGS " <<
FIXED(12,2) <<
detector.getWGS() <<
";" << endl;
238 }
239
240 } else if (option == version_t ||
241 option == VERSION_t) {
242
243 if (option == version_t) {
244
245 cout <<
detector.getVersion() << endl;
246
247 } else {
248
249 cout <<
"set_variable DETECTOR_VERSION " <<
detector.getVersion() <<
";" << endl;
250 }
251
252 } else if (option == identifier_t ||
253 option == IDENTIFIER_t) {
254
255 if (option == identifier_t) {
256
257 cout <<
"Detector " <<
detector.getID() << endl;
258
259 } else {
260
261 cout <<
"set_variable DETECTOR_ID " <<
detector.getID() <<
";" << endl;
262 }
263
264 } else if (option == can_t ||
265 option == CAN_t) {
266
268
269 const double V = (cylinder.getZmax() - cylinder.getZmin()) * PI * cylinder.getRadius() * cylinder.getRadius();
271
272 if (option == can_t) {
273
274 cout <<
"X = " <<
FIXED(7,1) << cylinder.getX() << endl;
275 cout <<
"Y = " <<
FIXED(7,1) << cylinder.getY() << endl;
276 cout <<
"Zmin = " <<
FIXED(7,1) << cylinder.getZmin() << endl;
277 cout <<
"Zmax = " <<
FIXED(7,1) << cylinder.getZmax() << endl;
278 cout <<
"Radius = " <<
FIXED(7,1) << cylinder.getRadius() << endl;
279 cout <<
"Depth = " <<
FIXED(7,1) <<
detector.getUTMZ() << endl;
280 cout <<
"Volume = " <<
SCIENTIFIC(12,3) << V << endl;
281 cout <<
"Distance = " <<
FIXED(9,3) << D << endl;
282
283 } else {
284
285 cout <<
"set_variable CAN_X_M " <<
FIXED(7,1) << cylinder.getX() <<
";" << endl;
286 cout <<
"set_variable CAN_Y_M " <<
FIXED(7,1) << cylinder.getY() <<
";" << endl;
287 cout <<
"set_variable CAN_ZMIN_M " <<
FIXED(7,1) << cylinder.getZmin() <<
";" << endl;
288 cout <<
"set_variable CAN_ZMAX_M " <<
FIXED(7,1) << cylinder.getZmax() <<
";" << endl;
289 cout <<
"set_variable CAN_RADIUS_M " <<
FIXED(7,1) << cylinder.getRadius() <<
";" << endl;
290 cout <<
"set_variable CAN_DEPTH_M " <<
FIXED(7,1) <<
detector.getUTMZ() <<
";" << endl;
291 cout <<
"set_variable CAN_VOLUME_M3 " <<
SCIENTIFIC(12,3) << V <<
";" << endl;
292 cout <<
"set_variable CAN_DISTANCE_M " <<
FIXED(9,3) << D <<
";" << endl;
293 }
294
295 } else if (option == center_t ||
296 option == CENTER_t) {
297
299
300 if (option == center_t) {
301
302 cout << "center = ";
303 cout << showpos <<
FIXED(8,3) << center.getX() <<
' ';
304 cout << showpos <<
FIXED(8,3) << center.getY() <<
' ';
305 cout << showpos <<
FIXED(8,3) << center.getZ() << endl;
306
307 } else {
308
309 cout <<
"set_variable CENTER_X_M " <<
FIXED(7,1) << center.getX() <<
";" << endl;
310 cout <<
"set_variable CENTER_Y_M " <<
FIXED(7,1) << center.getY() <<
";" << endl;
311 cout <<
"set_variable CENTER_Z_M " <<
FIXED(7,1) << center.getZ() <<
";" << endl;
312 }
313
314 } else if (option == summary_t ||
315 option == SUMMARY_t) {
316
317 const int numberOfStrings = getNumberOfStrings(
detector);
321
323
325 const JRange_t floor_t (make_array(
detector.begin(),
detector.end(), &JModule::getFloor));
326
329
330 for (JDetector::const_iterator module =
detector.begin(); module !=
detector.end(); ++module) {
331 strings.insert(module->getString());
332 modules.insert(module->getID());
333 }
334
335 if (option == summary_t) {
336
337 cout << "Number of strings = " << setw(4) << numberOfStrings << endl;
338 cout << "Number of floors = " << setw(4) << numberOfFloors << endl;
339 cout << "Number of modules = " << setw(4) << numberOfModules << endl;
340 cout << "Number of PMTs = " << setw(4) << numberOfPMTs << endl;
341 cout <<
"First string = " << setw(4) <<
string_t.first << endl;
342 cout <<
"Last string = " << setw(4) <<
string_t.second << endl;
343 cout << "First floor = " << setw(4) << floor_t .first << endl;
344 cout << "Last floor = " << setw(4) << floor_t .second << endl;
345
346 } else {
347
348 cout << "let \"NUMBER_OF_STRINGS = " << setw(5) << numberOfStrings << "\";" << endl;
349 cout << "let \"NUMBER_OF_FLOORS = " << setw(5) << numberOfFloors << "\";" << endl;
350 cout << "let \"NUMBER_OF_MODULES = " << setw(5) << numberOfModules << "\";" << endl;
351 cout << "let \"NUMBER_OF_PMTS = " << setw(5) << numberOfPMTs << "\";" << endl;
352 cout <<
"let \"FIRST_STRING = " << setw(5) <<
string_t.first <<
"\";" << endl;
353 cout <<
"let \"LAST_STRING = " << setw(5) <<
string_t.second <<
"\";" << endl;
354 cout << "let \"FIRST_FLOOR = " << setw(5) << floor_t .first << "\";" << endl;
355 cout << "let \"LAST_FLOOR = " << setw(5) << floor_t .second << "\";" << endl;
356 cout << "STRINGS=(";
357 copy(strings.begin(), strings.end(), ostream_iterator<int>(cout,
" "));
358 cout << ");" << endl;
359 cout << "MODULES=(";
360 copy(modules.begin(), modules.end(), ostream_iterator<int>(cout,
" "));
361 cout << ");" << endl;
362
363
364
365 for (const auto i : strings) {
366 cout <<
"typeset -A " <<
getString(i) <<
";" << endl;
367 }
369 cout <<
getString(i.getString()) <<
"[" << i.getFloor() <<
"]=" << i.getID() <<
";" << endl;
370 }
371 }
372 }
373}
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
const JModuleAddressMap & get(const int id) const
Get module address map.
virtual const JModuleAddressMap & getDefaultModuleAddressMap() const =0
Get default module address map.
Data structure for a composite optical module.
void rotate(const JRotation3D &R)
Rotate module.
Data structure for unit quaternion in three dimensions.
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.
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 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.
Auxiliary class for date and time.
std::string toString() const
Get ASCII formatted date and time.
Auxiliary data structure for floating point format specification.