Jpp  18.3.0
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Functions
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 "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

int main ( int  argc,
char **  argv 
)

Definition at line 31 of file JDrawDetector3D.cc.

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