[998] | 1 | // |
---|
| 2 | // ******************************************************************** |
---|
| 3 | // * License and Disclaimer * |
---|
| 4 | // * * |
---|
| 5 | // * The Geant4 software is copyright of the Copyright Holders of * |
---|
| 6 | // * the Geant4 Collaboration. It is provided under the terms and * |
---|
| 7 | // * conditions of the Geant4 Software License, included in the file * |
---|
| 8 | // * LICENSE and available at http://cern.ch/geant4/license . These * |
---|
| 9 | // * include a list of copyright holders. * |
---|
| 10 | // * * |
---|
| 11 | // * Neither the authors of this software system, nor their employing * |
---|
| 12 | // * institutes,nor the agencies providing financial support for this * |
---|
| 13 | // * work make any representation or warranty, express or implied, * |
---|
| 14 | // * regarding this software system or assume any liability for its * |
---|
| 15 | // * use. Please see the license in the file LICENSE and URL above * |
---|
| 16 | // * for the full disclaimer and the limitation of liability. * |
---|
| 17 | // * * |
---|
| 18 | // * This code implementation is the result of the scientific and * |
---|
| 19 | // * technical work of the GEANT4 collaboration. * |
---|
| 20 | // * By using, copying, modifying or distributing the software (or * |
---|
| 21 | // * any work based on the software) you agree to acknowledge its * |
---|
| 22 | // * use in resulting scientific publications, and indicate your * |
---|
| 23 | // * acceptance of all terms of the Geant4 Software license. * |
---|
| 24 | // ******************************************************************** |
---|
| 25 | // |
---|
| 26 | // |
---|
[1340] | 27 | // $Id: G4ScoringCylinder.cc,v 1.16 2010/08/30 08:15:20 akimura Exp $ |
---|
| 28 | // GEANT4 tag $Name: $ |
---|
[998] | 29 | // |
---|
| 30 | |
---|
| 31 | #include "G4ScoringCylinder.hh" |
---|
| 32 | #include "G4VPhysicalVolume.hh" |
---|
| 33 | |
---|
| 34 | #include "G4Tubs.hh" |
---|
| 35 | #include "G4LogicalVolume.hh" |
---|
| 36 | #include "G4VPhysicalVolume.hh" |
---|
| 37 | #include "G4PVPlacement.hh" |
---|
| 38 | #include "G4PVReplica.hh" |
---|
| 39 | #include "G4PVDivision.hh" |
---|
| 40 | #include "G4VisAttributes.hh" |
---|
| 41 | #include "G4VVisManager.hh" |
---|
| 42 | #include "G4VScoreColorMap.hh" |
---|
| 43 | |
---|
| 44 | #include "G4SDManager.hh" |
---|
| 45 | #include "G4MultiFunctionalDetector.hh" |
---|
| 46 | #include "G4SDParticleFilter.hh" |
---|
| 47 | #include "G4VPrimitiveScorer.hh" |
---|
| 48 | #include "G4PSEnergyDeposit.hh" |
---|
| 49 | #include "G4PSTrackLength.hh" |
---|
| 50 | #include "G4PSNofStep.hh" |
---|
| 51 | #include "G4ScoringManager.hh" |
---|
| 52 | |
---|
| 53 | |
---|
| 54 | G4ScoringCylinder::G4ScoringCylinder(G4String wName) |
---|
[1340] | 55 | :G4VScoringMesh(wName), fMeshElementLogical(0) |
---|
[998] | 56 | { |
---|
| 57 | fShape = cylinderMesh; |
---|
[1340] | 58 | |
---|
| 59 | fDivisionAxisNames[0] = "Z"; |
---|
| 60 | fDivisionAxisNames[1] = "PHI"; |
---|
| 61 | fDivisionAxisNames[2] = "R"; |
---|
[998] | 62 | } |
---|
| 63 | |
---|
| 64 | G4ScoringCylinder::~G4ScoringCylinder() |
---|
[1340] | 65 | {;} |
---|
[998] | 66 | |
---|
| 67 | void G4ScoringCylinder::Construct(G4VPhysicalVolume* fWorldPhys) |
---|
| 68 | { |
---|
| 69 | if(fConstructed) { |
---|
| 70 | |
---|
| 71 | if(verboseLevel > 0) |
---|
| 72 | G4cout << fWorldPhys->GetName() << " --- All quantities are reset." << G4endl; |
---|
| 73 | ResetScore(); |
---|
| 74 | |
---|
| 75 | } else { |
---|
| 76 | fConstructed = true; |
---|
| 77 | SetupGeometry(fWorldPhys); |
---|
| 78 | } |
---|
| 79 | } |
---|
| 80 | |
---|
| 81 | |
---|
| 82 | |
---|
| 83 | void G4ScoringCylinder::SetupGeometry(G4VPhysicalVolume * fWorldPhys) { |
---|
| 84 | |
---|
| 85 | if(verboseLevel > 9) G4cout << "G4ScoringCylinder::SetupGeometry() ..." << G4endl; |
---|
| 86 | |
---|
| 87 | // World |
---|
| 88 | G4VPhysicalVolume * scoringWorld = fWorldPhys; |
---|
| 89 | G4LogicalVolume * worldLogical = scoringWorld->GetLogicalVolume(); |
---|
| 90 | |
---|
| 91 | // Scoring Mesh |
---|
| 92 | if(verboseLevel > 9) G4cout << fWorldName << G4endl; |
---|
[1340] | 93 | G4String tubsName = fWorldName+"_mesh"; |
---|
[998] | 94 | |
---|
[1340] | 95 | if(verboseLevel > 9) G4cout << "R max., Dz =: " << fSize[0] << ", " << fSize[1] << G4endl; |
---|
[998] | 96 | G4VSolid * tubsSolid = new G4Tubs(tubsName+"0", // name |
---|
| 97 | 0., // R min |
---|
| 98 | fSize[0], // R max |
---|
[1340] | 99 | fSize[1], // Dz |
---|
[998] | 100 | 0., // starting phi |
---|
[1340] | 101 | twopi*rad); // segment phi |
---|
[998] | 102 | G4LogicalVolume * tubsLogical = new G4LogicalVolume(tubsSolid, 0, tubsName); |
---|
| 103 | new G4PVPlacement(fRotationMatrix, fCenterPosition, |
---|
| 104 | tubsLogical, tubsName+"0", worldLogical, false, 0); |
---|
| 105 | |
---|
[1340] | 106 | if(verboseLevel > 9) G4cout << " # of segments : r, phi, z =: " |
---|
| 107 | << fNSegment[IR] << ", " << fNSegment[IPHI] << ", " << fNSegment[IZ] << G4endl; |
---|
[998] | 108 | |
---|
| 109 | G4String layerName[2] = {tubsName + "1", tubsName + "2"}; |
---|
| 110 | G4VSolid * layerSolid[2]; |
---|
| 111 | G4LogicalVolume * layerLogical[2]; |
---|
| 112 | |
---|
[1340] | 113 | //-- fisrt nested layer (replicated along z direction) |
---|
[998] | 114 | if(verboseLevel > 9) G4cout << "layer 1 :" << G4endl; |
---|
[1340] | 115 | layerSolid[0] = new G4Tubs(layerName[0], // name |
---|
| 116 | 0., // inner radius |
---|
| 117 | fSize[0], // outer radius |
---|
| 118 | fSize[1]/fNSegment[IZ], // half len. in z |
---|
| 119 | 0., // starting phi angle |
---|
| 120 | twopi*rad); // delta angle of the segment |
---|
[998] | 121 | layerLogical[0] = new G4LogicalVolume(layerSolid[0], 0, layerName[0]); |
---|
[1340] | 122 | if(fNSegment[IZ] > 1) { |
---|
| 123 | if(verboseLevel > 9) G4cout << "G4ScoringCylinder::Construct() : Replicate along z direction" << G4endl; |
---|
| 124 | if(G4ScoringManager::GetReplicaLevel()>0) { |
---|
[998] | 125 | if(verboseLevel > 9) G4cout << "G4ScoringCylinder::Construct() : Replica" << G4endl; |
---|
[1340] | 126 | new G4PVReplica(layerName[0], layerLogical[0], tubsLogical, kZAxis, fNSegment[IZ], 2.*fSize[1]/fNSegment[IZ]); |
---|
[998] | 127 | } else { |
---|
| 128 | if(verboseLevel > 9) G4cout << "G4ScoringCylinder::Construct() : Division" << G4endl; |
---|
[1340] | 129 | new G4PVDivision(layerName[0], layerLogical[0], tubsLogical, kZAxis, fNSegment[IZ], 0.); |
---|
[998] | 130 | } |
---|
[1340] | 131 | } else if(fNSegment[IZ] == 1) { |
---|
[998] | 132 | if(verboseLevel > 9) G4cout << "G4ScoringCylinder::Construct() : Placement" << G4endl; |
---|
| 133 | new G4PVPlacement(0, G4ThreeVector(0.,0.,0.), layerLogical[0], layerName[0], tubsLogical, false, 0); |
---|
| 134 | } else { |
---|
| 135 | G4cerr << "G4ScoringCylinder::SetupGeometry() : invalid parameter (" |
---|
[1340] | 136 | << fNSegment[IZ] << ") " |
---|
[998] | 137 | << "in placement of the first nested layer." << G4endl; |
---|
| 138 | } |
---|
| 139 | |
---|
[1340] | 140 | // second nested layer (replicated along phi direction) |
---|
[998] | 141 | if(verboseLevel > 9) G4cout << "layer 2 :" << G4endl; |
---|
| 142 | layerSolid[1] = new G4Tubs(layerName[1], |
---|
| 143 | 0., |
---|
[1340] | 144 | fSize[0], |
---|
| 145 | fSize[1]/fNSegment[IZ], |
---|
| 146 | 0., |
---|
| 147 | twopi*rad/fNSegment[IPHI]); |
---|
[998] | 148 | layerLogical[1] = new G4LogicalVolume(layerSolid[1], 0, layerName[1]); |
---|
[1340] | 149 | if(fNSegment[IPHI] > 1) { |
---|
| 150 | if(verboseLevel > 9) G4cout << "G4ScoringCylinder::Construct() : Replicate along phi direction" << G4endl; |
---|
| 151 | if(G4ScoringManager::GetReplicaLevel()>1) { |
---|
[998] | 152 | if(verboseLevel > 9) G4cout << "G4ScoringCylinder::Construct() : Replica" << G4endl; |
---|
[1340] | 153 | new G4PVReplica(layerName[1], layerLogical[1], layerLogical[0], kPhi, |
---|
| 154 | fNSegment[IPHI], twopi*rad/fNSegment[IPHI]); |
---|
[998] | 155 | } else { |
---|
| 156 | if(verboseLevel > 9) G4cout << "G4ScoringCylinder::Construct() : Division" << G4endl; |
---|
[1340] | 157 | new G4PVDivision(layerName[1], layerLogical[1], layerLogical[0], kPhi, fNSegment[IPHI], 0.); |
---|
[998] | 158 | } |
---|
[1340] | 159 | } else if(fNSegment[IPHI] == 1) { |
---|
[998] | 160 | if(verboseLevel > 9) G4cout << "G4ScoringCylinder::Construct() : Placement" << G4endl; |
---|
| 161 | new G4PVPlacement(0, G4ThreeVector(0.,0.,0.), layerLogical[1], layerName[1], layerLogical[0], false, 0); |
---|
| 162 | } else |
---|
| 163 | G4cerr << "ERROR : G4ScoringCylinder::SetupGeometry() : invalid parameter (" |
---|
[1340] | 164 | << fNSegment[IPHI] << ") " |
---|
[998] | 165 | << "in placement of the second nested layer." << G4endl; |
---|
| 166 | |
---|
| 167 | // mesh elements |
---|
| 168 | if(verboseLevel > 9) G4cout << "mesh elements :" << G4endl; |
---|
| 169 | G4String elementName = tubsName +"3"; |
---|
| 170 | G4VSolid * elementSolid = new G4Tubs(elementName, |
---|
| 171 | 0., |
---|
[1340] | 172 | fSize[0]/fNSegment[IR], |
---|
| 173 | fSize[1]/fNSegment[IZ], |
---|
| 174 | 0., |
---|
| 175 | twopi*rad/fNSegment[IPHI]); |
---|
[998] | 176 | fMeshElementLogical = new G4LogicalVolume(elementSolid, 0, elementName); |
---|
[1340] | 177 | if(fNSegment[IR] > 1) { |
---|
[998] | 178 | |
---|
[1340] | 179 | if(verboseLevel > 9) G4cout << "G4ScoringCylinder::Construct() : Replicate along r direction" << G4endl; |
---|
[998] | 180 | |
---|
[1340] | 181 | if(G4ScoringManager::GetReplicaLevel()>2) { |
---|
[998] | 182 | if(verboseLevel > 9) G4cout << "G4ScoringCylinder::Construct() : Replica" << G4endl; |
---|
[1340] | 183 | new G4PVReplica(elementName, fMeshElementLogical, layerLogical[1], kRho, |
---|
| 184 | fNSegment[IR], fSize[0]/fNSegment[IR]); |
---|
[998] | 185 | } else { |
---|
| 186 | if(verboseLevel > 9) G4cout << "G4ScoringCylinder::Construct() : Division" << G4endl; |
---|
[1340] | 187 | new G4PVDivision(elementName, fMeshElementLogical, layerLogical[1], kRho, fNSegment[IR], 0.); |
---|
[998] | 188 | } |
---|
[1340] | 189 | } else if(fNSegment[IR] == 1) { |
---|
[998] | 190 | if(verboseLevel > 9) G4cout << "G4ScoringCylinder::Construct() : Placement" << G4endl; |
---|
| 191 | new G4PVPlacement(0, G4ThreeVector(0.,0.,0.), fMeshElementLogical, elementName, layerLogical[1], false, 0); |
---|
| 192 | } else { |
---|
| 193 | G4cerr << "G4ScoringCylinder::SetupGeometry() : " |
---|
[1340] | 194 | << "invalid parameter (" << fNSegment[IR] << ") " |
---|
[998] | 195 | << "in mesh element placement." << G4endl; |
---|
| 196 | } |
---|
| 197 | |
---|
| 198 | // set the sensitive detector |
---|
| 199 | fMeshElementLogical->SetSensitiveDetector(fMFD); |
---|
| 200 | |
---|
| 201 | |
---|
| 202 | // vis. attributes |
---|
[1340] | 203 | G4VisAttributes * visatt = new G4VisAttributes(G4Colour(.5,.5,.5)); |
---|
[998] | 204 | visatt->SetVisibility(true); |
---|
[1340] | 205 | layerLogical[0]->SetVisAttributes(visatt); |
---|
| 206 | layerLogical[1]->SetVisAttributes(visatt); |
---|
[998] | 207 | visatt = new G4VisAttributes(G4Colour(.5,.5,.5,0.01)); |
---|
| 208 | //visatt->SetForceSolid(true); |
---|
| 209 | fMeshElementLogical->SetVisAttributes(visatt); |
---|
| 210 | } |
---|
| 211 | |
---|
| 212 | void G4ScoringCylinder::List() const { |
---|
| 213 | G4cout << "G4ScoringCylinder : " << fWorldName << " --- Shape: Cylindrical mesh" << G4endl; |
---|
| 214 | |
---|
| 215 | G4cout << " Size (R, Dz): (" |
---|
| 216 | << fSize[0]/cm << ", " |
---|
| 217 | << fSize[1]/cm << ") [cm]" |
---|
| 218 | << G4endl; |
---|
| 219 | |
---|
| 220 | G4VScoringMesh::List(); |
---|
| 221 | } |
---|
| 222 | |
---|
| 223 | |
---|
| 224 | void G4ScoringCylinder::Draw(std::map<G4int, G4double*> * map, G4VScoreColorMap* colorMap, G4int axflg) { |
---|
| 225 | |
---|
| 226 | G4VVisManager * pVisManager = G4VVisManager::GetConcreteInstance(); |
---|
| 227 | if(pVisManager) { |
---|
| 228 | |
---|
| 229 | // cell vectors |
---|
| 230 | std::vector<double> ephi; |
---|
[1340] | 231 | for(int phi = 0; phi < fNSegment[IPHI]; phi++) ephi.push_back(0.); |
---|
| 232 | //- |
---|
[998] | 233 | std::vector<std::vector<double> > zphicell; // zphicell[Z][PHI] |
---|
[1340] | 234 | for(int z = 0; z < fNSegment[IZ]; z++) zphicell.push_back(ephi); |
---|
| 235 | //- |
---|
[998] | 236 | std::vector<std::vector<double> > rphicell; // rphicell[R][PHI] |
---|
[1340] | 237 | for(int r = 0; r < fNSegment[IR]; r++) rphicell.push_back(ephi); |
---|
[998] | 238 | |
---|
| 239 | // search max. values |
---|
[1340] | 240 | G4double zphimin = DBL_MAX, rphimin = DBL_MAX; |
---|
| 241 | G4double zphimax = 0., rphimax = 0.; |
---|
[998] | 242 | G4int q[3]; |
---|
| 243 | std::map<G4int, G4double*>::iterator itr = map->begin(); |
---|
| 244 | for(; itr != map->end(); itr++) { |
---|
[1340] | 245 | if(itr->first < 0) { |
---|
| 246 | G4cout << itr->first << G4endl; |
---|
| 247 | continue; |
---|
| 248 | } |
---|
[998] | 249 | GetRZPhi(itr->first, q); |
---|
| 250 | |
---|
[1340] | 251 | // projections |
---|
| 252 | zphicell[q[IZ]][q[IPHI]] += *(itr->second)/fDrawUnitValue; |
---|
| 253 | if(zphimin > zphicell[q[IZ]][q[IPHI]]) zphimin = zphicell[q[IZ]][q[IPHI]]; |
---|
| 254 | if(zphimax < zphicell[q[IZ]][q[IPHI]]) zphimax = zphicell[q[IZ]][q[IPHI]]; |
---|
| 255 | //- |
---|
| 256 | rphicell[q[IR]][q[IPHI]] += *(itr->second)/fDrawUnitValue; |
---|
| 257 | if(rphimin > rphicell[q[IR]][q[IPHI]]) rphimin = rphicell[q[IR]][q[IPHI]]; |
---|
| 258 | if(rphimax < rphicell[q[IR]][q[IPHI]]) rphimax = rphicell[q[IR]][q[IPHI]]; |
---|
[998] | 259 | } |
---|
| 260 | |
---|
| 261 | G4VisAttributes att; |
---|
| 262 | att.SetForceSolid(true); |
---|
| 263 | att.SetForceAuxEdgeVisible(true); |
---|
| 264 | |
---|
| 265 | |
---|
| 266 | G4Scale3D scale; |
---|
| 267 | if(axflg/100==1) { |
---|
| 268 | // rz plane |
---|
| 269 | } |
---|
| 270 | axflg = axflg%100; |
---|
| 271 | if(axflg/10==1) { |
---|
| 272 | // z-phi plane |
---|
| 273 | if(colorMap->IfFloatMinMax()) { colorMap->SetMinMax(zphimin, zphimax); } |
---|
| 274 | |
---|
[1340] | 275 | G4double zhalf = fSize[1]/fNSegment[IZ]; |
---|
| 276 | for(int phi = 0; phi < fNSegment[IPHI]; phi++) { |
---|
| 277 | for(int z = 0; z < fNSegment[IZ]; z++) { |
---|
| 278 | //- |
---|
| 279 | G4double angle = twopi/fNSegment[IPHI]*phi; |
---|
| 280 | G4double dphi = twopi/fNSegment[IPHI]; |
---|
| 281 | G4Tubs cylinder("z-phi", // name |
---|
| 282 | fSize[0]*0.99, fSize[0], // inner radius, outer radius |
---|
| 283 | zhalf, // half length in z |
---|
| 284 | angle, dphi*0.99999); // starting phi angle, delta angle |
---|
| 285 | //- |
---|
| 286 | G4ThreeVector zpos(0., 0., -fSize[1] + fSize[1]/fNSegment[IZ]*(1 + 2.*z)); |
---|
[998] | 287 | G4Transform3D trans; |
---|
| 288 | if(fRotationMatrix) { |
---|
| 289 | trans = G4Rotate3D(*fRotationMatrix).inverse()*G4Translate3D(zpos); |
---|
| 290 | trans = G4Translate3D(fCenterPosition)*trans; |
---|
| 291 | } else { |
---|
| 292 | trans = G4Translate3D(zpos)*G4Translate3D(fCenterPosition); |
---|
| 293 | } |
---|
| 294 | G4double c[4]; |
---|
| 295 | colorMap->GetMapColor(zphicell[z][phi], c); |
---|
| 296 | att.SetColour(c[0], c[1], c[2]);//, c[3]); |
---|
[1340] | 297 | //- |
---|
[998] | 298 | pVisManager->Draw(cylinder, att, trans); |
---|
| 299 | } |
---|
| 300 | } |
---|
| 301 | } |
---|
| 302 | axflg = axflg%10; |
---|
| 303 | if(axflg==1) { |
---|
| 304 | // r-phi plane |
---|
| 305 | if(colorMap->IfFloatMinMax()) { colorMap->SetMinMax(rphimin, rphimax); } |
---|
| 306 | |
---|
[1340] | 307 | G4double rsize = fSize[0]/fNSegment[IR]; |
---|
| 308 | for(int phi = 0; phi < fNSegment[IPHI]; phi++) { |
---|
| 309 | for(int r = 0; r < fNSegment[IR]; r++) { |
---|
[998] | 310 | |
---|
| 311 | G4double rs[2] = {rsize*r, rsize*(r+1)}; |
---|
[1340] | 312 | G4double angle = twopi/fNSegment[IPHI]*phi; |
---|
| 313 | G4double dphi = twopi/fNSegment[IPHI]; |
---|
[998] | 314 | G4Tubs cylinder("z-phi", rs[0], rs[1], 0.001, |
---|
| 315 | angle, dphi*0.99999); |
---|
| 316 | /* |
---|
| 317 | G4cout << ">>>> " |
---|
| 318 | << rs[0] << " - " << rs[1] << " : " |
---|
| 319 | << angle << " - " << angle + dphi |
---|
| 320 | << G4endl; |
---|
| 321 | */ |
---|
| 322 | |
---|
| 323 | G4ThreeVector zposn(0., 0., -fSize[1]); |
---|
| 324 | G4ThreeVector zposp(0., 0., fSize[1]); |
---|
| 325 | G4Transform3D transn, transp; |
---|
| 326 | if(fRotationMatrix) { |
---|
| 327 | transn = G4Rotate3D(*fRotationMatrix).inverse()*G4Translate3D(zposn); |
---|
| 328 | transn = G4Translate3D(fCenterPosition)*transn; |
---|
| 329 | transp = G4Rotate3D(*fRotationMatrix).inverse()*G4Translate3D(zposp); |
---|
| 330 | transp = G4Translate3D(fCenterPosition)*transp; |
---|
| 331 | } else { |
---|
| 332 | transn = G4Translate3D(zposn)*G4Translate3D(fCenterPosition); |
---|
| 333 | transp = G4Translate3D(zposp)*G4Translate3D(fCenterPosition); |
---|
| 334 | } |
---|
| 335 | G4double c[4]; |
---|
| 336 | colorMap->GetMapColor(rphicell[r][phi], c); |
---|
| 337 | att.SetColour(c[0], c[1], c[2]);//, c[3]); |
---|
| 338 | /* |
---|
| 339 | G4cout << " " << c[0] << ", " |
---|
| 340 | << c[1] << ", " << c[2] << G4endl; |
---|
| 341 | */ |
---|
| 342 | pVisManager->Draw(cylinder, att, transn); |
---|
| 343 | pVisManager->Draw(cylinder, att, transp); |
---|
| 344 | } |
---|
| 345 | } |
---|
| 346 | } |
---|
[1340] | 347 | |
---|
| 348 | colorMap->SetPSUnit(fDrawUnit); |
---|
| 349 | colorMap->SetPSName(fDrawPSName); |
---|
[998] | 350 | colorMap->DrawColorChart(); |
---|
[1340] | 351 | |
---|
[998] | 352 | } |
---|
| 353 | } |
---|
| 354 | |
---|
| 355 | void G4ScoringCylinder::DrawColumn(std::map<G4int, G4double*> * map, G4VScoreColorMap* colorMap, |
---|
| 356 | G4int idxProj, G4int idxColumn) |
---|
| 357 | { |
---|
[1340] | 358 | G4int projAxis = 0; |
---|
| 359 | switch(idxProj) { |
---|
| 360 | case 0: |
---|
| 361 | projAxis = IR; |
---|
| 362 | break; |
---|
| 363 | case 1: |
---|
| 364 | projAxis = IZ; |
---|
| 365 | break; |
---|
| 366 | case 2: |
---|
| 367 | projAxis = IPHI; |
---|
| 368 | break; |
---|
| 369 | } |
---|
[998] | 370 | |
---|
[1340] | 371 | if(idxColumn<0 || idxColumn>=fNSegment[projAxis]) |
---|
[998] | 372 | { |
---|
[1340] | 373 | G4cerr << "Warning : Column number " << idxColumn << " is out of scoring mesh [0," << fNSegment[projAxis]-1 << |
---|
[998] | 374 | "]. Method ignored." << G4endl; |
---|
| 375 | return; |
---|
| 376 | } |
---|
| 377 | G4VVisManager * pVisManager = G4VVisManager::GetConcreteInstance(); |
---|
| 378 | if(pVisManager) { |
---|
[1340] | 379 | |
---|
[998] | 380 | // cell vectors |
---|
| 381 | std::vector<std::vector<std::vector<double> > > cell; // cell[R][Z][PHI] |
---|
| 382 | std::vector<double> ephi; |
---|
[1340] | 383 | for(int phi = 0; phi < fNSegment[IPHI]; phi++) ephi.push_back(0.); |
---|
[998] | 384 | std::vector<std::vector<double> > ezphi; |
---|
[1340] | 385 | for(int z = 0; z < fNSegment[IZ]; z++) ezphi.push_back(ephi); |
---|
| 386 | for(int r = 0; r < fNSegment[IR]; r++) cell.push_back(ezphi); |
---|
[998] | 387 | |
---|
| 388 | std::vector<std::vector<double> > rzcell; // rzcell[R][Z] |
---|
| 389 | std::vector<double> ez; |
---|
[1340] | 390 | for(int z = 0; z < fNSegment[IZ]; z++) ez.push_back(0.); |
---|
| 391 | for(int r = 0; r < fNSegment[IR]; r++) rzcell.push_back(ez); |
---|
[998] | 392 | |
---|
| 393 | std::vector<std::vector<double> > zphicell; // zphicell[Z][PHI] |
---|
[1340] | 394 | for(int z = 0; z < fNSegment[IZ]; z++) zphicell.push_back(ephi); |
---|
[998] | 395 | |
---|
| 396 | std::vector<std::vector<double> > rphicell; // rphicell[R][PHI] |
---|
[1340] | 397 | for(int r = 0; r < fNSegment[IR]; r++) rphicell.push_back(ephi); |
---|
[998] | 398 | |
---|
| 399 | // search max. values |
---|
| 400 | G4double rzmax = 0., zphimax = 0., rphimax = 0.; |
---|
| 401 | G4int q[3]; |
---|
| 402 | std::map<G4int, G4double*>::iterator itr = map->begin(); |
---|
| 403 | for(; itr != map->end(); itr++) { |
---|
[1340] | 404 | if(itr->first < 0) { |
---|
| 405 | G4cout << itr->first << G4endl; |
---|
| 406 | continue; |
---|
| 407 | } |
---|
[998] | 408 | GetRZPhi(itr->first, q); |
---|
| 409 | |
---|
[1340] | 410 | if(projAxis == IR && q[IR] == idxColumn) { // zphi plane |
---|
| 411 | zphicell[q[IZ]][q[IPHI]] += *(itr->second)/fDrawUnitValue; |
---|
| 412 | if(zphimax < zphicell[q[IZ]][q[IPHI]]) zphimax = zphicell[q[IZ]][q[IPHI]]; |
---|
[998] | 413 | } |
---|
[1340] | 414 | if(projAxis == IZ && q[IZ] == idxColumn) { // rphi plane |
---|
| 415 | rphicell[q[IR]][q[IPHI]] += *(itr->second)/fDrawUnitValue; |
---|
| 416 | if(rphimax < rphicell[q[IR]][q[IPHI]]) rphimax = rphicell[q[IR]][q[IPHI]]; |
---|
[998] | 417 | } |
---|
[1340] | 418 | if(projAxis == IPHI && q[IPHI] == idxColumn) { // rz plane |
---|
| 419 | rzcell[q[IR]][q[IZ]] += *(itr->second)/fDrawUnitValue; |
---|
| 420 | if(rzmax < rzcell[q[IR]][q[IZ]]) rzmax = rzcell[q[IR]][q[IZ]]; |
---|
[998] | 421 | } |
---|
| 422 | } |
---|
| 423 | |
---|
| 424 | G4VisAttributes att; |
---|
| 425 | att.SetForceSolid(true); |
---|
| 426 | att.SetForceAuxEdgeVisible(true); |
---|
| 427 | |
---|
| 428 | |
---|
| 429 | G4Scale3D scale; |
---|
[1340] | 430 | // z-phi plane |
---|
| 431 | if(projAxis == IR) { |
---|
[998] | 432 | if(colorMap->IfFloatMinMax()) { colorMap->SetMinMax(0.,zphimax); } |
---|
| 433 | |
---|
[1340] | 434 | G4double zhalf = fSize[1]/fNSegment[IZ]; |
---|
| 435 | G4double rsize[2] = {fSize[0]/fNSegment[IR]*idxColumn, |
---|
| 436 | fSize[0]/fNSegment[IR]*(idxColumn+1)}; |
---|
| 437 | for(int phi = 0; phi < fNSegment[IPHI]; phi++) { |
---|
| 438 | for(int z = 0; z < fNSegment[IZ]; z++) { |
---|
[998] | 439 | |
---|
[1340] | 440 | G4double angle = twopi/fNSegment[IPHI]*phi*radian; |
---|
| 441 | G4double dphi = twopi/fNSegment[IPHI]*radian; |
---|
[998] | 442 | G4Tubs cylinder("z-phi", rsize[0], rsize[1], zhalf, |
---|
| 443 | angle, dphi*0.99999); |
---|
| 444 | |
---|
[1340] | 445 | G4ThreeVector zpos(0., 0., -fSize[1] + fSize[1]/fNSegment[IZ]*(1 + 2.*z)); |
---|
[998] | 446 | G4Transform3D trans; |
---|
| 447 | if(fRotationMatrix) { |
---|
| 448 | trans = G4Rotate3D(*fRotationMatrix).inverse()*G4Translate3D(zpos); |
---|
| 449 | trans = G4Translate3D(fCenterPosition)*trans; |
---|
| 450 | } else { |
---|
| 451 | trans = G4Translate3D(zpos)*G4Translate3D(fCenterPosition); |
---|
| 452 | } |
---|
| 453 | G4double c[4]; |
---|
| 454 | colorMap->GetMapColor(zphicell[z][phi], c); |
---|
| 455 | att.SetColour(c[0], c[1], c[2]);//, c[3]); |
---|
| 456 | pVisManager->Draw(cylinder, att, trans); |
---|
| 457 | } |
---|
| 458 | } |
---|
| 459 | |
---|
| 460 | // r-phi plane |
---|
[1340] | 461 | } else if(projAxis == IZ) { |
---|
[998] | 462 | if(colorMap->IfFloatMinMax()) { colorMap->SetMinMax(0.,rphimax); } |
---|
| 463 | |
---|
[1340] | 464 | G4double rsize = fSize[0]/fNSegment[IR]; |
---|
| 465 | for(int phi = 0; phi < fNSegment[IPHI]; phi++) { |
---|
| 466 | for(int r = 0; r < fNSegment[IR]; r++) { |
---|
[998] | 467 | |
---|
| 468 | G4double rs[2] = {rsize*r, rsize*(r+1)}; |
---|
[1340] | 469 | G4double angle = twopi/fNSegment[IPHI]*phi*radian; |
---|
| 470 | G4double dz = fSize[1]/fNSegment[IZ]; |
---|
| 471 | G4double dphi = twopi/fNSegment[IPHI]*radian; |
---|
[998] | 472 | G4Tubs cylinder("r-phi", rs[0], rs[1], dz, |
---|
| 473 | angle, dphi*0.99999); |
---|
| 474 | G4ThreeVector zpos(0., 0., |
---|
[1340] | 475 | -fSize[1]+fSize[1]/fNSegment[IZ]*(idxColumn*2+1)); |
---|
[998] | 476 | G4Transform3D trans; |
---|
| 477 | if(fRotationMatrix) { |
---|
| 478 | trans = G4Rotate3D(*fRotationMatrix).inverse()*G4Translate3D(zpos); |
---|
| 479 | trans = G4Translate3D(fCenterPosition)*trans; |
---|
| 480 | } else { |
---|
| 481 | trans = G4Translate3D(zpos)*G4Translate3D(fCenterPosition); |
---|
| 482 | } |
---|
| 483 | G4double c[4]; |
---|
| 484 | colorMap->GetMapColor(rphicell[r][phi], c); |
---|
| 485 | att.SetColour(c[0], c[1], c[2]);//, c[3]); |
---|
| 486 | pVisManager->Draw(cylinder, att, trans); |
---|
| 487 | } |
---|
| 488 | } |
---|
| 489 | |
---|
| 490 | // r-z plane |
---|
[1340] | 491 | } else if(projAxis == IPHI) { |
---|
[998] | 492 | if(colorMap->IfFloatMinMax()) { colorMap->SetMinMax(0.,rzmax); } |
---|
| 493 | |
---|
[1340] | 494 | G4double rsize = fSize[0]/fNSegment[IR]; |
---|
| 495 | G4double zhalf = fSize[1]/fNSegment[IZ]; |
---|
| 496 | G4double angle = twopi/fNSegment[IPHI]*idxColumn*radian; |
---|
| 497 | G4double dphi = twopi/fNSegment[IPHI]*radian; |
---|
| 498 | for(int z = 0; z < fNSegment[IZ]; z++) { |
---|
| 499 | for(int r = 0; r < fNSegment[IR]; r++) { |
---|
[998] | 500 | |
---|
| 501 | G4double rs[2] = {rsize*r, rsize*(r+1)}; |
---|
| 502 | G4Tubs cylinder("z-phi", rs[0], rs[1], zhalf, |
---|
| 503 | angle, dphi); |
---|
| 504 | |
---|
| 505 | G4ThreeVector zpos(0., 0., |
---|
[1340] | 506 | -fSize[1]+fSize[1]/fNSegment[IZ]*(2.*z+1)); |
---|
[998] | 507 | G4Transform3D trans; |
---|
| 508 | if(fRotationMatrix) { |
---|
| 509 | trans = G4Rotate3D(*fRotationMatrix).inverse()*G4Translate3D(zpos); |
---|
| 510 | trans = G4Translate3D(fCenterPosition)*trans; |
---|
| 511 | } else { |
---|
| 512 | trans = G4Translate3D(zpos)*G4Translate3D(fCenterPosition); |
---|
| 513 | } |
---|
| 514 | G4double c[4]; |
---|
| 515 | colorMap->GetMapColor(rzcell[r][z], c); |
---|
| 516 | att.SetColour(c[0], c[1], c[2]);//, c[3]); |
---|
| 517 | pVisManager->Draw(cylinder, att, trans); |
---|
| 518 | } |
---|
| 519 | } |
---|
| 520 | } |
---|
| 521 | } |
---|
| 522 | |
---|
[1340] | 523 | colorMap->SetPSUnit(fDrawUnit); |
---|
| 524 | colorMap->SetPSName(fDrawPSName); |
---|
[998] | 525 | colorMap->DrawColorChart(); |
---|
| 526 | |
---|
| 527 | } |
---|
| 528 | |
---|
| 529 | void G4ScoringCylinder::GetRZPhi(G4int index, G4int q[3]) const { |
---|
[1340] | 530 | // index = k + j * k-size + i * jk-plane-size |
---|
[998] | 531 | |
---|
[1340] | 532 | // nested : z -> phi -> r |
---|
| 533 | G4int i = IZ; |
---|
| 534 | G4int j = IPHI; |
---|
| 535 | G4int k = IR; |
---|
| 536 | G4int jk = fNSegment[j]*fNSegment[k]; |
---|
| 537 | q[i] = index/jk; |
---|
| 538 | q[j] = (index - q[i]*jk)/fNSegment[k]; |
---|
| 539 | q[k] = index - q[j]*fNSegment[k] - q[i]*jk; |
---|
[998] | 540 | } |
---|