Geant4-11
G4ScoringCylinder.cc
Go to the documentation of this file.
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//
27//
28
29#include "G4ScoringCylinder.hh"
30
31#include "G4VPhysicalVolume.hh"
32#include "G4Tubs.hh"
33#include "G4LogicalVolume.hh"
34#include "G4VPhysicalVolume.hh"
35#include "G4PVPlacement.hh"
36#include "G4PVReplica.hh"
37#include "G4PVDivision.hh"
38#include "G4VisAttributes.hh"
39#include "G4VVisManager.hh"
40#include "G4VScoreColorMap.hh"
41
42#include "G4SDManager.hh"
44#include "G4SDParticleFilter.hh"
45#include "G4VPrimitiveScorer.hh"
46#include "G4PSEnergyDeposit.hh"
47#include "G4PSTrackLength.hh"
48#include "G4PSNofStep.hh"
49#include "G4ScoringManager.hh"
50#include "G4StatDouble.hh"
51
53#include "G4SystemOfUnits.hh"
54
56 : G4VScoringMesh(wName)
57{
59
60 fDivisionAxisNames[0] = "Z";
61 fDivisionAxisNames[1] = "PHI";
62 fDivisionAxisNames[2] = "R";
63}
64
66
68{
69 if(verboseLevel > 9)
70 G4cout << "G4ScoringCylinder::SetupGeometry() ..." << G4endl;
71
72 // World
73 G4VPhysicalVolume* scoringWorld = fWorldPhys;
74 G4LogicalVolume* worldLogical = scoringWorld->GetLogicalVolume();
75
76 // Scoring Mesh
77 if(verboseLevel > 9)
79 G4String tubsName = fWorldName + "_mesh";
80
81 if(verboseLevel > 9)
82 {
83 G4cout << "R min, R max., Dz =: " << fSize[0] << ", " << fSize[1]
84 << ", " << fSize[2] << G4endl;
85 }
86 G4VSolid* tubsSolid = new G4Tubs(tubsName + "0", // name
87 fSize[0], // R min
88 fSize[1], // R max
89 fSize[2], // Dz
90 fAngle[0], // starting phi
91 fAngle[1]); // segment phi
92 G4LogicalVolume* tubsLogical = new G4LogicalVolume(tubsSolid, 0, tubsName);
94 tubsName + "0", worldLogical, false, 0);
95
96 if(verboseLevel > 9)
97 G4cout << " # of segments : r, phi, z =: " << fNSegment[IR] << ", "
98 << fNSegment[IPHI] << ", " << fNSegment[IZ] << G4endl;
99
100 G4String layerName[2] = { tubsName + "1", tubsName + "2" };
101 G4VSolid* layerSolid[2];
102 G4LogicalVolume* layerLogical[2];
103
104 //-- fisrt nested layer (replicated along z direction)
105 if(verboseLevel > 9)
106 G4cout << "layer 1 :" << G4endl;
107 layerSolid[0] = new G4Tubs(layerName[0], // name
108 fSize[0], // inner radius
109 fSize[1], // outer radius
110 fSize[2] / fNSegment[IZ], // half len. in z
111 fAngle[0], // starting phi angle
112 fAngle[1]); // delta angle of the segment
113 layerLogical[0] = new G4LogicalVolume(layerSolid[0], 0, layerName[0]);
114 if(fNSegment[IZ] > 1)
115 {
116 if(verboseLevel > 9)
117 G4cout << "G4ScoringCylinder::Construct() : Replicate along z direction"
118 << G4endl;
120 {
121 if(verboseLevel > 9)
122 G4cout << "G4ScoringCylinder::Construct() : Replica" << G4endl;
123 new G4PVReplica(layerName[0], layerLogical[0], tubsLogical, kZAxis,
124 fNSegment[IZ], 2. * fSize[2] / fNSegment[IZ]);
125 }
126 else
127 {
128 if(verboseLevel > 9)
129 G4cout << "G4ScoringCylinder::Construct() : Division" << G4endl;
130 new G4PVDivision(layerName[0], layerLogical[0], tubsLogical, kZAxis,
131 fNSegment[IZ], 0.);
132 }
133 }
134 else if(fNSegment[IZ] == 1)
135 {
136 if(verboseLevel > 9)
137 G4cout << "G4ScoringCylinder::Construct() : Placement" << G4endl;
138 new G4PVPlacement(0, G4ThreeVector(0., 0., 0.), layerLogical[0],
139 layerName[0], tubsLogical, false, 0);
140 }
141 else
142 {
143 G4cerr << "G4ScoringCylinder::SetupGeometry() : invalid parameter ("
144 << fNSegment[IZ] << ") "
145 << "in placement of the first nested layer." << G4endl;
146 }
147
148 // second nested layer (replicated along phi direction)
149 if(verboseLevel > 9)
150 G4cout << "layer 2 :" << G4endl;
151 layerSolid[1] =
152 new G4Tubs(layerName[1], fSize[0], fSize[1], fSize[2] / fNSegment[IZ],
153 fAngle[0], fAngle[1] / fNSegment[IPHI]);
154 layerLogical[1] = new G4LogicalVolume(layerSolid[1], 0, layerName[1]);
155 if(fNSegment[IPHI] > 1)
156 {
157 if(verboseLevel > 9)
158 G4cout << "G4ScoringCylinder::Construct() : Replicate along phi direction"
159 << G4endl;
161 {
162 if(verboseLevel > 9)
163 G4cout << "G4ScoringCylinder::Construct() : Replica" << G4endl;
164 new G4PVReplica(layerName[1], layerLogical[1], layerLogical[0], kPhi,
166 }
167 else
168 {
169 if(verboseLevel > 9)
170 G4cout << "G4ScoringCylinder::Construct() : Division" << G4endl;
171 new G4PVDivision(layerName[1], layerLogical[1], layerLogical[0], kPhi,
172 fNSegment[IPHI], 0.);
173 }
174 }
175 else if(fNSegment[IPHI] == 1)
176 {
177 if(verboseLevel > 9)
178 G4cout << "G4ScoringCylinder::Construct() : Placement" << G4endl;
179 new G4PVPlacement(0, G4ThreeVector(0., 0., 0.), layerLogical[1],
180 layerName[1], layerLogical[0], false, 0);
181 }
182 else
183 G4cerr << "ERROR : G4ScoringCylinder::SetupGeometry() : invalid parameter ("
184 << fNSegment[IPHI] << ") "
185 << "in placement of the second nested layer." << G4endl;
186
187 // mesh elements
188 if(verboseLevel > 9)
189 G4cout << "mesh elements :" << G4endl;
190 G4String elementName = tubsName + "3";
191 G4VSolid* elementSolid = new G4Tubs(
192 elementName, fSize[0], (fSize[1] - fSize[0]) / fNSegment[IR] + fSize[0],
193 fSize[2] / fNSegment[IZ], fAngle[0], fAngle[1] / fNSegment[IPHI]);
194 fMeshElementLogical = new G4LogicalVolume(elementSolid, 0, elementName);
195 if(fNSegment[IR] >= 1)
196 {
197 if(verboseLevel > 9)
198 G4cout << "G4ScoringCylinder::Construct() : Replicate along r direction"
199 << G4endl;
200
202 {
203 if(verboseLevel > 9)
204 G4cout << "G4ScoringCylinder::Construct() : Replica" << G4endl;
205 new G4PVReplica(elementName, fMeshElementLogical, layerLogical[1], kRho,
206 fNSegment[IR], (fSize[1] - fSize[0]) / fNSegment[IR],
207 fSize[0]);
208 }
209 else
210 {
211 if(verboseLevel > 9)
212 G4cout << "G4ScoringCylinder::Construct() : Division" << G4endl;
213 new G4PVDivision(elementName, fMeshElementLogical, layerLogical[1], kRho,
214 fNSegment[IR], 0.);
215 }
216 // } else if(fNSegment[IR] == 1) {
217 // if(verboseLevel > 9) G4cout << "G4ScoringCylinder::Construct() :
218 // Placement" << G4endl;
219 // G4cout<<"#@#@#@#@#@ G4ScoringCylinder::Construct() : Placement "<<G4endl;
220 // new G4PVPlacement(0, G4ThreeVector(0.,0.,0.), fMeshElementLogical,
221 // elementName, layerLogical[1], false, 0);
222 }
223 else
224 {
225 G4cerr << "G4ScoringCylinder::SetupGeometry() : "
226 << "invalid parameter (" << fNSegment[IR] << ") "
227 << "in mesh element placement." << G4endl;
228 }
229
230 // set the sensitive detector
232
233 // vis. attributes
234 G4VisAttributes* visatt = new G4VisAttributes(G4Colour(.5, .5, .5));
235 visatt->SetVisibility(true);
236 layerLogical[0]->SetVisAttributes(visatt);
237 layerLogical[1]->SetVisAttributes(visatt);
238 visatt = new G4VisAttributes(G4Colour(.5, .5, .5, 0.01));
239 // visatt->SetForceSolid(true);
241
242 if(verboseLevel > 9)
243 DumpVolumes();
244}
245
247{
248 G4cout << "G4ScoringCylinder : " << fWorldName
249 << " --- Shape: Cylindrical mesh" << G4endl;
250
251 G4cout << " Size (Rmin, Rmax, Dz): (" << fSize[0] / cm << ", "
252 << fSize[1] / cm << ", " << fSize[2] / cm << ") [cm]" << G4endl;
253 G4cout << " Angle (start, span): (" << fAngle[0] / deg << ", "
254 << fAngle[1] / deg << ") [deg]" << G4endl;
255
257}
258
260 G4int axflg)
261{
263 if(pVisManager)
264 {
265 // cell vectors
266 std::vector<double> ephi;
267 for(int phi = 0; phi < fNSegment[IPHI]; phi++)
268 ephi.push_back(0.);
269 //-
270 std::vector<std::vector<double>> zphicell; // zphicell[Z][PHI]
271 for(int z = 0; z < fNSegment[IZ]; z++)
272 zphicell.push_back(ephi);
273 //-
274 std::vector<std::vector<double>> rphicell; // rphicell[R][PHI]
275 for(int r = 0; r < fNSegment[IR]; r++)
276 rphicell.push_back(ephi);
277
278 // projections
279 G4int q[3];
280 std::map<G4int, G4StatDouble*>::iterator itr = map->GetMap()->begin();
281 for(; itr != map->GetMap()->end(); itr++)
282 {
283 if(itr->first < 0)
284 {
285 G4cout << itr->first << G4endl;
286 continue;
287 }
288 GetRZPhi(itr->first, q);
289
290 zphicell[q[IZ]][q[IPHI]] += (itr->second->sum_wx()) / fDrawUnitValue;
291 rphicell[q[IR]][q[IPHI]] += (itr->second->sum_wx()) / fDrawUnitValue;
292 }
293
294 // search min./max. values
295 G4double zphimin = DBL_MAX, rphimin = DBL_MAX;
296 G4double zphimax = 0., rphimax = 0.;
297 for(int iphi = 0; iphi < fNSegment[IPHI]; iphi++)
298 {
299 for(int iz = 0; iz < fNSegment[IZ]; iz++)
300 {
301 if(zphimin > zphicell[iz][iphi])
302 zphimin = zphicell[iz][iphi];
303 if(zphimax < zphicell[iz][iphi])
304 zphimax = zphicell[iz][iphi];
305 }
306 for(int ir = 0; ir < fNSegment[IR]; ir++)
307 {
308 if(rphimin > rphicell[ir][iphi])
309 rphimin = rphicell[ir][iphi];
310 if(rphimax < rphicell[ir][iphi])
311 rphimax = rphicell[ir][iphi];
312 }
313 }
314
315 G4VisAttributes att;
316 att.SetForceSolid(true);
317 att.SetForceAuxEdgeVisible(true);
318
319 G4Scale3D scale;
320 if(axflg / 100 == 1)
321 {
322 // rz plane
323 }
324 axflg = axflg % 100;
325 if(axflg / 10 == 1)
326 {
327 pVisManager->BeginDraw();
328
329 // z-phi plane
330 if(colorMap->IfFloatMinMax())
331 {
332 colorMap->SetMinMax(zphimin, zphimax);
333 }
334
335 G4double zhalf = fSize[2] / fNSegment[IZ];
336 for(int phi = 0; phi < fNSegment[IPHI]; phi++)
337 {
338 for(int z = 0; z < fNSegment[IZ]; z++)
339 {
340 //-
341 G4double angle = fAngle[0] + fAngle[1] / fNSegment[IPHI] * phi;
342 G4double dphi = fAngle[1] / fNSegment[IPHI];
343 G4Tubs cylinder(
344 "z-phi", // name
345 fSize[1] * 0.99, fSize[1], // inner radius, outer radius
346 zhalf, // half length in z
347 angle, dphi * 0.99999); // starting phi angle, delta angle
348 //-
349 G4ThreeVector zpos(
350 0., 0., -fSize[2] + fSize[2] / fNSegment[IZ] * (1 + 2. * z));
351 G4Transform3D trans;
353 {
354 trans =
355 G4Rotate3D(*fRotationMatrix).inverse() * G4Translate3D(zpos);
356 trans = G4Translate3D(fCenterPosition) * trans;
357 }
358 else
359 {
361 }
362 G4double c[4];
363 colorMap->GetMapColor(zphicell[z][phi], c);
364 att.SetColour(c[0], c[1], c[2]); //, c[3]);
365 //-
366 G4Polyhedron* poly = cylinder.GetPolyhedron();
367 poly->Transform(trans);
368 poly->SetVisAttributes(att);
369 pVisManager->Draw(*poly);
370 }
371 }
372 pVisManager->EndDraw();
373 }
374 axflg = axflg % 10;
375 if(axflg == 1)
376 {
377 pVisManager->BeginDraw();
378
379 // r-phi plane
380 if(colorMap->IfFloatMinMax())
381 {
382 colorMap->SetMinMax(rphimin, rphimax);
383 }
384
385 G4double rsize = (fSize[1] - fSize[0]) / fNSegment[IR];
386 for(int phi = 0; phi < fNSegment[IPHI]; phi++)
387 {
388 for(int r = 0; r < fNSegment[IR]; r++)
389 {
390 G4double rs[2] = { fSize[0] + rsize * r, fSize[0] + rsize * (r + 1) };
391 G4double angle = fAngle[0] + fAngle[1] / fNSegment[IPHI] * phi;
392 G4double dphi = fAngle[1] / fNSegment[IPHI];
393 G4Tubs cylindern("z-phi", rs[0], rs[1], 0.001, angle, dphi * 0.99999);
394 G4Tubs cylinderp = cylindern;
395
396 G4ThreeVector zposn(0., 0., -fSize[2]);
397 G4ThreeVector zposp(0., 0., fSize[2]);
398 G4Transform3D transn, transp;
400 {
401 transn =
402 G4Rotate3D(*fRotationMatrix).inverse() * G4Translate3D(zposn);
403 transn = G4Translate3D(fCenterPosition) * transn;
404 transp =
405 G4Rotate3D(*fRotationMatrix).inverse() * G4Translate3D(zposp);
406 transp = G4Translate3D(fCenterPosition) * transp;
407 }
408 else
409 {
412 }
413 G4double c[4];
414 colorMap->GetMapColor(rphicell[r][phi], c);
415 att.SetColour(c[0], c[1], c[2]); //, c[3]);
416
417 G4Polyhedron* polyn = cylindern.GetPolyhedron();
418 polyn->Transform(transn);
419 polyn->SetVisAttributes(att);
420 pVisManager->Draw(*polyn);
421
422 G4Polyhedron* polyp = cylinderp.GetPolyhedron();
423 polyp->Transform(transp);
424 polyp->SetVisAttributes(att);
425 pVisManager->Draw(*polyp);
426 }
427 }
428
429 pVisManager->EndDraw();
430 }
431
432 colorMap->SetPSUnit(fDrawUnit);
433 colorMap->SetPSName(fDrawPSName);
434 colorMap->DrawColorChart();
435 }
436}
437
439 G4int idxProj, G4int idxColumn)
440{
441 G4int projAxis = 0;
442 switch(idxProj)
443 {
444 case 0:
445 projAxis = IR;
446 break;
447 case 1:
448 projAxis = IZ;
449 break;
450 case 2:
451 projAxis = IPHI;
452 break;
453 }
454
455 if(idxColumn < 0 || idxColumn >= fNSegment[projAxis])
456 {
457 G4cerr << "Warning : Column number " << idxColumn
458 << " is out of scoring mesh [0," << fNSegment[projAxis] - 1
459 << "]. Method ignored." << G4endl;
460 return;
461 }
463 if(pVisManager)
464 {
465 // cell vectors
466 std::vector<std::vector<std::vector<double>>> cell; // cell[R][Z][PHI]
467 std::vector<double> ephi;
468 for(int phi = 0; phi < fNSegment[IPHI]; phi++)
469 ephi.push_back(0.);
470 std::vector<std::vector<double>> ezphi;
471 for(int z = 0; z < fNSegment[IZ]; z++)
472 ezphi.push_back(ephi);
473 for(int r = 0; r < fNSegment[IR]; r++)
474 cell.push_back(ezphi);
475
476 std::vector<std::vector<double>> rzcell; // rzcell[R][Z]
477 std::vector<double> ez;
478 for(int z = 0; z < fNSegment[IZ]; z++)
479 ez.push_back(0.);
480 for(int r = 0; r < fNSegment[IR]; r++)
481 rzcell.push_back(ez);
482
483 std::vector<std::vector<double>> zphicell; // zphicell[Z][PHI]
484 for(int z = 0; z < fNSegment[IZ]; z++)
485 zphicell.push_back(ephi);
486
487 std::vector<std::vector<double>> rphicell; // rphicell[R][PHI]
488 for(int r = 0; r < fNSegment[IR]; r++)
489 rphicell.push_back(ephi);
490
491 // projections
492 G4int q[3];
493 std::map<G4int, G4StatDouble*>::iterator itr = map->GetMap()->begin();
494 for(; itr != map->GetMap()->end(); itr++)
495 {
496 if(itr->first < 0)
497 {
498 G4cout << itr->first << G4endl;
499 continue;
500 }
501 GetRZPhi(itr->first, q);
502
503 if(projAxis == IR && q[IR] == idxColumn)
504 { // zphi plane
505 zphicell[q[IZ]][q[IPHI]] += (itr->second->sum_wx()) / fDrawUnitValue;
506 }
507 if(projAxis == IZ && q[IZ] == idxColumn)
508 { // rphi plane
509 rphicell[q[IR]][q[IPHI]] += (itr->second->sum_wx()) / fDrawUnitValue;
510 }
511 if(projAxis == IPHI && q[IPHI] == idxColumn)
512 { // rz plane
513 rzcell[q[IR]][q[IZ]] += (itr->second->sum_wx()) / fDrawUnitValue;
514 }
515 }
516
517 // search min./max. values
518 G4double rzmin = DBL_MAX, zphimin = DBL_MAX, rphimin = DBL_MAX;
519 G4double rzmax = 0., zphimax = 0., rphimax = 0.;
520 for(int r = 0; r < fNSegment[IR]; r++)
521 {
522 for(int phi = 0; phi < fNSegment[IPHI]; phi++)
523 {
524 if(rphimin > rphicell[r][phi])
525 rphimin = rphicell[r][phi];
526 if(rphimax < rphicell[r][phi])
527 rphimax = rphicell[r][phi];
528 }
529 for(int z = 0; z < fNSegment[IZ]; z++)
530 {
531 if(rzmin > rzcell[r][z])
532 rzmin = rzcell[r][z];
533 if(rzmax < rzcell[r][z])
534 rzmax = rzcell[r][z];
535 }
536 }
537 for(int z = 0; z < fNSegment[IZ]; z++)
538 {
539 for(int phi = 0; phi < fNSegment[IPHI]; phi++)
540 {
541 if(zphimin > zphicell[z][phi])
542 zphimin = zphicell[z][phi];
543 if(zphimax < zphicell[z][phi])
544 zphimax = zphicell[z][phi];
545 }
546 }
547
548 G4VisAttributes att;
549 att.SetForceSolid(true);
550 att.SetForceAuxEdgeVisible(true);
551
552 pVisManager->BeginDraw();
553
554 G4Scale3D scale;
555 // z-phi plane
556 if(projAxis == IR)
557 {
558 if(colorMap->IfFloatMinMax())
559 {
560 colorMap->SetMinMax(zphimin, zphimax);
561 }
562
563 G4double zhalf = fSize[2] / fNSegment[IZ];
564 G4double rsize[2] = {
565 fSize[0] + (fSize[1] - fSize[0]) / fNSegment[IR] * idxColumn,
566 fSize[0] + (fSize[1] - fSize[0]) / fNSegment[IR] * (idxColumn + 1)
567 };
568 for(int phi = 0; phi < fNSegment[IPHI]; phi++)
569 {
570 for(int z = 0; z < fNSegment[IZ]; z++)
571 {
572 G4double angle = fAngle[0] + fAngle[1] / fNSegment[IPHI] * phi;
573 G4double dphi = fAngle[1] / fNSegment[IPHI];
574 G4Tubs cylinder("z-phi", rsize[0], rsize[1], zhalf, angle,
575 dphi * 0.99999);
576
577 G4ThreeVector zpos(
578 0., 0., -fSize[2] + fSize[2] / fNSegment[IZ] * (1 + 2. * z));
579 G4Transform3D trans;
581 {
582 trans =
583 G4Rotate3D(*fRotationMatrix).inverse() * G4Translate3D(zpos);
584 trans = G4Translate3D(fCenterPosition) * trans;
585 }
586 else
587 {
589 }
590 G4double c[4];
591 colorMap->GetMapColor(zphicell[z][phi], c);
592 att.SetColour(c[0], c[1], c[2]); //, c[3]);
593
594 G4Polyhedron* poly = cylinder.GetPolyhedron();
595 poly->Transform(trans);
596 poly->SetVisAttributes(att);
597 pVisManager->Draw(*poly);
598 }
599 }
600
601 // r-phi plane
602 }
603 else if(projAxis == IZ)
604 {
605 if(colorMap->IfFloatMinMax())
606 {
607 colorMap->SetMinMax(rphimin, rphimax);
608 }
609
610 G4double rsize = (fSize[1] - fSize[0]) / fNSegment[IR];
611 for(int phi = 0; phi < fNSegment[IPHI]; phi++)
612 {
613 for(int r = 0; r < fNSegment[IR]; r++)
614 {
615 G4double rs[2] = { fSize[0] + rsize * r, fSize[0] + rsize * (r + 1) };
616 G4double angle = fAngle[0] + fAngle[1] / fNSegment[IPHI] * phi;
617 G4double dz = fSize[2] / fNSegment[IZ];
618 G4double dphi = fAngle[1] / fNSegment[IPHI];
619 G4Tubs cylinder("r-phi", rs[0], rs[1], dz, angle, dphi * 0.99999);
620 G4ThreeVector zpos(
621 0., 0., -fSize[2] + fSize[2] / fNSegment[IZ] * (idxColumn * 2 + 1));
622 G4Transform3D trans;
624 {
625 trans =
626 G4Rotate3D(*fRotationMatrix).inverse() * G4Translate3D(zpos);
627 trans = G4Translate3D(fCenterPosition) * trans;
628 }
629 else
630 {
632 }
633 G4double c[4];
634 colorMap->GetMapColor(rphicell[r][phi], c);
635 att.SetColour(c[0], c[1], c[2]); //, c[3]);
636
637 G4Polyhedron* poly = cylinder.GetPolyhedron();
638 poly->Transform(trans);
639 poly->SetVisAttributes(att);
640 pVisManager->Draw(*poly);
641 }
642 }
643
644 // r-z plane
645 }
646 else if(projAxis == IPHI)
647 {
648 if(colorMap->IfFloatMinMax())
649 {
650 colorMap->SetMinMax(rzmin, rzmax);
651 }
652
653 G4double rsize = (fSize[1] - fSize[0]) / fNSegment[IR];
654 G4double zhalf = fSize[2] / fNSegment[IZ];
655 G4double angle = fAngle[0] + fAngle[1] / fNSegment[IPHI] * idxColumn;
656 G4double dphi = fAngle[1] / fNSegment[IPHI];
657 for(int z = 0; z < fNSegment[IZ]; z++)
658 {
659 for(int r = 0; r < fNSegment[IR]; r++)
660 {
661 G4double rs[2] = { fSize[0] + rsize * r, fSize[0] + rsize * (r + 1) };
662 G4Tubs cylinder("z-phi", rs[0], rs[1], zhalf, angle, dphi);
663
664 G4ThreeVector zpos(
665 0., 0., -fSize[2] + fSize[2] / fNSegment[IZ] * (2. * z + 1));
666 G4Transform3D trans;
668 {
669 trans =
670 G4Rotate3D(*fRotationMatrix).inverse() * G4Translate3D(zpos);
671 trans = G4Translate3D(fCenterPosition) * trans;
672 }
673 else
674 {
676 }
677 G4double c[4];
678 colorMap->GetMapColor(rzcell[r][z], c);
679 att.SetColour(c[0], c[1], c[2]); //, c[3]);
680
681 G4Polyhedron* poly = cylinder.GetPolyhedron();
682 poly->Transform(trans);
683 poly->SetVisAttributes(att);
684 pVisManager->Draw(*poly);
685 }
686 }
687 }
688 pVisManager->EndDraw();
689 }
690
691 colorMap->SetPSUnit(fDrawUnit);
692 colorMap->SetPSName(fDrawPSName);
693 colorMap->DrawColorChart();
694}
695
697{
698 // index = k + j * k-size + i * jk-plane-size
699
700 // nested : z -> phi -> r
701 G4int i = IZ;
702 G4int j = IPHI;
703 G4int k = IR;
704 G4int jk = fNSegment[j] * fNSegment[k];
705 q[i] = index / jk;
706 q[j] = (index - q[i] * jk) / fNSegment[k];
707 q[k] = index - q[j] * fNSegment[k] - q[i] * jk;
708}
709
710#include "G4UnitsTable.hh"
711#include "G4VSolid.hh"
712#include "G4SolidStore.hh"
713#include "G4LogicalVolume.hh"
715#include "G4Material.hh"
717#include "G4VPhysicalVolume.hh"
719
721{
722 G4int lvl = 2;
723 DumpSolids(lvl);
724 DumpLogVols(lvl);
725 DumpPhysVols(lvl);
726}
727
729{
730 G4cout << "*********** List of registered solids *************" << G4endl;
731 auto store = G4SolidStore::GetInstance();
732 auto itr = store->begin();
733 for(; itr != store->end(); itr++)
734 {
735 switch(lvl)
736 {
737 case 0:
738 G4cout << (*itr)->GetName() << G4endl;
739 break;
740 case 1:
741 G4cout << (*itr)->GetName() << "\t volume = "
742 << G4BestUnit((*itr)->GetCubicVolume(), "Volume")
743 << "\t surface = "
744 << G4BestUnit((*itr)->GetSurfaceArea(), "Surface") << G4endl;
745 break;
746 default:
747 (*itr)->DumpInfo();
748 break;
749 }
750 }
751}
752
754{
755 G4cout << "*********** List of registered logical volumes *************"
756 << G4endl;
758 auto itr = store->begin();
759 for(; itr != store->end(); itr++)
760 {
761 G4cout << (*itr)->GetName()
762 << "\t Solid = " << (*itr)->GetSolid()->GetName();
763 if((*itr)->GetMaterial())
764 {
765 G4cout << "\t Material = " << (*itr)->GetMaterial()->GetName() << G4endl;
766 }
767 else
768 {
769 G4cout << "\t Material : not defined " << G4endl;
770 }
771 if(lvl < 1)
772 continue;
773 G4cout << "\t region = ";
774 if((*itr)->GetRegion())
775 {
776 G4cout << (*itr)->GetRegion()->GetName();
777 }
778 else
779 {
780 G4cout << "not defined";
781 }
782 G4cout << "\t sensitive detector = ";
783 if((*itr)->GetSensitiveDetector())
784 {
785 G4cout << (*itr)->GetSensitiveDetector()->GetName();
786 }
787 else
788 {
789 G4cout << "not defined";
790 }
791 G4cout << G4endl;
792 G4cout << "\t daughters = " << (*itr)->GetNoDaughters();
793 if((*itr)->GetNoDaughters() > 0)
794 {
795 switch((*itr)->CharacteriseDaughters())
796 {
797 case kNormal:
798 G4cout << " (placement)";
799 break;
800 case kReplica:
801 G4cout << " (replica : " << (*itr)->GetDaughter(0)->GetMultiplicity()
802 << ")";
803 break;
804 case kParameterised:
805 G4cout << " (parameterized : "
806 << (*itr)->GetDaughter(0)->GetMultiplicity() << ")";
807 break;
808 default:;
809 }
810 }
811 G4cout << G4endl;
812 if(lvl < 2)
813 continue;
814 if((*itr)->GetMaterial())
815 {
816 G4cout << "\t weight = " << G4BestUnit((*itr)->GetMass(), "Mass")
817 << G4endl;
818 }
819 else
820 {
821 G4cout << "\t weight : not available" << G4endl;
822 }
823 }
824}
825
827{
828 G4cout << "*********** List of registered physical volumes *************"
829 << G4endl;
831 auto itr = store->begin();
832 for(; itr != store->end(); itr++)
833 {
834 switch(lvl)
835 {
836 case 0:
837 G4cout << (*itr)->GetName() << G4endl;
838 break;
839 case 1:
840 G4cout << (*itr)->GetName() << "\t logical volume = "
841 << (*itr)->GetLogicalVolume()->GetName()
842 << "\t mother logical = ";
843 if((*itr)->GetMotherLogical())
844 {
845 G4cout << (*itr)->GetMotherLogical()->GetName();
846 }
847 else
848 {
849 G4cout << "not defined";
850 }
851 G4cout << G4endl;
852 break;
853 default:
854 G4cout << (*itr)->GetName() << "\t logical volume = "
855 << (*itr)->GetLogicalVolume()->GetName()
856 << "\t mother logical = ";
857 if((*itr)->GetMotherLogical())
858 {
859 G4cout << (*itr)->GetMotherLogical()->GetName();
860 }
861 else
862 {
863 G4cout << "not defined";
864 }
865 G4cout << "\t type = ";
866 switch((*itr)->VolumeType())
867 {
868 case kNormal:
869 G4cout << "placement";
870 break;
871 case kReplica:
872 G4cout << "replica";
873 break;
874 case kParameterised:
875 G4cout << "parameterized";
876 break;
877 default:;
878 }
879 G4cout << G4endl;
880 }
881 }
882}
static constexpr double cm
Definition: G4SIunits.hh:99
static constexpr double deg
Definition: G4SIunits.hh:132
static const G4double angle[DIMMOTT]
#define G4BestUnit(a, b)
CLHEP::Hep3Vector G4ThreeVector
HepGeom::Translate3D G4Translate3D
HepGeom::Rotate3D G4Rotate3D
double G4double
Definition: G4Types.hh:83
int G4int
Definition: G4Types.hh:85
G4GLOB_DLL std::ostream G4cerr
#define G4endl
Definition: G4ios.hh:57
G4GLOB_DLL std::ostream G4cout
virtual G4Polyhedron * GetPolyhedron() const
Definition: G4CSGSolid.cc:129
static G4LogicalVolumeStore * GetInstance()
void SetVisAttributes(const G4VisAttributes *pVA)
void SetSensitiveDetector(G4VSensitiveDetector *pSDetector)
static G4PhysicalVolumeStore * GetInstance()
void GetRZPhi(G4int index, G4int q[3]) const
virtual void DrawColumn(RunScore *map, G4VScoreColorMap *colorMap, G4int idxProj, G4int idxColumn)
virtual void SetupGeometry(G4VPhysicalVolume *fWorldPhys)
virtual void List() const
G4ScoringCylinder(G4String wName)
virtual void Draw(RunScore *map, G4VScoreColorMap *colorMap, G4int axflg=111)
static G4int GetReplicaLevel()
static G4SolidStore * GetInstance()
Definition: G4Tubs.hh:75
G4LogicalVolume * GetLogicalVolume() const
virtual void DrawColorChart(G4int nPoint=5)
G4bool IfFloatMinMax() const
void SetMinMax(G4double minVal, G4double maxVal)
void SetPSUnit(G4String &unit)
virtual void GetMapColor(G4double val, G4double color[4])=0
void SetPSName(G4String &psName)
G4RotationMatrix * fRotationMatrix
virtual void List() const
G4double fDrawUnitValue
G4String fDrawPSName
G4MultiFunctionalDetector * fMFD
G4String fDivisionAxisNames[3]
G4LogicalVolume * fMeshElementLogical
G4double fAngle[2]
G4double fSize[3]
G4ThreeVector fCenterPosition
virtual void EndDraw()=0
static G4VVisManager * GetConcreteInstance()
virtual void Draw(const G4Circle &, const G4Transform3D &objectTransformation=G4Transform3D())=0
virtual void BeginDraw(const G4Transform3D &objectTransformation=G4Transform3D())=0
void SetColour(const G4Colour &)
void SetVisibility(G4bool=true)
void SetForceAuxEdgeVisible(G4bool=true)
void SetForceSolid(G4bool=true)
void SetVisAttributes(const G4VisAttributes *)
Definition: G4Visible.cc:96
Transform3D inverse() const
Definition: Transform3D.cc:141
HepPolyhedron & Transform(const G4Transform3D &t)
@ kPhi
Definition: geomdefs.hh:60
@ kZAxis
Definition: geomdefs.hh:57
@ kRho
Definition: geomdefs.hh:58
@ kNormal
Definition: geomdefs.hh:84
@ kParameterised
Definition: geomdefs.hh:86
@ kReplica
Definition: geomdefs.hh:85
#define DBL_MAX
Definition: templates.hh:62