Geant4 9.6.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4ScoringBox Class Reference

#include <G4ScoringBox.hh>

+ Inheritance diagram for G4ScoringBox:

Public Member Functions

 G4ScoringBox (G4String wName)
 
 ~G4ScoringBox ()
 
void Construct (G4VPhysicalVolume *fWorldPhys)
 
void List () const
 
void Draw (std::map< G4int, G4double * > *map, G4VScoreColorMap *colorMap, G4int axflg=111)
 
void DrawColumn (std::map< G4int, G4double * > *map, G4VScoreColorMap *colorMap, G4int idxProj, G4int idxColumn)
 
void SetSegmentDirection (G4int dir)
 
- Public Member Functions inherited from G4VScoringMesh
 G4VScoringMesh (const G4String &wName)
 
virtual ~G4VScoringMesh ()
 
virtual void Construct (G4VPhysicalVolume *fWorldPhys)=0
 
virtual void List () const
 
const G4StringGetWorldName () const
 
G4bool IsActive () const
 
void Activate (G4bool vl=true)
 
MeshShape GetShape () const
 
void Accumulate (G4THitsMap< G4double > *map)
 
void Dump ()
 
void DrawMesh (const G4String &psName, G4VScoreColorMap *colorMap, G4int axflg=111)
 
void DrawMesh (const G4String &psName, G4int idxPlane, G4int iColumn, G4VScoreColorMap *colorMap)
 
virtual void Draw (std::map< G4int, G4double * > *map, G4VScoreColorMap *colorMap, G4int axflg=111)=0
 
virtual void DrawColumn (std::map< G4int, G4double * > *map, G4VScoreColorMap *colorMap, G4int idxProj, G4int idxColumn)=0
 
void ResetScore ()
 
void SetSize (G4double size[3])
 
G4ThreeVector GetSize () const
 
void SetCenterPosition (G4double centerPosition[3])
 
G4ThreeVector GetTranslation () const
 
void RotateX (G4double delta)
 
void RotateY (G4double delta)
 
void RotateZ (G4double delta)
 
G4RotationMatrix GetRotationMatrix () const
 
void SetNumberOfSegments (G4int nSegment[3])
 
void GetNumberOfSegments (G4int nSegment[3])
 
void SetPrimitiveScorer (G4VPrimitiveScorer *ps)
 
void SetFilter (G4VSDFilter *filter)
 
void SetCurrentPrimitiveScorer (const G4String &name)
 
G4bool FindPrimitiveScorer (const G4String &psname)
 
G4bool IsCurrentPrimitiveScorerNull ()
 
G4String GetPSUnit (const G4String &psname)
 
G4String GetCurrentPSUnit ()
 
void SetCurrentPSUnit (const G4String &unit)
 
G4double GetPSUnitValue (const G4String &psname)
 
void SetDrawPSName (const G4String &psname)
 
void GetDivisionAxisNames (G4String divisionAxisNames[3])
 
void SetNullToCurrentPrimitiveScorer ()
 
void SetVerboseLevel (G4int vl)
 
MeshScoreMap GetScoreMap ()
 
G4bool ReadyForQuantity () const
 

Additional Inherited Members

- Protected Member Functions inherited from G4VScoringMesh
G4VPrimitiveScorerGetPrimitiveScorer (const G4String &name)
 
- Protected Attributes inherited from G4VScoringMesh
G4String fWorldName
 
G4VPrimitiveScorerfCurrentPS
 
G4bool fConstructed
 
G4bool fActive
 
MeshShape fShape
 
G4double fSize [3]
 
G4ThreeVector fCenterPosition
 
G4RotationMatrixfRotationMatrix
 
G4int fNSegment [3]
 
std::map< G4String, G4THitsMap< G4double > * > fMap
 
G4MultiFunctionalDetectorfMFD
 
G4int verboseLevel
 
G4bool sizeIsSet
 
G4bool nMeshIsSet
 
G4String fDrawUnit
 
G4double fDrawUnitValue
 
G4String fDrawPSName
 
G4String fDivisionAxisNames [3]
 

Detailed Description

Definition at line 43 of file G4ScoringBox.hh.

Constructor & Destructor Documentation

◆ G4ScoringBox()

G4ScoringBox::G4ScoringBox ( G4String  wName)

Definition at line 52 of file G4ScoringBox.cc.

