179{
182
185
192 string legend;
193 double markerSize;
194 double textSize;
195 bool drawCircle;
196 bool all;
197 bool batch;
199
200 try {
201
203
204 properties["focus"] = focus;
205
206 JParser<> zap(
"Auxiliary program to draw the footprint of detector(s).");
207
208 zap[
'w'] =
make_field(canvas,
"size of canvas <nx>x<ny> [pixels]") =
JCanvas(500, 500);
214 zap[
'L'] =
make_field(legend,
"position legend e.g. TR") =
"",
"TL",
"TR",
"BR",
"BL";
215 zap[
'S'] =
make_field(markerSize,
"marker size") = 1.0;
216 zap[
's'] =
make_field(textSize,
"text size") = 0.02;
217 zap[
'C'] =
make_field(drawCircle,
"draw smallest enclosing cicrle");
218 zap[
'A'] =
make_field(all,
"draw all modules");
219 zap[
'B'] =
make_field(batch,
"batch processing");
221
222 zap(argc, argv);
223 }
224 catch(const exception &error) {
225 FATAL(error.what() << endl);
226 }
227
228
229 if (detectorFile.empty() && tripodsFile.empty()) {
230 FATAL(
"No detector elements." << endl);
231 }
232
233
234 gROOT->SetBatch(batch);
235
236 gErrorIgnoreLevel = kWarning;
237
238 TApplication* tp = new TApplication("user", NULL, NULL);
239 TCanvas* cv =
new TCanvas(
"detector",
"", canvas.
x, canvas.
y);
240
242
243 gROOT->SetStyle("gplot");
244 gROOT->ForceStyle();
245
246 cv->SetFillStyle(4000);
247 cv->SetFillColor(kWhite);
248 cv->Divide(1, 1);
249 cv->cd(1);
250
251 JMarkerAttributes::getInstance().setMarkerSize(markerSize);
252
254 TAttText(kHAlignLeft + kVAlignBottom, 0.25*PI, kBlack, 62, textSize),
255 TAttText(kHAlignRight + kVAlignBottom, 0.75*PI, kBlack, 62, textSize),
256 TAttText(kHAlignRight + kVAlignTop, 1.25*PI, kBlack, 62, textSize),
257 TAttText(kHAlignLeft + kVAlignTop, 1.75*PI, kBlack, 62, textSize)
258 };
259
262 double offset = 0.0;
263
264 for (size_t i = 0; i != detectorFile.size(); ++i) {
265
267
268 try {
270 }
273 }
274
275 position =
detector.getUTMPosition();
276
277 const TAttMarker& marker = *JMarkerAttributes::getInstance().next();
278 const TAttText&
text = text_attributes[(0+i)%text_attributes.size()];
280
281 if (offset == 0.0) {
283 }
284
286
287 for (JDetector::const_iterator module =
detector.begin(); module !=
detector.end(); ++module) {
288
289 if (module->getFloor() == 0) {
290
291 buffer.push_back(JPoint_t(
MAKE_STRING(module->getString()),
293 marker,
295 offset));
296
297 counter.insert(module->getString());
298 }
299 }
300
301 for (JDetector::const_iterator module =
detector.begin(); module !=
detector.end(); ++module) {
302
303 const bool status = (counter.count(module->getString()) == 0);
304
305 if (status || all) {
306
307 buffer.push_back(JPoint_t((status ?
MAKE_STRING(module->getString()) :
""),
309 marker,
311 offset));
312
313 counter.insert(module->getString());
314 }
315 }
316 }
317
318 for (size_t i = 0; i != tripodsFile.size(); ++i) {
319
321
322 tripods.
load(tripodsFile[i].c_str());
323
324 const TAttMarker& marker = *JMarkerAttributes::getInstance().next();
325 const TAttText&
text = text_attributes[(0+i)%text_attributes.size()];
327
328 if (offset == 0.0) {
330 }
331
332 for (tripods_container::iterator i = tripods.begin(); i != tripods.end(); ++i) {
333
336 marker,
338 offset));
339 }
340 }
341
342 if (!transmittersFile.empty()) {
343
344 if (transmittersFile.size() == detectorFile.size()) {
345
346 for (size_t i = 0; i != transmittersFile.size(); ++i) {
347
349
350 transmitters.
load(transmittersFile[i].c_str());
351
353
355
356 const TAttMarker& marker = *JMarkerAttributes::getInstance().next();
357 const TAttText&
text = text_attributes[(2+i)%text_attributes.size()];
359
360 if (offset == 0.0) {
361 offset = 3.0 * textSize *
JCircle2D(transmitters.begin(), transmitters.end()).
getRadius();
362 }
363
364 for (transmitters_container::iterator i = transmitters.begin(); i != transmitters.end(); ++i) {
365
367
370 marker,
372 offset));
373 }
374 }
375
376 } else {
377
378 FATAL(
"Tranmitter files and detector files should match one-to-one." << endl);
379 }
380 }
381
383
385 copy(i->second.begin(), i->second.end(), back_inserter(buffer));
386 }
387
388 JCircle2D circle(buffer.begin(), buffer.end());
389
391 circle = focus;
392 }
393
394 NOTICE(
"focus = " <<
FIXED(12,3) << circle.getX() <<
' ' <<
FIXED(12,3) << circle.getY() <<
' ' <<
FIXED(9,3) << circle.getRadius() << endl);
395
396
397
399 i->second.sub(circle.getX(), circle.getY());
400 }
401
402 circle.sub(circle.getPosition());
403
404
405
406
407 cv->cd(1);
408
409 const Double_t
xmin = circle.getX() - 1.15 * circle.getRadius();
410 const Double_t
xmax = circle.getX() + 1.15 * circle.getRadius();
411 const Double_t ymin = circle.getY() - 1.15 * circle.getRadius();
412 const Double_t ymax = circle.getY() + 1.15 * circle.getRadius();
413
414 TH2D h2("h2", "", 200, xmin, xmax, 200, ymin, ymax);
415
416 h2.GetXaxis()->SetTitle("x [m]");
417 h2.GetYaxis()->SetTitle("y [m]");
418
419 h2.GetXaxis()->CenterTitle(true);
420 h2.GetYaxis()->CenterTitle(true);
421
422 h2.SetStats(kFALSE);
423 h2.Draw("AXIS");
424
425
426 TEllipse ellipse(circle.getX(), circle.getY(), circle.getRadius());
427
428 if (drawCircle) {
429 ellipse.Draw();
430 }
431
433 i->second.Draw();
434 }
435
436 if (legend != "") {
437
438 Ssiz_t height =
data.size();
439 Ssiz_t width = 1;
440
442 width = max(width, (Ssiz_t) i->first.size());
443 }
444
445 TLegend* lg =
getLegend(width, height, legend);
446
447 lg->SetTextSize(textSize);
448
450 if (!i->second.empty()) {
451 lg->AddEntry(&i->second[0].marker, i->first.c_str(), "P");
452 }
453 }
454
455 lg->Draw();
456 }
457
458 cv->Update();
459
462 }
463
464 if (!batch) {
465 tp->Run();
466 }
467}
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
#define MAKE_STRING(A)
Make string.
Utility class to parse parameter values.
Data structure for circle in two dimensions.
double getRadius() const
Get radius.
Data structure for position in two dimensions.
Data structure for position in three dimensions.
double getY() const
Get y position.
double getX() const
Get x position.
The template JSinglePointer class can be used to hold a pointer to an object.
Utility class to parse command line options.
Data structure for size of TCanvas.
int y
number of pixels in Y
int x
number of pixels in X
Wrapper class around ROOT TStyle.
Data structure for UTM position.
double getUTMNorth() const
Get UTM north.
double getUTMEast() const
Get UTM east.
void copy(const Head &from, JHead &to)
Copy header from from to to.
void load(const std::string &file_name, JDetector &detector)
Load detector from input file.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
TLegend * getLegend(const Int_t width, const Int_t height, const std::string option, const Double_t factor=1.0)
Get legend.
Auxiliary data structure for floating point format specification.
Auxiliary wrapper for I/O of container with optional comment (see JComment).
void load(const char *file_name)
Load from input file.
Empty structure for specification of parser element that is initialised (i.e. does not require input)...