6 #include "TApplication.h"
10 #include "TGeoManager.h"
11 #include "TGeoMatrix.h"
12 #include "TGeoMaterial.h"
13 #include "TGeoMedium.h"
14 #include "TGeoVolume.h"
27 int main(
int argc,
char**argv)
36 JParser<> zap(
"Auxiliary program to draw the detector in 3D.");
43 catch(
const exception &error) {
44 FATAL(error.what() << endl);
53 load(detectorFile, detector);
55 catch(
const JException& error) {
59 if (!detector.empty()) {
61 JPosition3D pos(0.0, 0.0, 0.0);
63 for (JDetector::const_iterator i = detector.begin(); i != detector.end(); ++i) {
67 pos /= detector.size();
69 NOTICE(
"Detector center: " << pos.getX() <<
' ' << pos.getY() <<
' ' << pos.getZ() << endl);
71 double zmin = +numeric_limits<double>::max();
72 double zmax = -numeric_limits<double>::max();
76 for (JDetector::const_iterator i = detector.begin(); i != detector.end(); ++i) {
78 const double x = i->getX() - pos.getX();
79 const double y = i->getY() - pos.getY();
80 const double z = i->getZ() - pos.getZ();
82 const double R = sqrt(x*x + y*y);
84 if (z < zmin) zmin = z;
85 if (z > zmax) zmax = z;
87 if (R > radius) radius = R;
90 NOTICE(
"can: " << zmin <<
' ' << zmax <<
' ' << radius << endl);
98 for (JDetector::const_iterator i = detector.begin(); i != detector.end(); ++i) {
99 if (i->getX() > xmax) xmax = i->getX();
100 if (i->getY() > ymax) ymax = i->getY();
101 if (i->getZ() > zmax) zmax = i->getZ();
109 TApplication* tapple =
new TApplication(
"user", NULL, NULL);
110 TCanvas* canvas =
new TCanvas(
"a", detectorFile.c_str(), 1200, 1200);
112 canvas->SetFillColor(0);
114 TGeoManager* geom =
new TGeoManager (
"geometry",
"");
115 TGeoMaterial* material =
new TGeoMaterial(
"vacuum", 0, 0, 0);
116 TGeoMedium* medium =
new TGeoMedium (
"vacuum", 1, material);
117 TGeoVolume* top = geom->MakeBox (
"Top", medium, xmax, ymax, zmax);
118 TGeoVolume* shape = geom->MakeSphere(
"Module", medium, 0.4, 0.5);
120 shape->SetLineColor(kBlue);
124 for (JDetector::const_iterator i = detector.begin(); i != detector.end(); ++i) {
125 top->AddNode(shape, N++,
new TGeoTranslation(i->getX(), i->getY(), i->getZ()));
128 geom->SetTopVolume(top);
129 geom->CloseGeometry();
134 canvas->GetView()->ShowAxis();