FairRoot/PandaRoot
hypGeGeoCOSYBeamDumpTOF.C
Go to the documentation of this file.
1 #include "TGeoManager.h"
2 double Pi = TMath::Pi();
3 
5 {
6  TString outfileWithoutPath = "hypGeGeoCOSYBeamDumpTOF_dist";
7  outfileWithoutPath += BeamDumpDist;
8  outfileWithoutPath += "cm.root";
9  return outfileWithoutPath;
10 }
11 
12 TString hypGeGeoCOSYBeamDumpTOF(Double_t BeamDumpDist_ext )//= 200)
13 {
14 
15  gROOT->Macro("$VMCWORKDIR/gconfig/rootlogon.C");
16 
17  // Load this libraries
18  gSystem->Load("libGeoBase");
19  gSystem->Load("libParBase");
20  gSystem->Load("libBase");
21  gSystem->Load("libPndData");
22  gSystem->Load("libPassive");
23  gSystem->Load("libHypGe");
24 
25 
26  TString outfileWithoutPath = BuildOutputNameBeamDump(BeamDumpDist_ext);
27 
28  TString outfile= "../../../../geometry/";
29  outfile += outfileWithoutPath;
30  TFile* fi = new TFile(outfile,"RECREATE");
31 
32  FairGeoLoader* geoLoad = new FairGeoLoader("TGeo","FairGeoLoader");
33  FairGeoInterface *geoFace = geoLoad->getGeoInterface();
34  geoFace->setMediaFile("../MiscFiles/moded_media_pnd.geo");
35  geoFace->readMedia();
36  //geoFace->print();
37 
38  FairGeoMedia *Media = geoFace->getMedia();
39  FairGeoBuilder *geobuild=geoLoad->getGeoBuilder();
40 
41  FairGeoMedium *mediron = Media->getMedium("iron");
42  geobuild->createMedium(mediron);
43  TGeoMedium *Iron = gGeoManager->GetMedium("iron");
44 
45  FairGeoMedium *medconcrete = Media->getMedium("concrete");
46  geobuild->createMedium(medconcrete);
47  TGeoMedium *Concrete = gGeoManager->GetMedium("concrete");
48 
49  TGeoManager *geom = (TGeoManager*)gROOT->FindObject("FAIRGeom");
50  TGeoVolume *top = new TGeoVolumeAssembly("hpGe");
51  TGeoVolume *Realtop = new TGeoVolumeAssembly("Realtop");
52  TGeoVolume *BeamDumpAssembly = new TGeoVolumeAssembly("BeamDumpAssembly");
53 //cout<<" geom "<<geom<<endl;
54  geom->SetTopVolume(top);
55 
56  //Inner part - iron
57 
58  Double_t BeamTubeRadius = 30;
59  TGeoTube *BackTube = new TGeoTube("BackTube",0,100,120);
60  TGeoTube *FrontTube = new TGeoTube("FrontTube",BeamTubeRadius,50,20);
61 
62  TGeoTranslation *FrontTubeTranslation = new TGeoTranslation("FrontTubeTranslation",0,0,-140);
63  FrontTubeTranslation->RegisterYourself();
64  TGeoCompositeShape *BeamDumpIronShape = new TGeoCompositeShape("BeamDumpIronShape","BackTube+FrontTube : FrontTubeTranslation");
65  TGeoVolume *BeamDumpIron = new TGeoVolume("BeamDumpIron",BeamDumpIronShape,Iron);
66  BeamDumpIron->SetLineColor(4);
67  BeamDumpIron->SetFillColor(4);
68  BeamDumpAssembly->AddNode(BeamDumpIron,1);
69 
70  // Outer part - concrete
71 
72  TGeoBBox *BeamDumpBox = new TGeoBBox("BeamDumpBox",200,200,200);
73  TGeoTube *BeamTube = new TGeoTube ("BeamTube", 0,BeamTubeRadius,30);
74  TGeoTranslation *BeamTubeTranslation = new TGeoTranslation ("BeamTubeTranslation",0,0,-190);
75  BeamTubeTranslation->RegisterYourself();
76  TGeoCompositeShape *BeamDumpConcreteShape = new TGeoCompositeShape("BeamDumpConcreteShape", "BeamDumpBox - BeamDumpIronShape - BeamTube : BeamTubeTranslation");
77 
78  TGeoVolume *BeamDumpConcrete = new TGeoVolume("BeamDumpConcrete", BeamDumpConcreteShape, Concrete);
79  BeamDumpConcrete->SetLineColor(14);
80  BeamDumpConcrete->SetFillColor(14);
81  BeamDumpAssembly->AddNode(BeamDumpConcrete,1);
82 
83  Realtop->AddNode(BeamDumpAssembly,0,new TGeoTranslation(0,0,200+BeamDumpDist_ext));
84  top->AddNode(Realtop,0);
85  geom->CloseGeometry();
86  cout << "# of Nodes: " << Realtop->CountNodes(10,1) << endl;
87 
88  top->Write();
89  fi->Close();
90 
91  Realtop->Draw("ogl");
92 
93  //Realtop->Draw();
94 
95 
96 
97 
98  return outfileWithoutPath; // returns the name of the created geometry file
99 }
100 
101 
TString hypGeGeoCOSYBeamDumpTOF(Double_t BeamDumpDist_ext)
FairGeoLoader * geoLoad
FairGeoMedia * Media
TString BuildOutputNameBeamDump(Double_t BeamDumpDist)
TGeoManager * gGeoManager
TGeoVolume * top
FairGeoBuilder * geobuild
TFile * fi
Double_t
FairGeoInterface * geoFace
Double_t Pi
TString outfile