Geant4  v4-10.4-release
 모두 클래스 네임스페이스들 파일들 함수 변수 타입정의 열거형 타입 열거형 멤버 Friends 매크로 그룹들 페이지들
G4TrajectoryEncounteredVolumeFilter.cc
이 파일의 문서화 페이지로 가기
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 // $Id: G4TrajectoryEncounteredVolumeFilter.cc 95107 2016-01-26 12:41:11Z allison $
27 //
28 // Filter trajectories according to encountered volume name. Only registered
29 // volumes will pass the filter.
30 //
31 // John Allison, Feb 2016
32 //
35 #include "G4VTrajectoryPoint.hh"
36 #include "G4AttValue.hh"
37 #include "G4RichTrajectory.hh"
38 
41 {}
42 
44 
45 bool
47 {
48  try
49  {
50  const G4RichTrajectory& richTrajectory = dynamic_cast<const G4RichTrajectory&>(traj);
51 
52  for (const auto& pvname: fVolumes) {
53  for (G4int iPoint = 0; iPoint < richTrajectory.GetPointEntries(); iPoint++) {
54  G4VTrajectoryPoint* point = richTrajectory.GetPoint(iPoint);
55  if (!point) continue;
56  std::vector<G4AttValue>* attValues = point->CreateAttValues();
57  std::vector<G4AttValue>::const_iterator iAtt;
58  for (iAtt = attValues->begin(); iAtt != attValues->end(); ++iAtt) {
59  if (iAtt->GetName() == "PostVPath" &&
60  iAtt->GetValue().contains(pvname)) break;
61  }
62  if (iAtt != attValues->end()) { // Required value found
63  return true; // First found pvname determines selection.
64  }
65  }
66  }
67  return false;
68  }
69 
70  catch (const std::bad_cast&)
71  {
73  ed << "Requires G4RichTrajectory - \"/vis/scene/add/trajectories rich\"";
75  ("G4TrajectoryEncounteredVolumeFilter::Evaluate(const G4VTrajectory& traj)",
76  "modeling0126",
77  JustWarning, ed);
78  return false;
79  }
80 }
81 
82 void
84 {
85  fVolumes.push_back(volume);
86 }
87 
88 void
90 {
91  ostr<<"Volume names registered: "<<G4endl;
92  std::vector<G4String>::const_iterator iter = fVolumes.begin();
93 
94  while (iter != fVolumes.end()) {
95  ostr<<*iter<<G4endl;
96  iter++;
97  }
98 }
99 
100 void
102 {
103  // Clear volume vector
104  fVolumes.clear();
105 }
const XML_Char * name
Definition: expat.h:151
std::ostringstream G4ExceptionDescription
Definition: G4Exception.hh:45
int GetPointEntries() const
#define G4endl
Definition: G4ios.hh:61
virtual bool Evaluate(const G4VTrajectory &) const
virtual std::vector< G4AttValue > * CreateAttValues() const
G4TrajectoryEncounteredVolumeFilter(const G4String &name="Unspecified")
G4VTrajectoryPoint * GetPoint(G4int i) const
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
Definition: G4Exception.hh:65
int G4int
Definition: G4Types.hh:78
virtual void Print(std::ostream &ostr) const