FairRoot/PandaRoot
hypGeGeoCOSYTarget.C
Go to the documentation of this file.
1 #include "TGeoManager.h"
2 double Pi = TMath::Pi();
3 
4 
5 TString BuildOutputNameTarget(Double_t TargetThickness_Ext, Double_t Angle)
6 {
7  TString outfileWithoutPath = "hypGeGeoCOSYTarget_";
8  //char buf[10];
9  //sprintf(buf,"%.2f",TargetThickness_Ext);
10  //outfileWithoutPath += buf;
11  outfileWithoutPath +=TargetThickness_Ext;
12  //outfileWithoutPath +=
13  outfileWithoutPath += "cm_";
14  outfileWithoutPath += Angle;
15  outfileWithoutPath += "_Degree.root";
16  return outfileWithoutPath;
17 }
18 
19 TGeoShape* makeMaytec(Double_t length,TString Name)
20 {
21  char buf[100];
22  sprintf(buf, "%sRaw",Name.Data());
23  TGeoBBox *Raw = new TGeoBBox(buf,1.5,1.5,length/2);
24  sprintf(buf, "%sHole",Name.Data());
25  TGeoTube *Hole = new TGeoTube(buf,0,0.6, length);
26  sprintf(buf, "%sTrapez",Name.Data());
27  TGeoTrd1 *Trapez = new TGeoTrd1(buf,0.45,0.75,length,0.25);
28  sprintf(buf, "%sRectangle",Name.Data());
29  TGeoBBox *Rectangle = new TGeoBBox(buf,0.4,0.4,length);
30  sprintf(buf, "%sRectangle2",Name.Data());
31  TGeoBBox *Rectangle2 = new TGeoBBox(buf,0.15,0.5,length);
32  sprintf(buf, "%sRectangle3",Name.Data());
33  TGeoBBox *Rectangle3 = new TGeoBBox(buf,0.1,0.1,length);
34  sprintf(buf, "%sTube",Name.Data());
35  TGeoTubeSeg *Tube = new TGeoTubeSeg(buf, 0.2 , 1 ,length,0,90);
36 
37  TGeoCombiTrans *TrapezCombiTrans[4];
38  TGeoCombiTrans *RectangleCombiTrans[4];
39  TGeoCombiTrans *Rectangle2CombiTrans[4];
40  TGeoCombiTrans *Rectangle3CombiTrans[4];
41  TGeoCombiTrans *Rectangle3CombiTrans2[4];
42  TGeoCombiTrans *TubeCombiTrans[4];
43 
44  sprintf(buf,"%sRaw - %sHole",Name.Data(),Name.Data());
45  TString ShapeString = buf;
46 
47  // position and remove all the fine structure of a maytec profile
48  for (int i = 0; i< 4; i++)
49  {
50  sprintf(buf,"TrapezCombiTrans%d",i);
51  TrapezCombiTrans[i] = new TGeoCombiTrans(buf,1.05*TMath::Sin((i+1)*(TMath::Pi()/2)),1.05*TMath::Cos((i+1)*(TMath::Pi()/2)),0, new TGeoRotation("",90*(1-i),90,0) ); // sin for 4 fold symmetry
52  TrapezCombiTrans[i] ->RegisterYourself();
53  sprintf(buf,"-%sTrapez :TrapezCombiTrans%d",Name.Data(),i);
54  ShapeString += buf;
55  sprintf(buf,"RectangleCombiTrans%d",i);
56  RectangleCombiTrans[i] = new TGeoCombiTrans(buf,1.4*TMath::Sin((i+1)*(TMath::Pi()/2)),1.4*TMath::Cos((i+1)*(TMath::Pi()/2)),0, new TGeoRotation("",0,0,0) );
57  RectangleCombiTrans[i]->RegisterYourself();
58  sprintf(buf,"-%sRectangle :RectangleCombiTrans%d",Name.Data(),i);
59  ShapeString += buf;
60  sprintf(buf,"Rectangle2CombiTrans%d",i);
61  Rectangle2CombiTrans[i] = new TGeoCombiTrans(buf,0.9*pow(-1,i/2),0.9*pow(-1,(i+1)/2),0, new TGeoRotation("",-45+i*90,0,0) );
62  Rectangle2CombiTrans[i]->RegisterYourself();
63  sprintf(buf,"-%sRectangle2 :Rectangle2CombiTrans%d",Name.Data(),i);
64  ShapeString += buf;
65  sprintf(buf,"Rectangle3CombiTrans%d",i);
66  Rectangle3CombiTrans[i] = new TGeoCombiTrans(buf,0.9*pow(-1,i/2),1.58*pow(-1,(i+1)/2),0, new TGeoRotation("",0,0,0) );
67  Rectangle3CombiTrans[i]->RegisterYourself();
68  sprintf(buf,"-%sRectangle3 :Rectangle3CombiTrans%d",Name.Data(),i);
69  ShapeString += buf;
70  sprintf(buf,"Rectangle3CombiTrans2%d",i);
71  Rectangle3CombiTrans2[i] = new TGeoCombiTrans(buf,1.58*pow(-1,(i+1)/2),0.9*pow(-1,i/2),0, new TGeoRotation("",0,0,0) );
72  Rectangle3CombiTrans2[i]->RegisterYourself();
73  sprintf(buf,"-%sRectangle3 :Rectangle3CombiTrans2%d",Name.Data(),i);
74  ShapeString += buf;
75  sprintf(buf,"TubeCombiTrans%d",i);
76  TubeCombiTrans[i] = new TGeoCombiTrans(buf,1.3*pow(-1,(i+1)/2),1.3*pow(-1,i/2),0, new TGeoRotation("",i*90,0,0) );
77  TubeCombiTrans[i]->RegisterYourself();
78  sprintf(buf,"-%sTube :TubeCombiTrans%d",Name.Data(),i);
79  ShapeString += buf;
80  }
81 
82  TGeoCompositeShape *Profile = new TGeoCompositeShape(Name.Data(), ShapeString.Data());
83  cout << ShapeString.Data() << endl;
84  gDirectory->ls();
85 
86 
87  return Profile;
88 }
89 
90 TGeoVolume * makeMaytecFrame(TGeoMedium *Med_ext)
91 {
92  cout << "frame start" << endl;
93  TGeoVolumeAssembly *FrameAssembly= new TGeoVolumeAssembly("FrameAssembly");
94 
95  Double_t Height = 21.5;
96  Double_t Depth = 18.1;
97  Double_t Width = 24;
98  Double_t KermitWidth = 5;
99 
100  TGeoVolume *Pillar = new TGeoVolume ("Pillar", makeMaytec(Height,"Pillar"),Med_ext);
101  TGeoVolume *Pillar2 = new TGeoVolume ("Pillar2", makeMaytec(Height,"Pillar1"),Med_ext);
102  TGeoVolume *Pillar3 = new TGeoVolume ("Pillar3", makeMaytec(Height,"Pillar2"),Med_ext);
103  TGeoVolume *Pillar4 = new TGeoVolume ("Pillar4", makeMaytec(Height,"Pillar3"),Med_ext);
104  Pillar ->SetFillColor(kBlue);
105  Pillar ->SetFillColor(kBlue);
106  Pillar2 ->SetFillColor(kBlue);
107  Pillar2 ->SetFillColor(kBlue);
108  Pillar3 ->SetFillColor(kBlue);
109  Pillar3 ->SetFillColor(kBlue);
110  Pillar4 ->SetFillColor(kBlue);
111  Pillar4 ->SetFillColor(kBlue);
112  TGeoVolume *Beam1 = new TGeoVolume ("Beam1", makeMaytec(Width,"Beam1"),Med_ext);
113  TGeoVolume *Beam12 = new TGeoVolume ("Beam12", makeMaytec(Width,"Beam12"),Med_ext);
114  Beam1->SetFillColor(14);
115  Beam1 ->SetFillColor(14);
116  Beam12->SetFillColor(14);
117  Beam12 ->SetFillColor(14);
118  TGeoVolume *Beam2 = new TGeoVolume ("Beam2", makeMaytec(Depth,"Beam2"),Med_ext);
119  TGeoVolume *Beam22 = new TGeoVolume ("Beam22", makeMaytec(Depth,"Beam22"),Med_ext);
120  Beam2->SetFillColor(14);
121  Beam2 ->SetFillColor(14);
122  Beam22->SetFillColor(14);
123  Beam22 ->SetFillColor(14);
124  FrameAssembly ->AddNode(Pillar,1, new TGeoCombiTrans(Height/2,1.5,Width/2-1.5, new TGeoRotation("",90,90,0)));
125  FrameAssembly ->AddNode(Pillar2,2, new TGeoCombiTrans(Height/2,1.5,-(Width/2-1.5), new TGeoRotation("",90,90,0)));
126  FrameAssembly ->AddNode(Pillar3,3, new TGeoCombiTrans(Height/2,1.5+Depth+3,-(Width/2-1.5), new TGeoRotation("",90,90,0)));
127  FrameAssembly ->AddNode(Pillar4,4, new TGeoCombiTrans(Height/2,1.5+Depth+3,(Width/2-1.5), new TGeoRotation("",90,90,0)));
128  FrameAssembly ->AddNode(Beam1,1, new TGeoCombiTrans(Height+1.5,1.5,0, new TGeoRotation("",0,0,0)));
129  FrameAssembly ->AddNode(Beam12,2, new TGeoCombiTrans(Height+1.5,1.5+Depth+3,0, new TGeoRotation("",0,0,0)));
130  FrameAssembly ->AddNode(Beam2,1, new TGeoCombiTrans(Height+1.5,1.5+Depth/2+1.5,(KermitWidth/2+1.5), new TGeoRotation("",0,90,0)));
131  FrameAssembly ->AddNode(Beam22,2, new TGeoCombiTrans(Height+1.5,1.5+Depth/2+1.5,-(KermitWidth/2+1.5), new TGeoRotation("",0,90,0)));
132 
133 
134  cout << "frame built" << endl;
135  return FrameAssembly;
136 }
137 TGeoVolume *makeGlueStackFrame(TGeoMedium *Al_ext,TGeoMedium *Steel_ext)
138 {
139  // (0,0,0) on the front of the front plate of the stack!
140  Double_t BarLength = 6;
141 
142  TGeoBBox *GlueSampleFrameFrontBox = new TGeoBBox("GlueSampleFrameFrontBox",4,4,0.2);
143  //TGeoVolume *GlueSampleFrameFront = new TGeoVolume("GlueSampleFrameFront", GlueSampleFrontBox,Med_ext);
144 
145  TGeoTranslation *GlueSampleFrontTrans = new TGeoTranslation("GlueSampleFrontTrans",0,0,-0.2);
146  GlueSampleFrontTrans->RegisterYourself();
147  TGeoTranslation *GlueSampleBackTrans = new TGeoTranslation("GlueSampleBackTrans",0,0,-(0.4+BarLength+0.2));
148  GlueSampleBackTrans->RegisterYourself();
149 
150  TGeoBBox *GlueSampleFrameBarBox = new TGeoBBox("GlueSampleFrameBarBox",.4,.4,BarLength/2);
151  //TGeoVolume *GlueSampleFrameBar = new TGeoVolume("GlueSampleFrameBar", GlueSampleFrontBox,Med_ext);
152 
153  TGeoTranslation *GlueSampleFrameBarTrans1 = new TGeoTranslation("GlueSampleFrameBarTrans1",1.4+0.4,1.4+0.4,-(BarLength/2+0.4));
154  GlueSampleFrameBarTrans1->RegisterYourself();
155  TGeoTranslation *GlueSampleFrameBarTrans2 = new TGeoTranslation("GlueSampleFrameBarTrans2",-(1.4+0.4),1.4+0.4,-(BarLength/2+0.4));
156  GlueSampleFrameBarTrans2->RegisterYourself();
157  TGeoTranslation *GlueSampleFrameBarTrans3 = new TGeoTranslation("GlueSampleFrameBarTrans3",-(1.4+0.4),-(1.4+0.4),-(BarLength/2+0.4));
158  GlueSampleFrameBarTrans3->RegisterYourself();
159  TGeoTranslation *GlueSampleFrameBarTrans4 = new TGeoTranslation("GlueSampleFrameBarTrans4",1.4+0.4,-(1.4+0.4),-(BarLength/2+0.4));
160  GlueSampleFrameBarTrans4->RegisterYourself();
161 
162  TString ShapeString = "GlueSampleFrameFrontBox : GlueSampleFrontTrans + GlueSampleFrameFrontBox : GlueSampleBackTrans + GlueSampleFrameBarBox : GlueSampleFrameBarTrans1 + GlueSampleFrameBarBox : GlueSampleFrameBarTrans2 + GlueSampleFrameBarBox : GlueSampleFrameBarTrans3 + GlueSampleFrameBarBox : GlueSampleFrameBarTrans4";
163  TGeoCompositeShape *GlueStackFrameShape = new TGeoCompositeShape("GlueStackFrameShape", ShapeString.Data());
164  TGeoVolume *GlueSampleFrame = new TGeoVolume("GlueSampleFrame", GlueStackFrameShape);
165  return GlueSampleFrame;
166 }
167 
168 TGeoVolume *makeGlueSample(TGeoMedium *Al_ext,TGeoMedium *Glue_ext, Int_t SampleNumber )
169 {
170  // one glue sample sandwich is constructed in this function
171 
172  Double_t HolderThickness = 0.1; // 1 mm
173  Double_t GlueThickness = 0.003; // 40 µm
174  char buf[100];
175 
176  sprintf (buf,"GlueSampleAssembly%d", SampleNumber);
177  TGeoVolume *SampleAssembly = new TGeoVolumeAssembly (buf);
178 
179  sprintf (buf,"GlueHolderBox%d", SampleNumber);
180  TGeoBBox *GlueHolderBox = new TGeoBBox(buf,7.8/2,2.6/2,HolderThickness/2);
181  sprintf (buf,"GlueSampleBox%d", SampleNumber);
182  TGeoBBox *GlueBox = new TGeoBBox(buf,7.8/2,2.6/2,GlueThickness/2);
183 
184  sprintf (buf,"GlueHolder%d", SampleNumber);
185  TGeoVolume *GlueHolder = new TGeoVolume (buf, GlueHolderBox, Al_ext);
186 
187  sprintf (buf,"GlueSampleCrystal%d", SampleNumber);
188  TGeoVolume *GlueSampleCrystal = new TGeoVolume (buf, GlueBox, Glue_ext);
189 
190  sprintf (buf,"GlueHolderTrans1%d", SampleNumber);
191  TGeoTranslation *GlueHolderTrans1 = new TGeoTranslation(buf,0,0,-HolderThickness/2);
192  GlueHolderTrans1->RegisterYourself();
193  sprintf (buf,"GlueHolderTrans2%d", SampleNumber);
194  TGeoTranslation *GlueHolderTrans2 = new TGeoTranslation(buf,0,0,-(HolderThickness+GlueThickness +HolderThickness/2));
195  GlueHolderTrans2->RegisterYourself();
196  sprintf (buf,"GlueTransd", SampleNumber);
197  TGeoTranslation *GlueTrans = new TGeoTranslation(buf,0,0,-(HolderThickness+GlueThickness/2));
198  GlueTrans->RegisterYourself();
199 
200  SampleAssembly->AddNode(GlueHolder,0,GlueHolderTrans1);
201  SampleAssembly->AddNode(GlueHolder,1,GlueHolderTrans2);
202  SampleAssembly->AddNode(GlueSampleCrystal,0,GlueTrans);
203 
204  return SampleAssembly;
205 
206 }
207 
208 TString hypGeGeoCOSYTarget(Double_t TargetThickness_Ext = 5, Double_t Angle = 0)
209 {
210 
211  gROOT->Macro("$VMCWORKDIR/gconfig/rootlogon.C");
212 
213  // Load this libraries
214  gSystem->Load("libGeoBase");
215  gSystem->Load("libParBase");
216  gSystem->Load("libBase");
217  gSystem->Load("libPndData");
218  gSystem->Load("libPassive");
219  gSystem->Load("libHypGe");
220 
221  cout << TargetThickness_Ext;
222  TString outfileWithoutPath =BuildOutputNameTarget(TargetThickness_Ext, Angle); //"hypGeGeoCOSYTarget_";
226  //outfileWithoutPath +=TargetThickness_Ext;
228  //outfileWithoutPath += "cm_";
229  //outfileWithoutPath += Angle;
230  //outfileWithoutPath += "_Degree.root";
231  TString outfile= "../../../../geometry/";
232  outfile += outfileWithoutPath;
233 
234  cout << outfile << endl;
235 
236  TFile* fi = new TFile(outfile,"RECREATE");
237 
238  FairGeoLoader* geoLoad = new FairGeoLoader("TGeo","FairGeoLoader");
239  FairGeoInterface *geoFace = geoLoad->getGeoInterface();
240  geoFace->setMediaFile("../../../../geometry/media_pnd.geo");
241  geoFace->readMedia();
242  //geoFace->print();
243 
244  FairGeoMedia *Media = geoFace->getMedia();
245  FairGeoBuilder *geobuild=geoLoad->getGeoBuilder();
246 
247  FairGeoMedium *medcarbon = Media->getMedium("carbon");
248  Int_t nmedcap=geobuild->createMedium(medcarbon);
249  TGeoMedium *Carbon = gGeoManager->GetMedium("carbon");
250 
251  FairGeoMedium *medcap = Media->getMedium("HYPaluminium");
252  Int_t nmedcap=geobuild->createMedium(medcap);
253  TGeoMedium *Al = gGeoManager->GetMedium("HYPaluminium");
254 
255  FairGeoMedium *medGe = Media->getMedium("germanium");
256  Int_t nmedGe=geobuild->createMedium(medGe);
257  TGeoMedium *Ge = gGeoManager->GetMedium("germanium");
258 
259  FairGeoMedium *medsteel = Media->getMedium("steel");
260  Int_t nmedcap=geobuild->createMedium(medsteel);
261  TGeoMedium *Steel = gGeoManager->GetMedium("steel");
262 
263  FairGeoMedium *medcu = Media->getMedium("copper");
264  Int_t nmedcap=geobuild->createMedium(medcu);
265  TGeoMedium *Cu = gGeoManager->GetMedium("copper");
266 
267  FairGeoMedium *medpe_bor5 = Media->getMedium("pe_bor5");
268  Int_t nmedcap=geobuild->createMedium(medcu);
269  TGeoMedium *pe_bor5 = gGeoManager->GetMedium("pe_bor5"); // polyethylen with 5 % boronoxide
270 
271  TGeoManager *geom = (TGeoManager*)gROOT->FindObject("FAIRGeom");
272  TGeoVolume *top = new TGeoVolumeAssembly("hpGe");
273  TGeoVolume *Realtop = new TGeoVolumeAssembly("Realtop");
274 
275 //cout<<" geom "<<geom<<endl;
276  geom->SetTopVolume(top);
277 
278  // carbon target
279  Double_t TargetThickness = TargetThickness_Ext;
280  TGeoVolume* Target = geom->MakeBox("Target",Carbon,2.4,2.4,TargetThickness/2);
281  Target->SetLineColor(kRed);
282  Target->SetFillColor(kRed);
283  TGeoRotation *TargetRot = new TGeoRotation("TargetRot",0,Angle,0);
284  //Realtop->AddNode(Target,1,new TGeoCombiTrans(0,0,TargetThickness/2/TMath::Cos(Angle*Pi/180),TargetRot));
285  cout << TargetThickness/2/TMath::Cos(Angle*Pi/180) << endl;
286  TGeoVolume* TargetAddition = geom->MakeBox("TargetAddition",Carbon,0.5,2.4,2.4);
287  TargetAddition->SetLineColor(kRed);
288  TargetAddition->SetFillColor(kRed);
289  //Realtop->AddNode(TargetAddition,1,new TGeoCombiTrans(-2.9,0,-0.1+TargetThickness/2/TMath::Cos(Angle*Pi/180),TargetRot));
290  //Realtop->AddNode(TargetAddition,2,new TGeoCombiTrans(-3.9,0,-0.1+TargetThickness/2/TMath::Cos(Angle*Pi/180),TargetRot));
291 
292  // Al support
293  TGeoVolume *AlSupportAssembly = new TGeoVolumeAssembly("AlSupportAssembly");
294  // plate under target
295  TGeoTube *AlPlateTube = new TGeoTube("AlPlateTube",0,6,0.2);
296  TGeoRotation *AlPlateTubeRotation = new TGeoRotation ("AlPlateTubeRotation",90,90,0);
297  AlPlateTubeRotation->RegisterYourself();
298  TGeoBBox *AlPlateBox = new TGeoBBox("AlPlateBox",0.2,6,11.6/2);
299  TGeoTranslation *AlPlateBoxTranslation = new TGeoTranslation ("AlPlateBoxTranslation",0,0,+5.8);
300  AlPlateBoxTranslation->RegisterYourself();
301  TGeoCompositeShape *AlPlateShape = new TGeoCompositeShape("AlPlateShape", "AlPlateTube : AlPlateTubeRotation + AlPlateBox : AlPlateBoxTranslation");
302  TGeoVolume *AlPlate = new TGeoVolume("AlPlate", AlPlateShape, Al);
303  AlPlate->SetLineColor(14);
304  AlPlate->SetFillColor(14);
305 
306  // angle bracket in front of target
307  TGeoBBox *AlFrontAngleTop = new TGeoBBox("AlFrontAngleTop",0.5,2.5,0.1);
308  TGeoTranslation *AlFrontAngleTopTranslation = new TGeoTranslation ("AlFrontAngleTopTranslation",+0.2+0.5,0,-0.1);
309  AlFrontAngleTopTranslation->RegisterYourself();
310  TGeoBBox *AlFrontAngleBottom = new TGeoBBox("AlFrontAngleBottom",0.1,2.5,1.5);
311  TGeoTranslation *AlFrontAngleBottomTranslation = new TGeoTranslation ("AlFrontAngleBottomTranslation",+0.3,0,-1.5);
312  AlFrontAngleBottomTranslation->RegisterYourself();
313  TGeoBBox *AlFrontAngleBottomCutout = new TGeoBBox("AlFrontAngleBottomCutout",1,0.25,1.5);
314  TGeoTranslation *AlFrontAngleBottomCutoutTranslation = new TGeoTranslation ("AlFrontAngleBottomCutoutTranslation",+0.3,0,-2.5);
315  AlFrontAngleBottomCutoutTranslation->RegisterYourself();
316  TGeoCompositeShape *AlFrontAngleShape = new TGeoCompositeShape("AlFrontAngleShape", "(AlFrontAngleTop : AlFrontAngleTopTranslation + AlFrontAngleBottom : AlFrontAngleBottomTranslation ) - ( AlFrontAngleBottomCutout : AlFrontAngleBottomCutoutTranslation)");
317  TGeoVolume *AlFrontAngle = new TGeoVolume("AlFrontAngle", AlFrontAngleShape, Al);
318  AlFrontAngle ->SetLineColor(14);
319  AlFrontAngle ->SetFillColor(14);
320 
321  // angle bracket in the back of target
322  TGeoBBox *AlBackAngleTop = new TGeoBBox("AlBackAngleTop",0.5,2.5,0.1);
323  TGeoTranslation *AlBackAngleTopTranslation = new TGeoTranslation ("AlBackAngleTopTranslation",+0.2+0.5,0,4.9);
324  AlBackAngleTopTranslation->RegisterYourself();
325  TGeoBBox *AlBackAngleBottom = new TGeoBBox("AlBackAngleBottom",0.1,2.5,5);
326  TGeoTranslation *AlBackAngleBottomTranslation = new TGeoTranslation ("AlBackAngleBottomTranslation",+0.3,0,4.8+5);
327  AlBackAngleBottomTranslation->RegisterYourself();
328  TGeoBBox *AlBackAngleBottomCutout = new TGeoBBox("AlBackAngleBottomCutout",1,0.25,5);
329  TGeoTranslation *AlBackAngleBottomCutoutTranslation = new TGeoTranslation ("AlBackAngleBottomCutoutTranslation",+0.3,0,4.8+7);
330  AlBackAngleBottomCutoutTranslation->RegisterYourself();
331  TGeoCompositeShape *AlBackAngleShape = new TGeoCompositeShape("AlBackAngleShape", "(AlBackAngleTop : AlBackAngleTopTranslation + AlBackAngleBottom : AlBackAngleBottomTranslation ) - ( AlBackAngleBottomCutout : AlBackAngleBottomCutoutTranslation)");
332  TGeoVolume *AlBackAngle = new TGeoVolume("AlBackAngle", AlBackAngleShape, Al);
333  AlBackAngle ->SetLineColor(14);
334  AlBackAngle ->SetFillColor(14);
335 
336  // add Al goniometer
337  TGeoTube *AlGoniometerTube = new TGeoTube("AlGoniometerTube",5,6,2);
338  TGeoCombiTrans *AlGoniometerTubeCombiTrans = new TGeoCombiTrans ("AlGoniometerTubeCombiTrans",-2.2,0,0, new TGeoRotation("",90,90,0));
339  AlGoniometerTubeCombiTrans->RegisterYourself();
340  TGeoVolume *AlGoniometer = new TGeoVolume("AlGoniometer",AlGoniometerTube,Al);
341  AlGoniometer ->SetLineColor(14);
342  AlGoniometer ->SetFillColor(14);
343 
344  //screw head close to the beam
345 
346  TGeoTube *M5ScrewHeadOut = new TGeoTube("M5ScrewHeadOut",0.45/2,0.4,0.25);
347  TGeoTube *M5ScrewHeadIn = new TGeoTube("M5ScrewHeadIn",0,0.45/2,0.25/2);
348  TGeoTranslation *M5ScrewHeadInTrans = new TGeoTranslation("M5ScrewHeadInTrans",0,0,0.25/2);
349  M5ScrewHeadInTrans -> RegisterYourself();
350  TGeoCompositeShape *M5ScrewHeadShape = new TGeoCompositeShape("M5SrewHeadShape","M5ScrewHeadOut + M5ScrewHeadIn : M5ScrewHeadInTrans");
351  TGeoVolume *M5ScrewHead = new TGeoVolume("M5ScrewHead",M5ScrewHeadShape,Steel);
352  TGeoCombiTrans *M5ScrewHeadCombiTrans = new TGeoCombiTrans ("M5ScrewHeadCombiTrans",+0.4+0.25,0,8, new TGeoRotation("",90,270,0));
353  M5ScrewHeadCombiTrans->RegisterYourself();
354  TGeoCombiTrans *M5ScrewHead2CombiTrans = new TGeoCombiTrans ("M5ScrewHead2CombiTrans",+0.4+0.25,0,-2, new TGeoRotation("",90,270,0));
355  M5ScrewHead2CombiTrans->RegisterYourself();
356  M5ScrewHead->SetLineColor(36);
357  M5ScrewHead->SetFillColor(36);
358 
359  AlSupportAssembly->AddNode(M5ScrewHead,1, M5ScrewHeadCombiTrans);
360  AlSupportAssembly->AddNode(M5ScrewHead,2, M5ScrewHead2CombiTrans);
361 
362  // add Al base plate
363 
364  TGeoBBox *AlBasePlateBox = new TGeoBBox("AlBasePlateBox",0.4,30,40);
365  TGeoCombiTrans *AlBasePlateCombiTrans = new TGeoCombiTrans ("AlBasePlateCombiTrans",-4.6,25,-25, new TGeoRotation("",0,60,0));
366  AlBasePlateCombiTrans->RegisterYourself();
367  TGeoVolume *AlBasePlate = new TGeoVolume("AlBasePlate",AlBasePlateBox,Al);
368  AlBasePlate ->SetLineColor(14);
369  AlBasePlate ->SetFillColor(14);
370 
371  // add all Al parts to assembly
372  AlSupportAssembly->AddNode(AlBasePlate,1, AlBasePlateCombiTrans);
373  AlSupportAssembly->AddNode(AlGoniometer,1, AlGoniometerTubeCombiTrans);
374  AlSupportAssembly->AddNode(AlFrontAngle,1);
375  AlSupportAssembly->AddNode(AlBackAngle,1);
376  AlSupportAssembly->AddNode(AlPlate,1);
377 
378  TGeoVolume *Frame = makeMaytecFrame(Al);
379  AlSupportAssembly ->AddNode(Frame,1, new TGeoCombiTrans(-4.2,15*TMath::Sin(TMath::Pi()/180*60),-15*TMath::Cos(TMath::Pi()/180*60), new TGeoRotation("",0,-30,0)));
380 
381  //Realtop->AddNode(AlSupportAssembly,1, new TGeoTranslation (-4.6,0,0));
382 
383 
384 
385 
386 
387 
388 
389 
390  // neutron detectors
391 
392  TGeoVolume *NeutronDetectorAssembly = new TGeoVolumeAssembly("NeutronDetectorAssembly");
393  // electronic neutron dosimeter (Kermit)
394  TGeoTube *KermitTube= new TGeoTube("KermitTube",0,23.5/2,26.4/2);
395  TGeoVolume *KermitVolume = new TGeoVolume("KermitCrystal",KermitTube,pe_bor5);
396  TGeoCombiTrans *KermitCombiTrans = new TGeoCombiTrans ("KermitHeadCombiTrans",24.5+23.5/2,15+(26.4/2)*TMath::Sin(TMath::Pi()/180*60),-(15+26.4/2)*TMath::Cos(TMath::Pi()/180*60), new TGeoRotation("",0,60,0));
397  KermitCombiTrans->RegisterYourself();
398  NeutronDetectorAssembly ->AddNode(KermitVolume,1, KermitCombiTrans); // check x position of kermit, seems too high, but need better connection for this...
399 
400  // passive neutron ball
401  TGeoSphere *NeutronBallSphere = new TGeoSphere("NeutronBallSphere",0,32/2,0,180,0,360);
402  TGeoVolume *NeutronBall = new TGeoVolume ("NeutronBallCrystal", NeutronBallSphere,pe_bor5);
403  TGeoCombiTrans *NeutronBallCombiTrans = new TGeoCombiTrans ("NeutronBallHeadCombiTrans",20,21.5+32/2,-54, new TGeoRotation("",0,0,0));
404  NeutronBallCombiTrans->RegisterYourself();
405  NeutronDetectorAssembly ->AddNode(NeutronBall,1, NeutronBallCombiTrans);
406 
407  //Realtop->AddNode(NeutronDetectorAssembly,1, new TGeoTranslation (-4.6,0,0));
408 
409  //germanium
410 
411  PndGeoHypGeSingleCluster *SingleCluster = new PndGeoHypGeSingleCluster(Ge,Al,Cu,1);
412  Int_t CrystalNumber = 1;
413  //SingleCluster ->PlaceCluster(Realtop, 0,15, 0,60,0,&CrystalNumber);
414 
415  // stack of glue samples
416  // first the frame
417 
418  TGeoVolume *GlueStackAssembly = new TGeoVolumeAssembly("GlueStackAssembly");
419  TGeoVolume *GlueStackFrame = makeGlueStackFrame(Al,Steel);
420 
421  GlueStackAssembly->AddNode(GlueStackFrame,1);
422 
423  TGeoVolume *GlueSamples[23];
424  //TGeoCombiTrans GlueSampleTrans[23];
425 
426  for (int i= 0; i < 1; i++)
427  {
428  GlueSamples[i] = makeGlueSample(Al, Steel,i);
429  //GlueSampleTrans[i] = new TGeoCombiTrans (0,0,0.4 + i*(1), new TGeoRotation(0,0,0));
430  GlueStackAssembly->AddNode(GlueSamples[i],i, new TGeoCombiTrans (0,0,-(0.4 + (i+0.5)*(0.203)), new TGeoRotation("",0,0,0)));
431  }
432  Realtop->AddNode(GlueStackAssembly,1, new TGeoTranslation (0,0,-100));
433  top->AddNode(Realtop,0);
434 
435 
436  geom->CloseGeometry();
437  cout << "# of Nodes: " << Realtop->CountNodes(10,1) << endl;
438 
439 
440  top->Write();
441  fi->Close();
442  cout << "Wrote target geometry to file: " << outfileWithoutPath << endl;
443  Realtop->Draw("ogl");
444 
445 
446 
447 
448 
449 
450  return outfileWithoutPath; // returns the name of the created geometry file
451 }
452 
453 
FairGeoLoader * geoLoad
Int_t i
Definition: run_full.C:25
FairGeoMedia * Media
static T Sin(const T &x)
Definition: PndCAMath.h:42
TFile * Target
Definition: hadd.C:35
TString hypGeGeoCOSYTarget(Double_t TargetThickness_Ext=5, Double_t Angle=0)
trDW RegisterYourself()
TGeoManager * gGeoManager
static T Cos(const T &x)
Definition: PndCAMath.h:43
TGeoVolume * top
TString BuildOutputNameTarget(Double_t TargetThickness_Ext, Double_t Angle)
TGeoVolume * makeMaytecFrame(TGeoMedium *Med_ext)
FairGeoBuilder * geobuild
TFile * fi
Double_t
#define Cu
TGeoVolume * makeGlueStackFrame(TGeoMedium *Al_ext, TGeoMedium *Steel_ext)
TGeoVolume * makeGlueSample(TGeoMedium *Al_ext, TGeoMedium *Glue_ext, Int_t SampleNumber, Bool_t PassivePart, Bool_t ActivePart)
TGeoShape * makeMaytec(Double_t length, TString Name)
FairGeoInterface * geoFace
Double_t Pi
TString outfile