FairRoot/PandaRoot
createROOTEnDrcGeo.C
Go to the documentation of this file.
1 {
2 //
3 // created 2008 D. Glazier, K. Foehl Edinburgh
4 //
5 //setup dirc parameters
6 //note somewhere .geo size parameters are converted from mm to cm
7 //Here I define the .root geometry directly in cm
8  const Int_t nsegs =128; // Number of segments
9  //const Int_t npoints = 8; // Number of points in shape
10  Double_t dist_z1 = 0.;//cm // distance from beam axis (=z)
11  Double_t dist_z2 = 1100./10;//cm // outer distance from beam.
12  Double_t thickness = 15./10;//cm //thickness of the dirc
13  Double_t angle = 2*TMath::Pi()/nsegs;
14  //double angle = 360./nsegs;
15  Double_t ztarget =1945./10; //cm distance to front face +thick/2
16  Double_t LiFThick=50./10;//cm
17 
18  gROOT->LoadMacro("$VMCWORKDIR/gconfig/basiclibs.C");
19  basiclibs();
20 
21  // Load this example libraries
22  gSystem->Load("libGeoBase");
23  gSystem->Load("libParBase");
24  gSystem->Load("libBase");
25  gSystem->Load("libPndData");
26  gSystem->Load("libPassive");
27 
28  TString outfile= "../../geometry/endrc.root";
29  TFile* fi = new TFile(outfile,"RECREATE");
30 
31  FairGeoLoader* geoLoad = new FairGeoLoader("TGeo","FairGeoLoader");
32  FairGeoInterface *geoFace = geoLoad->getGeoInterface();
33  geoFace->setMediaFile("../../../pandaroot/geometry/media_pnd.geo");
34  geoFace->readMedia();
35  geoFace->print();
36 
37  FairGeoMedia *Media = geoFace->getMedia();
38  FairGeoBuilder *geobuild=geoLoad->getGeoBuilder();
39 
40  FairGeoMedium *CbmMediumDIRCair = Media->getMedium("DIRCair");
41  FairGeoMedium *CbmMediumDIRCglass = Media->getMedium("FusedSil");
42  FairGeoMedium *CbmMediumDIRClg = Media->getMedium("carbon");
43 
44  Int_t nmed=geobuild->createMedium(CbmMediumDIRCair);
45  nmed=geobuild->createMedium(CbmMediumDIRCglass);
46  nmed=geobuild->createMedium(CbmMediumDIRClg);
47 
48  TGeoManager* gGeoMan = (TGeoManager*)gROOT->FindObject("FAIRGeom");
49 
50  //Make mother volume
51  TGeoVolume *top = gGeoMan->MakeTube("EnDrc",gGeoMan->GetMedium("DIRCair"),0,dist_z2+20. ,5.);//cm
52  gGeoMan->SetTopVolume(top);
53 
54 
55  //Make the disc
56  //first trapezoid segment shape
57  TString segName="dseg";
58  TGeoTrd1 *dsegShape=new TGeoTrd1(segName,0.,dist_z2*tan(angle/2),thickness/2,dist_z2/2);
59  //dsegShape->RegisterYourself();
60 
61  TGeoRotation *rot;
63  char rotNamech[10];
65  TGeoTranslation *trans;
66  TGeoCombiTrans* combi;
67 
68  //now loop over and create rotation matrices for segments
69  if(nsegs%4!=0) return; //can#t split into 4
70  for(Int_t i=0;i<nsegs/4;i++){
71  //others rotated by seg*angle
72  sprintf(rotNamech,"drot%d",i);
73  rotName=rotNamech;
74  rot=new TGeoRotation(rotName);
75  //rot->RegisterYourself();
76  rot->RotateY((angle*i+angle/2)*TMath::RadToDeg());
77  sprintf(rotNamech,"dtra%d",i);
78  rotName=rotNamech;
79  TVector3 temp(0,0,dist_z2/2);
80  temp.RotateY(angle*i+angle/2);
81  trans=new TGeoTranslation(rotNamech,temp.X(),temp.Y(),temp.Z());
82  combi=new TGeoCombiTrans(*trans,*rot);
83  sprintf(rotNamech,"dcom%d",i);
84  rotName=rotNamech;
85  combi->SetName(rotName);
86  combi->RegisterYourself();
87  compShape+="(";
88  compShape+=segName;
89  compShape+=":";
90  compShape+=rotName;
91  compShape+="-hole:thole)";
92  //compShape+=")";
93  if(i!=nsegs/4-1)compShape+="+";
94  }
95  //now make rectangular hole
96  TGeoBBox* holeShape=new TGeoBBox("hole",ztarget*tan(5*TMath::DegToRad()),thickness,ztarget*tan(10*TMath::DegToRad()));
97  trans=new TGeoTranslation("thole",0,0,0);
98  trans->RegisterYourself();
99  // compShape+="-(hole:thole)";
100  //now make composite shape of disc
101  // compShape="(dseg:dcom4-hole:thole)+(dseg:dcom5-hole:thole)";
102  cout<<"Composite shape "<<compShape<<endl;
103  TGeoCompositeShape* discShape=new TGeoCompositeShape("dshape",compShape);
104  TGeoVolume* disc=new TGeoVolume("disc",discShape,gGeoMan->GetMedium("FusedSil"));
105  // TGeoVolume* disc=new TGeoVolume("disc",dsegShape);
106  TGeoRotation* rotCave=new TGeoRotation("drotCave");
107  rotCave->RotateX(90);
108  rotCave->RotateZ(90);
109  //currently a problem when loading into PandaRoot
110  //After running simulation and drawing resulting detector get a crash on exit
111  //seems to be due to the combination of TGeoCompositeShape placed with a TGeoMatrix
112  //Note 6 times faster to split disc into 4, than to have just one volume
113  top->AddNode(disc,1,new TGeoCombiTrans(TGeoTranslation(0,0,0),*rotCave));
114  rotCave->ReflectX(kFALSE);
115  top->AddNode(disc,2,new TGeoCombiTrans(TGeoTranslation(0,0,0),*rotCave));
116  //rotCave->ReflectY(kFALSE);
117  rotCave->RotateZ(-180);
118  top->AddNode(disc,3,new TGeoCombiTrans(TGeoTranslation(0,0,0),*rotCave));
119  rotCave->ReflectX(kFALSE);
120  top->AddNode(disc,4,new TGeoCombiTrans(TGeoTranslation(0,0,0),*rotCave));
121  // Now add LiF elements to the perimeter of the disc
122  TGeoBBox* LiFShape=new TGeoBBox("LiFShape",dist_z2*tan(angle/2),thickness/2,LiFThick/2);
123  //Add the "light guides"
124  TGeoBBox* LGShape=new TGeoBBox("LGShape",dist_z2*tan(angle/2),thickness/2,LiFThick);
125  TGeoVolume* lif;
126  TGeoVolume* lg;
127  for(Int_t i=0;i<nsegs;i++){
128  sprintf(rotNamech,"lrot%d",i);
129  rotName=rotNamech;
130  rot=new TGeoRotation(rotName);
131  //rot->RegisterYourself();
132  rot->RotateX(90);
133  rot->RotateZ(90);
134  rot->RotateZ((angle*i+angle/2)*TMath::RadToDeg());
135  TVector3 temp(0,0,dist_z2+LiFThick/2);
136  temp.RotateY(angle*i+angle/2);
137  temp.RotateX(90*TMath::DegToRad());
138  temp.RotateZ(90*TMath::DegToRad());
139  trans=new TGeoTranslation(rotNamech,temp.X(),temp.Y(),temp.Z());
140  combi=new TGeoCombiTrans(*trans,*rot);
141  sprintf(rotNamech,"lifc%d",i);
142  rotName=rotNamech;
143  combi->SetName(rotName);
144  sprintf(rotNamech,"lif%d",i);
145  rotName=rotNamech;
146  //position LiF
147  lif=new TGeoVolume(rotName,LiFShape,gGeoMan->GetMedium("FusedSil"));
148  top->AddNode(lif,i+1,combi);
149  //position light guide
150  sprintf(rotNamech,"lg%d",i);
151  rotName=rotNamech;
152  trans=new TGeoTranslation(rotNamech,temp.X(),temp.Y(),temp.Z()-thickness);
153  combi=new TGeoCombiTrans(*trans,*rot);
154  //lg=new TGeoVolume(rotName,LGShape,gGeoMan->GetMedium("carbon"));
155  lg=new TGeoVolume(rotName,LGShape,gGeoMan->GetMedium("FusedSil"));
156  top->AddNode(lg,i+1,combi);
157 
158 
159  //combi->RegisterYourself();
160  }
161  TGeoHMatrix *global = gGeoMan->GetHMatrix();
162  gGeoMan->GetListOfMatrices()->Remove(global);
163 
164  //Position in lab
165  trans=new TGeoTranslation("EnDrcPos",0,0,ztarget);
166  trans->Write();
167 
168  gGeoMan->CloseGeometry();
169  top->Draw();
170  //top->Raytrace();
171  // top->Export("../../geometry/endrc_vonly.root","EnDrc","recreate");
172  //TFile* ft=new TFile("../../geometry/endrc_vonly.root","update");
173  //trans->Write();
174  //ft->Close();
175  top->Write();
176  fi->Close();
177 
178 }
FairGeoMedium * CbmMediumDIRCglass
Int_t nmed
FairGeoLoader * geoLoad
Int_t i
Definition: run_full.C:25
FairGeoInterface * geoFace
TString rotName
TString compShape
TString outfile
TGeoVolume * lg
Double_t thickness
FairGeoMedia * Media
TGeoTranslation * trans
char rotNamech[10]
Double_t dist_z1
TGeoManager * gGeoMan
Double_t
FairGeoMedium * CbmMediumDIRCair
TGeoBBox * LiFShape
TGeoTrd1 * dsegShape
TGeoCombiTrans * combi
TFile * fi
TGeoBBox * holeShape
TGeoVolume * top
TGeoHMatrix * global
FairGeoMedium * CbmMediumDIRClg
FairGeoBuilder * geobuild
TString segName
TGeoRotation * rot
TGeoVolume * lif
Double_t dist_z2
basiclibs()
Double_t LiFThick
Double_t angle
Double_t Pi
Double_t ztarget
TGeoBBox * LGShape