GEAR  1.9.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Friends Pages
testFTD.cc
1 // _*_ C++ _*_
2 //
3 // testFTD.cc : testing the FTD geometry extracted
4 // from GEAR
5 //
6 // Compilation:
7 // g++ `root-config --cflags` -L`root-config --libdir`
8 // `root-config --libs` -lGeom
9 // -I/usr/local/ilcsoft/v01-08/gear/v00-13/src/cpp/include
10 // -L/usr/local/ilcsoft/v01-08/gear/v00-13/lib
11 // -lgear -lgearxml -o testFTD testFTD.cc
12 //
13 // @author: J. Duarte Campderros, IFCA
14 // 27, July 2011
15 
16 // FIXME: TO BE REVISITED!
17 
18 #include "TGeoManager.h"
19 #include "TGeoMatrix.h"
20 
21 #include "gearxml/GearXML.h"
22 #include "gearimpl/GearMgrImpl.h"
23 #include "gearimpl/FTDParametersImpl.h"
24 
25 #include<iostream>
26 #include<cmath>
27 
28 using namespace gear;
29 
30 int main(int argc, char *argv[])
31 {
32  if(argc != 2)
33  {
34  std::cout << "usage: " << argv[0] << " gearfile.xml" << std::endl;
35  return 1;
36  }
37 
38  // Extracting FTD geometry
39  GearXML *xmlmgr = new GearXML(argv[1]);
40  GearMgr *mgr = xmlmgr->createGearMgr();
41 
42  FTDParameters const & ftdParams = mgr->getFTDParameters();
43 
44 
45 
46  // Geometry construction ROOT
47  TGeoManager * ftdgeom = new TGeoManager("FTD","The FTD sub-detector geometry from GEAR");
48 
49  // As we only need visualization, use only air (vacuum)
50  // and Si
51  TGeoMaterial * vacuum = new TGeoMaterial("vacuum",0.0,0.0,0.0);
52  TGeoMaterial * vacuumTrans = new TGeoMaterial("vacuum_trans",0.0,0.0,0.0);
53  vacuumTrans->SetTransparency(50);
54  //TGeoMaterial *si = new TGeoMaterial("si",28.09,14,2.33);
55 
56  TGeoMedium * Air = new TGeoMedium("Vacuum",0,vacuum);
57  TGeoMedium * AirTrans = new TGeoMedium("Vacuum_Trans",0,vacuumTrans);
58  //TGeoMedium * Si = new TGeoMedium("Silicon",1,si);
59 
60  // Create volumes
61  TGeoVolume *top = ftdgeom->MakeBox("top",Air,12000,12000,12000);
62  ftdgeom->SetTopVolume(top);
63  ftdgeom->SetTopVisible(0);
64 
65  // Specular Matrix
66  TGeoRotation speRot;
67  speRot.SetAngles(90,180,0);
68 
69  // Disks
70  const FTDLayerLayout & ftdLayer = ftdParams.getFTDLayerLayout();
71 
72  //const int nLayers = ftdLayer.getNLayers();
73 
74 
75  double ZstartOuterShell = -1;
76  double ZendOuterShell = -1;
77  TGeoRotation petalRot;
78  for(int i = 0; i < ftdLayer.getNLayers(); i++)
79  {
80  const double zposition = ftdLayer.getZposition(i);
81  const double diskRinn = ftdLayer.getSupportRinner(i);
82  const double diskRout = diskRinn+ftdLayer.getSupportWidth(i);
83  const double halfthickness = (2.0*ftdLayer.getZoffset(i)+ftdLayer.getSupportThickness(i)+
84  ftdLayer.getSensitiveThickness(i))/2.0;
85  TGeoVolume * disk = ftdgeom->MakeTube("Air disk",AirTrans,
86  diskRinn,
87  diskRout,
88  halfthickness);
89  disk->SetLineColor(kBlue-5);
90  disk->SetFillColor(kBlue-5);
91  disk->SetAttVisibility(0);
92 
93  top->AddNode(disk,i+1,new TGeoTranslation(0,0,zposition-halfthickness) );
94  TGeoHMatrix hm = speRot*TGeoTranslation(0,0,zposition-halfthickness);
95  top->AddNode(disk,-(i+1),new TGeoHMatrix(hm) );
96  if( i == 3 )
97  {
98  ZstartOuterShell = zposition-halfthickness;
99  }
100  else if( i == 6)
101  {
102  ZendOuterShell = zposition+halfthickness;
103  }
104  //Petals Support as placeholders of the sensitives
105  const double total_halfthickness = (ftdLayer.getSupportThickness(i)+
106  ftdLayer.getSensitiveThickness(i))/2.0;
107  const double dy_half = ftdLayer.getSupportWidth(i)/2.0;
108  const double dxMin_half = ftdLayer.getSupportLengthMin(i)/2.0;
109  const double dxMax_half = ftdLayer.getSupportLengthMax(i)/2.0;
110  TGeoVolume * petal = ftdgeom->MakeTrap("Petal Support",AirTrans,
111  total_halfthickness,
112  0.0,
113  0.0,
114  dy_half,
115  dxMin_half,
116  dxMax_half,
117  0.0,
118  dy_half,
119  dxMin_half,
120  dxMax_half,
121  0.0);
122  petal->SetLineColor(kGray-3);
123  petal->SetFillColor(kGray-3);
124  petal->SetVisibility(0);
125  // Silicon
126  const double halfthicknessSi = ftdLayer.getSensitiveThickness(i)/2.0;
127  const double dy_halfSi = ftdLayer.getSensitiveWidth(i)/2.0;
128  const double dxMin_halfSi = ftdLayer.getSensitiveLengthMin(i)/2.0;
129  const double dxMax_halfSi = ftdLayer.getSensitiveLengthMax(i)/2.0;
130  TGeoVolume * sensor = ftdgeom->MakeTrap("Petal Support",AirTrans,
131  halfthicknessSi,
132  0.0,
133  0.0,
134  dy_halfSi,
135  dxMin_halfSi,
136  dxMax_halfSi,
137  0.0,
138  dy_halfSi,
139  dxMin_halfSi,
140  dxMax_halfSi,
141  0.0);
142  sensor->SetLineColor(kOrange-5);
143  sensor->SetFillColor(kOrange-5);
144 
145  petal->AddNode(sensor,1,new TGeoTranslation(0,0,ftdLayer.getZoffset(i)-ftdLayer.getSupportThickness(i)
146  -halfthicknessSi));
147  if( i > 2 )
148  {
149  petal->AddNode(sensor,2,new TGeoTranslation(0,0,ftdLayer.getZoffset(i)+ftdLayer.getSupportThickness(i)
150  +halfthicknessSi));
151  }
152 
153 
154  double phi = ftdLayer.getPhiHalfDistance(i)*180.0/M_PI;
155  for(int j=0; j < ftdLayer.getNPetals(i); j++)
156  {
157  // FIXME: Missing the turbine-blade rotation
158  int zsign = pow(-1,j);
159  petalRot.SetAngles(2.0*phi*j,0.0,0.0);
160 
161  TGeoHMatrix hmpetal = petalRot*TGeoTranslation(0.0,diskRinn+dy_half,
162  zsign*ftdLayer.getZoffset(i));
163  disk->AddNode(petal,j+1,new TGeoHMatrix(hmpetal));
164  }
165  }
166 
167  // Outer Shield: Basado en los discos, superficie de ayuda para
168  // metodos de GEAR
169  //const double outerR = ftdParams.getShellOuterRadius();
170  //const double half_z = ftdParams.getShellHalfLength();
171  const double outerR = ftdLayer.getSupportRinner(ftdLayer.getNLayers()-1)
172  +ftdLayer.getSupportWidth(ftdLayer.getNLayers()-1);
173  const double half_z= (ZendOuterShell-ZstartOuterShell)/2.0;
174 
175  TGeoVolume *outerShield = ftdgeom->MakeTube("outer_shell",AirTrans,
176  outerR,
177  outerR+1.0,
178  half_z
179  );
180  outerShield->SetLineColor(kBlue-3);
181  outerShield->SetFillColor(kBlue-3);
182  outerShield->SetAttVisibility(0);
183 
184  top->AddNodeOverlap(outerShield,1, new TGeoTranslation(0,0,ZstartOuterShell+half_z) );
185  TGeoHMatrix hmO = speRot*TGeoTranslation(0,0,ZstartOuterShell+half_z);
186  top->AddNodeOverlap(outerShield,2, new TGeoHMatrix(hmO) );
187 
188  // Inner SHield
189  const double innerRMin = ftdLayer.getSupportRinner(0);
190  const double innerRMax = ftdLayer.getSupportRinner(ftdLayer.getNLayers()-1);
191  const double ZstartInnerShell = ftdLayer.getZposition(0)-(ftdLayer.getSupportThickness(0)+
192  ftdLayer.getSensitiveThickness(0))/2.0;
193  const double half_zInner= (ZendOuterShell-ZstartInnerShell)/2.0;
194 
195  TGeoVolume *innerShield = ftdgeom->MakeCone("inner_shell",AirTrans,
196  half_zInner,
197  innerRMin-1.0,
198  innerRMin,
199  innerRMax-1.0,
200  innerRMax
201  );
202  innerShield->SetLineColor(kBlue-3);
203  innerShield->SetFillColor(kBlue-3);
204  innerShield->SetAttVisibility(0);
205 
206  top->AddNodeOverlap(innerShield,1, new TGeoTranslation(0,0,ZstartInnerShell+half_zInner) );
207  TGeoHMatrix hmI = speRot*TGeoTranslation(0,0,ZstartInnerShell+half_zInner);
208  top->AddNodeOverlap(innerShield,2, new TGeoHMatrix(hmI) );
209 
210  //close geometry
211  ftdgeom->CloseGeometry();
212  ftdgeom->Export("testFTD.root");
213 
214  //delete f;
215  delete ftdgeom;
216 
217  delete xmlmgr;
218 }
219 
virtual double getSupportLengthMax(int layerIndex) const =0
The length (x-direction) of the largest edge of the trapezoid support in layer layerIndex - layer ind...
virtual const FTDParameters & getFTDParameters() const =0
Get the FTD parameters.
virtual double getSensitiveThickness(int layerIndex) const =0
The thickness in mm of the sensitive area in petals in layer layerIndex.
GearMgr * createGearMgr()
Creates an instance of GearMgr from the data given in the XML file.
Definition: GearXML.cc:473
virtual double getSupportRinner(int layerIndex) const =0
The R-min of the support petals in the XY-plane in mm, for the layer layerIndex - layer indexing star...
virtual double getSupportLengthMin(int layerIndex) const =0
The length (x-direction) of the smallest edge of the trapezoid support in layer layerIndex - layer in...
Implementation of GEAR using XML.
Definition: GearXML.h:18
virtual double getZposition(const int &layerIndex) const =0
The z-position of the centroid of the disk structure.
virtual double getSupportThickness(int layerIndex) const =0
The thickness in mm of the supports in layerIndex - layer indexing starting at 0 for the layer closes...
virtual double getPhiHalfDistance(int layerIndex) const =0
Angular half-width of the petals of a layer - half of the opening angle of the trapezoid.
virtual int getNPetals(int layerIndex) const =0
The number of petals in the layer layerIndex - layer indexing starts at 0 for the layer closest to IP...
Abstract description of layers in a FTD detector.
virtual double getZoffset(const int &layerIndex) const =0
Z-offset of the petals in a staggered setup - the z position of the even numbered petals is getZposit...
virtual const FTDLayerLayout & getFTDLayerLayout() const =0
The layer layout in the Vertex.
virtual double getSensitiveLengthMax(int layerIndex) const =0
Same as getPetalLengthMax() except for the sensitive part of the petal.
virtual double getSensitiveLengthMin(int layerIndex) const =0
Same as getPetalLengthMin() except for the sensitive part of the petal.
Geometry properties of a FTD detector needed for reconstruction code.
Definition: FTDParameters.h:29
virtual double getSupportWidth(int layerIndex) const =0
The width of the support in layer in mm for petals in layer layerIndex - layer indexing starting at 0...
virtual int getNLayers() const =0
The total number of layers.
Abstract interface for a manager class that returns the Gear classes for the relevant subdetectors...
Definition: GearMgr.h:36
virtual double getSensitiveWidth(int layerIndex) const =0
The width of the sensitive area in petals in layer layerIndex in mm.