Hello,
I’m using the geometry package to take a data set containing tracks to determine if and where a detector was hit. The detectors are small hexagonal cells that I’m representing with TGeoPgon objects. I have drawn the volume and ray traced ( with top->Raytrace(true) ) and I’m getting hexagonal cells arranged the way I want.
When I wrote a function to tell me if and where a cell was hit, it would return hits on cells that are not within the cell area. I didn’t know what I did wrong, so I shrunk my cells so they fit entirely within the region with the most tracks. What I saw was that it appeared that my hexagon was built out of squares with the 4 diagonal sides made up from 3 small squares. I tried increasing the size of my cells relative to the base coordinates (my cells are 9 cm^2) by changing the base unit from meters to cm to no effect. Is there a way to fix this? Am I using a function for tracking that I shouldn’t?
Code building the geometry:
void Scope::BuildDetector()
{
//---Units: using centimeters as base, i.e. 1 position unit=1 centimeter
Double_t cm=1;//,micron=1e-4;
Double_t AdjustX=0*cm,AdjustY=0*cm;
geom = new TGeoManager("Assemblies", "Geometry using assemblies");
//--- define some materials
matVacuum = new TGeoMaterial("Vacuum", 0,0,0);
pvt=new TGeoMaterial("polyvinyltoluene");
//--- define some media
Vacuum = new TGeoMedium("Vacuum",1, matVacuum);
PVT=new TGeoMedium("PVT",1,pvt);
top = geom->MakeBox("TOP", Vacuum, 100., 100., 100.);
geom->SetTopVolume(top);
fixer=geom->MakeBox("fixer",Vacuum,99.9,99.9,99.9);
top->AddNode(fixer,1);
TGeoPgon *hex=new TGeoPgon(0,360,6,2);
hex->DefineSection(0,-.25*cm,0,.5*cm);//1.611*cm);
hex->DefineSection(1,.25*cm,0,.5*cm);//1.611*cm);
Ch4=new TGeoVolume("Ch4",hex,PVT);
fixer->AddNode(Ch4,1,new TGeoTranslation(-0.3*cm+AdjustX,-0.4*cm+AdjustY,-11.8*cm));
Ch5=new TGeoVolume("Ch5",hex,PVT);
fixer->AddNode(Ch5,1,new TGeoTranslation(-0.3*cm+AdjustX,-0.4*cm+AdjustY,-3.0*cm));
Ch8=new TGeoVolume("Ch8",hex,PVT);
fixer->AddNode(Ch8,1,new TGeoTranslation(-0.3*cm+AdjustX,-0.4*cm+AdjustY,0.2*cm));
Ch9=new TGeoVolume("Ch9",hex,PVT);
fixer->AddNode(Ch9,1,new TGeoTranslation(-0.3*cm+AdjustX,-0.4*cm+AdjustY,8.2*cm));
geom->CloseGeometry();
}
Here’s the function I’m using for tracking. The tree it’s pulling from contains a vector of the track direction and the z=0 intercept of the track:
vector<vector<Float_t> > Scope::CellHits(UInt_t evt, UInt_t ch)
{
Double_t cm=1, micron=1e-4;
TGeoNode *next;
Double_t startX,startY,startZ,norm,xmag,ymag,zmag,lpoint[3];
TString cName,DectList[4]={"Ch4_1","Ch5_1","Ch8_1","Ch9_1"};
vector<UInt_t> hits,trignum;
vector<Float_t> HitPos(3,0);
vector<vector<Float_t> > rtnVector;
CosmicData->GetEntry(evt);
for(Int_t n=0;n<CurrentEvent->GetNTracks();n++)
{
startX=CurrentEvent->GetXPos(n)*micron;
startY=CurrentEvent->GetYPos(n)*micron;
startZ=CurrentEvent->GetZPos(n)*micron;
xmag=CurrentEvent->GetXSlope(n);
ymag=CurrentEvent->GetYSlope(n);
zmag=CurrentEvent->GetZSlope(n);
norm=Sqrt(xmag*xmag+ymag*ymag+zmag*zmag);
xmag=xmag/norm;
ymag=ymag/norm;
zmag=zmag/norm;
gGeoManager->SetCurrentPoint(-50*xmag*cm+startX,-50*ymag*cm+startY,-50*zmag*cm+startZ);
gGeoManager->SetCurrentDirection(xmag,ymag,zmag);
gGeoManager->FindNode();
next=gGeoManager->FindNextBoundaryAndStep(TGeoShape::Big());
while(next!=NULL)
{
cName=next->GetName();
if(cName==DectList[ch])
{
gGeoManager->MasterToLocal(gGeoManager->GetCurrentPoint(),lpoint);
HitPos[0]=lpoint[0];
HitPos[1]=lpoint[1];
HitPos[2]=lpoint[2];
rtnVector.push_back(HitPos);
}
next=gGeoManager->FindNextBoundaryAndStep(TGeoShape::Big());
}
if(rtnVector.size()==0)
{
HitPos[0]=999;
rtnVector.push_back(HitPos);
}
}
return rtnVector;
}