#include #include #include #include #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" /** * \file * Auxiliary program to draw the detector in 3D. * \author mdejong */ int main(int argc, char**argv) { using namespace std; using namespace JPP; string detectorFile; int debug; try { JParser<> zap("Auxiliary program to draw the detector in 3D."); zap['a'] = make_field(detectorFile); zap['d'] = make_field(debug) = 1; zap(argc, argv); } catch(const exception &error) { FATAL(error.what() << endl); } JDetector detector; try { load(detectorFile, detector); } catch(const JException& error) { FATAL(error); } if (detector.empty()) { FATAL("Empty detector " << detectorFile << endl); } JCylinder3D cylinder(detector.begin(), detector.end()); NOTICE("Detector volume: " << cylinder << endl); TApplication* tp = new TApplication("user", NULL, NULL); TCanvas* cv = new TCanvas("a", detectorFile.c_str(), 1200, 1200); cv->SetFillColor(0); TGeoManager* geom = new TGeoManager ("geometry", ""); TGeoMaterial* material = new TGeoMaterial("vacuum", 0, 0, 0); TGeoMedium* medium = new TGeoMedium ("vacuum", 1, material); TGeoVolume* top = geom->MakeBox ("Top", medium, cylinder.getRadius(), cylinder.getRadius(), cylinder.getZmax() - cylinder.getZmin()); TGeoVolume* shape = geom->MakeSphere("Module", medium, 0.4, 0.5); shape->SetLineColor(kBlue); int N = 0; for (JDetector::const_iterator i = detector.begin(); i != detector.end(); ++i) { top->AddNode(shape, N++, new TGeoTranslation(i->getX() - cylinder.getX(), i->getY() - cylinder.getY(), i->getZ() - cylinder.getZmin())); } geom->SetTopVolume(top); geom->CloseGeometry(); //geom->SetVisLevel(4); top->Draw(); cv->GetView()->ShowAxis(); cv->Update(); tp->Run(); }