Geant4  v4-10.4-release
 모두 클래스 네임스페이스들 파일들 함수 변수 타입정의 열거형 타입 열거형 멤버 Friends 매크로 그룹들 페이지들
B01RunAction.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 //
28 //
29 //
30 // $Id: B01RunAction.cc 98774 2016-08-09 14:28:06Z gcosmo $
31 //
32 #include "B01RunAction.hh"
33 #include "B01Run.hh"
34 
35 //-- In order to obtain detector information.
36 #include "G4RunManager.hh"
38 #include "G4THitsMap.hh"
39 
40 #include "G4UnitsTable.hh"
41 
42 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
43 //
44 // B01RunAction
45 //
46 //
47 //
48 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
49 
50 // Constructor
53  // fFieldName(15),
54  fFieldValue(14)
55 {
56  // - Prepare data member for B01Run.
57  // vector represents a list of MultiFunctionalDetector names.
58  fSDName.push_back(G4String("ConcreteSD"));
59 }
60 
61 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
62 
63 // Destructor.
65 {
66  fSDName.clear();
67 }
68 
69 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
70 
72 {
73  // Generate new RUN object, which is specially
74  // dedicated for MultiFunctionalDetector scheme.
75  // Detail description can be found in B01Run.hh/cc.
76  return new B01Run(fSDName);
77 }
78 
79 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
80 
82 {
83  G4cout << "### Run " << aRun->GetRunID() << " start." << G4endl;
84 }
85 
86 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
87 
89 {
90  G4cout << " ###### EndOfRunAction " <<G4endl;
91  //- B01Run object.
92  B01Run* b01Run = (B01Run*)aRun;
93  //--- Dump all socred quantities involved in B01Run.
94  // re02Run->DumpAllScorer();
95  //---
97  //
98 
99  for ( G4int i = 0; i < (G4int)fSDName.size(); i++ ){
100  const G4VUserDetectorConstruction* vdet =
103  //
104 
105  //---------------------------------------------
106  // Dump accumulated quantities for this RUN.
107  // (Display only central region of x-y plane)
108  // 0 ConcreteSD/Collisions
109  // 1 ConcreteSD/CollWeight
110  // 2 ConcreteSD/Population
111  // 3 ConcreteSD/TrackEnter
112  // 4 ConcreteSD/SL
113  // 5 ConcreteSD/SLW
114  // 6 ConcreteSD/SLWE
115  // 7 ConcreteSD/SLW_V
116  // 8 ConcreteSD/SLWE_V
117  //---------------------------------------------
118  G4THitsMap<G4double>* Collisions =
119  b01Run->GetHitsMap(fSDName[i]+"/Collisions");
120  G4THitsMap<G4double>* CollWeight =
121  b01Run->GetHitsMap(fSDName[i]+"/CollWeight");
122  G4THitsMap<G4double>* Population =
123  b01Run->GetHitsMap(fSDName[i]+"/Population");
124  G4THitsMap<G4double>* TrackEnter =
125  b01Run->GetHitsMap(fSDName[i]+"/TrackEnter");
126  G4THitsMap<G4double>* SL = b01Run->GetHitsMap(fSDName[i]+"/SL");
127  G4THitsMap<G4double>* SLW = b01Run->GetHitsMap(fSDName[i]+"/SLW");
128  G4THitsMap<G4double>* SLWE = b01Run->GetHitsMap(fSDName[i]+"/SLWE");
129  G4THitsMap<G4double>* SLW_V = b01Run->GetHitsMap(fSDName[i]+"/SLW_V");
130  G4THitsMap<G4double>* SLWE_V = b01Run->GetHitsMap(fSDName[i]+"/SLWE_V");
131 
132  if (IsMaster())
133  {
134  G4cout <<
135  "\n--------------------End of Global Run-----------------------" <<
136  G4endl;
137  G4cout <<
138  " Number of event processed : "<< aRun->GetNumberOfEvent() << G4endl;
139  }
140  else
141  {
142  G4cout <<
143  "\n--------------------End of Local Run------------------------" <<
144  G4endl;
145  G4cout <<
146  " Number of event processed : "<< aRun->GetNumberOfEvent() << G4endl;
147  }
148 
149  G4cout << "============================================================="
150  <<G4endl;
151  G4cout << "============================================================="
152  <<G4endl;
153 
154  std::ostream *myout = &G4cout;
155  PrintHeader(myout);
156 
157  for ( G4int iz = 0; iz < 20; iz++){
158  G4double* SumCollisions = (*Collisions)[iz];
159  G4double* SumCollWeight = (*CollWeight)[iz];
160  G4double* Populations = (*Population)[iz];
161  G4double* TrackEnters = (*TrackEnter)[iz];
162  G4double* SLs = (*SL)[iz];
163  G4double* SLWs = (*SLW)[iz];
164  G4double* SLWEs = (*SLWE)[iz];
165  G4double* SLW_Vs = (*SLW_V)[iz];
166  G4double* SLWE_Vs = (*SLWE_V)[iz];
167  if ( !SumCollisions ) SumCollisions = new G4double(0.0);
168  if ( !SumCollWeight ) SumCollWeight = new G4double(0.0);
169  if ( !Populations ) Populations = new G4double(0.0);
170  if ( !TrackEnters ) TrackEnters = new G4double(0.0);
171  if ( !SLs ) SLs = new G4double(0.0);
172  if ( !SLWs ) SLWs = new G4double(0.0);
173  if ( !SLWEs ) SLWEs = new G4double(0.0);
174  if ( !SLW_Vs ) SLW_Vs = new G4double(0.0);
175  if ( !SLWE_Vs ) SLWE_Vs = new G4double(0.0);
176  G4double NumWeightedEnergy =0.0;
177  G4double FluxWeightedEnergy=0.0;
178  G4double AverageTrackWeight=0.0;
179  if ( *SLW_Vs !=0. ) NumWeightedEnergy = (*SLWE_Vs)/(*SLW_Vs);
180  if ( *SLWs !=0. ) FluxWeightedEnergy = (*SLWEs)/(*SLWs);
181  if ( *SLs !=0. ) AverageTrackWeight = (*SLWs)/(*SLs);
182  G4String cname = bdet->GetCellName(iz);
183  G4cout
184  << std::setw(fFieldValue) << cname << " |"
185  << std::setw(fFieldValue) << (*TrackEnters) << " |"
186  << std::setw(fFieldValue) << (*Populations) << " |"
187  << std::setw(fFieldValue) << (*SumCollisions) << " |"
188  << std::setw(fFieldValue) << (*SumCollWeight) << " |"
189  << std::setw(fFieldValue) << NumWeightedEnergy << " |"
190  << std::setw(fFieldValue) << FluxWeightedEnergy << " |"
191  << std::setw(fFieldValue) << AverageTrackWeight << " |"
192  << std::setw(fFieldValue) << (*SLs) << " |"
193  << std::setw(fFieldValue) << (*SLWs) << " |"
194  << std::setw(fFieldValue) << (*SLW_Vs) << " |"
195  << std::setw(fFieldValue) << (*SLWEs) << " |"
196  << std::setw(fFieldValue) << (*SLWE_Vs) << " |"
197  << G4endl;
198  }
199  G4cout << "============================================="<<G4endl;
200  }
201 }
202 
203 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
204 
205 void B01RunAction::PrintHeader(std::ostream *out)
206 {
207  std::vector<G4String> vecScoreName;
208  vecScoreName.push_back("Tr.Entering");
209  vecScoreName.push_back("Population");
210  vecScoreName.push_back("Collisions");
211  vecScoreName.push_back("Coll*WGT");
212  vecScoreName.push_back("NumWGTedE");
213  vecScoreName.push_back("FluxWGTedE");
214  vecScoreName.push_back("Av.Tr.WGT");
215  vecScoreName.push_back("SL");
216  vecScoreName.push_back("SLW");
217  vecScoreName.push_back("SLW_v");
218  vecScoreName.push_back("SLWE");
219  vecScoreName.push_back("SLWE_v");
220 
221  // head line
222 // std::string vname;
223 // vname = FillString("Volume", ' ', fFieldName+1);
224  //*out << vname << '|';
225  *out << std::setw(fFieldValue) << "Volume" << " |";
226  for (std::vector<G4String>::iterator it = vecScoreName.begin();
227  it != vecScoreName.end(); it++) {
228 // vname = FillString((*it),
229 // ' ',
230 // fFieldValue+1,
231 // false);
232 // *out << vname << '|';
233  *out << std::setw(fFieldValue) << (*it) << " |";
234  }
235  *out << G4endl;
236 }
237 
238 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
239 
240 std::string B01RunAction::FillString(const std::string &name,
241  char c, G4int n, G4bool back)
242 {
243  std::string fname("");
244  G4int k = n - name.size();
245  if (k > 0) {
246  if (back) {
247  fname = name;
248  fname += std::string(k,c);
249  }
250  else {
251  fname = std::string(k,c);
252  fname += name;
253  }
254  }
255  else {
256  fname = name;
257  }
258  return fname;
259 }
260 
261 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
static G4RunManager * GetRunManager()
Definition: G4RunManager.cc:80
std::string FillString(const std::string &name, char c, G4int n, G4bool back=true)
const XML_Char * name
Definition: expat.h:151
Definition: B01Run.hh:50
#define G4endl
Definition: G4ios.hh:61
virtual ~B01RunAction()
Definition: B01RunAction.cc:64
virtual void EndOfRunAction(const G4Run *)
Definition: B01RunAction.cc:88
std::vector< G4String > fSDName
Definition: B01RunAction.hh:70
G4int GetNumberOfEvent() const
Definition: G4Run.hh:79
double G4double
Definition: G4Types.hh:76
bool G4bool
Definition: G4Types.hh:79
Definition of the B01Run class.
G4int GetRunID() const
Definition: G4Run.hh:76
static const G4double * SL[nLA]
G4bool IsMaster() const
Definition: G4Run.hh:46
virtual G4Run * GenerateRun()
Definition: B01RunAction.cc:71
int G4int
Definition: G4Types.hh:78
void PrintHeader(std::ostream *out)
virtual void BeginOfRunAction(const G4Run *)
Definition: B01RunAction.cc:81
G4GLOB_DLL std::ostream G4cout
Definition of the B01DetectorConstruction class.
G4THitsMap< G4double > * GetHitsMap(G4int i)
Definition: B01Run.hh:70
Char_t n[5]
Definition of the B01RunAction class.
const G4VUserDetectorConstruction * GetUserDetectorConstruction() const
G4int fFieldValue
Definition: B01RunAction.hh:72