53 :G4VScoringMesh(wName), fSegmentDirection(-1),
54 fMeshElementLogical(0)
55{
57 fDivisionAxisNames[0] = "X";
58 fDivisionAxisNames[1] = "Y";
59 fDivisionAxisNames[2] = "Z";
60}
@ boxMesh
G4String fDivisionAxisNames[3]

◆ ~G4ScoringBox()

G4ScoringBox::~G4ScoringBox ( )

Definition at line 62 of file G4ScoringBox.cc.

63{
64}

Member Function Documentation

◆ Construct()

void G4ScoringBox::Construct ( G4VPhysicalVolume fWorldPhys)
virtual

Implements G4VScoringMesh.

Definition at line 66 of file G4ScoringBox.cc.

67{
68 if(fConstructed) {
69
70 if(verboseLevel > 0)
71 G4cout << fWorldPhys->GetName() << " --- All quantities are reset." << G4endl;
72 ResetScore();
73
74 } else {
75 fConstructed = true;
76 SetupGeometry(fWorldPhys);
77 }
78}
#define G4endl
Definition: G4ios.hh:52
G4DLLIMPORT std::ostream G4cout
const G4String & GetName() const

◆ Draw()

void G4ScoringBox::Draw ( std::map< G4int, G4double * > *  map,
G4VScoreColorMap colorMap,
G4int  axflg = 111 
)
virtual

Implements G4VScoringMesh.

Definition at line 245 of file G4ScoringBox.cc.

