Auxiliary program to draw the detector in 3D.
More...
#include <string>
#include <iostream>
#include <limits>
#include "TROOT.h"
#include "TApplication.h"
#include "TCanvas.h"
#include "TView.h"
#include "TGeometry.h"
#include "TGeoManager.h"
#include "TGeoMatrix.h"
#include "TGeoMaterial.h"
#include "TGeoMedium.h"
#include "TGeoVolume.h"
#include "Jeep/JParser.hh"
#include "Jeep/JMessage.hh"
#include "JDetector/JDetector.hh"
#include "JDetector/JDetectorToolkit.hh"
Go to the source code of this file.
|
int | main (int argc, char **argv) |
|
Auxiliary program to draw the detector in 3D.
- Author
- mdejong
Definition in file JDrawDetector3D.cc.
int main |
( |
int |
argc, |
|
|
char ** |
argv |
|
) |
| |
Definition at line 27 of file JDrawDetector3D.cc.
36 JParser<> zap(
"Auxiliary program to draw the detector in 3D.");
43 catch(
const exception &error) {
44 FATAL(error.what() << endl);
55 catch(
const JException& error) {
61 JPosition3D pos(0.0, 0.0, 0.0);
69 NOTICE(
"Detector center: " << pos.getX() <<
' ' << pos.getY() <<
' ' << pos.getZ() << endl);
71 double zmin = numeric_limits<double>::max();
72 double zmax = numeric_limits<double>::lowest();
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);
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);
125 top->AddNode(shape,
N++,
new TGeoTranslation(
i->getX(),
i->getY(),
i->getZ()));
128 geom->SetTopVolume(top);
129 geom->CloseGeometry();
134 canvas->GetView()->ShowAxis();
Utility class to parse command line options.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
then JCookie sh JDataQuality D $DETECTOR_ID R
then usage $script< input file >[option[primary[working directory]]] nWhere option can be N
void load(const std::string &file_name, JDetector &detector)
Load detector from input file.
do set_variable DETECTOR_TXT $WORKDIR detector