FairRoot/PandaRoot
createRootFscGeometryFile.C
Go to the documentation of this file.
1 {
2 // Macro to create Fsc geometry file
3 // of the FSC detector for PANDA
4 // in root format
5 //30.03.2010 Dmitry Morozov
6 
7  // Fsc geometry parameters
8  // in cm
9  //-----------------------------
10  Double_t beamlineangle = -TMath::DegToRad()*0.0; //in rad
11  const Double_t zpos = 760.0;
12  const Int_t numcellsx = 54;
13  const Int_t numcellsy = 28;
14  const Double_t tyvekbundle = 0.025;
15  const Double_t paperbundle = 0.025;
17  const Double_t Absorb_xsize = 5.5;
18  const Double_t Absorb_ysize = 5.5;
19  const Double_t Air_thickness = 0.0;
20  const Double_t Pb_thickness = 0.0275;
21  const Double_t Sci_thickness = 0.15;
22  const Double_t Sci_xsize = 5.5;
23  const Double_t Sci_ysize = 5.5;
24  const Int_t EMCnumlayers = 380;
25  const Int_t numfibers = 6;
26  const Double_t fiber_r = 0.06;
27  const Double_t fiber_hole_r = 0.07;
28 
29 
30 
31  Double_t cellxsize = TMath::Max(Absorb_xsize,Sci_xsize)+2.*crystalspace;
32  Double_t cellysize = TMath::Max(Absorb_ysize,Sci_ysize)+2.*crystalspace;
33  Double_t xsize = cellxsize*numcellsx;
34  Double_t ysize = cellysize*numcellsy;
35 
36  Double_t cell_thickness = 2*Air_thickness+Pb_thickness+Sci_thickness;
37  Double_t thickness = cell_thickness*EMCnumlayers + 2.*crystalspace;
39 
42  //position of the hole means - coordinate of its center
43  Double_t hole_xpos = 2.0*cellxsize; //Must be left to the beam line (check??)
45 
46 
47  //--------------------------------------------------------------------
48  // gROOT->Macro("$VMCWORKDIR/gconfig/rootlogon.C");
49 
50  // Load this example libraries
51  gSystem->Load("libGeoBase");
52  gSystem->Load("libParBase");
53  gSystem->Load("libBase");
54  gSystem->Load("libPndData");
55  gSystem->Load("libPassive");
56 
57  TString outfile= "emc_module5_fsc.root";
58  TFile* fi = new TFile(outfile,"RECREATE");
59 
60  FairGeoLoader* geoLoad = new FairGeoLoader("TGeo","FairGeoLoader");
61  FairGeoInterface *geoFace = geoLoad->getGeoInterface();
62 // geoFace->setMediaFile("../../../geometry/media_pnd.geo");
63 // geoFace->setMediaFile("$VMCWORKDIR/geometry/media_pnd.geo");
64  geoFace->setMediaFile("/home/freez/fairsoft_mar15/pandaroot/geometry/media_pnd.geo");
65  geoFace->readMedia();
66  geoFace->print();
67 
68  FairGeoMedia *Media = geoFace->getMedia();
69  FairGeoBuilder *geobuild=geoLoad->getGeoBuilder();
70 
71  FairGeoMedium *MediumAir = Media->getMedium("air");
72  FairGeoMedium *MediumTyvek = Media->getMedium("tyvek");
73  FairGeoMedium *MediumCarbon = Media->getMedium("carbon");
74  FairGeoMedium *MediumLead = Media->getMedium("lead");
75  FairGeoMedium *MediumScint = Media->getMedium("FscScint");
76  FairGeoMedium *MediumFiber = Media->getMedium("FscFiber");
77 
78  Int_t nmed=geobuild->createMedium(MediumAir);
79  nmed=geobuild->createMedium(MediumTyvek);
80  nmed=geobuild->createMedium(MediumCarbon);
81  nmed=geobuild->createMedium(MediumLead);
82  nmed=geobuild->createMedium(MediumScint);
83  nmed=geobuild->createMedium(MediumFiber);
84 
85  TGeoManager* gGeoMan = (TGeoManager*)gROOT->FindObject("FAIRGeom");
86 
87  //building main container
88 
89  TGeoVolume *top = new TGeoVolumeAssembly("Emc5");
90 
91  gGeoMan->SetTopVolume(top);
92 // TSrting name = "FscTopShape";
93 //
94 // TGeoShape* TopShape = new TGeoBBox(name,xsize/2.,ysize/2.,thickness/2.);
95 // TGeoVolume *TopVolume = new TGeoVolumeAssembly("FscBox");
96 
97  //Building paper volume to place everything inside it
98  TString name = "FscModuleShape";
99  TGeoShape* ModuleShape = new TGeoBBox(name,cellxsize/2.,cellysize/2.,thickness/2.);
100  name = "FscModuleVolume";
101  TString medium = "carbon";
102  TGeoVolume* ModuleVolume = new TGeoVolume(name, ModuleShape, gGeoMan->GetMedium(medium));
103  ModuleVolume->SetLineColor(2);
104 
105  //Building tyvek volume inside paper volume
106  name = "FscTyvekShape";
107  TGeoShape* TyvekShape = new TGeoBBox(name,cellxsize/2. - paperbundle,cellysize/2. - paperbundle,thickness/2. - paperbundle);
108  name = "FscTyvekVolume";
109  medium = "tyvek";
110  TGeoVolume* TyvekVolume = new TGeoVolume(name, TyvekShape, gGeoMan->GetMedium(medium));
111  TyvekVolume->SetLineColor(3);
112  ModuleVolume->AddNode(TyvekVolume,0);
113 
114  //Building and placing holder (for Scint+Lead layer) volumes inside tyvek volume
115  name = "FscLayerHolderShape";
116  TGeoShape* LayerHolderShape = new TGeoBBox(name, cellxsize/2. - crystalspace, cellysize/2. - crystalspace, cell_thickness/2.);
117  name = "FscLayerHolderVolume";
118  medium = "Air";
119  // TGeoVolume* LayerHolderVolume = new TGeoVolume(name, LayerHolderShape, gGeoMan->GetMedium(medium));
120 
121  TGeoVolume* LayerHolderVolume = new TGeoVolumeAssembly(name);
122 
123  TGeoCombiTrans* iCombTrans = NULL;
124  TGeoRotation rot;
125 
126  //Building and placing Lead + Scint layer inside holder Volume
127  name = "FscLeadShape";
128  TGeoShape* LeadShape = new TGeoBBox(name, cellxsize/2. - crystalspace, cellysize/2. - crystalspace, Pb_thickness/2.);
129  name = "FscLeadVolume";
130  medium = "lead";
131  TGeoVolume* LeadVolume = new TGeoVolume(name, LeadShape, gGeoMan->GetMedium(medium));
132  LeadVolume->SetLineColor(4);
133  iCombTrans = new TGeoCombiTrans(0,0,-cell_thickness/2.+Pb_thickness/2., new TGeoRotation(rot));
134  LayerHolderVolume->AddNode(LeadVolume,0,iCombTrans);
135 
136  name = "FscSciShape";
137  TGeoShape* SciShape = new TGeoBBox(name, cellxsize/2. - crystalspace, cellysize/2. - crystalspace, Sci_thickness/2.);
138  name = "FscSciVolume";
139  medium = "FscScint";
140  TGeoVolume* SciVolume = new TGeoVolume(name, SciShape, gGeoMan->GetMedium(medium));
141  SciVolume->SetLineColor(5);
142  iCombTrans = new TGeoCombiTrans(0,0,cell_thickness/2.-Sci_thickness/2., new TGeoRotation(rot));
143  LayerHolderVolume->AddNode(SciVolume,0,iCombTrans);
144 
145 
147 // TGeoCombiTrans* iCombTrans = NULL;
148 // TGeoRotation rot;
149  for(int iz = 1; iz <= EMCnumlayers; iz++)
150  {
151  z = -holder_thickness/2. + 0.5 * cell_thickness *(2.*iz - 1.);
152  iCombTrans = new TGeoCombiTrans(0,0,z, new TGeoRotation(rot));
153  name = "FscLayerHolder";
154  name += iz-1;
155  TyvekVolume->AddNode(LayerHolderVolume,iz-1,iCombTrans);
156  }
157 
158  Int_t iCopy = 0;
160 
161  //Building and placing Fibers inside FscModule Volume
162  //Holes for fibers Bottom right corner is (ix = 1, iy = 1)
163  name = "FscFibHoleSHape";
164 // TGeoShape* FiberHoleShape = new TGeoTube(name, 0., fiber_hole_r, (thickness-crystalspace)/2.);
165  TGeoShape* FiberHoleShape = new TGeoTube(name, 0., fiber_hole_r, (holder_thickness)/2.);
166  name = "FscFibHoleVolume";
167  medium = "air";
168  TGeoVolume* FiberHoleVolume = new TGeoVolume(name, FiberHoleShape, gGeoMan->GetMedium(medium));
169  for(int ix = 1; ix<= numfibers; ix++)
170  {
171  for(int iy = 1; iy<= numfibers; iy++)
172  {
173  x = -Absorb_xsize/2. + (Absorb_xsize/(Double_t)numfibers)*(ix - 0.5);
174  y = -Absorb_ysize/2. + (Absorb_ysize/(Double_t)numfibers)*(iy - 0.5);
175 // iCombTrans = new TGeoCombiTrans(x,y,crystalspace, new TGeoRotation(rot));
176  iCombTrans = new TGeoCombiTrans(x,y,0, new TGeoRotation(rot));
177  name = "FscFibHoleVolume";
178  name+=iCopy;
179  iCombTrans->SetName(name);
180  iCombTrans->RegisterYourself();
181 // ModuleVolume->AddNode(FiberHoleVolume,iCopy,iCombTrans);
182 // ModuleVolume->AddNodeOverlap(FiberHoleVolume,iCopy,iCombTrans);
183  TyvekVolume->AddNodeOverlap(FiberHoleVolume,iCopy,iCombTrans);
184 // TyvekVolume->AddNode(FiberHoleVolume,iCopy,iCombTrans);
185  iCopy++;
186  }
187  }
188  //FIbers itself inside holes
189  name = "FscFiberShape";
190 // TGeoShape* FiberShape = new TGeoTube(name, 0., fiber_r, (thickness-crystalspace)/2.);
191  TGeoShape* FiberShape = new TGeoTube(name, 0., fiber_r, (holder_thickness)/2.);
192  name = "FscFiberVolume";
193  medium = "FscFiber";
194  TGeoVolume* FiberVolume = new TGeoVolume(name, FiberShape, gGeoMan->GetMedium(medium));
195  FiberVolume->SetLineColor(5);
196  iCombTrans = new TGeoCombiTrans(0,0,0, new TGeoRotation(rot));
197  FiberHoleVolume->AddNode(FiberVolume,0,iCombTrans);
198 
199 
200  iCopy =0;
201  Int_t CopyCode=0;
202  // placing Modules of Carbon inside top FSC
203  // Bottom right corner is (ix = 1, iy = 1)
204  for(int ix = 1; ix<= numcellsx; ix++)
205  {
206  for(int iy = 1; iy<= numcellsy; iy++)
207  {
208  x = 0.5 * cellxsize * (2. * ix - numcellsx - 1.);
209  y = 0.5 * cellysize * (2. * iy - numcellsy - 1.);
210  if(TMath::Abs(x-hole_xpos)<hole_xsize/2. && TMath::Abs(y-hole_ypos)<hole_ysize/2.) continue;
211  iCombTrans = new TGeoCombiTrans(x,y,0., new TGeoRotation(rot));
212  name = "FscModuleVolume";
213  name+=iCopy;
214  CopyCode = 100*ix+iy;
215 
216  iCombTrans->SetName(name);
217  iCombTrans->RegisterYourself();
218 // top->AddNode(ModuleVolume,iCopy,iCombTrans);
219  top->AddNode(ModuleVolume,CopyCode,iCombTrans);
220  iCopy++;
221 
222  }
223  }
224 
225 
226  gGeoMan->CloseGeometry();
227  top->Write();
228  fi->Close();
229 // gGeoManager->Export(outfile);//
230  top->Draw("ogl");//
231 
232 }
const Int_t numfibers
Double_t crystalspace
FairGeoLoader * geoLoad
FairGeoMedia * Media
const Int_t numcellsx
TGeoManager * gGeoMan
const Double_t tyvekbundle
const Double_t fiber_hole_r
Double_t ysize
Double_t hole_xsize
FairGeoMedium * MediumScint
TGeoVolume * FiberVolume
TGeoShape * LayerHolderShape
TGeoVolume * TyvekVolume
TGeoShape * FiberHoleShape
Double_t hole_xpos
Double_t hole_ysize
Double_t xsize
const Double_t Sci_ysize
Double_t thickness
TGeoShape * FiberShape
TGeoVolume * top
const Double_t Sci_xsize
FairGeoMedium * MediumLead
static T Abs(const T &x)
Definition: PndCAMath.h:39
TGeoVolume * LeadVolume
Double_t cellysize
const Double_t Pb_thickness
FairGeoBuilder * geobuild
TFile * fi
const Double_t paperbundle
Double_t
TString medium
const Int_t EMCnumlayers
const Double_t zpos
Int_t CopyCode
TGeoVolume * SciVolume
FairGeoMedium * MediumTyvek
Double_t z
FairGeoMedium * MediumCarbon
TGeoShape * LeadShape
TString name
Double_t holder_thickness
const Double_t Sci_thickness
FairGeoMedium * MediumAir
static T Max(const T &x, const T &y)
Definition: PndCAMath.h:36
const Double_t Air_thickness
TGeoVolume * LayerHolderVolume
TGeoShape * TyvekShape
Double_t x
const Double_t Absorb_ysize
Double_t hole_ypos
TGeoRotation rot
const Int_t numcellsy
FairGeoMedium * MediumFiber
TGeoCombiTrans * iCombTrans
FairGeoInterface * geoFace
Double_t y
TGeoShape * SciShape
const Double_t fiber_r
TString outfile
Double_t cell_thickness
const Double_t Absorb_xsize
TGeoVolume * FiberHoleVolume
Double_t cellxsize
TGeoShape * ModuleShape
TGeoVolume * ModuleVolume