G4ScoringBox Class Reference

#include <G4ScoringBox.hh>

Inheritance diagram for G4ScoringBox:

G4VScoringMesh

Public Member Functions

 G4ScoringBox (G4String wName)
 ~G4ScoringBox ()
void Construct (G4VPhysicalVolume *fWorldPhys)
void List () const
void Draw (std::map< G4int, G4double * > *map, G4VScoreColorMap *colorMap, G4int axflg=111)
void DrawColumn (std::map< G4int, G4double * > *map, G4VScoreColorMap *colorMap, G4int idxProj, G4int idxColumn)
void SetSegmentDirection (G4int dir)

Detailed Description

Definition at line 43 of file G4ScoringBox.hh.


Constructor & Destructor Documentation

G4ScoringBox::G4ScoringBox ( G4String  wName  ) 

Definition at line 52 of file G4ScoringBox.cc.

References boxMesh, G4VScoringMesh::fDivisionAxisNames, and G4VScoringMesh::fShape.

00053   :G4VScoringMesh(wName), fSegmentDirection(-1),
00054    fMeshElementLogical(0)
00055 {
00056   fShape = boxMesh;
00057   fDivisionAxisNames[0] = "X";
00058   fDivisionAxisNames[1] = "Y";
00059   fDivisionAxisNames[2] = "Z";
00060 }

G4ScoringBox::~G4ScoringBox (  ) 

Definition at line 62 of file G4ScoringBox.cc.

00063 {
00064 }


Member Function Documentation

void G4ScoringBox::Construct ( G4VPhysicalVolume fWorldPhys  )  [virtual]

Implements G4VScoringMesh.

Definition at line 66 of file G4ScoringBox.cc.

References G4VScoringMesh::fConstructed, G4cout, G4endl, G4VPhysicalVolume::GetName(), G4VScoringMesh::ResetScore(), and G4VScoringMesh::verboseLevel.

00067 {
00068   if(fConstructed) {
00069 
00070     if(verboseLevel > 0) 
00071       G4cout << fWorldPhys->GetName() << " --- All quantities are reset." << G4endl;
00072     ResetScore();
00073 
00074   } else {
00075     fConstructed = true;
00076     SetupGeometry(fWorldPhys);
00077   }
00078 }

void G4ScoringBox::Draw ( std::map< G4int, G4double * > *  map,
G4VScoreColorMap colorMap,
G4int  axflg = 111 
) [virtual]

Implements G4VScoringMesh.

Definition at line 245 of file G4ScoringBox.cc.

References DBL_MAX, G4VVisManager::Draw(), G4VScoreColorMap::DrawColorChart(), G4VScoringMesh::fCenterPosition, G4VScoringMesh::fDrawPSName, G4VScoringMesh::fDrawUnit, G4VScoringMesh::fDrawUnitValue, G4VScoringMesh::fNSegment, G4VScoringMesh::fRotationMatrix, G4VScoringMesh::fSize, G4VVisManager::GetConcreteInstance(), G4VScoreColorMap::GetMapColor(), G4VScoreColorMap::IfFloatMinMax(), G4VisAttributes::SetColour(), G4VisAttributes::SetForceAuxEdgeVisible(), G4VisAttributes::SetForceSolid(), G4VScoreColorMap::SetMinMax(), G4VScoreColorMap::SetPSName(), and G4VScoreColorMap::SetPSUnit().