245 {
246
248 if(pVisManager) {
249
250 // cell vectors
251 std::vector<std::vector<std::vector<double> > > cell; // cell[X][Y][Z]
252 std::vector<double> ez;
253 for(int z = 0; z < fNSegment[2]; z++) ez.push_back(0.);
254 std::vector<std::vector<double> > eyz;
255 for(int y = 0; y < fNSegment[1]; y++) eyz.push_back(ez);
256 for(int x = 0; x < fNSegment[0]; x++) cell.push_back(eyz);
257
258 std::vector<std::vector<double> > xycell; // xycell[X][Y]
259 std::vector<double> ey;
260 for(int y = 0; y < fNSegment[1]; y++) ey.push_back(0.);
261 for(int x = 0; x < fNSegment[0]; x++) xycell.push_back(ey);
262
263 std::vector<std::vector<double> > yzcell; // yzcell[Y][Z]
264 for(int y = 0; y < fNSegment[1]; y++) yzcell.push_back(ez);
265
266 std::vector<std::vector<double> > xzcell; // xzcell[X][Z]
267 for(int x = 0; x < fNSegment[0]; x++) xzcell.push_back(ez);
268
269 // projections
270 G4int q[3];
271 std::map<G4int, G4double*>::iterator itr = map->begin();
272 for(; itr != map->end(); itr++) {
273 GetXYZ(itr->first, q);
274
275 xycell[q[0]][q[1]] += *(itr->second)/fDrawUnitValue;
276 yzcell[q[1]][q[2]] += *(itr->second)/fDrawUnitValue;
277 xzcell[q[0]][q[2]] += *(itr->second)/fDrawUnitValue;
278 }
279
280 // search max. & min. values in each slice
281 G4double xymin = DBL_MAX, yzmin = DBL_MAX, xzmin = DBL_MAX;
282 G4double xymax = 0., yzmax = 0., xzmax = 0.;
283 for(int x = 0; x < fNSegment[0]; x++) {
284 for(int y = 0; y < fNSegment[1]; y++) {
285 if(xymin > xycell[x][y]) xymin = xycell[x][y];
286 if(xymax < xycell[x][y]) xymax = xycell[x][y];
287 }
288 for(int z = 0; z < fNSegment[2]; z++) {
289 if(xzmin > xzcell[x][z]) xzmin = xzcell[x][z];
290 if(xzmax < xzcell[x][z]) xzmax = xzcell[x][z];
291 }
292 }
293 for(int y = 0; y < fNSegment[1]; y++) {
294 for(int z = 0; z < fNSegment[2]; z++) {
295 if(yzmin > yzcell[y][z]) yzmin = yzcell[y][z];
296 if(yzmax < yzcell[y][z]) yzmax = yzcell[y][z];
297 }
298 }
299
300
301 G4VisAttributes att;
302 att.SetForceSolid(true);
303 att.SetForceAuxEdgeVisible(true);
304
305 G4Scale3D scale;
306 if(axflg/100==1) {
307 // xy plane
308 if(colorMap->IfFloatMinMax()) { colorMap->SetMinMax(xymin ,xymax); }
309 G4ThreeVector zhalf(0., 0., fSize[2]/fNSegment[2]*0.98);
310 G4Box xyplate("xy", fSize[0]/fNSegment[0], fSize[1]/fNSegment[1], fSize[2]/fNSegment[2]*0.01);
311 for(int x = 0; x < fNSegment[0]; x++) {
312 for(int y = 0; y < fNSegment[1]; y++) {
313 G4ThreeVector pos(GetReplicaPosition(x, y, 0) - zhalf);
314 G4ThreeVector pos2(GetReplicaPosition(x, y, fNSegment[2]-1) + zhalf);
315 G4Transform3D trans, trans2;
316 if(fRotationMatrix) {
317 trans = G4Rotate3D(*fRotationMatrix).inverse()*G4Translate3D(pos);
318 trans = G4Translate3D(fCenterPosition)*trans;
319 trans2 = G4Rotate3D(*fRotationMatrix).inverse()*G4Translate3D(pos2);
320 trans2 = G4Translate3D(fCenterPosition)*trans2;
321 } else {
324 }
325 G4double c[4];
326 colorMap->GetMapColor(xycell[x][y], c);
327 att.SetColour(c[0], c[1], c[2]);//, c[3]);
328 pVisManager->Draw(xyplate, att, trans);
329 pVisManager->Draw(xyplate, att, trans2);
330
331 }
332 }
333 }
334 axflg = axflg%100;
335 if(axflg/10==1) {
336 // yz plane
337 if(colorMap->IfFloatMinMax()) { colorMap->SetMinMax(yzmin, yzmax); }
338 G4ThreeVector xhalf(fSize[0]/fNSegment[0]*0.98, 0., 0.);
339 G4Box yzplate("yz", fSize[0]/fNSegment[0]*0.01, fSize[1]/fNSegment[1], fSize[2]/fNSegment[2]);
340 for(int y = 0; y < fNSegment[1]; y++) {
341 for(int z = 0; z < fNSegment[2]; z++) {
342 G4ThreeVector pos(GetReplicaPosition(0, y, z) - xhalf);
343 G4ThreeVector pos2(GetReplicaPosition(fNSegment[0]-1, y, z) + xhalf);
344 G4Transform3D trans, trans2;
345 if(fRotationMatrix) {
346 trans = G4Rotate3D(*fRotationMatrix).inverse()*G4Translate3D(pos);
347 trans = G4Translate3D(fCenterPosition)*trans;
348 trans2 = G4Rotate3D(*fRotationMatrix).inverse()*G4Translate3D(pos2);
349 trans2 = G4Translate3D(fCenterPosition)*trans2;
350 } else {
353 }
354 G4double c[4];
355 colorMap->GetMapColor(yzcell[y][z], c);
356 att.SetColour(c[0], c[1], c[2]);//, c[3]);
357 pVisManager->Draw(yzplate, att, trans);
358 pVisManager->Draw(yzplate, att, trans2);
359
360 }
361 }
362 }
363 axflg = axflg%10;
364 if(axflg==1) {
365 // xz plane
366 if(colorMap->IfFloatMinMax()) { colorMap->SetMinMax(xzmin,xzmax); }
367 G4ThreeVector yhalf(0., fSize[1]/fNSegment[1]*0.98, 0.);
368 G4Box xzplate("xz", fSize[0]/fNSegment[0], fSize[1]/fNSegment[1]*0.01, fSize[2]/fNSegment[2]);
369 for(int x = 0; x < fNSegment[0]; x++) {
370 for(int z = 0; z < fNSegment[2]; z++) {
371 G4ThreeVector pos(GetReplicaPosition(x, 0, z) - yhalf);
372 G4ThreeVector pos2(GetReplicaPosition(x, fNSegment[1]-1, z) + yhalf);
373 G4Transform3D trans, trans2;
374 if(fRotationMatrix) {
375 trans = G4Rotate3D(*fRotationMatrix).inverse()*G4Translate3D(pos);
376 trans = G4Translate3D(fCenterPosition)*trans;
377 trans2 = G4Rotate3D(*fRotationMatrix).inverse()*G4Translate3D(pos2);
378 trans2 = G4Translate3D(fCenterPosition)*trans2;
379 } else {
382 }
383 G4double c[4];
384 colorMap->GetMapColor(xzcell[x][z], c);
385 att.SetColour(c[0], c[1], c[2]);//, c[3]);
386 pVisManager->Draw(xzplate, att, trans);
387 pVisManager->Draw(xzplate, att, trans2);
388
389 }
390 }
391 }
392 }
393 colorMap->SetPSUnit(fDrawUnit);
394 colorMap->SetPSName(fDrawPSName);
395 colorMap->DrawColorChart();
396}
HepGeom::Translate3D G4Translate3D
HepGeom::Rotate3D G4Rotate3D
double G4double
Definition: G4Types.hh:64
int G4int
Definition: G4Types.hh:66
Definition: G4Box.hh:55
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
G4double fDrawUnitValue
G4String fDrawPSName
G4double fSize[3]
G4ThreeVector fCenterPosition
static G4VVisManager * GetConcreteInstance()
virtual void Draw(const G4Circle &, const G4Transform3D &objectTransformation=G4Transform3D())=0
void SetForceAuxEdgeVisible(G4bool)
void SetColour(const G4Colour &)
void SetForceSolid(G4bool)
Transform3D inverse() const
Definition: Transform3D.cc:142
#define DBL_MAX
Definition: templates.hh:83

