96 #include "Sti/StiPlanarShape.h"
97 #include "Sti/StiCylindricalShape.h"
98 #include "Sti/StiMaterial.h"
99 #include "Sti/StiPlacement.h"
100 #include "Sti/StiDetector.h"
101 #include "Sti/Base/Factory.h"
106 #include "StiPixelDetectorBuilder.h"
108 #include "StDetectorDbMaker/StiPixelHitErrorCalculator.h"
109 #include "TDataSetIter.h"
110 #include "tables/St_HitError_Table.h"
112 #include "StEventTypes.h"
114 StiPixelDetectorBuilder::StiPixelDetectorBuilder(
bool active)
122 StiPixelDetectorBuilder::~StiPixelDetectorBuilder()
130 LOG_INFO <<
"StiPixelDetectorBuilder::buildDetectors() -I- Started" << endm;
133 unsigned int nRows=2;
138 if (StiVMCToolKit::GetVMC()) {useVMCGeometry();
return;}
141 _gasMat = add(
new StiMaterial(
"PixelAir",7.3, 14.61, 0.001205, 30420.*0.001205, 7.3*12.e-9));
144 _siMat = add(
new StiMaterial(
"PixelSi", 14., 28.0855, 2.33, 21.82, 14.*12.*1e-9) );
145 _hybridMat = add(
new StiMaterial(
"PixelHyb", 14., 28.0855, 2.33, 21.82, 14.*12.*1e-9) );
158 for (
unsigned int row=0; row<nRows; row++)
161 if (!pShape)
throw runtime_error(
"StiPixelDetectorBuilder::buildDetectors() - FATAL - pShape==0||ifcShape==0");
162 sprintf(name,
"Pixel/Layer_%d", row);
164 pShape->setThickness(0.0280);
165 pShape->setHalfDepth( 20./2. );
166 pShape->setHalfWidth(1.0);
167 for(
unsigned int sector = 0; sector<24; sector++)
170 pPlacement->setZcenter(0.);
172 double r = radiusForPixelSector(sector)* cos(psiForPixelSector(sector)) - 0.0040;
173 double dY = radiusForPixelSector(sector)*sin(psiForPixelSector(sector));
179 pPlacement->setNormalRep(phi, r, dY);
180 pPlacement->setLayerRadius(r);
181 pPlacement->setLayerAngle(phi);
182 pPlacement->setRegion(StiPlacement::kMidRapidity);
183 sprintf(name,
"Pixel/Layer_%d/Ladder_%d", row, sector);
186 pDetector->setIsOn(
true);
188 pDetector->setIsContinuousMedium(
true);
189 pDetector->setIsDiscreteScatterer(
false);
190 pDetector->setMaterial(_siMat);
191 pDetector->setGas(_gasMat);
192 pDetector->setGroupId(kPxlId);
193 pDetector->setShape(pShape);
194 pDetector->setPlacement(pPlacement);
195 pDetector->setHitErrorCalculator(StiPixelHitErrorCalculator::instance());
199 pDetector->setKey(1,1);
200 pDetector->setKey(2,sector);
201 add(1,sector,pDetector);
205 pDetector->setKey(1,0);
206 pDetector->setKey(2,sector-18);
207 add(0,(sector-18),pDetector);
214 LOG_INFO <<
" -I- Done" << endl;
217 void StiPixelDetectorBuilder::useVMCGeometry() {
218 LOG_INFO <<
"StiPixelDetectorBuilder::buildDetectors() -I- Use VMC geometry"
220 SetCurrentDetectorBuilder(
this);
231 {
"SILICON", &_siMat},
232 {
"SILICON", &_hybridMat}
234 Int_t M =
sizeof(map)/
sizeof(Material_t);
235 for (Int_t i = 0; i < M; i++)
237 const TGeoMaterial *mat = gGeoManager->GetMaterial(map[i].name);
239 Double_t PotI = StiVMCToolKit::GetPotI(mat);
244 mat->GetDensity()*mat->GetRadLen(),
256 {
"PLAC",
"Active ladder volume",
"HALL_1/CAVE_1/IDSM_1/PXMO_1",
"",
""}
261 Int_t NoPxlVols =
sizeof(PxlVolumes)/
sizeof(
VolumeMap_t);
262 gGeoManager->RestoreMasterVolume();
263 gGeoManager->CdTop();
264 for (Int_t i = 0; i < NoPxlVols; i++) {
265 gGeoManager->cd(PxlVolumes[i].path);
266 TGeoNode *nodeT = gGeoManager->GetCurrentNode();
267 if (! nodeT)
continue;;
268 LOG_DEBUG <<
" current node : " << i <<
"/" << NoPxlVols <<
" path is : " << PxlVolumes[i].name << endm;
269 StiVMCToolKit::LoopOverNodes(nodeT, PxlVolumes[i].path, PxlVolumes[i].name, MakeAverageVolume);
273 void StiPixelDetectorBuilder::AverageVolume(TGeoPhysicalNode *nodeP)
278 LOG_INFO <<
"StiPixelDetectorBuilder::AverageVolume -E- no TGeoPhysicalNode. "
279 <<
" Perhaps Pixel is turned on in tracking, but not present in simulation. Returning."
291 TString nameP(nodeP->GetName());
294 temp.ReplaceAll(
"HALL_1/CAVE_1/IDSM_1/PXMO_1/",
"");
295 int q=temp.Index(
"_");
296 temp.Replace(0,q+1,
"");
297 TString numsec=temp(0,2);
298 int sector=numsec.Atoi();
301 temp.Replace(0,q+1,
"");
302 TString numlad=temp(0,2);
303 if(!numlad.IsDigit()) numlad=temp(0,1);
304 int ladder=numlad.Atoi();
307 temp.Replace(0,q+1,
"");
308 TString numsens=temp(0,2);
309 if(!numsens.IsDigit()) numsens=temp(0,1);
310 int sensor=numsens.Atoi();
312 if(sensor!=1)
return;
315 Bool_t ActiveVolume = kFALSE;
316 if (nodeP->GetVolume()->GetMedium()->GetParam(0) == 1) {
317 ActiveVolume = kTRUE;
318 LOG_DEBUG <<
" this node is active " << endm;
322 TGeoMaterial *matP = nodeP->GetVolume()->GetMaterial();
323 Double_t PotI = StiVMCToolKit::GetPotI(matP);
325 if (! matS) matS = add(
new StiMaterial(matP->GetName(),
329 matP->GetDensity()*matP->GetRadLen(),
339 TGeoBBox *box = (TGeoBBox *) nodeP->GetShape();
347 TGeoHMatrix *hmat = nodeP->GetMatrix();
if (debug()) hmat->Print(
"");
348 Double_t *xyz = hmat->GetTranslation();
349 Double_t *rot = hmat->GetRotationMatrix();
354 Double_t prod = centerVector*normalVector;
355 if (prod < 0) normalVector *= -1;
357 normalVector /= normalVector.magnitude();
361 Double_t phi = centerVector.phi();
362 Double_t phiD = normalVector.phi();
363 Double_t r = centerVector.perp();
364 pPlacement->setZcenter(0);
365 pPlacement->setLayerRadius(r);
368 pPlacement->setLayerAngle(phi);
369 pPlacement->setRegion(StiPlacement::kMidRapidity);
370 pPlacement->setNormalRep(phiD, r*TMath::Cos(phi-phiD), r*TMath::Sin(phi-phiD));
378 LOG_INFO <<
"StiPixelDetectorBuilder::AverageVolume() -E- StiDetector pointer invalid." <<endm;
395 p->setIsContinuousMedium(
false);
396 p->setIsDiscreteScatterer(
true);
398 p->setPlacement(pPlacement);
399 p->setGas(GetCurrentDetectorBuilder()->getGasMat());
400 if(!p->getGas()) LOG_INFO <<
"gas not there!"<<endm;
401 p->setMaterial(matS);
403 p->setHitErrorCalculator(StiPixelHitErrorCalculator::instance());
420 SECTOR = (sector-1)*3 + (ladder -1);
423 p->setKey(2, SECTOR);
428 Float_t rad2deg = 180.0/3.1415927;
429 LOG_DEBUG <<
"===>NEW:PIXEL:pDetector:Name = " << p->
getName() << endm;
430 LOG_DEBUG <<
"===>NEW:PIXEL:pPlacement:NormalRefAngle = " << pPlacement->getNormalRefAngle()*rad2deg << endm;
431 LOG_DEBUG <<
"===>NEW:PIXEL:pPlacement:NormalRadius = " << pPlacement->getNormalRadius() << endm;
432 LOG_DEBUG <<
"===>NEW:PIXEL:pPlacement:NormalYoffset = " << pPlacement->getNormalYoffset() << endm;
433 LOG_DEBUG <<
"===>NEW:PIXEL:pPlacement:CenterRefAngle = " << pPlacement->getCenterRefAngle()*rad2deg << endm;
434 LOG_DEBUG <<
"===>NEW:PIXEL:pPlacement:CenterRadius = " << pPlacement->getCenterRadius() << endm;
435 LOG_DEBUG <<
"===>NEW:PIXEL:pPlacement:CenterOrientation = " << pPlacement->getCenterOrientation()*rad2deg << endm;
436 LOG_DEBUG <<
"===>NEW:PIXEL:pPlacement:LayerRadius = " << pPlacement->getLayerRadius() << endm;
437 LOG_DEBUG <<
"===>NEW:PIXEL:pPlacement:LayerAngle = " << pPlacement->getLayerAngle()*rad2deg << endm;
438 LOG_DEBUG <<
"===>NEW:PIXEL:pPlacement:Zcenter = " << pPlacement->getZcenter() << endm;
439 LOG_DEBUG <<
"===>NEW:PIXEL:pDetector:sector = " << sector << endm;
440 LOG_DEBUG <<
"===>NEW:PIXEL:pDetector:Ladder = " << ladder << endm;
441 LOG_DEBUG <<
"===>NEW:PIXEL:pDetector:sensor = " << sensor << endm;
442 LOG_DEBUG <<
"===>NEW:PIXEL:pDetector:row/sector (ITTF) = " << ROW <<
" / " << SECTOR << endm;
443 LOG_DEBUG <<
"===>NEW:PIXEL:pDetector:Active? = " << p->isActive() << endm;
virtual void buildDetectors(StMaker &source)
Build all detector components of the Pixel detector.
virtual Abstract * getInstance()=0
Get a pointer to instance of objects served by this factory.
function object for determine a Pixel padrow's active regions
virtual void setNRows(UInt_t nRows)
double phiForPixelSector(unsigned int iSector) const
returns the azimuthal angle [-pi, pi) for tpc sector [1-24]
void setName(const string &newName)
Set the name of the object.
const string & getName() const
Get the name of the object.
Class implements an object which is never active.