00245                                                                                                {
00246 
00247   G4VVisManager * pVisManager = G4VVisManager::GetConcreteInstance();
00248   if(pVisManager) {
00249     
00250     // cell vectors
00251     std::vector<std::vector<std::vector<double> > > cell; // cell[X][Y][Z]
00252     std::vector<double> ez;
00253     for(int z = 0; z < fNSegment[2]; z++) ez.push_back(0.);
00254     std::vector<std::vector<double> > eyz;
00255     for(int y = 0; y < fNSegment[1]; y++) eyz.push_back(ez);
00256     for(int x = 0; x < fNSegment[0]; x++) cell.push_back(eyz);
00257 
00258     std::vector<std::vector<double> > xycell; // xycell[X][Y]
00259     std::vector<double> ey;
00260     for(int y = 0; y < fNSegment[1]; y++) ey.push_back(0.);
00261     for(int x = 0; x < fNSegment[0]; x++) xycell.push_back(ey);
00262 
00263     std::vector<std::vector<double> > yzcell; // yzcell[Y][Z]
00264     for(int y = 0; y < fNSegment[1]; y++) yzcell.push_back(ez);
00265 
00266     std::vector<std::vector<double> > xzcell; // xzcell[X][Z]
00267     for(int x = 0; x < fNSegment[0]; x++) xzcell.push_back(ez);
00268 
00269     // projections
00270     G4int q[3];
00271     std::map<G4int, G4double*>::iterator itr = map->begin();
00272     for(; itr != map->end(); itr++) {
00273       GetXYZ(itr->first, q);
00274 
00275       xycell[q[0]][q[1]] += *(itr->second)/fDrawUnitValue;
00276       yzcell[q[1]][q[2]] += *(itr->second)/fDrawUnitValue;
00277       xzcell[q[0]][q[2]] += *(itr->second)/fDrawUnitValue;
00278     }  
00279     
00280     // search max. & min. values in each slice
00281     G4double xymin = DBL_MAX, yzmin = DBL_MAX, xzmin = DBL_MAX;
00282     G4double xymax = 0., yzmax = 0., xzmax = 0.;
00283     for(int x = 0; x < fNSegment[0]; x++) {
00284       for(int y = 0; y < fNSegment[1]; y++) {
00285         if(xymin > xycell[x][y]) xymin = xycell[x][y];
00286         if(xymax < xycell[x][y]) xymax = xycell[x][y];
00287       }
00288       for(int z = 0; z < fNSegment[2]; z++) {
00289         if(xzmin > xzcell[x][z]) xzmin = xzcell[x][z];
00290         if(xzmax < xzcell[x][z]) xzmax = xzcell[x][z];
00291       }
00292     }
00293     for(int y = 0; y < fNSegment[1]; y++) {
00294       for(int z = 0; z < fNSegment[2]; z++) {
00295         if(yzmin > yzcell[y][z]) yzmin = yzcell[y][z];
00296         if(yzmax < yzcell[y][z]) yzmax = yzcell[y][z];
00297       }
00298     }
00299 
00300 
00301     G4VisAttributes att;
00302     att.SetForceSolid(true);
00303     att.SetForceAuxEdgeVisible(true);
00304 
00305     G4Scale3D scale;
00306     if(axflg/100==1) {
00307       // xy plane
00308       if(colorMap->IfFloatMinMax()) { colorMap->SetMinMax(xymin ,xymax); }
00309       G4ThreeVector zhalf(0., 0., fSize[2]/fNSegment[2]*0.98);
00310       G4Box xyplate("xy", fSize[0]/fNSegment[0], fSize[1]/fNSegment[1], fSize[2]/fNSegment[2]*0.01);
00311       for(int x = 0; x < fNSegment[0]; x++) {
00312         for(int y = 0; y < fNSegment[1]; y++) {
00313           G4ThreeVector pos(GetReplicaPosition(x, y, 0) - zhalf);
00314           G4ThreeVector pos2(GetReplicaPosition(x, y, fNSegment[2]-1) + zhalf);
00315           G4Transform3D trans, trans2;
00316           if(fRotationMatrix) {
00317             trans = G4Rotate3D(*fRotationMatrix).inverse()*G4Translate3D(pos);
00318             trans = G4Translate3D(fCenterPosition)*trans;
00319             trans2 = G4Rotate3D(*fRotationMatrix).inverse()*G4Translate3D(pos2);
00320             trans2 = G4Translate3D(fCenterPosition)*trans2;
00321           } else {
00322             trans = G4Translate3D(pos)*G4Translate3D(fCenterPosition);
00323             trans2 = G4Translate3D(pos2)*G4Translate3D(fCenterPosition);
00324           }
00325           G4double c[4];
00326           colorMap->GetMapColor(xycell[x][y], c);
00327           att.SetColour(c[0], c[1], c[2]);//, c[3]);
00328           pVisManager->Draw(xyplate, att, trans);
00329           pVisManager->Draw(xyplate, att, trans2);
00330 
00331         }
00332       }
00333     }
00334     axflg = axflg%100;
00335     if(axflg/10==1) {
00336       // yz plane
00337       if(colorMap->IfFloatMinMax()) { colorMap->SetMinMax(yzmin, yzmax); }
00338       G4ThreeVector xhalf(fSize[0]/fNSegment[0]*0.98, 0., 0.);
00339       G4Box yzplate("yz", fSize[0]/fNSegment[0]*0.01, fSize[1]/fNSegment[1], fSize[2]/fNSegment[2]);
00340       for(int y = 0; y < fNSegment[1]; y++) {
00341         for(int z = 0; z < fNSegment[2]; z++) {
00342           G4ThreeVector pos(GetReplicaPosition(0, y, z) - xhalf);
00343           G4ThreeVector pos2(GetReplicaPosition(fNSegment[0]-1, y, z) + xhalf);
00344           G4Transform3D trans, trans2;
00345           if(fRotationMatrix) {
00346             trans = G4Rotate3D(*fRotationMatrix).inverse()*G4Translate3D(pos);
00347             trans = G4Translate3D(fCenterPosition)*trans;
00348             trans2 = G4Rotate3D(*fRotationMatrix).inverse()*G4Translate3D(pos2);
00349             trans2 = G4Translate3D(fCenterPosition)*trans2;
00350           } else {
00351             trans = G4Translate3D(pos)*G4Translate3D(fCenterPosition);
00352             trans2 = G4Translate3D(pos2)*G4Translate3D(fCenterPosition);
00353           }
00354           G4double c[4];
00355           colorMap->GetMapColor(yzcell[y][z], c);
00356           att.SetColour(c[0], c[1], c[2]);//, c[3]);
00357           pVisManager->Draw(yzplate, att, trans);
00358           pVisManager->Draw(yzplate, att, trans2);
00359 
00360         }
00361       }
00362     }
00363     axflg = axflg%10;
00364     if(axflg==1) {
00365       // xz plane
00366       if(colorMap->IfFloatMinMax()) { colorMap->SetMinMax(xzmin,xzmax); }
00367       G4ThreeVector yhalf(0., fSize[1]/fNSegment[1]*0.98, 0.);
00368       G4Box xzplate("xz", fSize[0]/fNSegment[0], fSize[1]/fNSegment[1]*0.01, fSize[2]/fNSegment[2]);
00369       for(int x = 0; x < fNSegment[0]; x++) {
00370         for(int z = 0; z < fNSegment[2]; z++) {
00371           G4ThreeVector pos(GetReplicaPosition(x, 0, z) - yhalf);
00372           G4ThreeVector pos2(GetReplicaPosition(x, fNSegment[1]-1, z) + yhalf);
00373           G4Transform3D trans, trans2;
00374           if(fRotationMatrix) {
00375             trans = G4Rotate3D(*fRotationMatrix).inverse()*G4Translate3D(pos);
00376             trans = G4Translate3D(fCenterPosition)*trans;
00377             trans2 = G4Rotate3D(*fRotationMatrix).inverse()*G4Translate3D(pos2);
00378             trans2 = G4Translate3D(fCenterPosition)*trans2;
00379           } else {
00380             trans = G4Translate3D(pos)*G4Translate3D(fCenterPosition);
00381             trans2 = G4Translate3D(pos2)*G4Translate3D(fCenterPosition);
00382           }
00383           G4double c[4];
00384           colorMap->GetMapColor(xzcell[x][z], c);
00385           att.SetColour(c[0], c[1], c[2]);//, c[3]);
00386           pVisManager->Draw(xzplate, att, trans);
00387           pVisManager->Draw(xzplate, att, trans2);
00388 
00389         }
00390       }
00391     }
00392   }
00393   colorMap->SetPSUnit(fDrawUnit);
00394   colorMap->SetPSName(fDrawPSName);
00395   colorMap->DrawColorChart();
00396 }

