Import Geant4 10.2.0 source tree

This commit is contained in:
Gabriele Cosmo
2016-06-10 14:11:04 +02:00
parent c9b32a6c0a
commit d4af681f38
4886 changed files with 420149 additions and 1023309 deletions
+18 -1
View File
@@ -1,4 +1,4 @@
$Id: History 74457 2013-10-07 15:21:35Z gcosmo $
$Id: History 89185 2015-03-23 16:11:02Z gcosmo $
-------------------------------------------------------------------
=========================================================
@@ -17,6 +17,23 @@ committal in the CVS repository !
* Reverse chronological order (last date on top), please *
----------------------------------------------------------
March 20, 2015 A.Kimura (detutils-V10-01-02)
- fixed type convertion warnigs at l.132 and l.157 of G4VScoreColorMap.cc
March 11, 2015 A.Kimura (detutils-V10-01-01)
- fine adjustment of the position drawing surfaces in G4ScoringBox::Draw(...)
March 11, 2015 A.Kimura (detutils-V10-01-00)
March 11, 2015 A.Kimura (detutils-V10-01-00)
- Revised G4ScoringBox::Draw(...), ::DrawColumn(...),
G4ScoringCylinder::Draw(...) and ::DrawColumn(...) to spped up
drawing primitive scorers attached to the scoring meshes.
October 03, 2014 A.Kimura (detutils-V10-00-00)
- Added several sets of G4VisManager::BeginDraw2D() call and
G4VisManager::EndDraw() call in G4VScoreColorMap.cc for the speedup
of drawing the texts and the color chart.
October 05, 2013 A.Kimura (detutils-V09-06-00)
- Fixed a bug in G4ScoringBox::DrawColumn(...), which was a wrong size check of the column.
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4DefaultLinearColorMap.cc 67992 2013-03-13 10:59:57Z gcosmo $
// $Id: G4DefaultLinearColorMap.cc 89031 2015-03-18 08:40:48Z gcosmo $
//
#include "G4DefaultLinearColorMap.hh"
@@ -75,6 +75,7 @@ void G4DefaultLinearColorMap::GetMapColor(G4double val, G4double color[4])
for(int i = 0; i < 4; i++) {
color[i] = (b*colormap[during[0]].rgb[i] + a*colormap[during[1]].rgb[i])
/(colormap[during[1]].val - colormap[during[0]].val);
if(color[i] > 1.) color[i] = 1.;
}
}
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4ScoreLogColorMap.cc 67992 2013-03-13 10:59:57Z gcosmo $
// $Id: G4ScoreLogColorMap.cc 89031 2015-03-18 08:40:48Z gcosmo $
//
#include "G4ScoreLogColorMap.hh"
@@ -93,7 +93,10 @@ void G4ScoreLogColorMap::GetMapColor(G4double val, G4double color[4])
}
G4double logmin = 0., logmax = 0., logval = 0.;
if(lmin) logmin = std::log10(fMinVal);
if(lmin) {
if(fMinVal > 0.) logmin = std::log10(fMinVal);
else logmin =0.;
}
if(lmax) logmax = std::log10(fMaxVal);
if(lval) logval = std::log10(val);
G4double value = 0.;
@@ -107,12 +110,12 @@ void G4ScoreLogColorMap::GetMapColor(G4double val, G4double color[4])
struct ColorMap {
G4double val;
G4double rgb[4];
} colormap[NCOLOR] = {{0.0, {1., 1., 1., 1.}}, // value, r, g, b, alpha
{0.2, {0., 0., 1., 1.}},
{0.4, {0., 1., 1., 1.}},
{0.6, {0., 1., 0., 1.}},
{0.8, {1., 1., 0., 1.}},
{1.0, {1., 0., 0., 1.}}};
} colormap[] = {{0.0, {1., 1., 1., 1.}}, // value, r, g, b, alpha
{0.2, {0., 0., 1., 1.}},
{0.4, {0., 1., 1., 1.}},
{0.6, {0., 1., 0., 1.}},
{0.8, {1., 1., 0., 1.}},
{1.0, {1., 0., 0., 1.}}};
// search
G4int during[2] = {0, 0};
@@ -130,6 +133,7 @@ void G4ScoreLogColorMap::GetMapColor(G4double val, G4double color[4])
for(int i = 0; i < 4; i++) {
color[i] = (b*colormap[during[0]].rgb[i] + a*colormap[during[1]].rgb[i])
/(colormap[during[1]].val - colormap[during[0]].val);
if(color[i] > 1.) color[i] = 1.;
}
}
@@ -179,7 +183,7 @@ void G4ScoreLogColorMap::DrawColorChartText(G4int _nPoint) {
//if(max > 0.) max = std::ceil(max);
//else max = std::floor(max);
G4double c[4];
G4double c[4] = {1., 1., 1., 1.};
G4Colour black(0., 0., 0.);
for(int n = 0; n < _nPoint; n++) {
G4double a = n/(_nPoint-1.), b = 1.-a;
@@ -205,12 +209,12 @@ void G4ScoreLogColorMap::DrawColorChartText(G4int _nPoint) {
std::ostringstream oss;
oss << std::setw(8) << std::setprecision(1) << std::scientific << std::pow(10., v);
std::string str = oss.str();
G4String value(str.c_str());
G4String value(str);//.c_str());
G4Text text(value, G4Point3D(-0.9, -0.9+0.05*n, 0));
G4double size = 12.;
text.SetScreenSize(size);
//this->GetMapColor(std::pow(10., v), c);
G4Colour color(c[0], c[1], c[2]);
G4Colour color(1.,1.,1.);//c[0], c[1], c[2], 1.);
G4VisAttributes att(color);
text.SetVisAttributes(&att);
+149 -29
View File
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4ScoringBox.cc 83518 2014-08-27 12:57:10Z gcosmo $
// $Id: G4ScoringBox.cc 89031 2015-03-18 08:40:48Z gcosmo $
//
#include "G4ScoringBox.hh"
@@ -43,6 +43,7 @@
#include "G4MultiFunctionalDetector.hh"
#include "G4SDParticleFilter.hh"
#include "G4VPrimitiveScorer.hh"
#include "G4Polyhedron.hh"
#include "G4ScoringManager.hh"
@@ -240,7 +241,7 @@ void G4ScoringBox::Draw(std::map<G4int, G4double*> * map,
G4VVisManager * pVisManager = G4VVisManager::GetConcreteInstance();
if(pVisManager) {
// cell vectors
std::vector<std::vector<std::vector<double> > > cell; // cell[X][Y][Z]
std::vector<double> ez;
@@ -295,16 +296,18 @@ void G4ScoringBox::Draw(std::map<G4int, G4double*> * map,
G4VisAttributes att;
att.SetForceSolid(true);
att.SetForceAuxEdgeVisible(true);
G4double thick = 0.01;
G4Scale3D scale;
if(axflg/100==1) {
pVisManager->BeginDraw();
// xy plane
if(colorMap->IfFloatMinMax()) { colorMap->SetMinMax(xymin ,xymax); }
G4ThreeVector zhalf(0., 0., fSize[2]/fNSegment[2]*0.98);
G4Box xyplate("xy", fSize[0]/fNSegment[0], fSize[1]/fNSegment[1],
fSize[2]/fNSegment[2]*0.01);
G4ThreeVector zhalf(0., 0., fSize[2]/fNSegment[2]-thick);
for(int x = 0; x < fNSegment[0]; x++) {
for(int y = 0; y < fNSegment[1]; y++) {
G4ThreeVector pos(GetReplicaPosition(x, y, 0) - zhalf);
G4ThreeVector pos2(GetReplicaPosition(x, y, fNSegment[2]-1) + zhalf);
G4Transform3D trans, trans2;
@@ -320,21 +323,54 @@ void G4ScoringBox::Draw(std::map<G4int, G4double*> * map,
G4double c[4];
colorMap->GetMapColor(xycell[x][y], c);
att.SetColour(c[0], c[1], c[2]);//, c[3]);
pVisManager->Draw(xyplate, att, trans);
pVisManager->Draw(xyplate, att, trans2);
G4Box xyplate("xy", fSize[0]/fNSegment[0], fSize[1]/fNSegment[1],
thick);
G4Polyhedron * poly = xyplate.GetPolyhedron();
poly->Transform(trans);
poly->SetVisAttributes(&att);
pVisManager->Draw(*poly);
G4Box xyplate2 = xyplate;
G4Polyhedron * poly2 = xyplate2.GetPolyhedron();
poly2->Transform(trans2);
poly2->SetVisAttributes(&att);
pVisManager->Draw(*poly2);
/*
G4double nodes[][3] =
{{-fSize[0]/fNSegment[0], -fSize[1]/fNSegment[1], 0.},
{ fSize[0]/fNSegment[0], -fSize[1]/fNSegment[1], 0.},
{ fSize[0]/fNSegment[0], fSize[1]/fNSegment[1], 0.},
{-fSize[0]/fNSegment[0], fSize[1]/fNSegment[1], 0.}};
G4int facets[][4] = {{4, 3, 2, 1}};
G4int facets2[][4] = {{1, 2, 3, 4}};
G4Polyhedron poly, poly2;
poly.createPolyhedron(4, 1, nodes, facets);
poly.Transform(trans);
poly.SetVisAttributes(att);
pVisManager->Draw(poly);
poly2.createPolyhedron(4, 1, nodes, facets2);
poly2.Transform(trans2);
poly2.SetVisAttributes(att);
pVisManager->Draw(poly2);
*/
}
}
pVisManager->EndDraw();
}
axflg = axflg%100;
if(axflg/10==1) {
pVisManager->BeginDraw();
// yz plane
if(colorMap->IfFloatMinMax()) { colorMap->SetMinMax(yzmin, yzmax); }
G4ThreeVector xhalf(fSize[0]/fNSegment[0]*0.98, 0., 0.);
G4Box yzplate("yz", fSize[0]/fNSegment[0]*0.01, fSize[1]/fNSegment[1],
fSize[2]/fNSegment[2]);
G4ThreeVector xhalf(fSize[0]/fNSegment[0]-thick, 0., 0.);
for(int y = 0; y < fNSegment[1]; y++) {
for(int z = 0; z < fNSegment[2]; z++) {
G4ThreeVector pos(GetReplicaPosition(0, y, z) - xhalf);
G4ThreeVector pos2(GetReplicaPosition(fNSegment[0]-1, y, z) + xhalf);
G4Transform3D trans, trans2;
@@ -350,21 +386,55 @@ void G4ScoringBox::Draw(std::map<G4int, G4double*> * map,
G4double c[4];
colorMap->GetMapColor(yzcell[y][z], c);
att.SetColour(c[0], c[1], c[2]);//, c[3]);
pVisManager->Draw(yzplate, att, trans);
pVisManager->Draw(yzplate, att, trans2);
G4Box yzplate("yz", thick,//fSize[0]/fNSegment[0]*0.001,
fSize[1]/fNSegment[1],
fSize[2]/fNSegment[2]);
G4Polyhedron * poly = yzplate.GetPolyhedron();
poly->Transform(trans);
poly->SetVisAttributes(&att);
pVisManager->Draw(*poly);
G4Box yzplate2 = yzplate;
G4Polyhedron * poly2 = yzplate2.GetPolyhedron();
poly2->Transform(trans2);
poly2->SetVisAttributes(&att);
pVisManager->Draw(*poly2);
/*
G4double nodes[][3] =
{{0., -fSize[1]/fNSegment[1], -fSize[2]/fNSegment[2]},
{0., fSize[1]/fNSegment[1], -fSize[2]/fNSegment[2]},
{0., fSize[1]/fNSegment[1], fSize[2]/fNSegment[2]},
{0., -fSize[1]/fNSegment[1], fSize[2]/fNSegment[2]}};
G4int facets[][4] = {{4, 3, 2, 1}};
G4int facets2[][4] = {{1, 2, 3, 4}};
G4Polyhedron poly, poly2;
poly.createPolyhedron(4, 1, nodes, facets);
poly.Transform(trans);
poly.SetVisAttributes(att);
pVisManager->Draw(poly);
poly2.createPolyhedron(4, 1, nodes, facets2);
poly2.Transform(trans2);
poly2.SetVisAttributes(att);
pVisManager->Draw(poly2);
*/
}
}
pVisManager->EndDraw();
}
axflg = axflg%10;
if(axflg==1) {
pVisManager->BeginDraw();
// xz plane
if(colorMap->IfFloatMinMax()) { colorMap->SetMinMax(xzmin,xzmax); }
G4ThreeVector yhalf(0., fSize[1]/fNSegment[1]*0.98, 0.);
G4Box xzplate("xz", fSize[0]/fNSegment[0], fSize[1]/fNSegment[1]*0.01,
fSize[2]/fNSegment[2]);
G4ThreeVector yhalf(0., fSize[1]/fNSegment[1]-thick, 0.);
for(int x = 0; x < fNSegment[0]; x++) {
for(int z = 0; z < fNSegment[2]; z++) {
G4ThreeVector pos(GetReplicaPosition(x, 0, z) - yhalf);
G4ThreeVector pos2(GetReplicaPosition(x, fNSegment[1]-1, z) + yhalf);
G4Transform3D trans, trans2;
@@ -380,11 +450,44 @@ void G4ScoringBox::Draw(std::map<G4int, G4double*> * map,
G4double c[4];
colorMap->GetMapColor(xzcell[x][z], c);
att.SetColour(c[0], c[1], c[2]);//, c[3]);
pVisManager->Draw(xzplate, att, trans);
pVisManager->Draw(xzplate, att, trans2);
G4Box xzplate("xz", fSize[0]/fNSegment[0], thick,//fSize[1]/fNSegment[1]*0.001,
fSize[2]/fNSegment[2]);
G4Polyhedron * poly = xzplate.GetPolyhedron();
poly->Transform(trans);
poly->SetVisAttributes(&att);
pVisManager->Draw(*poly);
G4Box xzplate2 = xzplate;
G4Polyhedron * poly2 = xzplate2.GetPolyhedron();
poly2->Transform(trans2);
poly2->SetVisAttributes(&att);
pVisManager->Draw(*poly2);
/*
G4double nodes[][3] =
{{-fSize[1]/fNSegment[1], 0., -fSize[2]/fNSegment[2]},
{ fSize[1]/fNSegment[1], 0., -fSize[2]/fNSegment[2]},
{ fSize[1]/fNSegment[1], 0., fSize[2]/fNSegment[2]},
{-fSize[1]/fNSegment[1], 0., fSize[2]/fNSegment[2]}};
G4int facets[][4] = {{1, 2, 3, 4}};
G4int facets2[][4] = {{4, 3, 2, 1}};
G4Polyhedron poly, poly2;
poly.createPolyhedron(4, 1, nodes, facets);
poly.Transform(trans);
poly.SetVisAttributes(att);
pVisManager->Draw(poly);
poly2.createPolyhedron(4, 1, nodes, facets2);
poly2.Transform(trans2);
poly2.SetVisAttributes(att);
pVisManager->Draw(poly2);
*/
}
}
pVisManager->EndDraw();
}
}
colorMap->SetPSUnit(fDrawUnit);
@@ -429,6 +532,7 @@ void G4ScoringBox::DrawColumn(std::map<G4int, G4double*> * map,
}
G4VVisManager * pVisManager = G4VVisManager::GetConcreteInstance();
if(pVisManager) {
pVisManager->BeginDraw();
// cell vectors
std::vector<std::vector<std::vector<double> > > cell; // cell[X][Y][Z]
@@ -490,16 +594,16 @@ void G4ScoringBox::DrawColumn(std::map<G4int, G4double*> * map,
G4VisAttributes att;
att.SetForceSolid(true);
att.SetForceAuxEdgeVisible(true);
G4Scale3D scale;
// xy plane
if(idxProj == 0) {
if(colorMap->IfFloatMinMax()) { colorMap->SetMinMax(xymin,xymax); }
G4Box xyplate("xy", fSize[0]/fNSegment[0], fSize[1]/fNSegment[1],
fSize[2]/fNSegment[2]);
for(int x = 0; x < fNSegment[0]; x++) {
for(int y = 0; y < fNSegment[1]; y++) {
G4Box xyplate("xy", fSize[0]/fNSegment[0], fSize[1]/fNSegment[1],
fSize[2]/fNSegment[2]);
G4ThreeVector pos(GetReplicaPosition(x, y, idxColumn));
G4Transform3D trans;
if(fRotationMatrix) {
@@ -510,19 +614,24 @@ void G4ScoringBox::DrawColumn(std::map<G4int, G4double*> * map,
}
G4double c[4];
colorMap->GetMapColor(xycell[x][y], c);
att.SetColour(c[0], c[1], c[2]);//, c[3]);
pVisManager->Draw(xyplate, att, trans);
att.SetColour(c[0], c[1], c[2]);
G4Polyhedron * poly = xyplate.GetPolyhedron();
poly->Transform(trans);
poly->SetVisAttributes(att);
pVisManager->Draw(*poly);
}
}
} else
// yz plane
if(idxProj == 1) {
if(colorMap->IfFloatMinMax()) { colorMap->SetMinMax(yzmin,yzmax); }
G4Box yzplate("yz", fSize[0]/fNSegment[0], fSize[1]/fNSegment[1],
fSize[2]/fNSegment[2]);
for(int y = 0; y < fNSegment[1]; y++) {
for(int z = 0; z < fNSegment[2]; z++) {
G4Box yzplate("yz", fSize[0]/fNSegment[0], fSize[1]/fNSegment[1],
fSize[2]/fNSegment[2]);
G4ThreeVector pos(GetReplicaPosition(idxColumn, y, z));
G4Transform3D trans;
if(fRotationMatrix) {
@@ -534,17 +643,22 @@ void G4ScoringBox::DrawColumn(std::map<G4int, G4double*> * map,
G4double c[4];
colorMap->GetMapColor(yzcell[y][z], c);
att.SetColour(c[0], c[1], c[2]);//, c[3]);
pVisManager->Draw(yzplate, att, trans);
G4Polyhedron * poly = yzplate.GetPolyhedron();
poly->Transform(trans);
poly->SetVisAttributes(att);
pVisManager->Draw(*poly);
}
}
} else
// xz plane
if(idxProj == 2) {
if(colorMap->IfFloatMinMax()) { colorMap->SetMinMax(xzmin,xzmax);}
G4Box xzplate("xz", fSize[0]/fNSegment[0], fSize[1]/fNSegment[1],
fSize[2]/fNSegment[2]);
for(int x = 0; x < fNSegment[0]; x++) {
for(int z = 0; z < fNSegment[2]; z++) {
G4Box xzplate("xz", fSize[0]/fNSegment[0], fSize[1]/fNSegment[1],
fSize[2]/fNSegment[2]);
G4ThreeVector pos(GetReplicaPosition(x, idxColumn, z));
G4Transform3D trans;
if(fRotationMatrix) {
@@ -556,10 +670,16 @@ void G4ScoringBox::DrawColumn(std::map<G4int, G4double*> * map,
G4double c[4];
colorMap->GetMapColor(xzcell[x][z], c);
att.SetColour(c[0], c[1], c[2]);//, c[3]);
pVisManager->Draw(xzplate, att, trans);
G4Polyhedron * poly = xzplate.GetPolyhedron();
poly->Transform(trans);
poly->SetVisAttributes(att);
pVisManager->Draw(*poly);
}
}
}
pVisManager->EndDraw();
}
colorMap->SetPSUnit(fDrawUnit);
+201 -176
View File
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4ScoringCylinder.cc 83518 2014-08-27 12:57:10Z gcosmo $
// $Id: G4ScoringCylinder.cc 89031 2015-03-18 08:40:48Z gcosmo $
//
#include "G4ScoringCylinder.hh"
@@ -206,7 +206,8 @@ void G4ScoringCylinder::List() const {
}
void G4ScoringCylinder::Draw(std::map<G4int, G4double*> * map, G4VScoreColorMap* colorMap, G4int axflg) {
void G4ScoringCylinder::Draw(std::map<G4int, G4double*> * map,
G4VScoreColorMap* colorMap, G4int axflg) {
G4VVisManager * pVisManager = G4VVisManager::GetConcreteInstance();
if(pVisManager) {
@@ -220,126 +221,135 @@ void G4ScoringCylinder::Draw(std::map<G4int, G4double*> * map, G4VScoreColorMap*
//-
std::vector<std::vector<double> > rphicell; // rphicell[R][PHI]
for(int r = 0; r < fNSegment[IR]; r++) rphicell.push_back(ephi);
// projections
G4int q[3];
std::map<G4int, G4double*>::iterator itr = map->begin();
for(; itr != map->end(); itr++) {
if(itr->first < 0) {
G4cout << itr->first << G4endl;
continue;
G4cout << itr->first << G4endl;
continue;
}
GetRZPhi(itr->first, q);
zphicell[q[IZ]][q[IPHI]] += *(itr->second)/fDrawUnitValue;
rphicell[q[IR]][q[IPHI]] += *(itr->second)/fDrawUnitValue;
}
}
// search min./max. values
G4double zphimin = DBL_MAX, rphimin = DBL_MAX;
G4double zphimax = 0., rphimax = 0.;
for(int iphi = 0; iphi < fNSegment[IPHI]; iphi++) {
for(int iz = 0; iz < fNSegment[IZ]; iz++) {
if(zphimin > zphicell[iz][iphi]) zphimin = zphicell[iz][iphi];
if(zphimax < zphicell[iz][iphi]) zphimax = zphicell[iz][iphi];
if(zphimin > zphicell[iz][iphi]) zphimin = zphicell[iz][iphi];
if(zphimax < zphicell[iz][iphi]) zphimax = zphicell[iz][iphi];
}
for(int ir = 0; ir < fNSegment[IR]; ir++) {
if(rphimin > rphicell[ir][iphi]) rphimin = rphicell[ir][iphi];
if(rphimax < rphicell[ir][iphi]) rphimax = rphicell[ir][iphi];
if(rphimin > rphicell[ir][iphi]) rphimin = rphicell[ir][iphi];
if(rphimax < rphicell[ir][iphi]) rphimax = rphicell[ir][iphi];
}
}
G4VisAttributes att;
att.SetForceSolid(true);
att.SetForceAuxEdgeVisible(true);
G4Scale3D scale;
if(axflg/100==1) {
// rz plane
}
axflg = axflg%100;
if(axflg/10==1) {
pVisManager->BeginDraw();
// z-phi plane
if(colorMap->IfFloatMinMax()) { colorMap->SetMinMax(zphimin, zphimax); }
G4double zhalf = fSize[1]/fNSegment[IZ];
for(int phi = 0; phi < fNSegment[IPHI]; phi++) {
for(int z = 0; z < fNSegment[IZ]; z++) {
//-
G4double angle = twopi/fNSegment[IPHI]*phi;
G4double dphi = twopi/fNSegment[IPHI];
G4Tubs cylinder("z-phi", // name
fSize[0]*0.99, fSize[0], // inner radius, outer radius
zhalf, // half length in z
angle, dphi*0.99999); // starting phi angle, delta angle
//-
G4ThreeVector zpos(0., 0., -fSize[1] + fSize[1]/fNSegment[IZ]*(1 + 2.*z));
G4Transform3D trans;
if(fRotationMatrix) {
trans = G4Rotate3D(*fRotationMatrix).inverse()*G4Translate3D(zpos);
trans = G4Translate3D(fCenterPosition)*trans;
} else {
trans = G4Translate3D(zpos)*G4Translate3D(fCenterPosition);
}
G4double c[4];
colorMap->GetMapColor(zphicell[z][phi], c);
att.SetColour(c[0], c[1], c[2]);//, c[3]);
//-
pVisManager->Draw(cylinder, att, trans);
}
for(int z = 0; z < fNSegment[IZ]; z++) {
//-
G4double angle = twopi/fNSegment[IPHI]*phi;
G4double dphi = twopi/fNSegment[IPHI];
G4Tubs cylinder("z-phi", // name
fSize[0]*0.99, fSize[0], // inner radius, outer radius
zhalf, // half length in z
angle, dphi*0.99999); // starting phi angle, delta angle
//-
G4ThreeVector zpos(0., 0., -fSize[1] + fSize[1]/fNSegment[IZ]*(1 + 2.*z));
G4Transform3D trans;
if(fRotationMatrix) {
trans = G4Rotate3D(*fRotationMatrix).inverse()*G4Translate3D(zpos);
trans = G4Translate3D(fCenterPosition)*trans;
} else {
trans = G4Translate3D(zpos)*G4Translate3D(fCenterPosition);
}
G4double c[4];
colorMap->GetMapColor(zphicell[z][phi], c);
att.SetColour(c[0], c[1], c[2]);//, c[3]);
//-
G4Polyhedron * poly = cylinder.GetPolyhedron();
poly->Transform(trans);
poly->SetVisAttributes(att);
pVisManager->Draw(*poly);
}
}
pVisManager->EndDraw();
}
axflg = axflg%10;
if(axflg==1) {
pVisManager->BeginDraw();
// r-phi plane
if(colorMap->IfFloatMinMax()) { colorMap->SetMinMax(rphimin, rphimax); }
G4double rsize = fSize[0]/fNSegment[IR];
for(int phi = 0; phi < fNSegment[IPHI]; phi++) {
for(int r = 0; r < fNSegment[IR]; r++) {
for(int r = 0; r < fNSegment[IR]; r++) {
G4double rs[2] = {rsize*r, rsize*(r+1)};
G4double angle = twopi/fNSegment[IPHI]*phi;
G4double dphi = twopi/fNSegment[IPHI];
G4Tubs cylindern("z-phi", rs[0], rs[1], 0.001,
angle, dphi*0.99999);
G4Tubs cylinderp = cylindern;
G4ThreeVector zposn(0., 0., -fSize[1]);
G4ThreeVector zposp(0., 0., fSize[1]);
G4Transform3D transn, transp;
if(fRotationMatrix) {
transn = G4Rotate3D(*fRotationMatrix).inverse()*G4Translate3D(zposn);
transn = G4Translate3D(fCenterPosition)*transn;
transp = G4Rotate3D(*fRotationMatrix).inverse()*G4Translate3D(zposp);
transp = G4Translate3D(fCenterPosition)*transp;
} else {
transn = G4Translate3D(zposn)*G4Translate3D(fCenterPosition);
transp = G4Translate3D(zposp)*G4Translate3D(fCenterPosition);
}
G4double c[4];
colorMap->GetMapColor(rphicell[r][phi], c);
att.SetColour(c[0], c[1], c[2]);//, c[3]);
G4double rs[2] = {rsize*r, rsize*(r+1)};
G4double angle = twopi/fNSegment[IPHI]*phi;
G4double dphi = twopi/fNSegment[IPHI];
G4Tubs cylinder("z-phi", rs[0], rs[1], 0.001,
angle, dphi*0.99999);
/*
G4cout << ">>>> "
<< rs[0] << " - " << rs[1] << " : "
<< angle << " - " << angle + dphi
<< G4endl;
*/
G4Polyhedron * polyn = cylindern.GetPolyhedron();
polyn->Transform(transn);
polyn->SetVisAttributes(att);
pVisManager->Draw(*polyn);
G4ThreeVector zposn(0., 0., -fSize[1]);
G4ThreeVector zposp(0., 0., fSize[1]);
G4Transform3D transn, transp;
if(fRotationMatrix) {
transn = G4Rotate3D(*fRotationMatrix).inverse()*G4Translate3D(zposn);
transn = G4Translate3D(fCenterPosition)*transn;
transp = G4Rotate3D(*fRotationMatrix).inverse()*G4Translate3D(zposp);
transp = G4Translate3D(fCenterPosition)*transp;
} else {
transn = G4Translate3D(zposn)*G4Translate3D(fCenterPosition);
transp = G4Translate3D(zposp)*G4Translate3D(fCenterPosition);
}
G4double c[4];
colorMap->GetMapColor(rphicell[r][phi], c);
att.SetColour(c[0], c[1], c[2]);//, c[3]);
/*
G4cout << " " << c[0] << ", "
<< c[1] << ", " << c[2] << G4endl;
*/
pVisManager->Draw(cylinder, att, transn);
pVisManager->Draw(cylinder, att, transp);
}
G4Polyhedron * polyp = cylinderp.GetPolyhedron();
polyp->Transform(transp);
polyp->SetVisAttributes(att);
pVisManager->Draw(*polyp);
}
}
pVisManager->EndDraw();
}
colorMap->SetPSUnit(fDrawUnit);
colorMap->SetPSName(fDrawPSName);
colorMap->DrawColorChart();
}
}
@@ -348,17 +358,17 @@ void G4ScoringCylinder::DrawColumn(std::map<G4int, G4double*> * map, G4VScoreCol
{
G4int projAxis = 0;
switch(idxProj) {
case 0:
projAxis = IR;
break;
case 1:
projAxis = IZ;
break;
case 2:
projAxis = IPHI;
break;
case 0:
projAxis = IR;
break;
case 1:
projAxis = IZ;
break;
case 2:
projAxis = IPHI;
break;
}
if(idxColumn<0 || idxColumn>=fNSegment[projAxis])
{
G4cerr << "Warning : Column number " << idxColumn << " is out of scoring mesh [0," << fNSegment[projAxis]-1 <<
@@ -367,7 +377,7 @@ void G4ScoringCylinder::DrawColumn(std::map<G4int, G4double*> * map, G4VScoreCol
}
G4VVisManager * pVisManager = G4VVisManager::GetConcreteInstance();
if(pVisManager) {
// cell vectors
std::vector<std::vector<std::vector<double> > > cell; // cell[R][Z][PHI]
std::vector<double> ephi;
@@ -375,163 +385,178 @@ void G4ScoringCylinder::DrawColumn(std::map<G4int, G4double*> * map, G4VScoreCol
std::vector<std::vector<double> > ezphi;
for(int z = 0; z < fNSegment[IZ]; z++) ezphi.push_back(ephi);
for(int r = 0; r < fNSegment[IR]; r++) cell.push_back(ezphi);
std::vector<std::vector<double> > rzcell; // rzcell[R][Z]
std::vector<double> ez;
for(int z = 0; z < fNSegment[IZ]; z++) ez.push_back(0.);
for(int r = 0; r < fNSegment[IR]; r++) rzcell.push_back(ez);
std::vector<std::vector<double> > zphicell; // zphicell[Z][PHI]
for(int z = 0; z < fNSegment[IZ]; z++) zphicell.push_back(ephi);
std::vector<std::vector<double> > rphicell; // rphicell[R][PHI]
for(int r = 0; r < fNSegment[IR]; r++) rphicell.push_back(ephi);
// projections
G4int q[3];
std::map<G4int, G4double*>::iterator itr = map->begin();
for(; itr != map->end(); itr++) {
if(itr->first < 0) {
G4cout << itr->first << G4endl;
continue;
G4cout << itr->first << G4endl;
continue;
}
GetRZPhi(itr->first, q);
if(projAxis == IR && q[IR] == idxColumn) { // zphi plane
zphicell[q[IZ]][q[IPHI]] += *(itr->second)/fDrawUnitValue;
zphicell[q[IZ]][q[IPHI]] += *(itr->second)/fDrawUnitValue;
}
if(projAxis == IZ && q[IZ] == idxColumn) { // rphi plane
rphicell[q[IR]][q[IPHI]] += *(itr->second)/fDrawUnitValue;
rphicell[q[IR]][q[IPHI]] += *(itr->second)/fDrawUnitValue;
}
if(projAxis == IPHI && q[IPHI] == idxColumn) { // rz plane
rzcell[q[IR]][q[IZ]] += *(itr->second)/fDrawUnitValue;
rzcell[q[IR]][q[IZ]] += *(itr->second)/fDrawUnitValue;
}
}
}
// search min./max. values
G4double rzmin = DBL_MAX, zphimin = DBL_MAX, rphimin = DBL_MAX;
G4double rzmax = 0., zphimax = 0., rphimax = 0.;
for(int r = 0; r < fNSegment[IR]; r++) {
for(int phi = 0; phi < fNSegment[IPHI]; phi++) {
if(rphimin > rphicell[r][phi]) rphimin = rphicell[r][phi];
if(rphimax < rphicell[r][phi]) rphimax = rphicell[r][phi];
if(rphimin > rphicell[r][phi]) rphimin = rphicell[r][phi];
if(rphimax < rphicell[r][phi]) rphimax = rphicell[r][phi];
}
for(int z = 0; z < fNSegment[IZ]; z++) {
if(rzmin > rzcell[r][z]) rzmin = rzcell[r][z];
if(rzmax < rzcell[r][z]) rzmax = rzcell[r][z];
if(rzmin > rzcell[r][z]) rzmin = rzcell[r][z];
if(rzmax < rzcell[r][z]) rzmax = rzcell[r][z];
}
}
for(int z = 0; z < fNSegment[IZ]; z++) {
for(int phi = 0; phi < fNSegment[IPHI]; phi++) {
if(zphimin > zphicell[z][phi]) zphimin = zphicell[z][phi];
if(zphimax < zphicell[z][phi]) zphimax = zphicell[z][phi];
if(zphimin > zphicell[z][phi]) zphimin = zphicell[z][phi];
if(zphimax < zphicell[z][phi]) zphimax = zphicell[z][phi];
}
}
G4VisAttributes att;
att.SetForceSolid(true);
att.SetForceAuxEdgeVisible(true);
pVisManager->BeginDraw();
G4Scale3D scale;
// z-phi plane
if(projAxis == IR) {
if(colorMap->IfFloatMinMax()) { colorMap->SetMinMax(zphimin,zphimax); }
G4double zhalf = fSize[1]/fNSegment[IZ];
G4double rsize[2] = {fSize[0]/fNSegment[IR]*idxColumn,
fSize[0]/fNSegment[IR]*(idxColumn+1)};
fSize[0]/fNSegment[IR]*(idxColumn+1)};
for(int phi = 0; phi < fNSegment[IPHI]; phi++) {
for(int z = 0; z < fNSegment[IZ]; z++) {
G4double angle = twopi/fNSegment[IPHI]*phi*radian;
G4double dphi = twopi/fNSegment[IPHI]*radian;
G4Tubs cylinder("z-phi", rsize[0], rsize[1], zhalf,
angle, dphi*0.99999);
G4ThreeVector zpos(0., 0., -fSize[1] + fSize[1]/fNSegment[IZ]*(1 + 2.*z));
G4Transform3D trans;
if(fRotationMatrix) {
trans = G4Rotate3D(*fRotationMatrix).inverse()*G4Translate3D(zpos);
trans = G4Translate3D(fCenterPosition)*trans;
} else {
trans = G4Translate3D(zpos)*G4Translate3D(fCenterPosition);
}
G4double c[4];
colorMap->GetMapColor(zphicell[z][phi], c);
att.SetColour(c[0], c[1], c[2]);//, c[3]);
pVisManager->Draw(cylinder, att, trans);
}
for(int z = 0; z < fNSegment[IZ]; z++) {
G4double angle = twopi/fNSegment[IPHI]*phi*radian;
G4double dphi = twopi/fNSegment[IPHI]*radian;
G4Tubs cylinder("z-phi", rsize[0], rsize[1], zhalf,
angle, dphi*0.99999);
G4ThreeVector zpos(0., 0., -fSize[1] + fSize[1]/fNSegment[IZ]*(1 + 2.*z));
G4Transform3D trans;
if(fRotationMatrix) {
trans = G4Rotate3D(*fRotationMatrix).inverse()*G4Translate3D(zpos);
trans = G4Translate3D(fCenterPosition)*trans;
} else {
trans = G4Translate3D(zpos)*G4Translate3D(fCenterPosition);
}
G4double c[4];
colorMap->GetMapColor(zphicell[z][phi], c);
att.SetColour(c[0], c[1], c[2]);//, c[3]);
G4Polyhedron * poly = cylinder.GetPolyhedron();
poly->Transform(trans);
poly->SetVisAttributes(att);
pVisManager->Draw(*poly);
}
}
// r-phi plane
} else if(projAxis == IZ) {
if(colorMap->IfFloatMinMax()) { colorMap->SetMinMax(rphimin,rphimax); }
G4double rsize = fSize[0]/fNSegment[IR];
for(int phi = 0; phi < fNSegment[IPHI]; phi++) {
for(int r = 0; r < fNSegment[IR]; r++) {
for(int r = 0; r < fNSegment[IR]; r++) {
G4double rs[2] = {rsize*r, rsize*(r+1)};
G4double angle = twopi/fNSegment[IPHI]*phi*radian;
G4double dz = fSize[1]/fNSegment[IZ];
G4double dphi = twopi/fNSegment[IPHI]*radian;
G4Tubs cylinder("r-phi", rs[0], rs[1], dz,
angle, dphi*0.99999);
G4ThreeVector zpos(0., 0.,
-fSize[1]+fSize[1]/fNSegment[IZ]*(idxColumn*2+1));
G4Transform3D trans;
if(fRotationMatrix) {
trans = G4Rotate3D(*fRotationMatrix).inverse()*G4Translate3D(zpos);
trans = G4Translate3D(fCenterPosition)*trans;
} else {
trans = G4Translate3D(zpos)*G4Translate3D(fCenterPosition);
}
G4double c[4];
colorMap->GetMapColor(rphicell[r][phi], c);
att.SetColour(c[0], c[1], c[2]);//, c[3]);
G4double rs[2] = {rsize*r, rsize*(r+1)};
G4double angle = twopi/fNSegment[IPHI]*phi*radian;
G4double dz = fSize[1]/fNSegment[IZ];
G4double dphi = twopi/fNSegment[IPHI]*radian;
G4Tubs cylinder("r-phi", rs[0], rs[1], dz,
angle, dphi*0.99999);
G4ThreeVector zpos(0., 0.,
-fSize[1]+fSize[1]/fNSegment[IZ]*(idxColumn*2+1));
G4Transform3D trans;
if(fRotationMatrix) {
trans = G4Rotate3D(*fRotationMatrix).inverse()*G4Translate3D(zpos);
trans = G4Translate3D(fCenterPosition)*trans;
} else {
trans = G4Translate3D(zpos)*G4Translate3D(fCenterPosition);
}
G4double c[4];
colorMap->GetMapColor(rphicell[r][phi], c);
att.SetColour(c[0], c[1], c[2]);//, c[3]);
pVisManager->Draw(cylinder, att, trans);
}
G4Polyhedron * poly = cylinder.GetPolyhedron();
poly->Transform(trans);
poly->SetVisAttributes(att);
pVisManager->Draw(*poly);
}
}
// r-z plane
} else if(projAxis == IPHI) {
if(colorMap->IfFloatMinMax()) { colorMap->SetMinMax(rzmin,rzmax); }
G4double rsize = fSize[0]/fNSegment[IR];
G4double zhalf = fSize[1]/fNSegment[IZ];
G4double angle = twopi/fNSegment[IPHI]*idxColumn*radian;
G4double dphi = twopi/fNSegment[IPHI]*radian;
for(int z = 0; z < fNSegment[IZ]; z++) {
for(int r = 0; r < fNSegment[IR]; r++) {
for(int r = 0; r < fNSegment[IR]; r++) {
G4double rs[2] = {rsize*r, rsize*(r+1)};
G4Tubs cylinder("z-phi", rs[0], rs[1], zhalf,
angle, dphi);
G4ThreeVector zpos(0., 0.,
-fSize[1]+fSize[1]/fNSegment[IZ]*(2.*z+1));
G4Transform3D trans;
if(fRotationMatrix) {
trans = G4Rotate3D(*fRotationMatrix).inverse()*G4Translate3D(zpos);
trans = G4Translate3D(fCenterPosition)*trans;
} else {
trans = G4Translate3D(zpos)*G4Translate3D(fCenterPosition);
}
G4double c[4];
colorMap->GetMapColor(rzcell[r][z], c);
att.SetColour(c[0], c[1], c[2]);//, c[3]);
G4double rs[2] = {rsize*r, rsize*(r+1)};
G4Tubs cylinder("z-phi", rs[0], rs[1], zhalf,
angle, dphi);
G4ThreeVector zpos(0., 0.,
-fSize[1]+fSize[1]/fNSegment[IZ]*(2.*z+1));
G4Transform3D trans;
if(fRotationMatrix) {
trans = G4Rotate3D(*fRotationMatrix).inverse()*G4Translate3D(zpos);
trans = G4Translate3D(fCenterPosition)*trans;
} else {
trans = G4Translate3D(zpos)*G4Translate3D(fCenterPosition);
}
G4double c[4];
colorMap->GetMapColor(rzcell[r][z], c);
att.SetColour(c[0], c[1], c[2]);//, c[3]);
pVisManager->Draw(cylinder, att, trans);
}
G4Polyhedron * poly = cylinder.GetPolyhedron();
poly->Transform(trans);
poly->SetVisAttributes(att);
pVisManager->Draw(*poly);
}
}
}
pVisManager->EndDraw();
}
colorMap->SetPSUnit(fDrawUnit);
colorMap->SetPSName(fDrawPSName);
colorMap->DrawColorChart();
}
void G4ScoringCylinder::GetRZPhi(G4int index, G4int q[3]) const {
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4VScoreColorMap.cc 67992 2013-03-13 10:59:57Z gcosmo $
// $Id: G4VScoreColorMap.cc 89185 2015-03-23 16:11:02Z gcosmo $
//
#include "G4VScoreColorMap.hh"
@@ -38,6 +38,7 @@
#include "G4Circle.hh"
#include "G4Polyline.hh"
#include "G4Colour.hh"
#include "G4Polyhedron.hh"
G4VScoreColorMap::G4VScoreColorMap(G4String mName)
:fName(mName),ifFloat(true),fMinVal(0.),fMaxVal(DBL_MAX),fVisManager(0)
@@ -64,6 +65,9 @@ void G4VScoreColorMap::DrawColorChartBar(G4int _nPoint) {
G4double max = this->GetMax();
G4double smin = -0.89, smax = smin + 0.05*(_nPoint)*0.83, step=0.001;
G4double c[4];
fVisManager->BeginDraw2D();
for(G4double y = smin; y < smax; y+=step) {
G4double ra = (y-smin)/(smax-smin), rb = 1.-ra;
G4Polyline line;
@@ -75,26 +79,33 @@ void G4VScoreColorMap::DrawColorChartBar(G4int _nPoint) {
line.SetVisAttributes(&att);
fVisManager->Draw2D(line);
}
fVisManager->EndDraw2D();
}
void G4VScoreColorMap::DrawColorChartText(G4int _nPoint) {
G4double min = this->GetMin();
G4double max = this->GetMax();
G4double c[4];
G4Colour black(0., 0., 0.);
G4Colour black(0.1, 0.1, 0.1, 0.8);
fVisManager->BeginDraw2D();
for(int n = 0; n < _nPoint; n++) {
G4double a = n/(_nPoint-1.), b = 1.-a;
G4double v = (a*max + b*min)/(a+b);
// background color
for(int l = 0; l < 21; l++) {
G4Polyline line;
line.push_back(G4Point3D(-0.908, -0.905+0.05*n+0.002*l, 0.));
line.push_back(G4Point3D(-0.705, -0.905+0.05*n+0.002*l, 0.));
line.push_back(G4Point3D(-0.9, -0.905+0.05*n+0.002*l, 0.));
line.push_back(G4Point3D(-0.75, -0.905+0.05*n+0.002*l, 0.));
G4VisAttributes attblack(black);
line.SetVisAttributes(&attblack);
fVisManager->Draw2D(line);
}
// text
//char cstring[80];
//std::sprintf(cstring, "%8.2e", v);
@@ -102,13 +113,14 @@ void G4VScoreColorMap::DrawColorChartText(G4int _nPoint) {
std::ostringstream oss;
oss << std::setw(8) << std::setprecision(1) << std::scientific << v;
std::string str = oss.str();
G4String value(str.c_str());
G4String value = str;//.c_str());
G4Text text(value, G4Point3D(-0.9, -0.9+0.05*n, 0));
G4Text text(value, G4Point3D(-0.9, -0.9+0.05*n, 0.4));
G4double size = 12.;
text.SetScreenSize(size);
this->GetMapColor(v, c);
G4Colour color(c[0], c[1], c[2]);
G4Colour color(c[0], c[1], c[2], 1.);
G4VisAttributes att(color);
text.SetVisAttributes(&att);
@@ -117,43 +129,46 @@ void G4VScoreColorMap::DrawColorChartText(G4int _nPoint) {
// draw ps name
// background
G4int lpsname = 20;//fPSName.size();
G4double lpsname = 2.+fPSName.size()*0.95;
if(lpsname > 0) {
for(int l = 0; l < 22; l++) {
G4Polyline line;
line.push_back(G4Point3D(-0.9, -0.965+0.002*l, 0.));
line.push_back(G4Point3D(-0.9+0.025*lpsname, -0.965+0.002*l, 0.));
line.push_back(G4Point3D(-0.92, -0.965+0.002*l, 0.));
line.push_back(G4Point3D(-0.92+0.025*lpsname, -0.965+0.002*l, 0.));
G4VisAttributes attblack(black);
//G4VisAttributes attblack(G4Colour(.5, .5, 1.));
line.SetVisAttributes(&attblack);
fVisManager->Draw2D(line);
}
// ps name
G4Text txtpsname(fPSName, G4Point3D(-0.9, -0.96, 0.));
G4Text txtpsname(fPSName, G4Point3D(-0.9, -0.96, 0.1));
G4double size = 12.;
txtpsname.SetScreenSize(size);
G4Colour color(1., 1., 1.);
G4VisAttributes att(color);
txtpsname.SetVisAttributes(&att);
fVisManager->Draw2D(txtpsname);
}
// draw unit
// background
G4int len = fPSUnit.size();
G4double len = 2.+fPSUnit.size();
if(len > 0) {
for(int l = 0; l < 21; l++) {
G4Polyline line;
line.push_back(G4Point3D(-0.7, -0.9+0.002*l, 0.));
line.push_back(G4Point3D(-0.7+0.3, -0.9+0.002*l, 0.));
line.push_back(G4Point3D(-0.7+0.025*len, -0.9+0.002*l, 0.));
G4VisAttributes attblack(black);
//G4VisAttributes attblack(G4Colour(.5, .5, .5));
line.SetVisAttributes(&attblack);
fVisManager->Draw2D(line);
}
// unit
G4String psunit = "[" + fPSUnit + "]";
G4Text txtunit(psunit, G4Point3D(-0.69, -0.9, 0.));
G4Text txtunit(psunit, G4Point3D(-0.69, -0.9, 0.1));
G4double size = 12.;
txtunit.SetScreenSize(size);
G4Colour color(1., 1., 1.);
@@ -161,5 +176,8 @@ void G4VScoreColorMap::DrawColorChartText(G4int _nPoint) {
txtunit.SetVisAttributes(&att);
fVisManager->Draw2D(txtunit);
}
fVisManager->EndDraw2D();
}