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