void G4ScoringBox::DrawColumn ( std::map< G4int, G4double * > *  map,
G4VScoreColorMap colorMap,
G4int  idxProj,
G4int  idxColumn 
) [virtual]

Implements G4VScoringMesh.

Definition at line 420 of file G4ScoringBox.cc.

References DBL_MAX, G4VVisManager::Draw(), G4VScoreColorMap::DrawColorChart(), G4VScoringMesh::fCenterPosition, G4VScoringMesh::fDrawPSName, G4VScoringMesh::fDrawUnit, G4VScoringMesh::fDrawUnitValue, G4VScoringMesh::fNSegment, G4VScoringMesh::fRotationMatrix, G4VScoringMesh::fSize, G4cerr, G4VVisManager::GetConcreteInstance(), G4VScoreColorMap::GetMapColor(), G4VScoreColorMap::IfFloatMinMax(), G4VisAttributes::SetColour(), G4VisAttributes::SetForceAuxEdgeVisible(), G4VisAttributes::SetForceSolid(), G4VScoreColorMap::SetMinMax(), G4VScoreColorMap::SetPSName(), and G4VScoreColorMap::SetPSUnit().

00422 {
00423   if(idxColumn<0 || idxColumn>=fNSegment[idxProj])
00424   {
00425     G4cerr << "ERROR : Column number " << idxColumn << " is out of scoring mesh [0," << fNSegment[idxProj]-1 <<
00426     "]. Method ignored." << G4endl;
00427     return;
00428   }
00429   G4VVisManager * pVisManager = G4VVisManager::GetConcreteInstance();
00430   if(pVisManager) {
00431     
00432     // cell vectors
00433     std::vector<std::vector<std::vector<double> > > cell; // cell[X][Y][Z]
00434     std::vector<double> ez;
00435     for(int z = 0; z < fNSegment[2]; z++) ez.push_back(0.);
00436     std::vector<std::vector<double> > eyz;
00437     for(int y = 0; y < fNSegment[1]; y++) eyz.push_back(ez);
00438     for(int x = 0; x < fNSegment[0]; x++) cell.push_back(eyz);
00439 
00440     std::vector<std::vector<double> > xycell; // xycell[X][Y]
00441     std::vector<double> ey;
00442     for(int y = 0; y < fNSegment[1]; y++) ey.push_back(0.);
00443     for(int x = 0; x < fNSegment[0]; x++) xycell.push_back(ey);
00444 
00445     std::vector<std::vector<double> > yzcell; // yzcell[Y][Z]
00446     for(int y = 0; y < fNSegment[1]; y++) yzcell.push_back(ez);
00447 
00448     std::vector<std::vector<double> > xzcell; // xzcell[X][Z]
00449     for(int x = 0; x < fNSegment[0]; x++) xzcell.push_back(ez);
00450 
00451     // projections
00452     G4int q[3];
00453     std::map<G4int, G4double*>::iterator itr = map->begin();
00454     for(; itr != map->end(); itr++) {
00455       GetXYZ(itr->first, q);
00456 
00457       if(idxProj == 0 && q[2] == idxColumn) { // xy plane
00458         xycell[q[0]][q[1]] += *(itr->second)/fDrawUnitValue;
00459       }
00460       if(idxProj == 1 && q[0] == idxColumn) { // yz plane
00461         yzcell[q[1]][q[2]] += *(itr->second)/fDrawUnitValue;
00462       }
00463       if(idxProj == 2 && q[1] == idxColumn) { // zx plane
00464         xzcell[q[0]][q[2]] += *(itr->second)/fDrawUnitValue;
00465       }
00466     }  
00467     
00468     // search max. & min. values in each slice
00469     G4double xymin = DBL_MAX, yzmin = DBL_MAX, xzmin = DBL_MAX;
00470     G4double xymax = 0., yzmax = 0., xzmax = 0.;
00471     for(int x = 0; x < fNSegment[0]; x++) {
00472       for(int y = 0; y < fNSegment[1]; y++) {
00473         if(xymin > xycell[x][y]) xymin = xycell[x][y];
00474         if(xymax < xycell[x][y]) xymax = xycell[x][y];
00475       }
00476       for(int z = 0; z < fNSegment[2]; z++) {
00477         if(xzmin > xzcell[x][z]) xzmin = xzcell[x][z];
00478         if(xzmax < xzcell[x][z]) xzmax = xzcell[x][z];
00479       }
00480     }
00481     for(int y = 0; y < fNSegment[1]; y++) {
00482       for(int z = 0; z < fNSegment[2]; z++) {
00483         if(yzmin > yzcell[y][z]) yzmin = yzcell[y][z];
00484         if(yzmax < yzcell[y][z]) yzmax = yzcell[y][z];
00485       }
00486     }
00487 
00488 
00489     G4VisAttributes att;
00490     att.SetForceSolid(true);
00491     att.SetForceAuxEdgeVisible(true);
00492 
00493 
00494     G4Scale3D scale;
00495     // xy plane
00496     if(idxProj == 0) {
00497       if(colorMap->IfFloatMinMax()) { colorMap->SetMinMax(xymin,xymax); }
00498       G4Box xyplate("xy", fSize[0]/fNSegment[0], fSize[1]/fNSegment[1], fSize[2]/fNSegment[2]);
00499       for(int x = 0; x < fNSegment[0]; x++) {
00500         for(int y = 0; y < fNSegment[1]; y++) {
00501           G4ThreeVector pos(GetReplicaPosition(x, y, idxColumn));
00502           G4Transform3D trans;
00503           if(fRotationMatrix) {
00504             trans = G4Rotate3D(*fRotationMatrix).inverse()*G4Translate3D(pos);
00505             trans = G4Translate3D(fCenterPosition)*trans;
00506           } else {
00507             trans = G4Translate3D(pos)*G4Translate3D(fCenterPosition);
00508           }
00509           G4double c[4];
00510           colorMap->GetMapColor(xycell[x][y], c);
00511           att.SetColour(c[0], c[1], c[2]);//, c[3]);
00512           pVisManager->Draw(xyplate, att, trans);
00513 
00514         }
00515       }
00516     } else
00517     // yz plane
00518     if(idxProj == 1) {
00519       if(colorMap->IfFloatMinMax()) { colorMap->SetMinMax(yzmin,yzmax); }
00520       G4Box yzplate("yz", fSize[0]/fNSegment[0], fSize[1]/fNSegment[1], fSize[2]/fNSegment[2]);
00521       for(int y = 0; y < fNSegment[1]; y++) {
00522         for(int z = 0; z < fNSegment[2]; z++) {
00523           G4ThreeVector pos(GetReplicaPosition(idxColumn, y, z));
00524           G4Transform3D trans;
00525           if(fRotationMatrix) {
00526             trans = G4Rotate3D(*fRotationMatrix).inverse()*G4Translate3D(pos);
00527             trans = G4Translate3D(fCenterPosition)*trans;
00528           } else {
00529             trans = G4Translate3D(pos)*G4Translate3D(fCenterPosition);
00530           }
00531           G4double c[4];
00532           colorMap->GetMapColor(yzcell[y][z], c);
00533           att.SetColour(c[0], c[1], c[2]);//, c[3]);
00534           pVisManager->Draw(yzplate, att, trans);
00535         }
00536       }
00537     } else
00538     // xz plane
00539       if(idxProj == 2) {
00540       if(colorMap->IfFloatMinMax()) { colorMap->SetMinMax(xzmin,xzmax);}
00541       G4Box xzplate("xz", fSize[0]/fNSegment[0], fSize[1]/fNSegment[1], fSize[2]/fNSegment[2]);
00542       for(int x = 0; x < fNSegment[0]; x++) {
00543         for(int z = 0; z < fNSegment[2]; z++) {
00544           G4ThreeVector pos(GetReplicaPosition(x, idxColumn, z));
00545           G4Transform3D trans;
00546           if(fRotationMatrix) {
00547             trans = G4Rotate3D(*fRotationMatrix).inverse()*G4Translate3D(pos);
00548             trans = G4Translate3D(fCenterPosition)*trans;
00549           } else {
00550             trans = G4Translate3D(pos)*G4Translate3D(fCenterPosition);
00551           }
00552           G4double c[4];
00553           colorMap->GetMapColor(xzcell[x][z], c);
00554           att.SetColour(c[0], c[1], c[2]);//, c[3]);
00555           pVisManager->Draw(xzplate, att, trans);
00556         }
00557       }
00558     }
00559   }
00560 
00561   colorMap->SetPSUnit(fDrawUnit);
00562   colorMap->SetPSName(fDrawPSName);
00563   colorMap->DrawColorChart();
00564 }

void G4ScoringBox::List (  )  const [virtual]

Reimplemented from G4VScoringMesh.

Definition at line 234 of file G4ScoringBox.cc.

References G4VScoringMesh::fSize, G4VScoringMesh::fWorldName, G4cout, and G4VScoringMesh::List().

00234                               {
00235   G4cout << "G4ScoringBox : " << fWorldName << " --- Shape: Box mesh" << G4endl;
00236   G4cout << " Size (x, y, z): ("
00237          << fSize[0]/cm << ", "
00238          << fSize[1]/cm << ", "
00239          << fSize[2]/cm << ") [cm]"
00240          << G4endl;
00241 
00242   G4VScoringMesh::List();
00243 }

void G4ScoringBox::SetSegmentDirection ( G4int  dir  )  [inline]

Definition at line 57 of file G4ScoringBox.hh.

00057 {fSegmentDirection = dir;}


The documentation for this class was generated from the following files:
Generated on Mon May 27 17:53:21 2013 for Geant4 by  doxygen 1.4.7