Geant4 Cross Reference |
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 /// \file biasing/B01/src/B01RunAction.cc 27 /// \brief Implementation of the B01RunAction class 28 // 29 // 30 // 31 #include "B01RunAction.hh" 32 33 #include "B01Run.hh" 34 35 //-- In order to obtain detector information. 36 #include "B01DetectorConstruction.hh" 37 38 #include "G4RunManager.hh" 39 #include "G4THitsMap.hh" 40 #include "G4UnitsTable.hh" 41 42 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 43 // 44 // B01RunAction 45 // 46 // 47 // 48 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 49 50 // Constructor 51 B01RunAction::B01RunAction() 52 : G4UserRunAction(), 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. 64 B01RunAction::~B01RunAction() 65 { 66 fSDName.clear(); 67 } 68 69 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 70 71 G4Run* B01RunAction::GenerateRun() 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 81 void B01RunAction::BeginOfRunAction(const G4Run* aRun) 82 { 83 G4cout << "### Run " << aRun->GetRunID() << " start." << G4endl; 84 } 85 86 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 87 88 void B01RunAction::EndOfRunAction(const G4Run* aRun) 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 //--- 96 G4RunManager* mgr = G4RunManager::GetRunManager(); 97 // 98 99 for (G4int i = 0; i < (G4int)fSDName.size(); i++) { 100 const G4VUserDetectorConstruction* vdet = mgr->GetUserDetectorConstruction(); 101 B01DetectorConstruction* bdet = (B01DetectorConstruction*)vdet; 102 // 103 104 //--------------------------------------------- 105 // Dump accumulated quantities for this RUN. 106 // (Display only central region of x-y plane) 107 // 0 ConcreteSD/Collisions 108 // 1 ConcreteSD/CollWeight 109 // 2 ConcreteSD/Population 110 // 3 ConcreteSD/TrackEnter 111 // 4 ConcreteSD/SL 112 // 5 ConcreteSD/SLW 113 // 6 ConcreteSD/SLWE 114 // 7 ConcreteSD/SLW_V 115 // 8 ConcreteSD/SLWE_V 116 //--------------------------------------------- 117 G4THitsMap<G4double>* Collisions = b01Run->GetHitsMap(fSDName[i] + "/Collisions"); 118 G4THitsMap<G4double>* CollWeight = b01Run->GetHitsMap(fSDName[i] + "/CollWeight"); 119 G4THitsMap<G4double>* Population = b01Run->GetHitsMap(fSDName[i] + "/Population"); 120 G4THitsMap<G4double>* TrackEnter = b01Run->GetHitsMap(fSDName[i] + "/TrackEnter"); 121 G4THitsMap<G4double>* SL = b01Run->GetHitsMap(fSDName[i] + "/SL"); 122 G4THitsMap<G4double>* SLW = b01Run->GetHitsMap(fSDName[i] + "/SLW"); 123 G4THitsMap<G4double>* SLWE = b01Run->GetHitsMap(fSDName[i] + "/SLWE"); 124 G4THitsMap<G4double>* SLW_V = b01Run->GetHitsMap(fSDName[i] + "/SLW_V"); 125 G4THitsMap<G4double>* SLWE_V = b01Run->GetHitsMap(fSDName[i] + "/SLWE_V"); 126 127 if (IsMaster()) { 128 G4cout << "\n--------------------End of Global Run-----------------------" << G4endl; 129 G4cout << " Number of event processed : " << aRun->GetNumberOfEvent() << G4endl; 130 } 131 else { 132 G4cout << "\n--------------------End of Local Run------------------------" << G4endl; 133 G4cout << " Number of event processed : " << aRun->GetNumberOfEvent() << G4endl; 134 } 135 136 G4cout << "=============================================================" << G4endl; 137 G4cout << "=============================================================" << G4endl; 138 139 std::ostream* myout = &G4cout; 140 PrintHeader(myout); 141 142 for (G4int iz = 0; iz < 20; iz++) { 143 G4double* SumCollisions = (*Collisions)[iz]; 144 G4double* SumCollWeight = (*CollWeight)[iz]; 145 G4double* Populations = (*Population)[iz]; 146 G4double* TrackEnters = (*TrackEnter)[iz]; 147 G4double* SLs = (*SL)[iz]; 148 G4double* SLWs = (*SLW)[iz]; 149 G4double* SLWEs = (*SLWE)[iz]; 150 G4double* SLW_Vs = (*SLW_V)[iz]; 151 G4double* SLWE_Vs = (*SLWE_V)[iz]; 152 if (!SumCollisions) SumCollisions = new G4double(0.0); 153 if (!SumCollWeight) SumCollWeight = new G4double(0.0); 154 if (!Populations) Populations = new G4double(0.0); 155 if (!TrackEnters) TrackEnters = new G4double(0.0); 156 if (!SLs) SLs = new G4double(0.0); 157 if (!SLWs) SLWs = new G4double(0.0); 158 if (!SLWEs) SLWEs = new G4double(0.0); 159 if (!SLW_Vs) SLW_Vs = new G4double(0.0); 160 if (!SLWE_Vs) SLWE_Vs = new G4double(0.0); 161 G4double NumWeightedEnergy = 0.0; 162 G4double FluxWeightedEnergy = 0.0; 163 G4double AverageTrackWeight = 0.0; 164 if (*SLW_Vs != 0.) NumWeightedEnergy = (*SLWE_Vs) / (*SLW_Vs); 165 if (*SLWs != 0.) FluxWeightedEnergy = (*SLWEs) / (*SLWs); 166 if (*SLs != 0.) AverageTrackWeight = (*SLWs) / (*SLs); 167 G4String cname = bdet->GetCellName(iz); 168 G4cout << std::setw(fFieldValue) << cname << " |" << std::setw(fFieldValue) << (*TrackEnters) 169 << " |" << std::setw(fFieldValue) << (*Populations) << " |" << std::setw(fFieldValue) 170 << (*SumCollisions) << " |" << std::setw(fFieldValue) << (*SumCollWeight) << " |" 171 << std::setw(fFieldValue) << NumWeightedEnergy << " |" << std::setw(fFieldValue) 172 << FluxWeightedEnergy << " |" << std::setw(fFieldValue) << AverageTrackWeight << " |" 173 << std::setw(fFieldValue) << (*SLs) << " |" << std::setw(fFieldValue) << (*SLWs) 174 << " |" << std::setw(fFieldValue) << (*SLW_Vs) << " |" << std::setw(fFieldValue) 175 << (*SLWEs) << " |" << std::setw(fFieldValue) << (*SLWE_Vs) << " |" << G4endl; 176 } 177 G4cout << "=============================================" << G4endl; 178 } 179 } 180 181 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 182 183 void B01RunAction::PrintHeader(std::ostream* out) 184 { 185 std::vector<G4String> vecScoreName; 186 vecScoreName.push_back("Tr.Entering"); 187 vecScoreName.push_back("Population"); 188 vecScoreName.push_back("Collisions"); 189 vecScoreName.push_back("Coll*WGT"); 190 vecScoreName.push_back("NumWGTedE"); 191 vecScoreName.push_back("FluxWGTedE"); 192 vecScoreName.push_back("Av.Tr.WGT"); 193 vecScoreName.push_back("SL"); 194 vecScoreName.push_back("SLW"); 195 vecScoreName.push_back("SLW_v"); 196 vecScoreName.push_back("SLWE"); 197 vecScoreName.push_back("SLWE_v"); 198 199 // head line 200 // std::string vname; 201 // vname = FillString("Volume", ' ', fFieldName+1); 202 //*out << vname << '|'; 203 *out << std::setw(fFieldValue) << "Volume" 204 << " |"; 205 for (std::vector<G4String>::iterator it = vecScoreName.begin(); it != vecScoreName.end(); it++) { 206 // vname = FillString((*it), 207 // ' ', 208 // fFieldValue+1, 209 // false); 210 // *out << vname << '|'; 211 *out << std::setw(fFieldValue) << (*it) << " |"; 212 } 213 *out << G4endl; 214 } 215 216 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 217 218 std::string B01RunAction::FillString(const std::string& name, char c, G4int n, G4bool back) 219 { 220 std::string fname(""); 221 G4int k = n - name.size(); 222 if (k > 0) { 223 if (back) { 224 fname = name; 225 fname += std::string(k, c); 226 } 227 else { 228 fname = std::string(k, c); 229 fname += name; 230 } 231 } 232 else { 233 fname = name; 234 } 235 return fname; 236 } 237 238 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 239