G4ScoringBox.cc

Go to the documentation of this file.
00001 //
00002 // ********************************************************************
00003 // * License and Disclaimer                                           *
00004 // *                                                                  *
00005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
00006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
00007 // * conditions of the Geant4 Software License,  included in the file *
00008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
00009 // * include a list of copyright holders.                             *
00010 // *                                                                  *
00011 // * Neither the authors of this software system, nor their employing *
00012 // * institutes,nor the agencies providing financial support for this *
00013 // * work  make  any representation or  warranty, express or implied, *
00014 // * regarding  this  software system or assume any liability for its *
00015 // * use.  Please see the license in the file  LICENSE  and URL above *
00016 // * for the full disclaimer and the limitation of liability.         *
00017 // *                                                                  *
00018 // * This  code  implementation is the result of  the  scientific and *
00019 // * technical work of the GEANT4 collaboration.                      *
00020 // * By using,  copying,  modifying or  distributing the software (or *
00021 // * any work based  on the software)  you  agree  to acknowledge its *
00022 // * use  in  resulting  scientific  publications,  and indicate your *
00023 // * acceptance of all terms of the Geant4 Software license.          *
00024 // ********************************************************************
00025 //
00026 //
00027 // $Id$
00028 //
00029 
00030 #include "G4ScoringBox.hh"
00031 
00032 #include "G4SystemOfUnits.hh"
00033 #include "G4Box.hh"
00034 #include "G4LogicalVolume.hh"
00035 #include "G4VPhysicalVolume.hh"
00036 #include "G4PVPlacement.hh"
00037 #include "G4PVReplica.hh"
00038 #include "G4PVDivision.hh"
00039 #include "G4VisAttributes.hh"
00040 #include "G4VVisManager.hh"
00041 #include "G4VScoreColorMap.hh"
00042 
00043 #include "G4MultiFunctionalDetector.hh"
00044 #include "G4SDParticleFilter.hh"
00045 #include "G4VPrimitiveScorer.hh"
00046 
00047 #include "G4ScoringManager.hh"
00048 
00049 #include <map>
00050 #include <fstream>
00051 
00052 G4ScoringBox::G4ScoringBox(G4String wName)
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 }
00061 
00062 G4ScoringBox::~G4ScoringBox()
00063 {
00064 }
00065 
00066 void G4ScoringBox::Construct(G4VPhysicalVolume* fWorldPhys)
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 }
00079 
00080 
00081 
00082 void G4ScoringBox::SetupGeometry(G4VPhysicalVolume * fWorldPhys) {
00083 
00084   if(verboseLevel > 9) G4cout << "G4ScoringBox::SetupGeometry() ..." << G4endl;
00085 
00086   // World
00087   G4VPhysicalVolume * scoringWorld = fWorldPhys;
00088   G4LogicalVolume * worldLogical = scoringWorld->GetLogicalVolume();
00089 
00090   // Scoring Mesh
00091   if(verboseLevel > 9) G4cout << fWorldName << G4endl;
00092   G4String boxName = fWorldName;
00093 
00094   if(verboseLevel > 9) G4cout << fSize[0] << ", " << fSize[1] << ", " << fSize[2] << G4endl;
00095   G4VSolid * boxSolid = new G4Box(boxName+"0", fSize[0], fSize[1], fSize[2]);
00096   G4LogicalVolume *  boxLogical = new G4LogicalVolume(boxSolid, 0, boxName);
00097   new G4PVPlacement(fRotationMatrix, fCenterPosition,
00098                     boxLogical, boxName+"0", worldLogical, false, 0);
00099 
00100   //G4double fsegment[3][3];
00101   //G4int segOrder[3];
00102   //GetSegmentOrder(fSegmentDirection, fNSegment, segOrder, fsegment);
00103   //EAxis axis[3] = {kXAxis, kYAxis, kZAxis};
00104 
00105   G4String layerName[2] = {boxName + "1",  boxName + "2"};
00106   G4VSolid * layerSolid[2]; 
00107   G4LogicalVolume * layerLogical[2];
00108 
00109   //-- fisrt nested layer (replicated to x direction)
00110   if(verboseLevel > 9) G4cout << "layer 1 :" << G4endl;
00111   layerSolid[0] = new G4Box(layerName[0],
00112                             fSize[0]/fNSegment[0],
00113                             fSize[1],
00114                             fSize[2]);
00115   layerLogical[0] = new G4LogicalVolume(layerSolid[0], 0, layerName[0]);
00116   if(fNSegment[0] > 1) {
00117     if(verboseLevel > 9) G4cout << "G4ScoringBox::Construct() : Replicate to x direction" << G4endl;
00118     if(G4ScoringManager::GetReplicaLevel()>0)
00119     {
00120       new G4PVReplica(layerName[0], layerLogical[0], boxLogical, kXAxis,
00121                     fNSegment[0], fSize[0]/fNSegment[0]*2.);
00122     }
00123     else
00124     {
00125       new G4PVDivision(layerName[0], layerLogical[0], boxLogical, kXAxis,
00126                     fNSegment[0], 0.);
00127     }
00128   } else if(fNSegment[0] == 1) {
00129     if(verboseLevel > 9) G4cout << "G4ScoringBox::Construct() : Placement" << G4endl;
00130     new G4PVPlacement(0, G4ThreeVector(0.,0.,0.), layerLogical[0], layerName[0], boxLogical, false, 0);
00131   } else
00132     G4cerr << "ERROR : G4ScoringBox::SetupGeometry() : invalid parameter ("
00133            << fNSegment[0] << ") "
00134            << "in placement of the first nested layer." << G4endl;
00135 
00136   if(verboseLevel > 9) {
00137     G4cout << fSize[0]/fNSegment[0] << ", "
00138            << fSize[1] << ", "
00139            << fSize[2] << G4endl;
00140     G4cout << layerName[0] << ": kXAxis, "
00141            << fNSegment[0] << ", "
00142            << 2.*fSize[0]/fNSegment[0] << G4endl;
00143   }
00144 
00145   // second nested layer (replicated to y direction)
00146   if(verboseLevel > 9) G4cout << "layer 2 :" << G4endl;
00147   layerSolid[1] = new G4Box(layerName[1],
00148                             fSize[0]/fNSegment[0],
00149                             fSize[1]/fNSegment[1],
00150                             fSize[2]);
00151   layerLogical[1] = new G4LogicalVolume(layerSolid[1], 0, layerName[1]);
00152   if(fNSegment[1] > 1) {
00153     if(verboseLevel > 9) G4cout << "G4ScoringBox::Construct() : Replicate to y direction" << G4endl;
00154     if(G4ScoringManager::GetReplicaLevel()>1)
00155     {
00156       new G4PVReplica(layerName[1], layerLogical[1], layerLogical[0], kYAxis,
00157                     fNSegment[1], fSize[1]/fNSegment[1]*2.);
00158     }
00159     else
00160     {
00161       new G4PVDivision(layerName[1], layerLogical[1], layerLogical[0], kYAxis,
00162                     fNSegment[1], 0.);
00163     }
00164   } else if(fNSegment[1] == 1) {
00165     if(verboseLevel > 9) G4cout << "G4ScoringBox::Construct() : Placement" << G4endl;
00166     new G4PVPlacement(0, G4ThreeVector(0.,0.,0.), layerLogical[1], layerName[1], layerLogical[0], false, 0);
00167   } else
00168     G4cerr << "ERROR : G4ScoringBox::SetupGeometry() : invalid parameter ("
00169            << fNSegment[1] << ") "
00170            << "in placement of the second nested layer." << G4endl;
00171 
00172   if(verboseLevel > 9) {
00173     G4cout << fSize[0]/fNSegment[0] << ", "
00174            << fSize[1]/fNSegment[1] << ", "
00175            << fSize[2] << G4endl;
00176     G4cout << layerName[1] << ": kYAxis, "
00177            << fNSegment[1] << ", "
00178            << 2.*fSize[1]/fNSegment[1] << G4endl;
00179   }
00180 
00181   // mesh elements (replicated to z direction)
00182   if(verboseLevel > 9) G4cout << "mesh elements :" << G4endl;
00183   G4String elementName = boxName +"3";
00184   G4VSolid * elementSolid = new G4Box(elementName,
00185                                       fSize[0]/fNSegment[0],
00186                                       fSize[1]/fNSegment[1],
00187                                       fSize[2]/fNSegment[2]);
00188   fMeshElementLogical = new G4LogicalVolume(elementSolid, 0, elementName);
00189   if(fNSegment[2] > 1) {
00190     if(verboseLevel > 9) G4cout << "G4ScoringBox::Construct() : Replicate to z direction" << G4endl;
00191 
00192     if(G4ScoringManager::GetReplicaLevel()>2) 
00193     { 
00194       new G4PVReplica(elementName, fMeshElementLogical, layerLogical[1], kZAxis,
00195                       fNSegment[2], 2.*fSize[2]/fNSegment[2]);
00196     }
00197     else
00198     {
00199       new G4PVDivision(elementName, fMeshElementLogical, layerLogical[1], kZAxis,
00200                        fNSegment[2], 0.);
00201     }
00202   } else if(fNSegment[2] == 1) {
00203     if(verboseLevel > 9) G4cout << "G4ScoringBox::Construct() : Placement" << G4endl;
00204     new G4PVPlacement(0, G4ThreeVector(0.,0.,0.), fMeshElementLogical, elementName, layerLogical[1], false, 0);
00205   } else
00206     G4cerr << "ERROR : G4ScoringBox::SetupGeometry() : "
00207            << "invalid parameter (" << fNSegment[2] << ") "
00208            << "in mesh element placement." << G4endl;
00209 
00210   if(verboseLevel > 9) {
00211     G4cout << fSize[0]/fNSegment[0] << ", "
00212            << fSize[1]/fNSegment[1] << ", "
00213            << fSize[2]/fNSegment[2] << G4endl;
00214     G4cout << elementName << ": kZAxis, "
00215            << fNSegment[2] << ", "
00216            << 2.*fSize[2]/fNSegment[2] << G4endl;
00217   }
00218 
00219 
00220   // set the sensitive detector
00221   fMeshElementLogical->SetSensitiveDetector(fMFD);
00222   
00223 
00224   // vis. attributes
00225   G4VisAttributes * visatt = new G4VisAttributes(G4Colour(.5,.5,.5));
00226   visatt->SetVisibility(false);
00227   layerLogical[0]->SetVisAttributes(visatt);
00228   layerLogical[1]->SetVisAttributes(visatt);
00229   visatt->SetVisibility(true);
00230   fMeshElementLogical->SetVisAttributes(visatt);
00231 }
00232 
00233 
00234 void G4ScoringBox::List() const {
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 }
00244 
00245 void G4ScoringBox::Draw(std::map<G4int, G4double*> * map, G4VScoreColorMap* colorMap, G4int axflg) {
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 }
00397 
00398 G4ThreeVector G4ScoringBox::GetReplicaPosition(G4int x, G4int y, G4int z) {
00399 
00400   G4ThreeVector width(fSize[0]/fNSegment[0], fSize[1]/fNSegment[1], fSize[2]/fNSegment[2]);
00401   G4ThreeVector pos(-fSize[0] + 2*(x+0.5)*width.x(),
00402                     -fSize[1] + 2*(y+0.5)*width.y(),
00403                     -fSize[2] + 2*(z+0.5)*width.z());
00404 
00405   return pos;
00406 }
00407 
00408 void G4ScoringBox::GetXYZ(G4int index, G4int q[3]) const {
00409 
00410   q[0] = index/(fNSegment[2]*fNSegment[1]);
00411   q[1] = (index - q[0]*fNSegment[2]*fNSegment[1])/fNSegment[2];
00412   q[2] = index - q[1]*fNSegment[2] - q[0]*fNSegment[2]*fNSegment[1];
00413 
00414 }
00415 
00416 G4int G4ScoringBox::GetIndex(G4int x, G4int y, G4int z) const {
00417   return x + y*fNSegment[0] + z*fNSegment[0]*fNSegment[1];
00418 }
00419 
00420 void G4ScoringBox::DrawColumn(std::map<G4int, G4double*> * map, G4VScoreColorMap* colorMap,
00421                               G4int idxProj, G4int idxColumn) 
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 }
00565 
00566 

Generated on Mon May 27 17:49:48 2013 for Geant4 by  doxygen 1.4.7