7 #include "TGeoVolume.h"
8 #include "TGeoMatrix.h"
11 #include "Sti/StiPlanarShape.h"
12 #include "Sti/StiCylindricalShape.h"
13 #include "Sti/StiMaterial.h"
14 #include "Sti/StiPlacement.h"
15 #include "Sti/StiDetector.h"
16 #include "Sti/Base/Factory.h"
19 #include "StiPxl/StiPxlDetectorBuilder.h"
21 #include "StiPxl/StiPxlHitErrorCalculator.h"
22 #include "tables/St_HitError_Table.h"
23 #include "StEvent/StEvent.h"
24 #include "StEvent/StEventTypes.h"
25 #include "StPxlDbMaker/StPxlDb.h"
26 #include "StPxlDbMaker/StPxlDbMaker.h"
27 #include "StPxlUtil/StPxlConstants.h"
28 #include "StBFChain/StBFChain.h"
54 throw runtime_error(
"StiPxlDetectorBuilder::StiPxlDetectorBuilder() "
55 "- Cannot build Sti geometry due to missing global object of TGeoManager class. "
56 "Make sure STAR geometry is properly loaded with BFC AgML option");
58 SetCurrentDetectorBuilder(
this);
61 if (!mBuildIdealGeom) {
65 LOG_ERROR <<
"StiPxlDetectorBuilder::buildDetectors() - PXL geometry was requested from "
66 "DB but no StPxlDb object found. Check for pxlDb option in BFC chain" << endm;
73 LOG_INFO <<
"StiPxlDetectorBuilder::buildDetectors() - Will build PXL geometry from DB tables" << endm;
77 const TGeoMaterial* geoMat = gGeoManager->GetMaterial(
"AIR");
79 _gasMat = geoMat ? add(
new StiMaterial(geoMat->GetName(), geoMat->GetZ(), geoMat->GetA(), geoMat->GetDensity(), geoMat->GetRadLen()))
80 : add(
new StiMaterial(
"AIR", 7.3, 14.61, 0.001205, 30420.));
82 if (StiVMCToolKit::GetVMC()) {
84 buildInactiveVolumes();
98 const TGeoMaterial* geoMat = gGeoManager->GetMaterial(
"SILICON");
100 StiMaterial* silicon = geoMat ? add(
new StiMaterial(geoMat->GetName(), geoMat->GetZ(), geoMat->GetA(), geoMat->GetDensity(), geoMat->GetRadLen()))
101 : add(
new StiMaterial(
"SILICON", 14, 28.0855, 2.33, 9.36) );
104 int iSensor = floor(kNumberOfPxlSensorsPerLadder/2);
106 for (
int iSector = 1; iSector <= kNumberOfPxlSectors; ++iSector)
108 for (
int iLadder = 1; iLadder <= kNumberOfPxlLaddersPerSector; ++iLadder)
110 std::string geoPath( formTGeoPath(iSector, iLadder, iSensor) );
112 if ( geoPath.empty() ) {
113 LOG_WARN <<
"StiPxlDetectorBuilder::useVMCGeometry() - Cannot find path to PLAC (PXL sensitive) node. Skipping to next ladder..." << endm;
117 TGeoVolume* sensorVol = gGeoManager->GetCurrentNode()->GetVolume();
118 TGeoHMatrix sensorMatrix( *gGeoManager->MakePhysicalNode(geoPath.c_str())->GetMatrix() );
122 double idealOffsetZ = sensorMatrix.GetTranslation()[2];
124 if (!mBuildIdealGeom) {
125 const TGeoHMatrix* sensorMatrixDb = mPxlDb->geoHMatrixSensorOnGlobal(iSector, iLadder, iSensor);
127 if (!sensorMatrixDb) {
128 LOG_WARN <<
"StiPxlDetectorBuilder::useVMCGeometry() - Cannot get PXL sensor position matrix. Skipping to next ladder..." << endm;
132 sensorMatrix = *sensorMatrixDb;
136 sensorMatrix.SetDz(sensorMatrix.GetTranslation()[2] - idealOffsetZ);
138 TGeoBBox *sensorBBox = (TGeoBBox*) sensorVol->GetShape();
141 for (
int iLadderHalf = 1; iLadderHalf <= 2; iLadderHalf++) {
143 std::string halfLadderName(geoPath + (iLadderHalf == 1 ?
"_HALF1" :
"_HALF2") );
144 double sensorLength = kNumberOfPxlSensorsPerLadder * (sensorBBox->GetDZ() + 0.02);
145 StiShape *stiShape =
new StiPlanarShape(halfLadderName.c_str(), sensorLength, 2*sensorBBox->GetDY(), sensorBBox->GetDX()/2);
147 TVector3 offset((iLadderHalf == 1 ? -sensorBBox->GetDX()/2 : sensorBBox->GetDX()/2), 0, 0);
155 stiDetector->
setProperties(halfLadderName, isActive, stiShape, pPlacement, getGasMat(), silicon);
156 stiDetector->setHitErrorCalculator(StiPxlHitErrorCalculator::instance());
160 int stiRow, stiSensor;
161 convertSensor2StiId(iSector, iLadder, iLadderHalf, stiRow, stiSensor);
164 add(stiRow, stiSensor, stiDetector);
186 int stiRow, stiSensor;
187 convertSensor2StiId(sector, ladder, sensorHalf, stiRow, stiSensor);
189 return stiRow < 0 ? 0 : getDetector(stiRow, stiSensor);
198 std::string StiPxlDetectorBuilder::formTGeoPath(
int sector,
int ladder,
int sensor)
200 const std::string tgeoPathToMother(
"/HALL_1/CAVE_1/TpcRefSys_1/IDSM_1/PXMO_1");
202 std::ostringstream geoPath;
204 geoPath << tgeoPathToMother <<
"/PXLA_" << sector
205 <<
"/LADR_" << ladder
206 <<
"/PXSI_" << sensor
209 bool found = gGeoManager->cd( geoPath.str().c_str() );
215 geoPath << tgeoPathToMother <<
"/LADR_" << 4*(sector - 1) + ladder
216 <<
"/PXSI_" << sensor
218 found = gGeoManager->cd( geoPath.str().c_str() );
225 geoPath << tgeoPathToMother <<
"/PXSI_" << 40*(sector - 1) + 10*(ladder - 1) + sensor
227 found = gGeoManager->cd( geoPath.str().c_str() );
230 return found ? geoPath.str() :
"";
235 void StiPxlDetectorBuilder::buildInactiveVolumes()
239 {
"DTUH",
"Dtube part of pixel support",
"HALL_1/CAVE_1/TpcRefSys_1/IDSM_1",
"",
""},
242 {
"PSHA",
"Detail in half pixel support",
"HALL_1/CAVE_1/TpcRefSys_1/IDSM_1",
"",
""},
243 {
"PSHC",
"Detail in half pixel support",
"HALL_1/CAVE_1/TpcRefSys_1/IDSM_1",
"",
""},
244 {
"PSHE",
"Detail in half pixel support",
"HALL_1/CAVE_1/TpcRefSys_1/IDSM_1",
"",
""},
245 {
"PSHG",
"Detail in half pixel support",
"HALL_1/CAVE_1/TpcRefSys_1/IDSM_1",
"",
""},
246 {
"PSAL",
"Long tube in half pixel support",
"HALL_1/CAVE_1/TpcRefSys_1/IDSM_1",
"",
""},
247 {
"PSAK",
"Short tube in half pixel support",
"HALL_1/CAVE_1/TpcRefSys_1/IDSM_1",
"",
""},
248 {
"PSCL",
"Plane in half pixel support",
"HALL_1/CAVE_1/TpcRefSys_1/IDSM_1",
"",
""},
249 {
"PSCK",
"Detail in half pixel support",
"HALL_1/CAVE_1/TpcRefSys_1/IDSM_1",
"",
""},
250 {
"PSAB",
"Detail in half pixel support",
"HALL_1/CAVE_1/TpcRefSys_1/IDSM_1",
"",
""},
251 {
"PSAE",
"Detail in half pixel support",
"HALL_1/CAVE_1/TpcRefSys_1/IDSM_1",
"",
""},
252 {
"PSMD",
"Detail in half pixel support",
"HALL_1/CAVE_1/TpcRefSys_1/IDSM_1",
"",
""},
256 {
"PXRB",
"Pixel sector support",
"HALL_1/CAVE_1/TpcRefSys_1/IDSM_1/PXMO_1",
"",
""},
257 {
"PXTR",
"Pixel sector support",
"HALL_1/CAVE_1/TpcRefSys_1/IDSM_1/PXMO_1",
"",
""},
258 {
"PXTM",
"Pixel sector support",
"HALL_1/CAVE_1/TpcRefSys_1/IDSM_1/PXMO_1",
"",
""},
259 {
"PXTL",
"Pixel sector support",
"HALL_1/CAVE_1/TpcRefSys_1/IDSM_1/PXMO_1",
"",
""},
260 {
"PXLB",
"Pixel sector support",
"HALL_1/CAVE_1/TpcRefSys_1/IDSM_1/PXMO_1",
"",
""},
261 {
"PXIB",
"Pixel sector support",
"HALL_1/CAVE_1/TpcRefSys_1/IDSM_1/PXMO_1",
"",
""},
264 {
"DRIV",
"Driver Board",
"HALL_1/CAVE_1/TpcRefSys_1/IDSM_1/PXMO_1",
"",
""},
265 {
"GLUA",
"Glu layer A",
"HALL_1/CAVE_1/TpcRefSys_1/IDSM_1/PXMO_1",
"",
""},
266 {
"GLUB",
"Glu layer B",
"HALL_1/CAVE_1/TpcRefSys_1/IDSM_1/PXMO_1",
"",
""},
267 {
"GLUC",
"Glu layer C",
"HALL_1/CAVE_1/TpcRefSys_1/IDSM_1/PXMO_1",
"",
""},
268 {
"ALCA",
"Aluminium cable",
"HALL_1/CAVE_1/TpcRefSys_1/IDSM_1/PXMO_1",
"",
""},
269 {
"CFBK",
"Carbon Fiber Backing",
"HALL_1/CAVE_1/TpcRefSys_1/IDSM_1/PXMO_1",
"",
""},
272 {
"APTS1",
"Tube shell",
"HALL_1/CAVE_1/TpcRefSys_1/IDSM_1/PSTM_1/APTS_1",
"",
""},
273 {
"PITN1",
"Pixel insertion TubeNaked",
"HALL_1/CAVE_1/TpcRefSys_1/IDSM_1/PSTM_1/PITN_1",
"",
""}
276 int nPxlVolumes =
sizeof(pxlVolumes) /
sizeof(
VolumeMap_t);
278 for (
int i = 0; i < nPxlVolumes; i++) {
280 if (! gGeoManager->cd(pxlVolumes[i].path) ) {
281 LOG_WARN <<
"StiPxlDetectorBuilder::buildInactiveVolumes() - Cannot find path to '"
282 << pxlVolumes[i].name <<
"' node. Skipping to next node..." << endm;
286 TGeoNode *geoNode = gGeoManager->GetCurrentNode();
288 if (!geoNode)
continue;
290 StiVMCToolKit::LoopOverNodes(geoNode, pxlVolumes[i].path, pxlVolumes[i].name, MakeAverageVolume);
327 void StiPxlDetectorBuilder::convertSensor2StiId(
int sector,
int ladder,
int sensorHalf,
int& stiRow,
int& stiSensor)
330 if (sector < 1 || sector > kNumberOfPxlSectors ||
331 ladder < 1 || ladder > kNumberOfPxlLaddersPerSector ||
332 sensorHalf < 1 || sensorHalf > 2)
334 stiRow = stiSensor = -1;
339 stiRow = sensorHalf == 1 ? 0 : 1;
340 stiSensor = (sector - 1);
342 stiRow = sensorHalf == 1 ? 2 : 3;
343 stiSensor = (sector - 1) * (kNumberOfPxlLaddersPerSector - 1) + (ladder - 2);
void setProperties(std::string name, StiIsActiveFunctor *activeFunctor, StiShape *shape, StiPlacement *placement, StiMaterial *gas, StiMaterial *material)
virtual void buildDetectors(StMaker &source)
virtual Abstract * getInstance()=0
Get a pointer to instance of objects served by this factory.
StiPxlDetectorBuilder(bool active, bool buildIdealGeom=true)
const StiDetector * getActiveDetector(int sector, int ladder, int sensorHalf) const
function object for determine a detector's active regions
function object for determine a Pixel padrow's active regions
virtual TObject * GetObject() const
The depricated method (left here for the sake of the backward compatibility)
virtual void useVMCGeometry()
Class implements an object which is never active.