8 #include "TApplication.h"
31 int main(
int argc,
char**argv)
42 JParser<> zap(
"Auxiliary program to draw the footprint of detector(s).");
51 catch(
const exception &error) {
52 FATAL(error.what() << endl);
73 load(*file_name, detector);
75 catch(
const JException& error) {
79 if (detector.empty()) {
80 ERROR(
"Empty detector." << endl);
83 circle = JCircle2D(detector.begin(), detector.end());
85 TGraph* graph =
new TGraph(detector.size());
87 graph->SetTitle(file_name->c_str());
91 for (JDetector::const_iterator i = detector.begin(); i != detector.end(); ++i, ++n) {
95 graph->GetX()[n] = i->getX();
96 graph->GetY()[n] = i->getY();
101 buffer.push_back(graph);
106 FATAL(
"No detector elements." << endl);
110 DEBUG(
"Detector (x,y,R): " << circle.getX() <<
' ' << circle.getY() <<
' ' << circle.getRadius() << endl);
113 for (
int i = 0; i != (*graph)->GetN(); ++i) {
114 (*graph)->GetX()[i] -= circle.getX();
115 (*graph)->GetY()[i] -= circle.getY();
119 circle.sub(circle.getPosition());
121 Double_t R = circle.getRadius();
127 Double_t xmin = circle.getX() - R;
128 Double_t xmax = circle.getX() + R;
129 Double_t ymin = circle.getY() - R;
130 Double_t ymax = circle.getY() + R;
133 TApplication* tp =
new TApplication(
"user", NULL, NULL);
136 TCanvas cv(
"detector",
"", 400, 400);
138 cv.SetFillStyle(4000);
144 const Double_t dx = (xmax - xmin);
145 const Double_t dy = (ymax - ymin);
153 TH2D h2(
"h2",
"", 1, xmin, xmax, 1, ymin, ymax);
155 h2.GetXaxis()->SetTitle(
"x [m]");
156 h2.GetYaxis()->SetTitle(
"y [m]");
158 h2.GetXaxis()->CenterTitle(
true);
159 h2.GetYaxis()->CenterTitle(
true);
165 TEllipse ellipse(circle.getX(), circle.getY(), circle.getRadius());
176 const Double_t x2 = gPad->GetX2() - gStyle->GetPadRightMargin();
177 const Double_t y2 = gPad->GetY2() - gStyle->GetPadTopMargin();
180 Double_t font_size = 0.03;
183 length = max(length, strlen((*graph)->GetTitle()));
186 TLegend* legend =
new TLegend(x2 - length * font_size * 0.65 - 0.02,
187 y2 - buffer.size() * font_size,
192 legend->SetFillColor(0);
193 legend->SetBorderSize(0);
194 legend->SetTextSize(font_size);
197 legend->AddEntry(*graph, (*graph)->GetTitle(),
"P");
Utility class to parse command line options.
virtual const pointer_type & next()
Get next element.
Data structure for detector geometry and calibration.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
void setMarkerSize(const Double_t size)
Set marker size.
void load(const JString &file_name, JDetector &detector)
Load detector from input file.
General purpose messaging.
Utility class to parse command line options.
#define DEBUG(A)
Message macros.
static JMarkerAttributes & getInstance()
Get reference to unique instance of this class object.
int main(int argc, char *argv[])