StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StiSvtDetectorBuilder.cxx
1 #include <stdexcept>
2 #include "StDbUtilities/StGlobalCoordinate.hh"
3 #include "StDbUtilities/StSvtLocalCoordinate.hh"
4 #include "StDbUtilities/StSvtCoordinateTransform.hh"
5 #include "StiSvtDetectorBuilder.h"
6 #include "StSvtClassLibrary/StSvtConfig.hh"
7 #include "StSvtClassLibrary/StSvtGeometry.hh"
8 #include "StSvtClassLibrary/StSvtWaferGeometry.hh"
9 #include "StSvtDbMaker/StSvtDbMaker.h"
10 #include "StDbUtilities/St_svtRDOstrippedC.h"
11 #include "Sti/Base/Factory.h"
12 #include "Sti/StiPlanarShape.h"
13 #include "Sti/StiMaterial.h"
14 #include "Sti/StiPlacement.h"
15 #include "Sti/StiDetector.h"
16 #include "Sti/StiToolkit.h"
18 #include "StiIsSvtActiveFunctor.h"
19 //#include "Sti/StiElossCalculator.h"
20 #include "StDetectorDbMaker/StiSvtHitErrorCalculator.h"
21 #include <stdio.h>
22 #include "tables/St_HitError_Table.h"
23 #include "StThreeVectorD.hh"
24 #include "StiSvtHitLoader.h"
25 /*
26  Geant names: SVTT the mother of all SVT volumes
27  SFMO: is the mother of all Silicon Strip Detector volumes
28  SOUM: Outer shielding structure
29  SXR[L,1,2]: Circular water feeds
30  SCBM: Mother of All Cables
31  SALM: aluminum shield mesh
32  SOSH: SVT outer shield "
33  SISH: SVT inner shield "
34  SLY[D,1,2,3,4,5]: layer mother
35  SLS[D,1,2,3,4,5]: ladder mother
36  SELE: electronics mother volume
37  SLDI: a ladder volume
38  SPCB: the G10 PCB
39  SRHC: roha cell wafer supports
40  STAB: the Berrillium tabs and the ends of the wafer carriers
41  SBER: the Berillium wafer carrier rails
42  STLI: the wafer pack container
43  STSI: a single waver container
44  SVTD: an active wafer volume
45  SSIR: a non-sensitive up-down border of the wafer
46  SSID: a non-sensitive left-right border of the wafer
47  STRA: a trapezoid of triangular shape
48  Total epoxy: ~10 pounds = 4.57 kG ==> 4.57 / 216 = 21.16 g/wafer *7 => 148.1 g/big ladder
49  SROD: Support rod
50  SBSP: Beampipe support mother
51  SCON: Support cone mother
52  SBWC: water manifold to support cone bracket mother
53  SWMM: water manifold mother
54  SIES: Volume to hold inner endring screws
55  SOES: Volume to hold outer endring screws
56  SBRG: Bracket joining the end rungs
57  SOER: outer end ring
58  SIRT: inner end ring tube piece
59  SIRP: inner end ring polygon piece
60 
61  SVT Layer and Ladder Naming Convention
62  Hardware StiSvtBuilder
63  ----------------------------------
64  Layer Ladder Layer Ladder
65  1 2 0 0
66  1 4 0 1
67  1 6 0 2
68  1 8 0 3
69  2 1 1 0
70  2 3 1 1
71  2 5 1 2
72  2 7 1 3
73 
74  3 2 2 0
75  3 4 2 1
76  3 6 2 2
77  3 8 2 3
78  3 10 2 4
79  3 12 2 5
80  4 1 3 0
81  4 3 3 1
82  4 5 3 2
83  4 7 3 3
84  4 9 3 4
85  4 11 3 5
86 
87  5 2 4 0
88  5 4 4 1
89  5 6 4 2
90  5 8 4 3
91  5 10 4 4
92  5 12 4 5
93  5 14 4 6
94  5 16 4 7
95  6 1 5 0
96  6 3 5 1
97  6 5 5 2
98  6 7 5 3
99  6 9 5 4
100  6 11 5 5
101  6 13 5 6
102  6 15 5 7
103  */
104 //static Int_t _debug = 0;
105 StiSvtDetectorBuilder::StiSvtDetectorBuilder(bool active)
106  : StiDetectorBuilder("Svt",active), _siMat(0), _hybridMat(0){}
107 
108 StiSvtDetectorBuilder::~StiSvtDetectorBuilder() {}
109 
110 void StiSvtDetectorBuilder::buildDetectors(StMaker & source)
111 {
112  char name[50];
113  int nRows;
114  cout << "StiSvtDetectorBuilder::buildDetectors() -I- Started" << endl;
115 
116  St_DataSet *dataSet = NULL;
117  dataSet = source.GetDataSet("StSvtConfig");
118  if (!dataSet) throw runtime_error("StiSvtDetectorBuilder::loadDb() -E- dataSet==0 while getting StSvtConfig");
119  _config = static_cast<StSvtConfig*>(dataSet->GetObject());
120  if (!_config) throw runtime_error("StiSvtDetectorBuilder::loadDb() -E- _config==0");
121 
122  dataSet = source.GetDataSet("StSvtGeometry");
123  if (!dataSet) throw runtime_error("StiSvtDetectorBuilder::loadDb() -E- dataSet==0 while getting StSvtGeometry");
124  _geometry = static_cast<StSvtGeometry*>(dataSet->GetObject());
125  if (!_geometry) throw runtime_error("StiSvtDetectorBuilder::loadDb() -E- _geometry==0");
126  nRows = 2* _config->getNumberOfBarrels();
127  setNRows(nRows);
128 
129  cout << "SVT Number of Rows : "<<2* _config->getNumberOfBarrels()<<endl
130  << " Layer# numberOfLadders Radius" << endl;
131  cout << "StiSvtDetectorBuilder::buildDetectors() -I- Define Svt Materials" << endl;
132  if (! _gasMat)
133  _gasMat = add(new StiMaterial("Air",7.3, 14.61, 0.001205, 30420.*0.001205, 7.3*12.e-9));
134  if (! _siMat)
135  _siMat = add(new StiMaterial("Si", 14., 28.0855, 2.33, 21.82, 14.*12.*1e-9) );
136  if (! _hybridMat)
137  _hybridMat = add(new StiMaterial("Hybrid", 14., 28.0855, 2.33, 21.82, 14.*12.*1e-9) );
138  cout << "StiSvtDetectorBuilder::buildDetectors() -I- Define Svt Shapes" << endl;
139 
140 // double ionization = _siMat->getIonization();
141 // StiElossCalculator * siElossCalculator =
142 // new StiElossCalculator(_siMat->getZOverA(), ionization*ionization, _siMat->getA(), _siMat->getZ(), _siMat->getDensity());
143  for (int layer=0;layer<nRows;layer++) {
144  cout << " "<<layer<<" "<<_config->getNumberOfLadders(1+layer/2)/2 << " "
145  << _geometry->getBarrelRadius(layer+1) << endl;
146  Int_t svtLayer = layer+1;
147  Int_t svtBarrel = StiSvtHitLoader::getSvtBarrel(svtLayer);
148  int nWafers = _config->getNumberOfWafers(svtBarrel);
149  // Si wafer
150  sprintf(name, "Svt/Layer_%d/Wafers", layer);
151  _waferShape[layer] = new StiPlanarShape(name,
152  nWafers*3.15, //_geometry->getWaferLength(),
153  2.*_geometry->getWaferThickness(),
154  3.15); //_geometry->getWaferWidth() );
155  add(_waferShape[layer]);
156  int nSectors = _config->getNumberOfLadders(svtBarrel)/2;
157  setNSectors(layer,nSectors);
158  // calculate generic params for this layer
159  // number of ladders per layer (not barrel) & phi increment between ladders
160  // float fDeltaPhi = M_PI/nSectors;
161  // width of gap between the edges of 2 adjacent ladders:
162  // first, the angle subtended by 1/2 of the ladder
163  float fLadderRadius = _geometry->getBarrelRadius(svtLayer);
164  if (fLadderRadius<=0) throw runtime_error("StiSvtDetectorBuilder::buildDetectors() - FATAL - fLadderRadius<=0");
165  StSvtWaferGeometry* waferGeom;
166  Int_t index1, index2;
167  StSvtWaferGeometry* waferGeom2;
168  for(unsigned int ladder = 0; ladder<getNSectors(layer); ladder++) {
169  Int_t svtLadder = 2*(ladder+1) - (svtLayer-1)%2;
170  Int_t wafer = nWafers/2+1;
171  index1 = _geometry->getWaferIndex(svtBarrel,svtLadder,wafer);
172  assert (index1 >= 0);
173  waferGeom = (StSvtWaferGeometry*) _geometry->at(index1);
174  if (_debug) waferGeom->print();
175  StThreeVectorD centerVector(waferGeom->x(0), waferGeom->x(1), waferGeom->x(2) );
176  if ( nWafers%2 == 0) {
177  index2 = _geometry->getWaferIndex(svtBarrel,svtLadder,wafer-1);
178  assert(index2 >= 0);
179  waferGeom2 = (StSvtWaferGeometry*) _geometry->at(index2);
180  StThreeVectorD centerVector2(waferGeom2->x(0), waferGeom2->x(1), waferGeom2->x(2) );
181  if (_debug) waferGeom2->print();
182  centerVector += centerVector2;
183  centerVector *= 0.5;
184  }
185  StThreeVectorD normalVector(waferGeom->n(0), waferGeom->n(1), waferGeom->n(2) );
186  Double_t prod = centerVector.x()*normalVector.x() + centerVector.y()*normalVector.y();
187  if (prod < 0) normalVector *= -1;
188  double phi = centerVector.phi();
189  double phiD = normalVector.phi();
190  double r = centerVector.perp();
191  cout <<"Det Id = "<<waferGeom->getID()<<"\tcv\t:"<<centerVector<<"\tphi:\t"<<phi<<"\tr:\t"<<r<<"\tz:\t" << centerVector.z() << endl;
192  StiPlacement *pPlacement = new StiPlacement;
193  pPlacement->setZcenter(centerVector.z());
194  pPlacement->setLayerRadius(r); //this is only used for ordering in detector container...
195  pPlacement->setLayerAngle(phi); //this is only used for ordering in detector container...
196  pPlacement->setRegion(StiPlacement::kMidRapidity);
197  pPlacement->setNormalRep(phiD, r*TMath::Cos(phi-phiD), r*TMath::Sin(phi-phiD));
198  sprintf(name, "Svt/Layer_%d/Ladder_%d/Wafers", layer, ladder);
199  StiDetector *pLadder = _detectorFactory->getInstance();
200  pLadder->setName(name);
201  pLadder->setIsOn(true);
202  pLadder->setIsActive(new StiIsSvtActiveFunctor(svtBarrel,svtLadder, nWafers, _geometry->getWaferWidth(), _geometry->getWaferLength(), _active));
203  pLadder->setIsContinuousMedium(true);
204  pLadder->setIsDiscreteScatterer(true);
205  pLadder->setGas(_gasMat);
206  pLadder->setMaterial(_siMat);
207  pLadder->setShape(_waferShape[layer]);
208  pLadder->setPlacement(pPlacement);
209  pLadder->setHitErrorCalculator(StiSvtHitErrorCalculator::instance());
210  pLadder->setKey(1,layer);
211  pLadder->setKey(2,ladder);
212 // pLadder->setElossCalculator(siElossCalculator);
213  add(layer,ladder,pLadder);
214  } // for ladder
215  } // for layer
216  if (StiVMCToolKit::GetVMC()) {useVMCGeometry();}
217  if (debug()) {
218  cout << "StiSvtDetectorBuilder::buildDetectors list of built detectors" << endl;
219  Int_t nlayers = _detectors.size();
220  for (Int_t layer = 0; layer < nlayers; layer++) {
221  Int_t nLadders = _detectors[layer].size();
222  for (Int_t ladder = 0; ladder < nLadders; ladder++) {
223  cout << "layer " << layer << "\tladder = " << ladder << "\t" << _detectors[layer][ladder]->getName() << endl;
224  }
225  }
226  }
227 }
228 //________________________________________________________________________________
229 void StiSvtDetectorBuilder::useVMCGeometry() {
230  cout << "StiSvtDetectorBuilder::buildDetectors() -I- Use VMC geometry" << endl;
231  SetCurrentDetectorBuilder(this);
232  struct Material_t {
233  const Char_t *name;
234  StiMaterial **p;
235  };
236  Material_t map[] = {
237  {"AIR", &_gasMat},
238  {"SILICON", &_siMat},
239  {"SILICON", &_hybridMat}
240  };
241  Int_t M = sizeof(map)/sizeof(Material_t);
242  for (Int_t i = 0; i < M; i++) {
243  const TGeoMaterial *mat = gGeoManager->GetMaterial(map[i].name);
244  if (! mat) continue;
245  Double_t PotI = StiVMCToolKit::GetPotI(mat);
246  *map[i].p = add(new StiMaterial(mat->GetName(),
247  mat->GetZ(),
248  mat->GetA(),
249  mat->GetDensity(),
250  mat->GetDensity()*mat->GetRadLen(),
251  PotI));
252  }
253  const VolumeMap_t SvtVolumes[] = {
254  {"SOUM", "Outer shileding structure","HALL_1/CAVE_1/SVTT_1/SOUM_1/*","",""},
255  {"SXRL", "Circular water feeds","HALL_1/CAVE_1/SVTT_1/SXRL_1-2/*","",""},
256  {"SXR1", "Circular water feeds","HALL_1/CAVE_1/SVTT_1/SXR1_3-4/*","",""},
257  {"SXR2", "Circular water feeds","HALL_1/CAVE_1/SVTT_1/SXR2_5-6/*","",""},
258  // {"SCBM", "Mother of All Cables","HALL_1/CAVE_1/SVTT_1/SCBM_1-2/*","",""},
259  {"SCBL", "The bundles of cables connecting PCBs with the transition boards","HALL_1/CAVE_1/SVTT_1/SCBM_1-2/SCBL_1","",""},
260  {"SCB1", "The bundles of cables connecting PCBs with the transition boards","HALL_1/CAVE_1/SVTT_1/SCBM_1-2/SCB1_2","",""},
261  {"SCB2", "The bundles of cables connecting PCBs with the transition boards","HALL_1/CAVE_1/SVTT_1/SCBM_1-2/SCB2_3","",""},
262  {"SCB3", "The bundles of cables connecting PCBs with the transition boards","HALL_1/CAVE_1/SVTT_1/SCBM_1-2/SCB3_4","",""},
263  {"SFED", "bundles of water pipes","HALL_1/CAVE_1/SVTT_1/SCBM_1-2/SFED_1","",""},
264  {"SFE1", "bundles of water pipes","HALL_1/CAVE_1/SVTT_1/SCBM_1-2/SFE1_2","",""},
265  {"SFE2", "bundles of water pipes","HALL_1/CAVE_1/SVTT_1/SCBM_1-2/SFE2_3","",""},
266  {"SPLS", "plastic of the water pipes","HALL_1/CAVE_1/SVTT_1/SCBM_1-2/SPLS_1","",""},
267  {"SPL1", "plastic of the water pipes","HALL_1/CAVE_1/SVTT_1/SCBM_1-2/SPL1_2","",""},
268  {"SPL2", "plastic of the water pipes","HALL_1/CAVE_1/SVTT_1/SCBM_1-2/SPL2_3","",""},
269  {"SALM", "aluminum shield mesh","HALL_1/CAVE_1/SVTT_1/SALM_1-2","",""},
270  {"SOSH", "SVT outer shield","HALL_1/CAVE_1/SVTT_1/SOSH_1","",""},
271  {"SISH", "SVT inner shield","HALL_1/CAVE_1/SVTT_1/SISH_1","",""},
272 // {"SLYD", "layer mother","HALL_1/CAVE_1/SVTT_1/SLYD_1/*","",""},
273 // {"SLY1", "layer mother","HALL_1/CAVE_1/SVTT_1/SLY1_2/*","",""},
274 // {"SLY2", "layer mother","HALL_1/CAVE_1/SVTT_1/SLY2_3/*","",""},
275 // {"SLY3", "layer mother","HALL_1/CAVE_1/SVTT_1/SLY3_4/*","",""},
276 // {"SLY4", "layer mother","HALL_1/CAVE_1/SVTT_1/SLY4_5/*","",""},
277 // {"SLY5", "layer mother","HALL_1/CAVE_1/SVTT_1/SLY5_6/*","",""},
278  {"SELE","electronics mother volume","HALL_1/CAVE_1/SVTT_1/SLYD_1/SLSD_1/SELE_1","",""},// Weight = 0.0422223[kG]
279 #if 1
280  {"SEL1","electronics mother volume","HALL_1/CAVE_1/SVTT_1/SLYD_2/SLSD_1/SELE_1","",""},// Weight = 0.0422223[kG]
281  {"SEL2","electronics mother volume","HALL_1/CAVE_1/SVTT_1/SLYD_3/SLSD_1/SELE_1","",""},// Weight = 0.048099[kG]
282  {"SEL3","electronics mother volume","HALL_1/CAVE_1/SVTT_1/SLYD_4/SLSD_1/SELE_1","",""},// Weight = 0.048099[kG]
283  {"SEL4","electronics mother volume","HALL_1/CAVE_1/SVTT_1/SLYD_5/SLSD_1/SELE_1","",""},// Weight = 0.0510373[kG]
284  {"SEL5","electronics mother volume","HALL_1/CAVE_1/SVTT_1/SLYD_6/SLSD_1/SELE_1","",""},// Weight = 0.0510373[kG]
285 #endif
286  // {"SVTD", "an active wafer volume","HALL_1/CAVE_1/SVTT_1/SLY*/SLS*/SLD*/STL*/STS*/SVTD_1","svt","SVTD"}, // <+++
287  {"SBWC", "water manifold to support cone bracket mother","HALL_1/CAVE_1/SVTT_1/SBWC_1-2/*","",""},
288  {"SWMM", "water manifold mother","HALL_1/CAVE_1/SVTT_1/SWMM_1-2/*","",""},
289  {"SIES", "Volume to hold inner endring screws","HALL_1/CAVE_1/SVTT_1/SIES_1-2/*","",""},
290  {"SOES", "Volume to hold outer endring screws","HALL_1/CAVE_1/SVTT_1/SOES_1-2/*","",""},
291  {"SBRG", "Bracket joining the end rungs","HALL_1/CAVE_1/SVTT_1/SBRG_1-2/*","",""},
292  {"SOER", "outer end ring","HALL_1/CAVE_1/SVTT_1/SOER_1-2/*","",""},
293  {"SIRT", "inner end ring tube piece ","HALL_1/CAVE_1/SVTT_1/SIRT_1-2","",""},
294  {"SIRP", "inner end ring polygon piece ","HALL_1/CAVE_1/SVTT_1/SIRP_1-2","",""}
295  //? {"STAC", "twinax cable approximation, copper","HALL_1/CAVE_1/SVTT_1/SCON_1/STAC_1-2","",""}
296  // StiDetectorVolume SVTT_1_SCON_1_STAC_1 StiDetector OBJ: TTUBE STAC StiCylindricalShape Rmin 21.935 Rmax 37.77 dz 86.9
297  };
298  Int_t NoSvtVols = sizeof(SvtVolumes)/sizeof(VolumeMap_t);
299  TString pathT("HALL_1/CAVE_1");
300  TString path("");
301  for (Int_t i = 0; i < NoSvtVols; i++) {
302  gGeoManager->RestoreMasterVolume();
303  gGeoManager->CdTop();
304  gGeoManager->cd(pathT); path = pathT;
305  TGeoNode *nodeT = gGeoManager->GetCurrentNode();
306  if (! nodeT) continue;
307  StiVMCToolKit::LoopOverNodes(nodeT, path, SvtVolumes[i].name, MakeAverageVolume);
308  }
309 }
function object for determine a detector&#39;s active regions
virtual Abstract * getInstance()=0
Get a pointer to instance of objects served by this factory.
virtual TObject * GetObject() const
The depricated method (left here for the sake of the backward compatibility)
Definition: TDataSet.cxx:428
virtual void setNRows(UInt_t nRows)
Abstract interface for a STI toolkit.
void setName(const string &newName)
Set the name of the object.
Definition: Named.cxx:15
virtual UInt_t getNSectors(UInt_t row=0) const