StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StiSstDetectorBuilder1.cxx
1 #include "StMessMgr.h"
2 
3 #include "Sti/StiCylindricalShape.h"
4 #include "Sti/StiMaterial.h"
5 #include "Sti/StiPlacement.h"
6 #include "Sti/StiDetector.h"
7 #include "StiSsd/StiSstDetectorBuilder1.h"
8 
9 
10 StiSstDetectorBuilder1::StiSstDetectorBuilder1(bool active, bool buildIdealGeom)
11  : StiSstDetectorBuilder(active, buildIdealGeom)
12 {
13 }
14 
15 
16 StiSstDetectorBuilder1::~StiSstDetectorBuilder1()
17 {}
18 
19 
28 {
29  // Build average inactive volumes
30  const VolumeMap_t volumes[] = {
31  {"SFMO", "Mother of the SST detector", "HALL_1/CAVE_1/TpcRefSys_1/IDSM_1", "", ""}
32  };
33 
34  // Build the volume map and loop over all found volumes
35  Int_t nVolumes = sizeof(volumes) / sizeof(VolumeMap_t);
36  gGeoManager->RestoreMasterVolume();
37  gGeoManager->CdTop();
38 
39  for (Int_t i = 0; i < nVolumes; i++) {
40 
41  if ( !gGeoManager->cd(volumes[i].path) ) {
42  Warning("buildInactiveVolumes()", "Cannot find path to %s node. Skipping to next node...", volumes[i].name);
43  continue;
44  }
45 
46  TGeoNode *geoNode = gGeoManager->GetCurrentNode();
47 
48  if (!geoNode) continue;
49 
50  LOG_DEBUG << "Current node : " << i << "/" << nVolumes << " path is : " << volumes[i].name << endm;
51  LOG_DEBUG << "Number of daughters : " << geoNode->GetNdaughters() << " weight : " << geoNode->GetVolume()->Weight() << endm;
52 
53  StiVMCToolKit::LoopOverNodes(geoNode, volumes[i].path, volumes[i].name, MakeAverageVolume);
54 
55  // Access last added volume
56  int row = getNRows() - 1;
57  int sector = 0;
58 
59  // Make Sti detector active, i.e. use it in tracking. XXX:ds: Not sure it has any effect but should not hurt
60  StiDetector *stiDetector = getDetector(row, sector);
61 
62  // Manually modify dimensions of the mother volume
63  if (std::string(volumes[i].name) == std::string("SFMO"))
64  segmentSFMOVolume(stiDetector);
65  }
66 }
67 
68 
99 void StiSstDetectorBuilder1::segmentSFMOVolume(StiDetector* stiSFMO)
100 {
101  StiCylindricalShape* stiSFMOShape = (StiCylindricalShape*) stiSFMO->getShape();
102 
103  // Reduce the thickness of the tube to avoid overlapping with the sensitive layers
104  stiSFMOShape->setThickness(0.75*stiSFMOShape->getThickness());
105 
106  // Copy original shape (before its depth is modified) to a new one for the end SFMO tubes
107  StiCylindricalShape* stiSFMOEndShape = new StiCylindricalShape(*stiSFMOShape);
108  stiSFMOEndShape->setName(stiSFMOEndShape->getName() + "_end");
109  stiSFMOEndShape->setHalfDepth(8.25); // 8.25 cm = (50.5-34)/2 cm
110 
111  add(stiSFMOEndShape);
112 
113  stiSFMOShape->setHalfDepth(34); // 34 cm
114 
115  // Redefine the material of the central tube
116  StiMaterial* stiSFMOMaterial = stiSFMO->getMaterial();
117  // The parameters provided by Jason W.: name, Z, A, density, X0
118  stiSFMOMaterial->set(stiSFMOMaterial->getName(), 7.33, 14.66, 0.0843, 29480);
119 
120  // Define the material for the end tubes by creating a shalow copy from the original SFMO material
121  StiMaterial* stiSFMOEndMaterial = new StiMaterial(*stiSFMOMaterial);
122  stiSFMOEndMaterial->set(stiSFMOMaterial->getName() + "_end", 7.63, 15.29, 0.380, 24650);
123 
124  add(stiSFMOEndMaterial);
125 
126  // Create a shalow copy for end tube 1
127  StiDetector* stiSFMOEnd = new StiDetector(*stiSFMO);
128 
129  StiPlacement* stiSFMOEndPlacement = new StiPlacement(*stiSFMOEnd->getPlacement());
130  stiSFMOEndPlacement->setZcenter(stiSFMOShape->getHalfDepth() + stiSFMOEndShape->getHalfDepth());
131 
132  stiSFMOEnd->setName(stiSFMO->getName() + "_end1");
133  stiSFMOEnd->setShape(stiSFMOEndShape);
134  stiSFMOEnd->setPlacement(stiSFMOEndPlacement);
135  stiSFMOEnd->setMaterial(stiSFMOEndMaterial);
136 
137  add(getNRows(), 0, stiSFMOEnd);
138 
139  // Create a shalow copy for end tube 2
140  StiDetector* stiSFMOEnd2 = new StiDetector(*stiSFMOEnd);
141 
142  stiSFMOEndPlacement = new StiPlacement(*stiSFMOEnd2->getPlacement());
143  stiSFMOEndPlacement->setZcenter(-stiSFMOShape->getHalfDepth() - stiSFMOEndShape->getHalfDepth());
144 
145  stiSFMOEnd2->setName(stiSFMO->getName() + "_end2");
146  stiSFMOEnd2->setShape(stiSFMOEndShape);
147  stiSFMOEnd2->setPlacement(stiSFMOEndPlacement);
148  stiSFMOEnd2->setMaterial(stiSFMOEndMaterial);
149 
150  add(getNRows(), 0, stiSFMOEnd2);
151 }
void set(const string &name, double z, double a, double density, double radLength, double ionization)
Definition: StiMaterial.cxx:50
void setName(const string &newName)
Set the name of the object.
Definition: Named.cxx:15
const string & getName() const
Get the name of the object.
Definition: Named.cxx:22