Geant4 Cross Reference |
1 // 1 // 2 // ******************************************* 2 // ******************************************************************** 3 // * License and Disclaimer 3 // * License and Disclaimer * 4 // * 4 // * * 5 // * The Geant4 software is copyright of th 5 // * The Geant4 software is copyright of the Copyright Holders of * 6 // * the Geant4 Collaboration. It is provided 6 // * the Geant4 Collaboration. It is provided under the terms and * 7 // * conditions of the Geant4 Software License 7 // * conditions of the Geant4 Software License, included in the file * 8 // * LICENSE and available at http://cern.ch/ 8 // * LICENSE and available at http://cern.ch/geant4/license . These * 9 // * include a list of copyright holders. 9 // * include a list of copyright holders. * 10 // * 10 // * * 11 // * Neither the authors of this software syst 11 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing fin 12 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warran 13 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assum 14 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file 15 // * use. Please see the license in the file LICENSE and URL above * 16 // * for the full disclaimer and the limitatio 16 // * for the full disclaimer and the limitation of liability. * 17 // * 17 // * * 18 // * This code implementation is the result 18 // * This code implementation is the result of the scientific and * 19 // * technical work of the GEANT4 collaboratio 19 // * technical work of the GEANT4 collaboration. * 20 // * By using, copying, modifying or distri 20 // * By using, copying, modifying or distributing the software (or * 21 // * any work based on the software) you ag 21 // * any work based on the software) you agree to acknowledge its * 22 // * use in resulting scientific publicati 22 // * use in resulting scientific publications, and indicate your * 23 // * acceptance of all terms of the Geant4 Sof 23 // * acceptance of all terms of the Geant4 Software license. * 24 // ******************************************* 24 // ******************************************************************** 25 // 25 // 26 /// \file biasing/B02/src/B02RunAction.cc 26 /// \file biasing/B02/src/B02RunAction.cc 27 /// \brief Implementation of the B02RunAction 27 /// \brief Implementation of the B02RunAction class 28 // 28 // 29 // 29 // 30 // << 30 // $Id: B02RunAction.cc 77475 2013-11-25 09:38:51Z gcosmo $ >> 31 // 31 #include "B02RunAction.hh" 32 #include "B02RunAction.hh" 32 << 33 #include "B02Run.hh" 33 #include "B02Run.hh" 34 34 35 //-- In order to obtain detector information. 35 //-- In order to obtain detector information. >> 36 #include "G4RunManager.hh" 36 #include "B02DetectorConstruction.hh" 37 #include "B02DetectorConstruction.hh" 37 #include "B02ImportanceDetectorConstruction.hh 38 #include "B02ImportanceDetectorConstruction.hh" 38 << 39 #include "G4RunManager.hh" << 40 #include "G4THitsMap.hh" 39 #include "G4THitsMap.hh" >> 40 41 #include "G4UnitsTable.hh" 41 #include "G4UnitsTable.hh" 42 42 43 //....oooOO0OOooo........oooOO0OOooo........oo 43 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 44 // 44 // 45 // B02RunAction 45 // B02RunAction 46 // << 46 // 47 // 47 // 48 // 48 // 49 //....oooOO0OOooo........oooOO0OOooo........oo 49 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 50 50 51 // Constructor 51 // Constructor 52 B02RunAction::B02RunAction() << 52 B02RunAction::B02RunAction(): 53 : G4UserRunAction(), << 53 G4UserRunAction(), 54 // fFieldName(15), << 54 // fFieldName(15), 55 fFieldValue(14) << 55 fFieldValue(14) 56 { 56 { 57 // - Prepare data member for B02Run. 57 // - Prepare data member for B02Run. 58 // vector represents a list of MultiFuncti 58 // vector represents a list of MultiFunctionalDetector names. 59 fSDName.push_back(G4String("ConcreteSD")); 59 fSDName.push_back(G4String("ConcreteSD")); 60 } 60 } 61 61 62 //....oooOO0OOooo........oooOO0OOooo........oo 62 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 63 63 64 // Destructor. 64 // Destructor. 65 B02RunAction::~B02RunAction() 65 B02RunAction::~B02RunAction() 66 { 66 { 67 fSDName.clear(); 67 fSDName.clear(); 68 } 68 } 69 69 70 //....oooOO0OOooo........oooOO0OOooo........oo 70 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 71 71 72 G4Run* B02RunAction::GenerateRun() 72 G4Run* B02RunAction::GenerateRun() 73 { 73 { 74 // Generate new RUN object, which is special 74 // Generate new RUN object, which is specially 75 // dedicated for MultiFunctionalDetector sch 75 // dedicated for MultiFunctionalDetector scheme. 76 // Detail description can be found in B02Ru 76 // Detail description can be found in B02Run.hh/cc. 77 return new B02Run(fSDName); 77 return new B02Run(fSDName); 78 } 78 } 79 79 80 //....oooOO0OOooo........oooOO0OOooo........oo 80 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 81 81 82 void B02RunAction::BeginOfRunAction(const G4Ru 82 void B02RunAction::BeginOfRunAction(const G4Run* aRun) 83 { 83 { 84 G4cout << "### Run " << aRun->GetRunID() << 84 G4cout << "### Run " << aRun->GetRunID() << " start." << G4endl; 85 } 85 } 86 86 87 //....oooOO0OOooo........oooOO0OOooo........oo 87 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 88 88 89 void B02RunAction::EndOfRunAction(const G4Run* 89 void B02RunAction::EndOfRunAction(const G4Run* aRun) 90 { 90 { 91 G4cout << " ###### EndOfRunAction " << G4en << 91 G4cout << " ###### EndOfRunAction " <<G4endl; 92 //- B02Run object. 92 //- B02Run object. 93 B02Run* b02Run = (B02Run*)aRun; 93 B02Run* b02Run = (B02Run*)aRun; 94 //--- Dump all socred quantities involved in 94 //--- Dump all socred quantities involved in B02Run. 95 // re02Run->DumpAllScorer(); 95 // re02Run->DumpAllScorer(); 96 //--- 96 //--- 97 G4RunManager* mgr = G4RunManager::GetRunMana 97 G4RunManager* mgr = G4RunManager::GetRunManager(); 98 // 98 // 99 << 99 100 for (G4int i = 0; i < (G4int)fSDName.size(); << 100 for ( G4int i = 0; i < (G4int)fSDName.size(); i++ ){ 101 const G4VUserDetectorConstruction* vdet = << 101 const G4VUserDetectorConstruction* vdet = 102 B02ImportanceDetectorConstruction* bdet = << 102 mgr->GetUserDetectorConstruction(); >> 103 B02ImportanceDetectorConstruction* bdet = >> 104 (B02ImportanceDetectorConstruction*)vdet; 103 // 105 // 104 << 106 105 //---------------------------------------- 107 //--------------------------------------------- 106 // Dump accumulated quantities for this RU 108 // Dump accumulated quantities for this RUN. 107 // (Display only central region of x-y pl 109 // (Display only central region of x-y plane) 108 // 0 ConcreteSD/Collisions 110 // 0 ConcreteSD/Collisions 109 // 1 ConcreteSD/CollWeight 111 // 1 ConcreteSD/CollWeight 110 // 2 ConcreteSD/Population 112 // 2 ConcreteSD/Population 111 // 3 ConcreteSD/TrackEnter 113 // 3 ConcreteSD/TrackEnter 112 // 4 ConcreteSD/SL 114 // 4 ConcreteSD/SL 113 // 5 ConcreteSD/SLW 115 // 5 ConcreteSD/SLW 114 // 6 ConcreteSD/SLWE 116 // 6 ConcreteSD/SLWE 115 // 7 ConcreteSD/SLW_V 117 // 7 ConcreteSD/SLW_V 116 // 8 ConcreteSD/SLWE_V 118 // 8 ConcreteSD/SLWE_V 117 //---------------------------------------- 119 //--------------------------------------------- 118 G4THitsMap<G4double>* Collisions = b02Run- << 120 G4THitsMap<G4double>* Collisions = 119 G4THitsMap<G4double>* CollWeight = b02Run- << 121 b02Run->GetHitsMap(fSDName[i]+"/Collisions"); 120 G4THitsMap<G4double>* Population = b02Run- << 122 G4THitsMap<G4double>* CollWeight = 121 G4THitsMap<G4double>* TrackEnter = b02Run- << 123 b02Run->GetHitsMap(fSDName[i]+"/CollWeight"); 122 G4THitsMap<G4double>* SL = b02Run->GetHits << 124 G4THitsMap<G4double>* Population = 123 G4THitsMap<G4double>* SLW = b02Run->GetHit << 125 b02Run->GetHitsMap(fSDName[i]+"/Population"); 124 G4THitsMap<G4double>* SLWE = b02Run->GetHi << 126 G4THitsMap<G4double>* TrackEnter = 125 G4THitsMap<G4double>* SLW_V = b02Run->GetH << 127 b02Run->GetHitsMap(fSDName[i]+"/TrackEnter"); 126 G4THitsMap<G4double>* SLWE_V = b02Run->Get << 128 G4THitsMap<G4double>* SL = b02Run->GetHitsMap(fSDName[i]+"/SL"); 127 << 129 G4THitsMap<G4double>* SLW = b02Run->GetHitsMap(fSDName[i]+"/SLW"); 128 if (IsMaster()) { << 130 G4THitsMap<G4double>* SLWE = b02Run->GetHitsMap(fSDName[i]+"/SLWE"); 129 G4cout << "\n--------------------End of << 131 G4THitsMap<G4double>* SLW_V = b02Run->GetHitsMap(fSDName[i]+"/SLW_V"); 130 G4cout << " Number of event processed : << 132 G4THitsMap<G4double>* SLWE_V = b02Run->GetHitsMap(fSDName[i]+"/SLWE_V"); 131 } << 133 132 else { << 134 133 G4cout << "\n--------------------End of << 135 if (IsMaster()) 134 G4cout << " Number of event processed : << 136 { 135 } << 137 G4cout << 136 << 138 "\n--------------------End of Global Run-----------------------" << 137 G4cout << "=============================== << 139 G4endl; 138 G4cout << "=============================== << 140 G4cout << >> 141 " Number of event processed : "<< aRun->GetNumberOfEvent() << G4endl; >> 142 } >> 143 else >> 144 { >> 145 G4cout << >> 146 "\n--------------------End of Local Run------------------------" << >> 147 G4endl; >> 148 G4cout << >> 149 " Number of event processed : "<< aRun->GetNumberOfEvent() << G4endl; >> 150 } >> 151 >> 152 G4cout << "=============================================================" >> 153 <<G4endl; >> 154 G4cout << "=============================================================" >> 155 <<G4endl; 139 156 140 std::ostream* myout = &G4cout; << 157 std::ostream *myout = &G4cout; 141 PrintHeader(myout); 158 PrintHeader(myout); 142 159 143 for (G4int iz = 0; iz < 20; iz++) { << 160 for ( G4int iz = 0; iz < 20; iz++){ 144 G4double* SumCollisions = (*Collisions)[ 161 G4double* SumCollisions = (*Collisions)[iz]; 145 G4double* SumCollWeight = (*CollWeight)[ 162 G4double* SumCollWeight = (*CollWeight)[iz]; 146 G4double* Populations = (*Population)[iz << 163 G4double* Populations = (*Population)[iz]; 147 G4double* TrackEnters = (*TrackEnter)[iz << 164 G4double* TrackEnters = (*TrackEnter)[iz]; 148 G4double* SLs = (*SL)[iz]; << 165 G4double* SLs = (*SL)[iz]; 149 G4double* SLWs = (*SLW)[iz]; << 166 G4double* SLWs = (*SLW)[iz]; 150 G4double* SLWEs = (*SLWE)[iz]; << 167 G4double* SLWEs = (*SLWE)[iz]; 151 G4double* SLW_Vs = (*SLW_V)[iz]; << 168 G4double* SLW_Vs = (*SLW_V)[iz]; 152 G4double* SLWE_Vs = (*SLWE_V)[iz]; << 169 G4double* SLWE_Vs = (*SLWE_V)[iz]; 153 if (!SumCollisions) SumCollisions = new << 170 if ( !SumCollisions ) SumCollisions = new G4double(0.0); 154 if (!SumCollWeight) SumCollWeight = new << 171 if ( !SumCollWeight ) SumCollWeight = new G4double(0.0); 155 if (!Populations) Populations = new G4do << 172 if ( !Populations ) Populations = new G4double(0.0); 156 if (!TrackEnters) TrackEnters = new G4do << 173 if ( !TrackEnters ) TrackEnters = new G4double(0.0); 157 if (!SLs) SLs = new G4double(0.0); << 174 if ( !SLs ) SLs = new G4double(0.0); 158 if (!SLWs) SLWs = new G4double(0.0); << 175 if ( !SLWs ) SLWs = new G4double(0.0); 159 if (!SLWEs) SLWEs = new G4double(0.0); << 176 if ( !SLWEs ) SLWEs = new G4double(0.0); 160 if (!SLW_Vs) SLW_Vs = new G4double(0.0); << 177 if ( !SLW_Vs ) SLW_Vs = new G4double(0.0); 161 if (!SLWE_Vs) SLWE_Vs = new G4double(0.0 << 178 if ( !SLWE_Vs ) SLWE_Vs = new G4double(0.0); 162 G4double NumWeightedEnergy = 0.0; << 179 G4double NumWeightedEnergy =0.0; 163 G4double FluxWeightedEnergy = 0.0; << 180 G4double FluxWeightedEnergy=0.0; 164 G4double AverageTrackWeight = 0.0; << 181 G4double AverageTrackWeight=0.0; 165 if (*SLW_Vs != 0.) NumWeightedEnergy = ( << 182 if ( *SLW_Vs !=0. ) NumWeightedEnergy = (*SLWE_Vs)/(*SLW_Vs); 166 if (*SLWs != 0.) FluxWeightedEnergy = (* << 183 if ( *SLWs !=0. ) FluxWeightedEnergy = (*SLWEs)/(*SLWs); 167 if (*SLs != 0.) AverageTrackWeight = (*S << 184 if ( *SLs !=0. ) AverageTrackWeight = (*SLWs)/(*SLs); 168 G4String cname = bdet->GetCellName(iz); 185 G4String cname = bdet->GetCellName(iz); 169 G4cout << std::setw(fFieldValue) << cnam << 186 G4cout 170 << " |" << std::setw(fFieldValue) << 187 << std::setw(fFieldValue) << cname << " |" 171 << (*SumCollisions) << " |" << st << 188 << std::setw(fFieldValue) << (*TrackEnters) << " |" 172 << std::setw(fFieldValue) << NumW << 189 << std::setw(fFieldValue) << (*Populations) << " |" 173 << FluxWeightedEnergy << " |" << << 190 << std::setw(fFieldValue) << (*SumCollisions) << " |" 174 << std::setw(fFieldValue) << (*SL << 191 << std::setw(fFieldValue) << (*SumCollWeight) << " |" 175 << " |" << std::setw(fFieldValue) << 192 << std::setw(fFieldValue) << NumWeightedEnergy << " |" 176 << (*SLWEs) << " |" << std::setw( << 193 << std::setw(fFieldValue) << FluxWeightedEnergy << " |" >> 194 << std::setw(fFieldValue) << AverageTrackWeight << " |" >> 195 << std::setw(fFieldValue) << (*SLs) << " |" >> 196 << std::setw(fFieldValue) << (*SLWs) << " |" >> 197 << std::setw(fFieldValue) << (*SLW_Vs) << " |" >> 198 << std::setw(fFieldValue) << (*SLWEs) << " |" >> 199 << std::setw(fFieldValue) << (*SLWE_Vs) << " |" >> 200 << G4endl; 177 } 201 } 178 G4cout << "=============================== << 202 G4cout << "============================================="<<G4endl; 179 } 203 } 180 } 204 } 181 205 182 //....oooOO0OOooo........oooOO0OOooo........oo 206 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 183 207 184 void B02RunAction::PrintHeader(std::ostream* o << 208 void B02RunAction::PrintHeader(std::ostream *out) 185 { 209 { 186 std::vector<G4String> vecScoreName; 210 std::vector<G4String> vecScoreName; 187 vecScoreName.push_back("Tr.Entering"); 211 vecScoreName.push_back("Tr.Entering"); 188 vecScoreName.push_back("Population"); 212 vecScoreName.push_back("Population"); 189 vecScoreName.push_back("Collisions"); 213 vecScoreName.push_back("Collisions"); 190 vecScoreName.push_back("Coll*WGT"); 214 vecScoreName.push_back("Coll*WGT"); 191 vecScoreName.push_back("NumWGTedE"); 215 vecScoreName.push_back("NumWGTedE"); 192 vecScoreName.push_back("FluxWGTedE"); 216 vecScoreName.push_back("FluxWGTedE"); 193 vecScoreName.push_back("Av.Tr.WGT"); 217 vecScoreName.push_back("Av.Tr.WGT"); 194 vecScoreName.push_back("SL"); 218 vecScoreName.push_back("SL"); 195 vecScoreName.push_back("SLW"); 219 vecScoreName.push_back("SLW"); 196 vecScoreName.push_back("SLW_v"); 220 vecScoreName.push_back("SLW_v"); 197 vecScoreName.push_back("SLWE"); 221 vecScoreName.push_back("SLWE"); 198 vecScoreName.push_back("SLWE_v"); 222 vecScoreName.push_back("SLWE_v"); 199 223 200 // head line 224 // head line 201 // std::string vname; << 225 // std::string vname; 202 // vname = FillString("Volume", ' ', fFiel << 226 // vname = FillString("Volume", ' ', fFieldName+1); 203 //*out << vname << '|'; 227 //*out << vname << '|'; 204 *out << std::setw(fFieldValue) << "Volume" << 228 *out << std::setw(fFieldValue) << "Volume" << " |"; 205 << " |"; << 229 for (std::vector<G4String>::iterator it = vecScoreName.begin(); 206 for (std::vector<G4String>::iterator it = ve << 230 it != vecScoreName.end(); it++) { 207 // vname = FillString((*it), << 231 // vname = FillString((*it), 208 // ' ', << 232 // ' ', 209 // fFieldValue+1, << 233 // fFieldValue+1, 210 // false); << 234 // false); 211 // *out << vname << '|'; << 235 // *out << vname << '|'; 212 *out << std::setw(fFieldValue) << (*it) << << 236 *out << std::setw(fFieldValue) << (*it) << " |"; 213 } 237 } 214 *out << G4endl; << 238 *out << G4endl; 215 } 239 } 216 240 217 //....oooOO0OOooo........oooOO0OOooo........oo 241 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 218 242 219 std::string B02RunAction::FillString(const std << 243 std::string B02RunAction::FillString(const std::string &name, >> 244 char c, G4int n, G4bool back) 220 { 245 { 221 std::string fname(""); 246 std::string fname(""); 222 G4int k = n - name.size(); 247 G4int k = n - name.size(); 223 if (k > 0) { 248 if (k > 0) { 224 if (back) { 249 if (back) { 225 fname = name; 250 fname = name; 226 fname += std::string(k, c); << 251 fname += std::string(k,c); 227 } 252 } 228 else { 253 else { 229 fname = std::string(k, c); << 254 fname = std::string(k,c); 230 fname += name; 255 fname += name; 231 } 256 } 232 } 257 } 233 else { 258 else { 234 fname = name; 259 fname = name; 235 } 260 } 236 return fname; 261 return fname; 237 } 262 } 238 263 239 //....oooOO0OOooo........oooOO0OOooo........oo 264 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 240 265