◆ DrawColumn()

void G4ScoringBox::DrawColumn ( std::map< G4int, G4double * > *  map,
G4VScoreColorMap colorMap,
G4int  idxProj,
G4int  idxColumn 
)
virtual

Implements G4VScoringMesh.

Definition at line 420 of file G4ScoringBox.cc.

422{
423 if(idxColumn<0 || idxColumn>=fNSegment[idxProj])
424 {
425 G4cerr << "ERROR : Column number " << idxColumn << " is out of scoring mesh [0," << fNSegment[idxProj]-1 <<
426 "]. Method ignored." << G4endl;
427 return;
428 }
430 if(pVisManager) {
431
432 // cell vectors
433 std::vector<std::vector<std::vector<double> > > cell; // cell[X][Y][Z]
434 std::vector<double> ez;
435 for(int z = 0; z < fNSegment[2]; z++) ez.push_back(0.);
436 std::vector<std::vector<double> > eyz;
437 for(int y = 0; y < fNSegment[1]; y++) eyz.push_back(ez);
438 for(int x = 0; x < fNSegment[0]; x++) cell.push_back(eyz);
439
440 std::vector<std::vector<double> > xycell; // xycell[X][Y]
441 std::vector<double> ey;
442 for(int y = 0; y < fNSegment[1]; y++) ey.push_back(0.);
443 for(int x = 0; x < fNSegment[0]; x++) xycell.push_back(ey);
444
445 std::vector<std::vector<double> > yzcell; // yzcell[Y][Z]
446 for(int y = 0; y < fNSegment[1]; y++) yzcell.push_back(ez);
447
448 std::vector<std::vector<double> > xzcell; // xzcell[X][Z]
449 for(int x = 0; x < fNSegment[0]; x++) xzcell.push_back(ez);
450
451 // projections
452 G4int q[3];
453 std::map<G4int, G4double*>::iterator itr = map->begin();
454 for(; itr != map->end(); itr++) {
455 GetXYZ(itr->first, q);
456
457 if(idxProj == 0 && q[2] == idxColumn) { // xy plane
458 xycell[q[0]][q[1]] += *(itr->second)/fDrawUnitValue;
459 }
460 if(idxProj == 1 && q[0] == idxColumn) { // yz plane
461 yzcell[q[1]][q[2]] += *(itr->second)/fDrawUnitValue;
462 }
463 if(idxProj == 2 && q[1] == idxColumn) { // zx plane
464 xzcell[q[0]][q[2]] += *(itr->second)/fDrawUnitValue;
465 }
466 }
467
468 // search max. & min. values in each slice
469 G4double xymin = DBL_MAX, yzmin = DBL_MAX, xzmin = DBL_MAX;
470 G4double xymax = 0., yzmax = 0., xzmax = 0.;
471 for(int x = 0; x < fNSegment[0]; x++) {
472 for(int y = 0; y < fNSegment[1]; y++) {
473 if(xymin > xycell[x][y]) xymin = xycell[x][y];
474 if(xymax < xycell[x][y]) xymax = xycell[x][y];
475 }
476 for(int z = 0; z < fNSegment[2]; z++) {
477 if(xzmin > xzcell[x][z]) xzmin = xzcell[x][z];
478 if(xzmax < xzcell[x][z]) xzmax = xzcell[x][z];
479 }
480 }
481 for(int y = 0; y < fNSegment[1]; y++) {
482 for(int z = 0; z < fNSegment[2]; z++) {
483 if(yzmin > yzcell[y][z]) yzmin = yzcell[y][z];
484 if(yzmax < yzcell[y][z]) yzmax = yzcell[y][z];
485 }
486 }
487
488
489 G4VisAttributes att;
490 att.SetForceSolid(true);
491 att.SetForceAuxEdgeVisible(true);
492
493
494 G4Scale3D scale;
495 // xy plane
496 if(idxProj == 0) {
497 if(colorMap->IfFloatMinMax()) { colorMap->SetMinMax(xymin,xymax); }
498 G4Box xyplate("xy", fSize[0]/fNSegment[0], fSize[1]/fNSegment[1], fSize[2]/fNSegment[2]);
499 for(int x = 0; x < fNSegment[0]; x++) {
500 for(int y = 0; y < fNSegment[1]; y++) {
501 G4ThreeVector pos(GetReplicaPosition(x, y, idxColumn));
502 G4Transform3D trans;
503 if(fRotationMatrix) {
504 trans = G4Rotate3D(*fRotationMatrix).inverse()*G4Translate3D(pos);
505 trans = G4Translate3D(fCenterPosition)*trans;
506 } else {
508 }
509 G4double c[4];
510 colorMap->GetMapColor(xycell[x][y], c);
511 att.SetColour(c[0], c[1], c[2]);//, c[3]);
512 pVisManager->Draw(xyplate, att, trans);
513
514 }
515 }
516 } else
517 // yz plane
518 if(idxProj == 1) {
519 if(colorMap->IfFloatMinMax()) { colorMap->SetMinMax(yzmin,yzmax); }
520 G4Box yzplate("yz", fSize[0]/fNSegment[0], fSize[1]/fNSegment[1], fSize[2]/fNSegment[2]);
521 for(int y = 0; y < fNSegment[1]; y++) {
522 for(int z = 0; z < fNSegment[2]; z++) {
523 G4ThreeVector pos(GetReplicaPosition(idxColumn, y, z));
524 G4Transform3D trans;
525 if(fRotationMatrix) {
526 trans = G4Rotate3D(*fRotationMatrix).inverse()*G4Translate3D(pos);
527 trans = G4Translate3D(fCenterPosition)*trans;
528 } else {
530 }
531 G4double c[4];
532 colorMap->GetMapColor(yzcell[y][z], c);
533 att.SetColour(c[0], c[1], c[2]);//, c[3]);
534 pVisManager->Draw(yzplate, att, trans);
535 }
536 }
537 } else
538 // xz plane
539 if(idxProj == 2) {
540 if(colorMap->IfFloatMinMax()) { colorMap->SetMinMax(xzmin,xzmax);}
541 G4Box xzplate("xz", fSize[0]/fNSegment[0], fSize[1]/fNSegment[1], fSize[2]/fNSegment[2]);
542 for(int x = 0; x < fNSegment[0]; x++) {
543 for(int z = 0; z < fNSegment[2]; z++) {
544 G4ThreeVector pos(GetReplicaPosition(x, idxColumn, z));
545 G4Transform3D trans;
546 if(fRotationMatrix) {
547 trans = G4Rotate3D(*fRotationMatrix).inverse()*G4Translate3D(pos);
548 trans = G4Translate3D(fCenterPosition)*trans;
549 } else {
551 }
552 G4double c[4];
553 colorMap->GetMapColor(xzcell[x][z], c);
554 att.SetColour(c[0], c[1], c[2]);//, c[3]);
555 pVisManager->Draw(xzplate, att, trans);
556 }
557 }
558 }
559 }
560
561 colorMap->SetPSUnit(fDrawUnit);
562 colorMap->SetPSName(fDrawPSName);
563 colorMap->DrawColorChart();
564}
G4DLLIMPORT std::ostream G4cerr

◆ List()

void G4ScoringBox::List ( ) const
virtual

Reimplemented from G4VScoringMesh.

Definition at line 234 of file G4ScoringBox.cc.

234 {
235 G4cout << "G4ScoringBox : " << fWorldName << " --- Shape: Box mesh" << G4endl;
236 G4cout << " Size (x, y, z): ("
237 << fSize[0]/cm << ", "
238 << fSize[1]/cm << ", "
239 << fSize[2]/cm << ") [cm]"
240 << G4endl;
241
243}
virtual void List() const

◆ SetSegmentDirection()

void G4ScoringBox::SetSegmentDirection ( G4int  dir)
inline

Definition at line 57 of file G4ScoringBox.hh.

57{fSegmentDirection = dir;}

The documentation for this class was generated from the following files: