BmnRoot 26.10.0-18-g4e3414f9
Software framework of the BM@N experiment
Loading...
Searching...
No Matches
create_rootgeom_MWPC3.C
Go to the documentation of this file.
1/**
2 * @brief
3 * Macro for creating geometry root-file describing MWPC3
4 * the first BM@N run (<<Shanghai>>)
5 * @author Sergey Merts
6 * @date 15.10.2014
7 *
8 */
9
10#include "TFile.h"
11#include "TGeoBBox.h"
12#include "TGeoManager.h"
13#include "TGeoShape.h"
14#include "TMath.h"
15#include "TString.h"
16
17using namespace TMath;
18
20
21// Number of active planes with wires
22const Int_t NofPlanes = 6;
23
24// Detector's position
25const Double_t MWPC3_Xpos = 0.0;
26const Double_t MWPC3_Ypos = 0.0;
27const Double_t MWPC3_Zpos = 120.0;
28
29// x
30// A______B
31// / \ |\
32// v' / \ | \ u
33// / \ | \
34// \ \ | /
35// u' \ \ | / v
36// \______\|/
37// C
38// x'
39
40// X
41// _____ <----1----> _____ <-2-> _____
42// | | | | | | |
43// | | | | | | |
44// | | | | | | |
45// | | | | | | |
46// |_____|_____|_____|_____|_____|_____|
47// X'
48//
49// 1 - GapWireOnePlane
50// 2 - GapWireTwoPlanes
51
52// Detector's construct parameters
53const Double_t ABsize = 24.6; // cm
54const Double_t BCsize = 43.3; // cm
55const Double_t ACsize = 49.8; // cm
56const Double_t GapZsize = 1.0; // cm
57const Double_t GapWireOnePlane = 0.25; // cm
58const Double_t GapWireTwoPlanes = GapWireOnePlane / 2.0; // cm // 0.125
59
63
65
66// FIXME!!! make sure! sizes of frame
70
72{
73
74 // Load the necessary FairRoot libraries
75 gROOT->LoadMacro("$VMCWORKDIR/macro/run/bmnloadlibs.C");
76 bmnloadlibs(); // load libraries
77
78 // ------- Load media from media file -----------------------------------
79 FairGeoLoader* geoLoad = new FairGeoLoader("TGeo", "FairGeoLoader");
80 FairGeoInterface* geoFace = geoLoad->getGeoInterface();
81 TString geoPath = TString(gSystem->Getenv("VMCWORKDIR")) + "/geometry/";
82 TString medFile = geoPath + "media.geo";
83 geoFace->setMediaFile(medFile);
84 geoFace->readMedia();
86 // --------------------------------------------------------------------------
87
88 // ------- Geometry file name (output) ----------------------------------
89 const TString geoDetectorName = "mwpc3";
90 const TString geoDetectorVersion = "v1";
91 TString geoFileName = geoPath + geoDetectorName + "_" + geoDetectorVersion + ".root";
92 // --------------------------------------------------------------------------
93
94 // ----------------- Get and create the required media -----------------
95 FairGeoMedia* geoMedia = geoFace->getMedia();
96 FairGeoBuilder* geoBuild = geoLoad->getGeoBuilder();
97
98 FairGeoMedium* mAir = geoMedia->getMedium("air");
99 if (!mAir)
100 Fatal("Main", "FairMedium air not found");
101 geoBuild->createMedium(mAir);
102 TGeoMedium* pMedAir = gGeoMan->GetMedium("air");
103 if (!pMedAir)
104 Fatal("Main", "Medium air not found");
105
106 FairGeoMedium* mArCO27030 = geoMedia->getMedium("arco27030");
107 if (!mArCO27030)
108 Fatal("Main", "FairMedium arco27030 not found");
109 geoBuild->createMedium(mArCO27030);
110 TGeoMedium* pMedArCO27030 = gGeoMan->GetMedium("arco27030");
111 if (!pMedArCO27030)
112 Fatal("Main", "Medium arco27030 not found");
113
114 // --------------------------------------------------------------------------
115
116 // -------------- Create geometry and top volume -------------------------
117 gGeoMan = (TGeoManager*)gROOT->FindObject("FAIRGeom");
118 gGeoMan->SetName(geoDetectorName + "_geom");
119 TGeoVolume* top = new TGeoVolumeAssembly("TOP");
120 top->SetMedium(pMedAir);
121 gGeoMan->SetTopVolume(top);
122 // gGeoMan->SetTopVisible(1);
123 // --------------------------------------------------------------------------
124
125 // Define TOP Geometry
126 TGeoVolume* MWPC3Top = new TGeoVolumeAssembly(geoDetectorName);
127 MWPC3Top->SetMedium(pMedAir);
128 MWPC3Top->SetTransparency(50);
129 // Transformations (translations, rotations and scales)
130 TGeoTranslation* DetPos_trans = new TGeoTranslation("DetPos_trans", MWPC3_Xpos, MWPC3_Ypos, MWPC3_Zpos);
131
132 // Solids (shapes)
133 // hexagon which contains active wire planes
134 TGeoPgon* MWPC3ContainerS = new TGeoPgon("MWPC3ContainerS", 0, 360, 6, 2);
135 MWPC3ContainerS->DefineSection(0, -ZLengthChamber / 2.0, 0.0, YSizeOfActiveVolume / 2.0 + 1.0);
136 MWPC3ContainerS->DefineSection(1, ZLengthChamber / 2.0, 0.0, YSizeOfActiveVolume / 2.0 + 1.0);
137 // active wire plane
138 TGeoBBox* MWPC3ActivePlaneS =
139 new TGeoBBox("MWPC3ActivePlaneS", XSizeOfActiveVolume / 2.0, YSizeOfActiveVolume / 2.0, 0.1 /*GapZsize / 2.0*/);
140
141 // Volumes
142 TGeoVolume* MWPC3ContainerV = new TGeoVolume("MWPC3ContainerV", MWPC3ContainerS);
143 MWPC3ContainerV->SetMedium(pMedAir);
144 MWPC3ContainerV->SetVisibility(kTRUE);
145 MWPC3ContainerV->SetTransparency(60);
146
147 TGeoVolume* MWPC3ActivePlaneV = new TGeoVolume("MWPC3ActivePlaneV", MWPC3ActivePlaneS);
148 MWPC3ActivePlaneV->SetMedium(pMedArCO27030);
149 MWPC3ActivePlaneV->SetLineColor(kBlue);
150 MWPC3ActivePlaneV->SetTransparency(40);
151
152 // Adding volumes to the TOP Volume
153 top->AddNode(MWPC3Top, 1, DetPos_trans);
154 MWPC3Top->AddNode(MWPC3ContainerV, 1);
155 for (Int_t iPlane = 1; iPlane <= NofPlanes; ++iPlane) {
156 TGeoTranslation t1(0.0, 0.0, GapZsize * (iPlane - (NofPlanes + 1) / 2.0));
157 TGeoRotation r1("r1", 0.0, 0.0, (iPlane - 1) * 60.0);
158 MWPC3ContainerV->AddNode(MWPC3ActivePlaneV, iPlane, new TGeoCombiTrans(t1, r1));
159 }
160
162
163 // --------------- Finish -----------------------------------------------
164 gGeoMan->CloseGeometry();
165 gGeoMan->CheckOverlaps(0.001);
166 gGeoMan->PrintOverlaps();
167 gGeoMan->Test();
168
169 TFile* geoFile = new TFile(geoFileName, "RECREATE");
170 top->Write();
171 geoFile->Close();
172 top->Draw("ogl");
173}
int Int_t
double Double_t
constexpr Bool_t kTRUE
kBlue
void Fatal(const char *location, const char *msgfmt,...)
R__EXTERN TGeoManager * gGeoManager
#define gROOT
R__EXTERN TSystem * gSystem
void Close(Option_t *option="") override
virtual void DefineSection(Int_t snum, Double_t z, Double_t rmin, Double_t rmax)
void SetVisContainers(Bool_t flag=kTRUE) override
void SetVisibility(Bool_t vis=kTRUE) override
virtual TGeoNode * AddNode(TGeoVolume *vol, Int_t copy_no, TGeoMatrix *mat=nullptr, Option_t *option="")
void Draw(Option_t *option="") override
void SetTransparency(Char_t transparency=0)
virtual void SetMedium(TGeoMedium *medium)
void SetLineColor(Color_t lcolor) override
virtual Int_t Write(const char *name=nullptr, Int_t option=0, Int_t bufsize=0)
TGeoManager * gGeoMan
const Double_t XSizeOfActiveVolume
const Double_t GapWireOnePlane
const Double_t YSizeOfActiveVolume
const Double_t InnerRadiusOfHexagon
const Double_t ZSizeOfActiveVolume
const Double_t XWidthChamber
const Double_t ZLengthChamber
const Int_t NofPlanes
const Double_t YHeightChamber
const Double_t BCsize
const Double_t ACsize
const Double_t GapZsize
const Double_t ABsize
const Double_t GapWireTwoPlanes
const Double_t MWPC3_Zpos
const Double_t MWPC3_Ypos
void create_rootgeom_MWPC3()
const Double_t MWPC3_Xpos
Double_t Sqrt(Double_t x)