Jpp test-rotations-new
the software that should make you happy
Loading...
Searching...
No Matches
JDrawDetector3D.cc File Reference

Auxiliary program to draw the detector in 3D. More...

#include <string>
#include <iostream>
#include <limits>
#include <memory>
#include "TROOT.h"
#include "TApplication.h"
#include "TCanvas.h"
#include "TRootCanvas.h"
#include "TView.h"
#include "TGeometry.h"
#include "TGeoManager.h"
#include "TGeoMatrix.h"
#include "TGeoMaterial.h"
#include "TGeoMedium.h"
#include "TGeoVolume.h"
#include "JDetector/JDetector.hh"
#include "JDetector/JDetectorToolkit.hh"
#include "JGeometry3D/JCylinder3D.hh"
#include "Jeep/JParser.hh"
#include "Jeep/JMessage.hh"

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Detailed Description

Auxiliary program to draw the detector in 3D.

Author
mdejong

Definition in file JDrawDetector3D.cc.

Function Documentation

◆ main()

int main ( int argc,
char ** argv )

Definition at line 32 of file JDrawDetector3D.cc.

33{
34 using namespace std;
35 using namespace JPP;
36
37 string detectorFile;
38 int debug;
39
40 try {
41
42 JParser<> zap("Auxiliary program to draw the detector in 3D.");
43
44 zap['a'] = make_field(detectorFile);
45 zap['d'] = make_field(debug) = 1;
46
47 zap(argc, argv);
48 }
49 catch(const exception &error) {
50 FATAL(error.what() << endl);
51 }
52
53
55
56 try {
57 load(detectorFile, detector);
58 }
59 catch(const JException& error) {
60 FATAL(error);
61 }
62
63 if (detector.empty()) {
64 FATAL("Empty detector " << detectorFile << endl);
65 }
66
67 JCylinder3D cylinder(detector.begin(), detector.end());
68
69 NOTICE("Detector volume: " << cylinder << endl);
70
71 TApplication* tp = new TApplication("user", NULL, NULL);
72 TCanvas* cv = new TCanvas("a", detectorFile.c_str(), 1200, 1200);
73
74 ((TRootCanvas *) cv->GetCanvasImp())->Connect("CloseWindow()", "TApplication", tp, "Terminate()");
75
76 cv->SetFillColor(0);
77
78 TGeoManager* geom = new TGeoManager ("geometry", "");
79 TGeoMaterial* material = new TGeoMaterial("vacuum", 0, 0, 0);
80 TGeoMedium* medium = new TGeoMedium ("vacuum", 1, material);
81 TGeoVolume* top = geom->MakeBox ("Top", medium, cylinder.getRadius(), cylinder.getRadius(), cylinder.getZmax() - cylinder.getZmin());
82 TGeoVolume* shape = geom->MakeSphere("Module", medium, 0.4, 0.5);
83
84 shape->SetLineColor(kBlue);
85
86 int N = 0;
87
88 for (JDetector::const_iterator i = detector.begin(); i != detector.end(); ++i) {
89 top->AddNode(shape, N++, new TGeoTranslation(i->getX() - cylinder.getX(), i->getY() - cylinder.getY(), i->getZ() - cylinder.getZmin()));
90 }
91
92 geom->SetTopVolume(top);
93 geom->CloseGeometry();
94 //geom->SetVisLevel(4);
95
96 top->Draw();
97
98 cv->GetView()->ShowAxis();
99 cv->Update();
100
101 tp->Run();
102}
#define NOTICE(A)
Definition JMessage.hh:64
#define FATAL(A)
Definition JMessage.hh:67
int debug
debug level
Definition JSirene.cc:72
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition JParser.hh:2142
Detector data structure.
Definition JDetector.hh:96
General exception.
Definition JException.hh:24
Utility class to parse command line options.
Definition JParser.hh:1698
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).
Detector file.
Definition JHead.hh:227