FairRoot/PandaRoot
create_ftof_stof_rootgeo.C
Go to the documentation of this file.
1 Bool_t create_stof(TGeoManager *gGeoMan, TGeoVolume *top,TGeoVolume *unitVol){
2  // all position parameters in cm
3  // side tof plate geometry parameters
4  //-----------------------------
5  //-- geo created by M. J. Galuska based on 3d pdf drawing of the PANDA detector (Panda_v912.pdf)
6  //--
7 
8  // PANDA Coordinate System
9  // y x
10  // ^ /
11  // |/
12  // |----> z
13 
14  // Detector sketch
15 
16 
17  // ____
18  // /|
19  // / | y
20  // / | ^
21  // ___/ | |
22  // | | |
23  // dy1 | | dy2 |
24  // | | ----------------> z
25  // | | |
26  // ___|-dz-| |
27  // \ | |
28  // \ | |
29  // \ |
30  // \|___
31 
32 
33  // Positions in cm (PANDA coordinate system)
34  const Double_t zDistStof = 500;
35  const Double_t xInnerDistStof = 279.6;
36  const Double_t yMiddleStof = 0.;
37 
38  // Dimensions
39  const Double_t kdX = 2.0; // half length (cm) = dx/2. //from 3d pdf
40  const Double_t kdY1 = 45.0; // half length (cm) = dy1/2. closer to int. point //from 3d pdf
41  const Double_t kdY2 = 53.0; //half length (cm) = dy2/2. further from int. point //from 3d pdf
42  const Double_t kdZ = 48.0; //half length (cm) = dz/2. //from 3d pdf
43 
44  TGeoVolumeAssembly* subunitVol = new TGeoVolumeAssembly("Stof_plates");
45 
46 
47  char nameShape[13];
48  char nameVol[13];
49 
50  TGeoTrd1 *detShape[2];
51  TGeoVolume* detVol[2];
52 
53 
54 
55  for(int i=0;i<2;i++){
56 
57 
58 
59  sprintf (nameShape,"PlateShape%d",i);
60  sprintf (nameVol,"Stof_plate%d",i);
61 
62  detShape[i] = new TGeoTrd1(nameShape, kdY1, kdY2, kdX, kdZ); // for stof plate y has to vary with z
63  detVol[i] = new TGeoVolume(nameVol,detShape[i],gGeoMan->GetMedium("polyvinyltoluene"));
64 
65  Int_t sign = pow(-1,i); // plus/minus 1
66  TGeoRotation rot;
67  rot.RotateZ(90.);
68  Double_t xPos = xInnerDistStof/2.+kdX;
69  TGeoCombiTrans* transMat= new TGeoCombiTrans(sign*xPos,0.,0.,new TGeoRotation (rot));
70 
71  transMat->SetName(nameShape);
72  transMat->RegisterYourself();
73  subunitVol->AddNode(detVol[i],i,transMat);
74  }
75 
76 
77 
78  unitVol->AddNode(subunitVol,0,new TGeoCombiTrans(0.,yMiddleStof,zDistStof+kdZ,new TGeoRotation ()));
79  top->AddNode(unitVol,0,new TGeoCombiTrans(0.,0.,0.,new TGeoRotation ()));
80  return kTRUE;
81 }
82 
83 
84 
85 
86 
87 
88 Bool_t create_ftofwall(Double_t zDistFtofWall, TGeoManager *gGeoMan, TGeoVolume *top, TGeoVolume *unitVol)
89 {
90  // Forward tof wall geometry parameters
91  //-----------------------------
92  //-- macro created by Alicia S. based on
93  //-- Panda TPR and on previous geant3 geometry for forward tof (Vladimir V.)
94  const Double_t kBCentX = 2.5; // half length (cm) //from EMC TDR
95  const Double_t kBCentY = 70.0; // half length (cm) //?
96  const Double_t kBCentZ = 0.75; // half length (cm) //?
97 
98  const Double_t kBBeamX = 2.5; // half length (cm) //from EMC TDR
99  const Double_t kBBeamY = 32.5; // half length (cm) //?
100  const Double_t kBBeamZ = 0.75; // half length (cm) //?
101 
102  const Double_t kBVertX = 5.0; // half length (cm) //from EMC TDR
103  const Double_t kBVertY = 70.0; // half length (cm) //?
104  const Double_t kBVertZ = 0.75; // half length (cm) //from EMC TDR
105 
106  TGeoBBox *CentShape[22];
107  TGeoBBox *BeamShape[22];
108  TGeoBBox *VertShape[46];
109 
110  TGeoVolume* CentVol[22];
111  TGeoVolume* BeamVol[22];
112  TGeoVolume* VertVol[46];
113 
114 
115  Double_t bx[22],by[22],bz[22];
116  Double_t bvx[46],bvy[46],bvz[46];
117  TGeoVolumeAssembly* SubunitVol = new TGeoVolumeAssembly("Ftof_strips");
118 
119 
120  char name[13];
121  char namB[13];
122  char namV[13];
123  char name1[13];
124  char namB1[13];
125  char namV1[20];
126  char name2[13];
127  char namB2[13];
128  char namV2[13];
129 
130 
131  for(int i=0;i<22;i++){
132  bx[i]=-40+kBCentX*((2*i)+1);
133  }
134 
135 
137  for(int i=0;i<22;i++){
138  if(i<9||i>12){
139 
140  sprintf (name,"Centshape%d",i);
141  sprintf (name1,"Ftof_Central_Strip%d",i);
142 
143  CentShape[i] = new TGeoBBox(name,kBCentX,kBCentY,kBCentZ);
144  CentVol[i] = new TGeoVolume(name1,CentShape[i],gGeoMan->GetMedium("polyvinyltoluene"));
145  TGeoCombiTrans* trc1=0;
146  if(i<9) trc1= new TGeoCombiTrans(bx[i],0,0.,new TGeoRotation ());
147  else if (i>12) trc1= new TGeoCombiTrans(bx[i-2],0,0.,new TGeoRotation ());
148 
149  trc1->SetName(name);
150  trc1->RegisterYourself();
151  SubunitVol->AddNode(CentVol[i],i,trc1);
152  }
153  else{
154 
155  sprintf (namB,"Beamshape%d",i);
156  sprintf (namB1,"Ftof_Beam_Strip%02d",i);
157  BeamShape[i] = new TGeoBBox(namB,kBBeamX,kBBeamY,kBBeamZ);
158  BeamVol[i] = new TGeoVolume(namB1,BeamShape[i],gGeoMan->GetMedium("polyvinyltoluene"));
159 
160  if(i==9||i==10){
161 
162 
163  (i==9 ? (offset = -70+kBBeamY) : (offset = 70-kBBeamY));
164  TGeoCombiTrans* trc1= new TGeoCombiTrans(bx[9],offset,0.,new TGeoRotation ());
165 
166  trc1->SetName(namB);
167  trc1->RegisterYourself();
168  SubunitVol->AddNode(BeamVol[i],i,trc1);
169 
170  }
171  if(i==11||i==12){
172 
173  (i==11 ? (offset = -70+kBBeamY) : (offset = 70-kBBeamY));
174 
175  TGeoCombiTrans* trc1= new TGeoCombiTrans(bx[10],offset,0.,new TGeoRotation ());
176 
177  trc1->SetName(namB);
178  trc1->RegisterYourself();
179  SubunitVol->AddNode(BeamVol[i],i,trc1);
180 
181  }
182  }
183 
184  }
185 
186  for(int i=0;i<24;i++){
187  bvx[i]=-280+kBVertX*((2*i)+1);
188  }
189 
190  for(int i=0;i<22;i++){
191 
192  bvx[i+24]=60+kBVertX*((2*i)+1);
193  }
194 
195  for(int i=0;i<46;i++){
196 
197 
198  sprintf (namV,"VertShape%d",i);
199  sprintf (namV1,"Ftof_Vertical_Strip%d",i);
200 
201  VertShape[i] = new TGeoBBox(namV,kBVertX,kBVertY,kBVertZ);
202  VertVol[i] = new TGeoVolume(namV1,VertShape[i],gGeoMan->GetMedium("polyvinyltoluene"));
203  TGeoCombiTrans* trc1= new TGeoCombiTrans(bvx[i],0,0.,new TGeoRotation ());
204 
205  trc1->SetName(namV);
206  trc1->RegisterYourself();
207  SubunitVol->AddNode(VertVol[i],i,trc1);
208  }
209 
210  unitVol->AddNode(SubunitVol,0,new TGeoCombiTrans(0.,0.,zDistFtofWall,new TGeoRotation ()));
211  top->AddNode(unitVol,0,new TGeoCombiTrans(0.,0.,0.,new TGeoRotation ()));
212  return kTRUE;
213 }
214 
215 
216 
217 
218 
219 
220 
221 int create_ftof_stof_rootgeo(Double_t zDistFtofWall = 775){
222 
223 
224  //--------------------------------------------------------------------
225  gROOT->Macro("$VMCWORKDIR/gconfig/rootlogon.C");
226 
227  // Load this libraries
228  gSystem->Load("libGeoBase");
229  gSystem->Load("libParBase");
230  gSystem->Load("libBase");
231  gSystem->Load("libPndData");
232  gSystem->Load("libPassive");
233 
234  TString outfile= "../../geometry/ftofwall+stof.root";
235  TFile* fi = new TFile(outfile,"RECREATE");
236 
237  FairGeoLoader* geoLoad = new FairGeoLoader("TGeo","FairGeoLoader");
238  FairGeoInterface *geoFace = geoLoad->getGeoInterface();
239  geoFace->setMediaFile("../../geometry/media_pnd.geo");
240  geoFace->readMedia();
241  geoFace->print();
242 
243  FairGeoMedia *Media = geoFace->getMedia();
244  FairGeoBuilder *geobuild=geoLoad->getGeoBuilder();
245 
246  FairGeoMedium *MediumSci = Media->getMedium("polyvinyltoluene");
247 
248 
249  Int_t nmed=geobuild->createMedium(MediumSci);
250 
251 
252  TGeoManager* gGeoMan = (TGeoManager*)gROOT->FindObject("FAIRGeom");
253 
254  TGeoVolume *top = new TGeoVolumeAssembly("Ftof");
255 
256  gGeoMan->SetTopVolume(top);
257 
258 
259  TGeoVolume *merge_fstof = new TGeoVolumeAssembly("FStof");
260  //merging the two assemblies volumes ftof and stof as unit
261 
262  create_ftofwall(zDistFtofWall, gGeoMan, top,merge_fstof);
263  std::cout << "\nftof wall was created.\n";
264 
265  create_stof(gGeoMan, top,merge_fstof);
266  std::cout << "stof side plates were created in dipole region.\n\n";
267 
268 
269 
270  gGeoMan->CloseGeometry();
271  top->Write();
272  fi->Close();
273  // gGeoManager->Export(outfile);
274  top->Draw("ogl");
275  return 0;
276 }
Bool_t create_ftofwall(Double_t zDistFtofWall, TGeoManager *gGeoMan, TGeoVolume *top, TGeoVolume *unitVol)
FairGeoLoader * geoLoad
Int_t i
Definition: run_full.C:25
FairGeoMedia * Media
TGeoManager * gGeoMan
TVector3 offset(2, 0, 0)
TGeoVolume * top
TGeoVolume * SubunitVol
Bool_t create_stof(TGeoManager *gGeoMan, TGeoVolume *top, TGeoVolume *unitVol)
FairGeoBuilder * geobuild
TFile * fi
Double_t
int create_ftof_stof_rootgeo(Double_t zDistFtofWall=775)
TString name
TGeoCombiTrans * trc1
TGeoRotation rot
int sign(T val)
Definition: PndCADef.h:48
FairGeoInterface * geoFace
TString outfile