Jpp test-rotations-old
the software that should make you happy
Loading...
Searching...
No Matches
JDrawDetector3D.cc
Go to the documentation of this file.
1#include <string>
2#include <iostream>
3#include <limits>
4#include <memory>
5
6#include "TROOT.h"
7#include "TApplication.h"
8#include "TCanvas.h"
9#include "TRootCanvas.h"
10#include "TView.h"
11#include "TGeometry.h"
12#include "TGeoManager.h"
13#include "TGeoMatrix.h"
14#include "TGeoMaterial.h"
15#include "TGeoMedium.h"
16#include "TGeoVolume.h"
17
20
22
23#include "Jeep/JParser.hh"
24#include "Jeep/JMessage.hh"
25
26
27/**
28 * \file
29 * Auxiliary program to draw the detector in 3D.
30 * \author mdejong
31 */
32int main(int argc, char**argv)
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}
Data structure for detector geometry and calibration.
int main(int argc, char **argv)
General purpose messaging.
#define NOTICE(A)
Definition JMessage.hh:64
#define FATAL(A)
Definition JMessage.hh:67
int debug
debug level
Definition JSirene.cc:72
Utility class to parse command line options.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition JParser.hh:2142
Detector data structure.
Definition JDetector.hh:96
double getRadius() const
Get radius.
Definition JCircle2D.hh:144
double getY() const
Get y position.
Definition JVector2D.hh:74
double getX() const
Get x position.
Definition JVector2D.hh:63
double getZmin() const
Get minimal z position.
double getZmax() const
Get maximal z position.
General exception.
Definition JException.hh:24
Utility class to parse command line options.
Definition JParser.hh:1698
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Detector file.
Definition JHead.hh:227