From ea22a1b6a1dae8f4b205591d0218344559611753 Mon Sep 17 00:00:00 2001 From: Alexander Zinchenko <Alexander.Zinchenko@jinr.ru> Date: Thu, 1 Dec 2016 09:31:30 +0400 Subject: [PATCH] Macro can be compiled. --- macro/mpd/geometry/mpdshape.class.C | 119 +++++++++++++++++++++++----- macro/mpd/geometry/mpdshape.class.h | 81 +++++++++++++++++++ 2 files changed, 180 insertions(+), 20 deletions(-) create mode 100644 macro/mpd/geometry/mpdshape.class.h diff --git a/macro/mpd/geometry/mpdshape.class.C b/macro/mpd/geometry/mpdshape.class.C index c789dea..dce4dcd 100644 --- a/macro/mpd/geometry/mpdshape.class.C +++ b/macro/mpd/geometry/mpdshape.class.C @@ -4,7 +4,10 @@ *****************************************************************************/ class FairGeoRotation; +#include <TVector3.h> + #include <iostream> +#include <fstream> #include <string> class Mpdshape: public TObject { @@ -53,15 +56,17 @@ public: void Clear(); void Fill_TUBE(Double_t length_z, Double_t r_max, Double_t r_min); void Fill_TUBS(Double_t zmin, Double_t zmax, Double_t rmin,Double_t rmax, Double_t dr_st, Double_t dr_end); - void Fill_TRAP(Double_t x, Double_t X,Double_t x_small_f, Double_t x_large_f, Double_t yW, Double_t zW, Int_t ra); - // void Fill_TRAP(Double_t x_small, Double_t x_large, Double_t yWidth, Double_t zWidth); + void Fill_TRAP(Double_t x, Double_t X,Double_t x_small_f, Double_t x_large_f, Double_t yW, Double_t yW2,Double_t zW, Double_t zW2, Int_t ra); //void Fill_RECTRAP(Double_t x_small, Double_t x_large,Double_t xx_small, Double_t xx_large, // Double_t yWidth, Double_t zWidth); - void Fill_PGON( Double_t zmin, Double_t zmax, Double_t rmin, Double_t rmax, Double_t phi1, Int_t nEdges = 12); - void Fill_BOX(Double_t xWidth, Double_t yWidth, Double_t zWidth); + void Fill_SPHE( Double_t rzmin, Double_t rmax, Double_t thetamin, Double_t thetamax, Double_t phimin, Double_t phimax); + void Fill_PGON( Double_t zmin, Double_t zmax, Double_t rmin, Double_t rmax, Double_t phi1); + //void Fill_BOX(Double_t x, Double_t y, Double_t z); + void Fill_BRIK(Double_t xWidth1, Double_t xWidth2, Double_t yWidth, Double_t zWidth1, Double_t zWidth2, Int_t ra); + protected: - ofstream* fFile; + std::ofstream* fFile; std::string fVolumeName; std::string fMotherVolumeName; std::string fShape; @@ -73,8 +78,19 @@ protected: Int_t fMotherSegment; FairGeoRotation* rot; + ClassDef(Mpdshape,0) }; +ClassImp(Mpdshape) + +#include "FairGeoRotation.h" + +#include <TROOT.h> +#include <TSystem.h> + +#include <sstream> +using namespace std; + Mpdshape::Mpdshape() { gROOT->LoadMacro("$VMCWORKDIR/gconfig/basiclibs.C"); @@ -182,7 +198,7 @@ void Mpdshape::SetRotation(Double_t z, Double_t y1, Double_t z1) { std::ostringstream o; o.setf(ios::showpoint); o.setf(ios::fixed); - o << setprecision(10); + o.precision(10); for (Int_t i = 0; i < 9; i++) { o << rot->operator()(i) << " "; } @@ -205,6 +221,7 @@ void Mpdshape::Clear() { fPoints.clear(); fPosition.clear(); fRotation.clear(); } + //______________________________________________________________ void Mpdshape::Fill_TUBE(Double_t length_z, Double_t r_in, Double_t r_out) { // @@ -238,24 +255,38 @@ void Mpdshape::Fill_TUBS(Double_t zmin,Double_t zmax, Double_t rmin, Double_t rm } //_______________________________________________________________ -void Mpdshape::Fill_PGON( Double_t zmin, Double_t zmax, Double_t rmin, Double_t rmax, Double_t phi1, Int_t nEdges) { +void Mpdshape::Fill_SPHE( Double_t rm, Double_t rx, Double_t thm, Double_t thx, Double_t phim, Double_t phix) { + fPoints.clear(); + std::ostringstream o; + o.setf(ios::showpoint); + o.setf(ios::fixed); + o.precision(10); + + o << rm << " " << rx << endl + << thm << " " << thx << endl + << phim << " " << phix; + fPoints = o.str(); + +} + +//_______________________________________________________________ +void Mpdshape::Fill_PGON( Double_t zmin, Double_t zmax, Double_t rmin, Double_t rmax, Double_t phi1) { fPoints.clear(); std::ostringstream o; o.setf(ios::showpoint); o.setf(ios::fixed); o.precision(10); o << "2 " << endl - << phi1 << " 360 " << nEdges << endl + << phi1 << " 360 12 " << endl << zmin << " " << rmin << " " << rmax << endl << zmax << " " << rmin << " " << rmax; fPoints = o.str(); } -//______________________________________________________________ //______________________________________________________________ void Mpdshape::Fill_TRAP(Double_t x_small, Double_t x_large,Double_t x_large_f, Double_t x_small_f, - Double_t yWidth, Double_t zWidth, + Double_t yWidth, Double_t yWidth2,Double_t zWidth, Double_t /*zWidth2*/, Int_t right_angled) { // fPoints.clear(); @@ -329,6 +360,8 @@ void Mpdshape::Fill_TRAP(Double_t x_small, Double_t x_large,Double_t x_large_f, } if (right_angled == 3){ + +//BOX o << x_small << " " << 0. << " " << -zWidth << endl << x_small << " " << yWidth << " " << -zWidth << endl << -x_small << " " << yWidth << " " << -zWidth << endl @@ -339,11 +372,23 @@ void Mpdshape::Fill_TRAP(Double_t x_small, Double_t x_large,Double_t x_large_f, << -x_small << " " << yWidth << " " << zWidth << endl << -x_small << " " << 0. << " " << zWidth; } - + if (right_angled == 4) { + o << x_small << " " << yWidth << " " << -zWidth << endl + << x_large << " " << yWidth2 << " " << -zWidth << endl + << -x_large << " " << yWidth2 << " " << -zWidth << endl + << -x_small << " " << yWidth << " " << -zWidth << endl + + << x_small << " " << yWidth << " " << zWidth << endl + << x_large << " " << yWidth2 << " " << zWidth << endl + << -x_large << " " << yWidth2 << " " << zWidth << endl + << -x_small << " " << yWidth << " " << zWidth << endl; + } fPoints = o.str(); } + +/* //______________________________________________________________ void Mpdshape::Fill_BOX(Double_t xWidth, Double_t yWidth, Double_t zWidth) { @@ -352,24 +397,58 @@ void Mpdshape::Fill_BOX(Double_t xWidth, Double_t yWidth, Double_t zWidth) { std::ostringstream o; o.setf(ios::showpoint); o.setf(ios::fixed); - o.precision(6); + o.precision(10); - o << xWidth << " " << -yWidth << " " << -zWidth << endl + + o << xWidth << " " << yWidt<< " " << -zWidth << endl << xWidth << " " << yWidth << " " << -zWidth << endl << -xWidth << " " << yWidth << " " << -zWidth << endl - << -xWidth << " " << -yWidth << " " << -zWidth << endl - << xWidth << " " << -yWidth << " " << zWidth << endl + << -xWidth << " " << yWidt << " " << -zWidth << endl + << xWidth << " " << yWidt << " " << zWidth << endl << xWidth << " " << yWidth << " " << zWidth << endl << -xWidth << " " << yWidth << " " << zWidth << endl - << -xWidth << " " << -yWidth << " " << zWidth; - fPoints = o.str(); + << -xWidth << " " <<yWidt << " " << zWidth; + + fPoints = o.str(); + } +*/ + +//______________________________________________________________ +void Mpdshape::Fill_BRIK(Double_t xWidth1, Double_t xWidth2, Double_t yWidth, Double_t zWidth1, Double_t zWidth2, Int_t right_angled) { + // box + fPoints.clear(); + std::ostringstream o; + o.setf(ios::showpoint); + o.setf(ios::fixed); + o.precision(10); -//============================================================= -//============================================================= -//============================================================= + if( right_angled == 0){ + o << xWidth1 << " " << 0. << " " << -zWidth1 << endl + << xWidth1 << " " << yWidth << " " << -zWidth1 << endl + << -xWidth1 << " " << yWidth << " " << -zWidth1 << endl + << -xWidth1 << " " << 0. << " " << -zWidth1 << endl + << xWidth1 << " " << 0. << " " << zWidth1 << endl + << xWidth1 << " " << yWidth << " " << zWidth1 << endl + << -xWidth1 << " " << yWidth << " " << zWidth1 << endl + << -xWidth1 << " " << 0. << " " << zWidth1; + fPoints = o.str(); + } + if( right_angled == 1){ + o << xWidth1 << " " << 0. << " " << -zWidth1 << endl + << xWidth2 << " " << yWidth << " " << -zWidth2 << endl + << -xWidth2 << " " << yWidth << " " << -zWidth2 << endl + << -xWidth1 << " " << 0. << " " << -zWidth1 << endl + << xWidth1 << " " << 0. << " " << zWidth1 << endl + << xWidth2 << " " << yWidth << " " << zWidth2 << endl + << -xWidth2 << " " << yWidth << " " << zWidth2 << endl + << -xWidth1 << " " << 0. << " " << zWidth1; + fPoints = o.str(); + } +} +//============================================================ TVector3 LineCrossesCircle(TVector3 CircleCenter, Double_t CircleRadius, TVector3 LineStart, TVector3 LineEnd) { diff --git a/macro/mpd/geometry/mpdshape.class.h b/macro/mpd/geometry/mpdshape.class.h new file mode 100644 index 0000000..7d5f142 --- /dev/null +++ b/macro/mpd/geometry/mpdshape.class.h @@ -0,0 +1,81 @@ +/****************************************************************************** +* Version: 09-Jun-2012 (EL) +*****************************************************************************/ +class FairGeoRotation; + +#include <TVector3.h> + +#include <iostream> +#include <fstream> +#include <string> + +class Mpdshape: public TObject { + +public: + Mpdshape(); + Mpdshape(ofstream* file, std::string volume_name, + std::string mother_volume_name, std::string shape, + std::string media, std::string points, + std::string position = "0. 0. 0.", + std::string rotation = "1. 0. 0. 0. 1. 0. 0. 0. 1.", + Int_t segment = 0, Int_t mother_segment = 0); + Mpdshape(ofstream* file, std::string volume_name, + std::string mother_volume_name, std::string shape, + std::string media); + ~Mpdshape(); + + void SetFile(ofstream* file) { fFile = file; } + void SetVolumeName(std::string name) { fVolumeName = name; } + void SetMotherVolumeName(std::string name) { fMotherVolumeName = name; } + void SetShape(std::string shape) { fShape = shape; } + void SetMedia(std::string media) { fMedia = media; } + void SetPoints(std::string points) { fPoints = points; } + + void SetPosition(std::string position) { fPosition = position; } + void SetPosition(Double_t x, Double_t y, Double_t z, Int_t precision=6); + void SetPosition(TVector3 vec); + + void SetRotation(std::string rotation) { fRotation = rotation; } + void SetRotation(Double_t p1, Double_t p2, Double_t p3, + Double_t p4, Double_t p5, Double_t p6, + Double_t p7, Double_t p8, Double_t p9); + void SetRotation(Double_t z, Double_t y1, Double_t z1); + + void SetPositionRotation(std::string position, std::string rotation) + { fPosition = position; fRotation = rotation; } + void SetSegment(Int_t segment) { fSegment = segment; } + void SetMotherSegment(Int_t segment) { fMotherSegment = segment; } + + void DumpToFile(); + void DumpWithIncrement() { DumpToFile(); fSegment++; } + static std::string itoa(Double_t x); + + std::string GetVolumeName() const { return fVolumeName;} + Int_t GetSegment() const { return fSegment;} + void Clear(); + void Fill_TUBE(Double_t length_z, Double_t r_max, Double_t r_min); + void Fill_TUBS(Double_t zmin, Double_t zmax, Double_t rmin,Double_t rmax, Double_t dr_st, Double_t dr_end); + void Fill_TRAP(Double_t x, Double_t X,Double_t x_small_f, Double_t x_large_f, Double_t yW, Double_t yW2,Double_t zW, Double_t zW2, Int_t ra); + //void Fill_RECTRAP(Double_t x_small, Double_t x_large,Double_t xx_small, Double_t xx_large, + // Double_t yWidth, Double_t zWidth); + void Fill_SPHE( Double_t rzmin, Double_t rmax, Double_t thetamin, Double_t thetamax, Double_t phimin, Double_t phimax); + void Fill_PGON( Double_t zmin, Double_t zmax, Double_t rmin, Double_t rmax, Double_t phi1); + //void Fill_BOX(Double_t x, Double_t y, Double_t z); + void Fill_BRIK(Double_t xWidth1, Double_t xWidth2, Double_t yWidth, Double_t zWidth1, Double_t zWidth2, Int_t ra); + + +protected: + std::ofstream* fFile; + std::string fVolumeName; + std::string fMotherVolumeName; + std::string fShape; + std::string fMedia; + std::string fPoints; + std::string fPosition; + std::string fRotation; + Int_t fSegment; + Int_t fMotherSegment; + FairGeoRotation* rot; + + ClassDef(Mpdshape,0) +}; -- GitLab