180{
183
186
193 string legend;
194 double markerSize;
195 double textSize;
196 bool drawCircle;
197 bool all;
198 bool batch;
200
201 try {
202
204
205 properties["focus"] = focus;
206
207 JParser<> zap(
"Auxiliary program to draw the footprint of detector(s).");
208
209 zap[
'w'] =
make_field(canvas,
"size of canvas <nx>x<ny> [pixels]") =
JCanvas(500, 500);
215 zap[
'L'] =
make_field(legend,
"position legend e.g. TR") =
"",
"TL",
"TR",
"BR",
"BL";
216 zap[
'S'] =
make_field(markerSize,
"marker size") = 1.0;
217 zap[
's'] =
make_field(textSize,
"text size") = 0.02;
218 zap[
'C'] =
make_field(drawCircle,
"draw smallest enclosing cicrle");
219 zap[
'A'] =
make_field(all,
"draw all modules");
220 zap[
'B'] =
make_field(batch,
"batch processing");
222
223 zap(argc, argv);
224 }
225 catch(const exception &error) {
226 FATAL(error.what() << endl);
227 }
228
229
230 if (detectorFile.empty() && tripodsFile.empty()) {
231 FATAL(
"No detector elements." << endl);
232 }
233
234
235 gROOT->SetBatch(batch);
236
237 gErrorIgnoreLevel = kWarning;
238
239 TApplication* tp = new TApplication("user", NULL, NULL);
240 TCanvas* cv =
new TCanvas(
"detector",
"", canvas.
x, canvas.
y);
241
242 if (!batch) {
243 ((TRootCanvas *) cv->GetCanvasImp())->Connect("CloseWindow()", "TApplication", tp, "Terminate()");
244 }
245
246 unique_ptr<TStyle> gStyle(
new JStyle(
"gplot", cv->GetWw(), cv->GetWh()));
247
248 gROOT->SetStyle("gplot");
249 gROOT->ForceStyle();
250
251 cv->SetFillStyle(4000);
252 cv->SetFillColor(kWhite);
253 cv->Divide(1, 1);
254 cv->cd(1);
255
256 JMarkerAttributes::getInstance().setMarkerSize(markerSize);
257
259 TAttText(kHAlignLeft + kVAlignBottom, 0.25*PI, kBlack, 62, textSize),
260 TAttText(kHAlignRight + kVAlignBottom, 0.75*PI, kBlack, 62, textSize),
261 TAttText(kHAlignRight + kVAlignTop, 1.25*PI, kBlack, 62, textSize),
262 TAttText(kHAlignLeft + kVAlignTop, 1.75*PI, kBlack, 62, textSize)
263 };
264
267 double offset = 0.0;
268
269 for (size_t i = 0; i != detectorFile.size(); ++i) {
270
272
273 try {
275 }
278 }
279
280 position =
detector.getUTMPosition();
281
282 const TAttMarker& marker = *JMarkerAttributes::getInstance().next();
283 const TAttText&
text = text_attributes[(0+i)%text_attributes.size()];
285
286 if (offset == 0.0) {
288 }
289
291
292 for (JDetector::const_iterator module =
detector.begin(); module !=
detector.end(); ++module) {
293
294 if (module->getFloor() == 0) {
295
296 buffer.push_back(JPoint_t(
MAKE_STRING(module->getString()),
298 marker,
300 offset));
301
302 counter.insert(module->getString());
303 }
304 }
305
306 for (JDetector::const_iterator module =
detector.begin(); module !=
detector.end(); ++module) {
307
308 const bool status = (counter.count(module->getString()) == 0);
309
310 if (status || all) {
311
312 buffer.push_back(JPoint_t((status ?
MAKE_STRING(module->getString()) :
""),
314 marker,
316 offset));
317
318 counter.insert(module->getString());
319 }
320 }
321 }
322
323 for (size_t i = 0; i != tripodsFile.size(); ++i) {
324
326
327 tripods.
load(tripodsFile[i].c_str());
328
329 const TAttMarker& marker = *JMarkerAttributes::getInstance().next();
330 const TAttText&
text = text_attributes[(0+i)%text_attributes.size()];
332
333 if (offset == 0.0) {
335 }
336
337 for (tripods_container::iterator i = tripods.begin(); i != tripods.end(); ++i) {
338
341 marker,
343 offset));
344 }
345 }
346
347 if (!transmittersFile.empty()) {
348
349 if (transmittersFile.size() == detectorFile.size()) {
350
351 for (size_t i = 0; i != transmittersFile.size(); ++i) {
352
354
355 transmitters.
load(transmittersFile[i].c_str());
356
358
360
361 const TAttMarker& marker = *JMarkerAttributes::getInstance().next();
362 const TAttText&
text = text_attributes[(2+i)%text_attributes.size()];
364
365 if (offset == 0.0) {
366 offset = 3.0 * textSize *
JCircle2D(transmitters.begin(), transmitters.end()).
getRadius();
367 }
368
369 for (transmitters_container::iterator i = transmitters.begin(); i != transmitters.end(); ++i) {
370
372
375 marker,
377 offset));
378 }
379 }
380
381 } else {
382
383 FATAL(
"Tranmitter files and detector files should match one-to-one." << endl);
384 }
385 }
386
388
390 copy(i->second.begin(), i->second.end(), back_inserter(buffer));
391 }
392
393 JCircle2D circle(buffer.begin(), buffer.end());
394
396 circle = focus;
397 }
398
399 NOTICE(
"focus = " <<
FIXED(12,3) << circle.getX() <<
' ' <<
FIXED(12,3) << circle.getY() <<
' ' <<
FIXED(9,3) << circle.getRadius() << endl);
400
401
402
404 i->second.sub(circle.getX(), circle.getY());
405 }
406
407 circle.sub(circle.getPosition());
408
409
410
411
412 cv->cd(1);
413
414 const Double_t
xmin = circle.getX() - 1.15 * circle.getRadius();
415 const Double_t
xmax = circle.getX() + 1.15 * circle.getRadius();
416 const Double_t ymin = circle.getY() - 1.15 * circle.getRadius();
417 const Double_t ymax = circle.getY() + 1.15 * circle.getRadius();
418
419 TH2D h2("h2", "", 200, xmin, xmax, 200, ymin, ymax);
420
421 h2.GetXaxis()->SetTitle("x [m]");
422 h2.GetYaxis()->SetTitle("y [m]");
423
424 h2.GetXaxis()->CenterTitle(true);
425 h2.GetYaxis()->CenterTitle(true);
426
427 h2.SetStats(kFALSE);
428 h2.Draw("AXIS");
429
430
431 TEllipse ellipse(circle.getX(), circle.getY(), circle.getRadius());
432
433 if (drawCircle) {
434 ellipse.Draw();
435 }
436
438 i->second.Draw();
439 }
440
441 if (legend != "") {
442
443 Ssiz_t height =
data.size();
444 Ssiz_t width = 1;
445
447 width = max(width, (Ssiz_t) i->first.size());
448 }
449
450 TLegend* lg =
getLegend(width, height, legend);
451
452 lg->SetTextSize(textSize);
453
455 if (!i->second.empty()) {
456 lg->AddEntry(&i->second[0].marker, i->first.c_str(), "P");
457 }
458 }
459
460 lg->Draw();
461 }
462
463 cv->Update();
464
467 }
468
469 if (!batch) {
470 tp->Run();
471 }
472}
#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.
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)...