84 #include "StMessMgr.h"
85 #include "StThreeVectorD.hh"
86 #include "tables/St_ssdDimensions_Table.h"
87 #include "tables/St_ssdConfiguration_Table.h"
88 #include "tables/St_ssdWafersPosition_Table.h"
90 #include "Sti/Base/Factory.h"
91 #include "Sti/StiPlanarShape.h"
92 #include "Sti/StiCylindricalShape.h"
93 #include "Sti/StiMaterial.h"
94 #include "Sti/StiPlacement.h"
95 #include "Sti/StiDetector.h"
97 #include "StDetectorDbMaker/StiHitErrorCalculator.h"
100 #include "StiSsd/StiSsdIsActiveFunctor.h"
101 #include "StiSsd/StiSsdDetectorBuilder.h"
102 #include "StSsdUtil/StSsdBarrel.hh"
103 #include "StDetectorDbMaker/StiSsdHitErrorCalculator.h"
104 StiSsdDetectorBuilder::StiSsdDetectorBuilder(
bool active)
110 StiSsdDetectorBuilder::~StiSsdDetectorBuilder()
117 throw runtime_error(
"StiSsdDetectorBuilder::StiSsdDetectorBuilder() "
118 "- Cannot build Sti geometry due to missing global object of TGeoManager class. "
119 "Make sure STAR geometry is properly loaded with BFC AgML option");
121 gMessMgr->Info() <<
"StiSsdDetectorBuilder::buildDetectors() - I - Started "<<endm;
124 gMessMgr->Info() <<
"StiSsdDetectorBuilder::buildDetectors() - I - there is no SSD barrel - take whatever exist in GEANT" << endm;
125 StiVMCToolKit::GetVMC();
131 _gasMat = add(
new StiMaterial(
"SsdAir",7.3, 14.61, 0.001205, 30420.*0.001205, 7.3*12.e-9));
133 _siMat = add(
new StiMaterial(
"SsdSi",14., 28.0855, 2.33, 21.82, 14.*12.*1e-9));
135 _hybridMat = add(
new StiMaterial(
"SsdHyb",14., 28.0855, 2.33, 21.82, 14.*12.*1e-9));
138 cout <<
"StiSsdDetectorBuilder::buildMaterials() - I - Done "<<endl;
139 ssdDimensions_st *dimensions = mySsd->getDimensions();
140 Int_t NL = mySsd->getNumberOfLadders();
141 Int_t NW = mySsd->getNWaferPerLadder();
146 assert(Wafer1 && Wafer2);
147 Double_t width = TMath::Abs(Wafer1->x(2) - Wafer2->x(2))/2. + 2;
151 dimensions->waferHalfLength );
154 setNSectors(layer,NL);
161 for (Int_t ladder = 0; ladder < NL; ladder++) {
162 Ladder = mySsd->getLadder(ladder);
163 if (! Ladder)
continue;
164 Wafer1 = Ladder->getWafer(0);
165 Wafer2 = Ladder->getWafer(NW-1);
166 if (! Wafer1 || ! Wafer2)
continue;
167 StThreeVectorD centerVector1(Wafer1->x(0),Wafer1->x(1),Wafer1->x(2));
168 StThreeVectorD normalVector1(Wafer1->n(0),Wafer1->n(1),Wafer1->n(2));
169 StThreeVectorD centerVector2(Wafer2->x(0),Wafer2->x(1),Wafer2->x(2));
170 StThreeVectorD normalVector2(Wafer2->n(0),Wafer2->n(1),Wafer2->n(2));
171 StThreeVectorD centerVector = centerVector1 + centerVector2; centerVector *= 0.5;
172 StThreeVectorD normalVector = normalVector1 + normalVector2; normalVector *= 0.5;
173 Double_t prod = centerVector*normalVector;
174 if (prod < 0) normalVector *= -1;
175 double phi = centerVector.phi();
176 double phiD = normalVector.phi();
177 double r = centerVector.perp();
178 cout <<
"Det Id = "<<Wafer1->getId()<<
"\tcv\t:"<<centerVector<<
"\tphi:\t"<<phi<<
"\tr:\t"<<r<<
"\tz:\t" << centerVector.z()<< endl;
180 pPlacement->setZcenter(centerVector.z());
181 pPlacement->setLayerRadius(r);
182 pPlacement->setLayerAngle(phi);
183 pPlacement->setRegion(StiPlacement::kMidRapidity);
185 pPlacement->setNormalRep(phiD, r*TMath::Cos(phi-phiD), r*TMath::Sin(phi-phiD));
187 pLadder->
setName(Form(
"Ssd/Layer_%d/Ladder_%d/Wafers", layer, ladder));
189 pLadder->setGas(_gasMat);
190 pLadder->setMaterial(_siMat);
191 pLadder->setShape(ladderShape);
192 pLadder->setPlacement(pPlacement);
193 pLadder->setHitErrorCalculator(StiSsdHitErrorCalculator::instance());
194 pLadder->setKey(1,0);
195 pLadder->setKey(2,ladder-1);
196 add(layer,ladder,pLadder);
201 void StiSsdDetectorBuilder::useVMCGeometry() {
202 cout <<
"StiSsdDetectorBuilder::buildDetectors() -I- Use VMC geometry" << endl;
203 SetCurrentDetectorBuilder(
this);
210 {
"SILICON", &_siMat},
211 {
"SILICON", &_hybridMat}
213 Int_t M =
sizeof(map)/
sizeof(Material_t);
214 for (Int_t i = 0; i < M; i++) {
215 const TGeoMaterial *mat = gGeoManager->GetMaterial(map[i].name);
217 Double_t PotI = StiVMCToolKit::GetPotI(mat);
222 mat->GetDensity()*mat->GetRadLen(),
236 {
"SFLM",
"the mother of the ladder",
"HALL_1/CAVE_1/SVTT_1/SFMO_1/SFLM_1-20/*",
"",
""}
241 Int_t NoSsdVols =
sizeof(SsdVolumes)/
sizeof(
VolumeMap_t);
242 TString pathT(
"HALL_1/CAVE_1");
243 gGeoManager->RestoreMasterVolume();
244 gGeoManager->CdTop();
247 for (Int_t i = 0; i < NoSsdVols; i++) {
248 gGeoManager->RestoreMasterVolume();
249 gGeoManager->CdTop();
250 if (gGeoManager->cd(pathT)) {
252 TGeoNode *nodeT = gGeoManager->GetCurrentNode();
253 if (! nodeT)
continue;;
254 StiVMCToolKit::LoopOverNodes(nodeT, path, SsdVolumes[i].name, MakeAverageVolume);
255 }
else gMessMgr->Info() <<
"StiSsdDetectorBuilder::useVMCGeometry skip node " << pathT.Data() << endm;
259 ssdWafersPosition_st *StiSsdDetectorBuilder::ssdWafersPosition(Int_t Id, St_ssdWafersPosition *wafers) {
260 Int_t N = wafers->GetNRows();
261 ssdWafersPosition_st *wafer = wafers->GetTable();
262 for (Int_t i = 0; i < N; i++, wafer++)
if (Id == wafer->id)
return wafer;
virtual void buildDetectors(StMaker &source)
virtual Abstract * getInstance()=0
Get a pointer to instance of objects served by this factory.
virtual void setNRows(UInt_t nRows)
function object for determine a detector's active regions
void setName(const string &newName)
Set the name of the object.