G4ScoringCylinder.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 "G4ScoringCylinder.hh"
00031 
00032 #include "G4PhysicalConstants.hh"
00033 #include "G4SystemOfUnits.hh"
00034 #include "G4VPhysicalVolume.hh"
00035 #include "G4Tubs.hh"
00036 #include "G4LogicalVolume.hh"
00037 #include "G4VPhysicalVolume.hh"
00038 #include "G4PVPlacement.hh"
00039 #include "G4PVReplica.hh"
00040 #include "G4PVDivision.hh"
00041 #include "G4VisAttributes.hh"
00042 #include "G4VVisManager.hh"
00043 #include "G4VScoreColorMap.hh"
00044 
00045 #include "G4SDManager.hh"
00046 #include "G4MultiFunctionalDetector.hh"
00047 #include "G4SDParticleFilter.hh"
00048 #include "G4VPrimitiveScorer.hh"
00049 #include "G4PSEnergyDeposit.hh"
00050 #include "G4PSTrackLength.hh"
00051 #include "G4PSNofStep.hh"
00052 #include "G4ScoringManager.hh"
00053 
00054 
00055 G4ScoringCylinder::G4ScoringCylinder(G4String wName)
00056   :G4VScoringMesh(wName), fMeshElementLogical(0)
00057 {
00058   fShape = cylinderMesh;
00059 
00060   fDivisionAxisNames[0] = "Z";
00061   fDivisionAxisNames[1] = "PHI";
00062   fDivisionAxisNames[2] = "R";
00063 }
00064 
00065 G4ScoringCylinder::~G4ScoringCylinder()
00066 {;}
00067 
00068 void G4ScoringCylinder::Construct(G4VPhysicalVolume* fWorldPhys)
00069 {
00070   if(fConstructed) {
00071 
00072     if(verboseLevel > 0) 
00073       G4cout << fWorldPhys->GetName() << " --- All quantities are reset." << G4endl;
00074     ResetScore();
00075 
00076   } else {
00077     fConstructed = true;
00078     SetupGeometry(fWorldPhys);
00079   }
00080 }
00081 
00082 
00083 
00084 void G4ScoringCylinder::SetupGeometry(G4VPhysicalVolume * fWorldPhys) {
00085 
00086   if(verboseLevel > 9) G4cout << "G4ScoringCylinder::SetupGeometry() ..." << G4endl;
00087 
00088   // World
00089   G4VPhysicalVolume * scoringWorld = fWorldPhys;
00090   G4LogicalVolume * worldLogical = scoringWorld->GetLogicalVolume();
00091 
00092   // Scoring Mesh
00093   if(verboseLevel > 9) G4cout << fWorldName << G4endl;
00094   G4String tubsName = fWorldName+"_mesh";
00095 
00096   if(verboseLevel > 9) G4cout << "R max., Dz =: " << fSize[0] << ", " << fSize[1] << G4endl;
00097   G4VSolid * tubsSolid = new G4Tubs(tubsName+"0", // name
00098                                     0.,           // R min
00099                                     fSize[0],     // R max
00100                                     fSize[1],     // Dz
00101                                     0.,           // starting phi
00102                                     twopi*rad);   // segment phi
00103   G4LogicalVolume *  tubsLogical = new G4LogicalVolume(tubsSolid, 0, tubsName);
00104   new G4PVPlacement(fRotationMatrix, fCenterPosition,
00105                     tubsLogical, tubsName+"0", worldLogical, false, 0);
00106 
00107   if(verboseLevel > 9) G4cout << " # of segments : r, phi, z =: "
00108          << fNSegment[IR] << ", " << fNSegment[IPHI] << ", " << fNSegment[IZ] << G4endl;
00109 
00110   G4String layerName[2] = {tubsName + "1",  tubsName + "2"};
00111   G4VSolid * layerSolid[2]; 
00112   G4LogicalVolume * layerLogical[2];
00113 
00114   //-- fisrt nested layer (replicated along z direction)
00115   if(verboseLevel > 9) G4cout << "layer 1 :" << G4endl;
00116   layerSolid[0] = new G4Tubs(layerName[0],           // name
00117                              0.,                     // inner radius
00118                              fSize[0],               // outer radius
00119                              fSize[1]/fNSegment[IZ], // half len. in z
00120                              0.,                     // starting phi angle
00121                              twopi*rad);             // delta angle of the segment
00122   layerLogical[0] = new G4LogicalVolume(layerSolid[0], 0, layerName[0]);
00123   if(fNSegment[IZ] > 1) {
00124     if(verboseLevel > 9) G4cout << "G4ScoringCylinder::Construct() : Replicate along z direction" << G4endl;
00125     if(G4ScoringManager::GetReplicaLevel()>0) {
00126       if(verboseLevel > 9) G4cout << "G4ScoringCylinder::Construct() : Replica" << G4endl;
00127       new G4PVReplica(layerName[0], layerLogical[0], tubsLogical, kZAxis, fNSegment[IZ], 2.*fSize[1]/fNSegment[IZ]);
00128     } else {
00129       if(verboseLevel > 9) G4cout << "G4ScoringCylinder::Construct() : Division" << G4endl;
00130       new G4PVDivision(layerName[0], layerLogical[0], tubsLogical, kZAxis, fNSegment[IZ], 0.);
00131     }
00132   } else if(fNSegment[IZ] == 1) {
00133     if(verboseLevel > 9) G4cout << "G4ScoringCylinder::Construct() : Placement" << G4endl;
00134     new G4PVPlacement(0, G4ThreeVector(0.,0.,0.), layerLogical[0], layerName[0], tubsLogical, false, 0);
00135   } else {
00136     G4cerr << "G4ScoringCylinder::SetupGeometry() : invalid parameter ("
00137            << fNSegment[IZ] << ") "
00138            << "in placement of the first nested layer." << G4endl;
00139   }
00140 
00141   // second nested layer (replicated along phi direction)
00142   if(verboseLevel > 9) G4cout << "layer 2 :" << G4endl;
00143   layerSolid[1] = new G4Tubs(layerName[1],
00144                              0.,
00145                              fSize[0],
00146                              fSize[1]/fNSegment[IZ],
00147                              0.,
00148                              twopi*rad/fNSegment[IPHI]);
00149   layerLogical[1] = new G4LogicalVolume(layerSolid[1], 0, layerName[1]);
00150   if(fNSegment[IPHI] > 1)  {
00151     if(verboseLevel > 9) G4cout << "G4ScoringCylinder::Construct() : Replicate along phi direction" << G4endl;
00152     if(G4ScoringManager::GetReplicaLevel()>1) {
00153       if(verboseLevel > 9) G4cout << "G4ScoringCylinder::Construct() : Replica" << G4endl;
00154       new G4PVReplica(layerName[1], layerLogical[1], layerLogical[0], kPhi,
00155                       fNSegment[IPHI], twopi*rad/fNSegment[IPHI]);
00156     } else {
00157       if(verboseLevel > 9) G4cout << "G4ScoringCylinder::Construct() : Division" << G4endl;
00158       new G4PVDivision(layerName[1], layerLogical[1], layerLogical[0], kPhi, fNSegment[IPHI], 0.);
00159     }
00160   } else if(fNSegment[IPHI] == 1) {
00161     if(verboseLevel > 9) G4cout << "G4ScoringCylinder::Construct() : Placement" << G4endl;
00162     new G4PVPlacement(0, G4ThreeVector(0.,0.,0.), layerLogical[1], layerName[1], layerLogical[0], false, 0);
00163   } else
00164     G4cerr << "ERROR : G4ScoringCylinder::SetupGeometry() : invalid parameter ("
00165            << fNSegment[IPHI] << ") "
00166            << "in placement of the second nested layer." << G4endl;
00167 
00168   // mesh elements
00169   if(verboseLevel > 9) G4cout << "mesh elements :" << G4endl;
00170   G4String elementName = tubsName +"3";
00171   G4VSolid * elementSolid = new G4Tubs(elementName,
00172                                        0.,
00173                                        fSize[0]/fNSegment[IR],
00174                                        fSize[1]/fNSegment[IZ],
00175                                        0.,
00176                                        twopi*rad/fNSegment[IPHI]);
00177   fMeshElementLogical = new G4LogicalVolume(elementSolid, 0, elementName);
00178   if(fNSegment[IR] > 1) {
00179 
00180     if(verboseLevel > 9) G4cout << "G4ScoringCylinder::Construct() : Replicate along r direction" << G4endl;
00181 
00182     if(G4ScoringManager::GetReplicaLevel()>2) {
00183       if(verboseLevel > 9) G4cout << "G4ScoringCylinder::Construct() : Replica" << G4endl;
00184       new G4PVReplica(elementName, fMeshElementLogical, layerLogical[1], kRho,
00185                         fNSegment[IR], fSize[0]/fNSegment[IR]);
00186     } else {
00187       if(verboseLevel > 9) G4cout << "G4ScoringCylinder::Construct() : Division" << G4endl;
00188       new G4PVDivision(elementName, fMeshElementLogical, layerLogical[1], kRho, fNSegment[IR], 0.);
00189     }
00190   } else if(fNSegment[IR] == 1) {
00191     if(verboseLevel > 9) G4cout << "G4ScoringCylinder::Construct() : Placement" << G4endl;
00192     new G4PVPlacement(0, G4ThreeVector(0.,0.,0.), fMeshElementLogical, elementName, layerLogical[1], false, 0);
00193   } else {
00194     G4cerr << "G4ScoringCylinder::SetupGeometry() : "
00195            << "invalid parameter (" << fNSegment[IR] << ") "
00196            << "in mesh element placement." << G4endl;
00197   }
00198 
00199   // set the sensitive detector
00200   fMeshElementLogical->SetSensitiveDetector(fMFD);
00201   
00202 
00203   // vis. attributes
00204   G4VisAttributes * visatt = new G4VisAttributes(G4Colour(.5,.5,.5));
00205   visatt->SetVisibility(true);
00206   layerLogical[0]->SetVisAttributes(visatt);
00207   layerLogical[1]->SetVisAttributes(visatt);
00208   visatt = new G4VisAttributes(G4Colour(.5,.5,.5,0.01));
00209   //visatt->SetForceSolid(true);
00210   fMeshElementLogical->SetVisAttributes(visatt);
00211 }
00212 
00213 void G4ScoringCylinder::List() const {
00214   G4cout << "G4ScoringCylinder : " << fWorldName << " --- Shape: Cylindrical mesh" << G4endl;
00215 
00216   G4cout << " Size (R, Dz): ("
00217          << fSize[0]/cm << ", "
00218          << fSize[1]/cm << ") [cm]"
00219          << G4endl;
00220 
00221   G4VScoringMesh::List();
00222 }
00223 
00224 
00225 void G4ScoringCylinder::Draw(std::map<G4int, G4double*> * map, G4VScoreColorMap* colorMap, G4int axflg) {
00226 
00227   G4VVisManager * pVisManager = G4VVisManager::GetConcreteInstance();
00228   if(pVisManager) {
00229     
00230     // cell vectors
00231     std::vector<double> ephi;
00232     for(int phi = 0; phi < fNSegment[IPHI]; phi++) ephi.push_back(0.);
00233     //-
00234     std::vector<std::vector<double> > zphicell; // zphicell[Z][PHI]
00235     for(int z = 0; z < fNSegment[IZ]; z++) zphicell.push_back(ephi);
00236     //-
00237     std::vector<std::vector<double> > rphicell; // rphicell[R][PHI]
00238     for(int r = 0; r < fNSegment[IR]; r++) rphicell.push_back(ephi);
00239 
00240     // projections
00241     G4int q[3];
00242     std::map<G4int, G4double*>::iterator itr = map->begin();
00243     for(; itr != map->end(); itr++) {
00244       if(itr->first < 0) {
00245         G4cout << itr->first << G4endl;
00246         continue;
00247       }
00248       GetRZPhi(itr->first, q);
00249 
00250       zphicell[q[IZ]][q[IPHI]] += *(itr->second)/fDrawUnitValue;
00251       rphicell[q[IR]][q[IPHI]] += *(itr->second)/fDrawUnitValue;
00252     }  
00253     
00254     // search min./max. values
00255     G4double zphimin = DBL_MAX, rphimin = DBL_MAX;
00256     G4double zphimax = 0., rphimax = 0.;
00257     for(int iphi = 0; iphi < fNSegment[IPHI]; iphi++) {
00258       for(int iz = 0; iz < fNSegment[IZ]; iz++) {
00259         if(zphimin > zphicell[iz][iphi]) zphimin = zphicell[iz][iphi];
00260         if(zphimax < zphicell[iz][iphi]) zphimax = zphicell[iz][iphi];
00261       }
00262       for(int ir = 0; ir < fNSegment[IR]; ir++) {
00263         if(rphimin > rphicell[ir][iphi]) rphimin = rphicell[ir][iphi];
00264         if(rphimax < rphicell[ir][iphi]) rphimax = rphicell[ir][iphi];
00265       }
00266     }
00267 
00268     G4VisAttributes att;
00269     att.SetForceSolid(true);
00270     att.SetForceAuxEdgeVisible(true);
00271 
00272 
00273     G4Scale3D scale;
00274     if(axflg/100==1) {
00275       // rz plane
00276     }
00277     axflg = axflg%100;
00278     if(axflg/10==1) {
00279       // z-phi plane
00280       if(colorMap->IfFloatMinMax()) { colorMap->SetMinMax(zphimin, zphimax); }
00281 
00282       G4double zhalf = fSize[1]/fNSegment[IZ];
00283       for(int phi = 0; phi < fNSegment[IPHI]; phi++) {
00284         for(int z = 0; z < fNSegment[IZ]; z++) {
00285           //-
00286           G4double angle = twopi/fNSegment[IPHI]*phi;
00287           G4double dphi = twopi/fNSegment[IPHI];
00288           G4Tubs cylinder("z-phi",                    // name
00289                           fSize[0]*0.99, fSize[0],  // inner radius, outer radius
00290                           zhalf,                      // half length in z
00291                           angle, dphi*0.99999);       // starting phi angle, delta angle
00292           //-
00293           G4ThreeVector zpos(0., 0., -fSize[1] + fSize[1]/fNSegment[IZ]*(1 + 2.*z));
00294           G4Transform3D trans;
00295           if(fRotationMatrix) {
00296             trans = G4Rotate3D(*fRotationMatrix).inverse()*G4Translate3D(zpos);
00297             trans = G4Translate3D(fCenterPosition)*trans;
00298           } else {
00299             trans = G4Translate3D(zpos)*G4Translate3D(fCenterPosition);
00300           }
00301           G4double c[4];
00302           colorMap->GetMapColor(zphicell[z][phi], c);
00303           att.SetColour(c[0], c[1], c[2]);//, c[3]);
00304           //-
00305           pVisManager->Draw(cylinder, att, trans);
00306         }
00307       }
00308     }
00309     axflg = axflg%10;
00310     if(axflg==1) {
00311       // r-phi plane
00312       if(colorMap->IfFloatMinMax()) { colorMap->SetMinMax(rphimin, rphimax); }
00313 
00314       G4double rsize = fSize[0]/fNSegment[IR];
00315       for(int phi = 0; phi < fNSegment[IPHI]; phi++) {
00316         for(int r = 0; r < fNSegment[IR]; r++) {
00317 
00318           G4double rs[2] = {rsize*r, rsize*(r+1)};
00319           G4double angle = twopi/fNSegment[IPHI]*phi;
00320           G4double dphi = twopi/fNSegment[IPHI];
00321           G4Tubs cylinder("z-phi", rs[0], rs[1], 0.001,
00322                           angle, dphi*0.99999);
00323           /*
00324           G4cout << ">>>> "
00325                  << rs[0] << " - " << rs[1] << " : "
00326                  << angle << " - " << angle + dphi
00327                  << G4endl;
00328           */
00329 
00330           G4ThreeVector zposn(0., 0., -fSize[1]);
00331           G4ThreeVector zposp(0., 0.,  fSize[1]);
00332           G4Transform3D transn, transp;
00333           if(fRotationMatrix) {
00334             transn = G4Rotate3D(*fRotationMatrix).inverse()*G4Translate3D(zposn);
00335             transn = G4Translate3D(fCenterPosition)*transn;
00336             transp = G4Rotate3D(*fRotationMatrix).inverse()*G4Translate3D(zposp);
00337             transp = G4Translate3D(fCenterPosition)*transp;
00338           } else {
00339             transn = G4Translate3D(zposn)*G4Translate3D(fCenterPosition);
00340             transp = G4Translate3D(zposp)*G4Translate3D(fCenterPosition);
00341           }
00342           G4double c[4];
00343           colorMap->GetMapColor(rphicell[r][phi], c);
00344           att.SetColour(c[0], c[1], c[2]);//, c[3]);
00345           /*
00346           G4cout << "   " << c[0] << ", "
00347                  << c[1] << ", " << c[2] << G4endl;
00348           */
00349           pVisManager->Draw(cylinder, att, transn);
00350           pVisManager->Draw(cylinder, att, transp);
00351         }
00352       }
00353     }
00354 
00355     colorMap->SetPSUnit(fDrawUnit);
00356     colorMap->SetPSName(fDrawPSName);
00357     colorMap->DrawColorChart();
00358 
00359   }
00360 }
00361 
00362 void G4ScoringCylinder::DrawColumn(std::map<G4int, G4double*> * map, G4VScoreColorMap* colorMap, 
00363                                    G4int idxProj, G4int idxColumn) 
00364 {
00365   G4int projAxis = 0;
00366   switch(idxProj) {
00367   case 0: 
00368     projAxis = IR;
00369     break;
00370   case 1:
00371     projAxis = IZ;
00372     break;
00373   case 2:
00374     projAxis = IPHI;
00375     break;
00376   }
00377 
00378   if(idxColumn<0 || idxColumn>=fNSegment[projAxis])
00379   {
00380     G4cerr << "Warning : Column number " << idxColumn << " is out of scoring mesh [0," << fNSegment[projAxis]-1 <<
00381     "]. Method ignored." << G4endl;
00382     return;
00383   }
00384   G4VVisManager * pVisManager = G4VVisManager::GetConcreteInstance();
00385   if(pVisManager) {
00386 
00387     // cell vectors
00388     std::vector<std::vector<std::vector<double> > > cell; // cell[R][Z][PHI]
00389     std::vector<double> ephi;
00390     for(int phi = 0; phi < fNSegment[IPHI]; phi++) ephi.push_back(0.);
00391     std::vector<std::vector<double> > ezphi;
00392     for(int z = 0; z < fNSegment[IZ]; z++) ezphi.push_back(ephi);
00393     for(int r = 0; r < fNSegment[IR]; r++) cell.push_back(ezphi);
00394 
00395     std::vector<std::vector<double> > rzcell; // rzcell[R][Z]
00396     std::vector<double> ez;
00397     for(int z = 0; z < fNSegment[IZ]; z++) ez.push_back(0.);
00398     for(int r = 0; r < fNSegment[IR]; r++) rzcell.push_back(ez);
00399 
00400     std::vector<std::vector<double> > zphicell; // zphicell[Z][PHI]
00401     for(int z = 0; z < fNSegment[IZ]; z++) zphicell.push_back(ephi);
00402 
00403     std::vector<std::vector<double> > rphicell; // rphicell[R][PHI]
00404     for(int r = 0; r < fNSegment[IR]; r++) rphicell.push_back(ephi);
00405 
00406     // projections
00407     G4int q[3];
00408     std::map<G4int, G4double*>::iterator itr = map->begin();
00409     for(; itr != map->end(); itr++) {
00410       if(itr->first < 0) {
00411         G4cout << itr->first << G4endl;
00412         continue;
00413       }
00414       GetRZPhi(itr->first, q);
00415 
00416       if(projAxis == IR && q[IR] == idxColumn) { // zphi plane
00417         zphicell[q[IZ]][q[IPHI]] += *(itr->second)/fDrawUnitValue;
00418       }
00419       if(projAxis == IZ && q[IZ] == idxColumn) { // rphi plane
00420         rphicell[q[IR]][q[IPHI]] += *(itr->second)/fDrawUnitValue;
00421       }
00422       if(projAxis == IPHI && q[IPHI] == idxColumn) { // rz plane
00423         rzcell[q[IR]][q[IZ]] += *(itr->second)/fDrawUnitValue; 
00424       }
00425     }  
00426 
00427     // search min./max. values
00428     G4double rzmin = DBL_MAX, zphimin = DBL_MAX, rphimin = DBL_MAX;
00429     G4double rzmax = 0., zphimax = 0., rphimax = 0.;
00430     for(int r = 0; r < fNSegment[IR]; r++) {
00431       for(int phi = 0; phi < fNSegment[IPHI]; phi++) {
00432         if(rphimin > rphicell[r][phi]) rphimin = rphicell[r][phi];
00433         if(rphimax < rphicell[r][phi]) rphimax = rphicell[r][phi];
00434       }
00435       for(int z = 0; z < fNSegment[IZ]; z++) {
00436         if(rzmin > rzcell[r][z]) rzmin = rzcell[r][z];
00437         if(rzmax < rzcell[r][z]) rzmax = rzcell[r][z];
00438       }
00439     }
00440     for(int z = 0; z < fNSegment[IZ]; z++) {
00441       for(int phi = 0; phi < fNSegment[IPHI]; phi++) {
00442         if(zphimin > zphicell[z][phi]) zphimin = zphicell[z][phi];
00443         if(zphimax < zphicell[z][phi]) zphimax = zphicell[z][phi];
00444       }
00445     }
00446 
00447 
00448     G4VisAttributes att;
00449     att.SetForceSolid(true);
00450     att.SetForceAuxEdgeVisible(true);
00451 
00452 
00453     G4Scale3D scale;
00454     // z-phi plane
00455     if(projAxis == IR) {
00456       if(colorMap->IfFloatMinMax()) { colorMap->SetMinMax(zphimin,zphimax); }
00457 
00458       G4double zhalf = fSize[1]/fNSegment[IZ];
00459       G4double rsize[2] = {fSize[0]/fNSegment[IR]*idxColumn,
00460                             fSize[0]/fNSegment[IR]*(idxColumn+1)};
00461       for(int phi = 0; phi < fNSegment[IPHI]; phi++) {
00462         for(int z = 0; z < fNSegment[IZ]; z++) {
00463 
00464           G4double angle = twopi/fNSegment[IPHI]*phi*radian;
00465           G4double dphi = twopi/fNSegment[IPHI]*radian;
00466           G4Tubs cylinder("z-phi", rsize[0], rsize[1], zhalf,
00467                           angle, dphi*0.99999);
00468 
00469           G4ThreeVector zpos(0., 0., -fSize[1] + fSize[1]/fNSegment[IZ]*(1 + 2.*z));
00470           G4Transform3D trans;
00471           if(fRotationMatrix) {
00472             trans = G4Rotate3D(*fRotationMatrix).inverse()*G4Translate3D(zpos);
00473             trans = G4Translate3D(fCenterPosition)*trans;
00474           } else {
00475             trans = G4Translate3D(zpos)*G4Translate3D(fCenterPosition);
00476           }
00477           G4double c[4];
00478           colorMap->GetMapColor(zphicell[z][phi], c);
00479           att.SetColour(c[0], c[1], c[2]);//, c[3]);
00480           pVisManager->Draw(cylinder, att, trans);
00481         }
00482       }
00483 
00484       // r-phi plane
00485     } else if(projAxis == IZ) {
00486       if(colorMap->IfFloatMinMax()) { colorMap->SetMinMax(rphimin,rphimax); }
00487 
00488       G4double rsize = fSize[0]/fNSegment[IR];
00489       for(int phi = 0; phi < fNSegment[IPHI]; phi++) {
00490         for(int r = 0; r < fNSegment[IR]; r++) {
00491 
00492           G4double rs[2] = {rsize*r, rsize*(r+1)};
00493           G4double angle = twopi/fNSegment[IPHI]*phi*radian;
00494           G4double dz = fSize[1]/fNSegment[IZ];
00495           G4double dphi = twopi/fNSegment[IPHI]*radian;
00496           G4Tubs cylinder("r-phi", rs[0], rs[1], dz,
00497                           angle, dphi*0.99999);
00498           G4ThreeVector zpos(0., 0.,
00499                              -fSize[1]+fSize[1]/fNSegment[IZ]*(idxColumn*2+1));
00500           G4Transform3D trans;
00501           if(fRotationMatrix) {
00502             trans = G4Rotate3D(*fRotationMatrix).inverse()*G4Translate3D(zpos);
00503             trans = G4Translate3D(fCenterPosition)*trans;
00504           } else {
00505             trans = G4Translate3D(zpos)*G4Translate3D(fCenterPosition);
00506           }
00507           G4double c[4];
00508           colorMap->GetMapColor(rphicell[r][phi], c);
00509           att.SetColour(c[0], c[1], c[2]);//, c[3]);
00510           pVisManager->Draw(cylinder, att, trans);
00511         }
00512       }
00513 
00514       // r-z plane
00515     } else if(projAxis == IPHI) {
00516       if(colorMap->IfFloatMinMax()) { colorMap->SetMinMax(rzmin,rzmax); }
00517 
00518       G4double rsize = fSize[0]/fNSegment[IR];
00519       G4double zhalf = fSize[1]/fNSegment[IZ];
00520       G4double angle = twopi/fNSegment[IPHI]*idxColumn*radian;
00521       G4double dphi = twopi/fNSegment[IPHI]*radian;
00522       for(int z = 0; z < fNSegment[IZ]; z++) {
00523         for(int r = 0; r < fNSegment[IR]; r++) {
00524 
00525           G4double rs[2] = {rsize*r, rsize*(r+1)};
00526           G4Tubs cylinder("z-phi", rs[0], rs[1], zhalf,
00527                           angle, dphi);
00528 
00529           G4ThreeVector zpos(0., 0.,
00530                              -fSize[1]+fSize[1]/fNSegment[IZ]*(2.*z+1));
00531           G4Transform3D trans;
00532           if(fRotationMatrix) {
00533             trans = G4Rotate3D(*fRotationMatrix).inverse()*G4Translate3D(zpos);
00534             trans = G4Translate3D(fCenterPosition)*trans;
00535           } else {
00536             trans = G4Translate3D(zpos)*G4Translate3D(fCenterPosition);
00537           }
00538           G4double c[4];
00539           colorMap->GetMapColor(rzcell[r][z], c);
00540           att.SetColour(c[0], c[1], c[2]);//, c[3]);
00541           pVisManager->Draw(cylinder, att, trans);
00542         }
00543       }
00544     }
00545   }
00546 
00547   colorMap->SetPSUnit(fDrawUnit);
00548   colorMap->SetPSName(fDrawPSName);
00549   colorMap->DrawColorChart();
00550 
00551 }
00552 
00553 void G4ScoringCylinder::GetRZPhi(G4int index, G4int q[3]) const {
00554   // index = k + j * k-size + i * jk-plane-size
00555 
00556   // nested : z -> phi -> r
00557   G4int i = IZ;
00558   G4int j = IPHI;
00559   G4int k = IR;
00560   G4int jk = fNSegment[j]*fNSegment[k];
00561   q[i] = index/jk;
00562   q[j] = (index - q[i]*jk)/fNSegment[k];
00563   q[k] = index - q[j]*fNSegment[k] - q[i]*jk;
00564 }

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