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/B03/src/B03RunAction.cc 26 /// \file biasing/B03/src/B03RunAction.cc 27 /// \brief Implementation of the B03RunAction 27 /// \brief Implementation of the B03RunAction class 28 // 28 // 29 // 29 // 30 // << 30 // $Id: B03RunAction.cc 72953 2013-08-14 14:13:36Z gcosmo $ >> 31 // 31 #include "B03RunAction.hh" 32 #include "B03RunAction.hh" 32 << 33 #include "B03Run.hh" 33 #include "B03Run.hh" 34 34 35 //-- In order to obtain detector information. 35 //-- In order to obtain detector information. 36 #include "B03ImportanceDetectorConstruction.hh << 37 << 38 #include "G4RunManager.hh" 36 #include "G4RunManager.hh" >> 37 #include "B03ImportanceDetectorConstruction.hh" 39 #include "G4THitsMap.hh" 38 #include "G4THitsMap.hh" >> 39 40 #include "G4UnitsTable.hh" 40 #include "G4UnitsTable.hh" 41 41 42 //....oooOO0OOooo........oooOO0OOooo........oo 42 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 43 43 44 // B03RunAction 44 // B03RunAction 45 // << 45 // 46 // 46 // 47 // 47 // 48 48 49 //....oooOO0OOooo........oooOO0OOooo........oo 49 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 50 50 51 // Constructor 51 // Constructor 52 B03RunAction::B03RunAction() << 52 B03RunAction::B03RunAction(): 53 : G4UserRunAction(), << 53 G4UserRunAction(), 54 // fFieldName(15), << 54 // fFieldName(15), 55 fFieldValue(14) << 55 fFieldValue(14) 56 { 56 { 57 // - Prepare data member for B03Run. 57 // - Prepare data member for B03Run. 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 B03RunAction::~B03RunAction() 65 B03RunAction::~B03RunAction() 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* B03RunAction::GenerateRun() 72 G4Run* B03RunAction::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 B03Ru 76 // Detail description can be found in B03Run.hh/cc. 77 return new B03Run(fSDName); 77 return new B03Run(fSDName); 78 } 78 } 79 79 80 //....oooOO0OOooo........oooOO0OOooo........oo 80 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 81 81 82 void B03RunAction::BeginOfRunAction(const G4Ru 82 void B03RunAction::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 B03RunAction::EndOfRunAction(const G4Run* 89 void B03RunAction::EndOfRunAction(const G4Run* aRun) 90 { 90 { 91 G4cout << " ###### EndOfRunAction " << G4en << 91 G4cout << " ###### EndOfRunAction " <<G4endl; 92 //- B03Run object. 92 //- B03Run object. 93 B03Run* b02Run = (B03Run*)aRun; 93 B03Run* b02Run = (B03Run*)aRun; 94 //--- Dump all socred quantities involved in 94 //--- Dump all socred quantities involved in B03Run. 95 // b02Run->DumpAllScorer(); 95 // b02Run->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 mgr->GetUserDetectorConstruction(); 102 // B03DetectorConstruction* bdet = (B03 103 // B03DetectorConstruction* bdet = (B03DetectorConstruction*)vdet; 103 B03ImportanceDetectorConstruction* bdet = << 104 B03ImportanceDetectorConstruction* bdet = >> 105 (B03ImportanceDetectorConstruction*)vdet; 104 // 106 // 105 << 107 106 //---------------------------------------- 108 //--------------------------------------------- 107 // Dump accumulated quantities for this RU 109 // Dump accumulated quantities for this RUN. 108 // (Display only central region of x-y pl 110 // (Display only central region of x-y plane) 109 // 0 ConcreteSD/Collisions 111 // 0 ConcreteSD/Collisions 110 // 1 ConcreteSD/CollWeight 112 // 1 ConcreteSD/CollWeight 111 // 2 ConcreteSD/Population 113 // 2 ConcreteSD/Population 112 // 3 ConcreteSD/TrackEnter 114 // 3 ConcreteSD/TrackEnter 113 // 4 ConcreteSD/SL 115 // 4 ConcreteSD/SL 114 // 5 ConcreteSD/SLW 116 // 5 ConcreteSD/SLW 115 // 6 ConcreteSD/SLWE 117 // 6 ConcreteSD/SLWE 116 // 7 ConcreteSD/SLW_V 118 // 7 ConcreteSD/SLW_V 117 // 8 ConcreteSD/SLWE_V 119 // 8 ConcreteSD/SLWE_V 118 //---------------------------------------- 120 //--------------------------------------------- 119 G4THitsMap<G4double>* Collisions = b02Run- << 121 G4THitsMap<G4double>* Collisions = 120 G4THitsMap<G4double>* CollWeight = b02Run- << 122 b02Run->GetHitsMap(fSDName[i]+"/Collisions"); 121 G4THitsMap<G4double>* Population = b02Run- << 123 G4THitsMap<G4double>* CollWeight = 122 G4THitsMap<G4double>* TrackEnter = b02Run- << 124 b02Run->GetHitsMap(fSDName[i]+"/CollWeight"); 123 G4THitsMap<G4double>* SL = b02Run->GetHits << 125 G4THitsMap<G4double>* Population = 124 G4THitsMap<G4double>* SLW = b02Run->GetHit << 126 b02Run->GetHitsMap(fSDName[i]+"/Population"); 125 G4THitsMap<G4double>* SLWE = b02Run->GetHi << 127 G4THitsMap<G4double>* TrackEnter = 126 G4THitsMap<G4double>* SLW_V = b02Run->GetH << 128 b02Run->GetHitsMap(fSDName[i]+"/TrackEnter"); 127 G4THitsMap<G4double>* SLWE_V = b02Run->Get << 129 G4THitsMap<G4double>* SL = 128 << 130 b02Run->GetHitsMap(fSDName[i]+"/SL"); 129 if (IsMaster()) { << 131 G4THitsMap<G4double>* SLW = 130 G4cout << "\n--------------------End of << 132 b02Run->GetHitsMap(fSDName[i]+"/SLW"); 131 G4cout << " Number of event processed : << 133 G4THitsMap<G4double>* SLWE = 132 } << 134 b02Run->GetHitsMap(fSDName[i]+"/SLWE"); 133 else { << 135 G4THitsMap<G4double>* SLW_V = 134 G4cout << "\n--------------------End of << 136 b02Run->GetHitsMap(fSDName[i]+"/SLW_V"); 135 G4cout << " Number of event processed : << 137 G4THitsMap<G4double>* SLWE_V = 136 } << 138 b02Run->GetHitsMap(fSDName[i]+"/SLWE_V"); 137 << 139 138 G4cout << "=============================== << 140 if (IsMaster()) 139 G4cout << "=============================== << 141 { >> 142 G4cout << >> 143 "\n--------------------End of Global Run-----------------------" << >> 144 G4endl; >> 145 G4cout << >> 146 " Number of event processed : "<< aRun->GetNumberOfEvent() << G4endl; >> 147 } >> 148 else >> 149 { >> 150 G4cout << >> 151 "\n--------------------End of Local Run------------------------" << >> 152 G4endl; >> 153 G4cout << " Number of event processed : "<< aRun->GetNumberOfEvent() << >> 154 G4endl; >> 155 } >> 156 >> 157 G4cout << "=============================================================" >> 158 <<G4endl; >> 159 G4cout << "=============================================================" >> 160 <<G4endl; 140 161 141 std::ostream* myout = &G4cout; << 162 std::ostream *myout = &G4cout; 142 PrintHeader(myout); 163 PrintHeader(myout); 143 164 144 for (G4int iz = 0; iz < 20; iz++) { << 165 for ( G4int iz = 0; iz < 20; iz++){ 145 G4double* SumCollisions = (*Collisions)[ 166 G4double* SumCollisions = (*Collisions)[iz]; 146 G4double* SumCollWeight = (*CollWeight)[ 167 G4double* SumCollWeight = (*CollWeight)[iz]; 147 G4double* Populations = (*Population)[iz << 168 G4double* Populations = (*Population)[iz]; 148 G4double* TrackEnters = (*TrackEnter)[iz << 169 G4double* TrackEnters = (*TrackEnter)[iz]; 149 G4double* SLs = (*SL)[iz]; << 170 G4double* SLs = (*SL)[iz]; 150 G4double* SLWs = (*SLW)[iz]; << 171 G4double* SLWs = (*SLW)[iz]; 151 G4double* SLWEs = (*SLWE)[iz]; << 172 G4double* SLWEs = (*SLWE)[iz]; 152 G4double* SLW_Vs = (*SLW_V)[iz]; << 173 G4double* SLW_Vs = (*SLW_V)[iz]; 153 G4double* SLWE_Vs = (*SLWE_V)[iz]; << 174 G4double* SLWE_Vs = (*SLWE_V)[iz]; 154 if (!SumCollisions) SumCollisions = new << 175 if ( !SumCollisions ) SumCollisions = new G4double(0.0); 155 if (!SumCollWeight) SumCollWeight = new << 176 if ( !SumCollWeight ) SumCollWeight = new G4double(0.0); 156 if (!Populations) Populations = new G4do << 177 if ( !Populations ) Populations = new G4double(0.0); 157 if (!TrackEnters) { << 178 if ( !TrackEnters ) { G4cout << " NO TRACKS - WHY? " << G4endl; 158 G4cout << " NO TRACKS - WHY? " << G4en << 179 TrackEnters = new G4double(0.0);} 159 TrackEnters = new G4double(0.0); << 180 if ( !SLs ) SLs = new G4double(0.0); 160 } << 181 if ( !SLWs ) SLWs = new G4double(0.0); 161 if (!SLs) SLs = new G4double(0.0); << 182 if ( !SLWEs ) SLWEs = new G4double(0.0); 162 if (!SLWs) SLWs = new G4double(0.0); << 183 if ( !SLW_Vs ) SLW_Vs = new G4double(0.0); 163 if (!SLWEs) SLWEs = new G4double(0.0); << 184 if ( !SLWE_Vs ) SLWE_Vs = new G4double(0.0); 164 if (!SLW_Vs) SLW_Vs = new G4double(0.0); << 185 G4double NumWeightedEnergy =0.0; 165 if (!SLWE_Vs) SLWE_Vs = new G4double(0.0 << 186 G4double FluxWeightedEnergy=0.0; 166 G4double NumWeightedEnergy = 0.0; << 187 G4double AverageTrackWeight=0.0; 167 G4double FluxWeightedEnergy = 0.0; << 188 if ( *SLW_Vs !=0. ) NumWeightedEnergy = (*SLWE_Vs)/(*SLW_Vs); 168 G4double AverageTrackWeight = 0.0; << 189 if ( *SLWs !=0. ) FluxWeightedEnergy = (*SLWEs)/(*SLWs); 169 if (*SLW_Vs != 0.) NumWeightedEnergy = ( << 190 if ( *SLs !=0. ) AverageTrackWeight = (*SLWs)/(*SLs); 170 if (*SLWs != 0.) FluxWeightedEnergy = (* << 171 if (*SLs != 0.) AverageTrackWeight = (*S << 172 G4String cname = bdet->GetCellName(iz); 191 G4String cname = bdet->GetCellName(iz); 173 G4cout << std::setw(fFieldValue) << cnam << 192 G4cout 174 << " |" << std::setw(fFieldValue) << 193 << std::setw(fFieldValue) << cname << " |" 175 << (*SumCollisions) << " |" << st << 194 << std::setw(fFieldValue) << (*TrackEnters) << " |" 176 << std::setw(fFieldValue) << NumW << 195 << std::setw(fFieldValue) << (*Populations) << " |" 177 << FluxWeightedEnergy << " |" << << 196 << std::setw(fFieldValue) << (*SumCollisions) << " |" 178 << std::setw(fFieldValue) << (*SL << 197 << std::setw(fFieldValue) << (*SumCollWeight) << " |" 179 << " |" << std::setw(fFieldValue) << 198 << std::setw(fFieldValue) << NumWeightedEnergy << " |" 180 << (*SLWEs) << " |" << std::setw( << 199 << std::setw(fFieldValue) << FluxWeightedEnergy << " |" >> 200 << std::setw(fFieldValue) << AverageTrackWeight << " |" >> 201 << std::setw(fFieldValue) << (*SLs) << " |" >> 202 << std::setw(fFieldValue) << (*SLWs) << " |" >> 203 << std::setw(fFieldValue) << (*SLW_Vs) << " |" >> 204 << std::setw(fFieldValue) << (*SLWEs) << " |" >> 205 << std::setw(fFieldValue) << (*SLWE_Vs) << " |" >> 206 << G4endl; 181 } 207 } 182 G4cout << "=============================== << 208 G4cout << "============================================="<<G4endl; 183 } 209 } 184 } 210 } 185 211 186 //....oooOO0OOooo........oooOO0OOooo........oo 212 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 187 213 188 void B03RunAction::PrintHeader(std::ostream* o << 214 void B03RunAction::PrintHeader(std::ostream *out) 189 { 215 { 190 std::vector<G4String> vecScoreName; 216 std::vector<G4String> vecScoreName; 191 vecScoreName.push_back("Tr.Entering"); 217 vecScoreName.push_back("Tr.Entering"); 192 vecScoreName.push_back("Population"); 218 vecScoreName.push_back("Population"); 193 vecScoreName.push_back("Collisions"); 219 vecScoreName.push_back("Collisions"); 194 vecScoreName.push_back("Coll*WGT"); 220 vecScoreName.push_back("Coll*WGT"); 195 vecScoreName.push_back("NumWGTedE"); 221 vecScoreName.push_back("NumWGTedE"); 196 vecScoreName.push_back("FluxWGTedE"); 222 vecScoreName.push_back("FluxWGTedE"); 197 vecScoreName.push_back("Av.Tr.WGT"); 223 vecScoreName.push_back("Av.Tr.WGT"); 198 vecScoreName.push_back("SL"); 224 vecScoreName.push_back("SL"); 199 vecScoreName.push_back("SLW"); 225 vecScoreName.push_back("SLW"); 200 vecScoreName.push_back("SLW_v"); 226 vecScoreName.push_back("SLW_v"); 201 vecScoreName.push_back("SLWE"); 227 vecScoreName.push_back("SLWE"); 202 vecScoreName.push_back("SLWE_v"); 228 vecScoreName.push_back("SLWE_v"); 203 229 204 // head line 230 // head line 205 // std::string vname = FillString("Volume", << 231 //std::string vname = FillString("Volume", ' ', FieldName+1); 206 //*out << vname << '|'; 232 //*out << vname << '|'; 207 std::string vname; 233 std::string vname; 208 *out << std::setw(fFieldValue) << "Volume" << 234 *out << std::setw(fFieldValue) << "Volume" << " |"; 209 << " |"; << 235 for (std::vector<G4String>::iterator it = vecScoreName.begin(); 210 for (std::vector<G4String>::iterator it = ve << 236 it != vecScoreName.end(); it++) { 211 // vname = FillString((*it), << 237 //vname = FillString((*it), 212 // ' ', << 238 // ' ', 213 // fFieldValue+1, << 239 // fFieldValue+1, 214 // false); << 240 // false); 215 // *out << vname << '|'; << 241 // *out << vname << '|'; 216 *out << std::setw(fFieldValue) << (*it) << << 242 *out << std::setw(fFieldValue) << (*it) << " |"; 217 } 243 } 218 *out << G4endl; << 244 *out << G4endl; 219 } 245 } 220 246 221 //....oooOO0OOooo........oooOO0OOooo........oo 247 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 222 248 223 std::string B03RunAction::FillString(const std << 249 std::string B03RunAction::FillString(const std::string &name, >> 250 char c, G4int n, G4bool back) 224 { 251 { 225 std::string fname(""); 252 std::string fname(""); 226 G4int k = n - name.size(); 253 G4int k = n - name.size(); 227 if (k > 0) { 254 if (k > 0) { 228 if (back) { 255 if (back) { 229 fname = name; 256 fname = name; 230 fname += std::string(k, c); << 257 fname += std::string(k,c); 231 } 258 } 232 else { 259 else { 233 fname = std::string(k, c); << 260 fname = std::string(k,c); 234 fname += name; 261 fname += name; 235 } 262 } 236 } 263 } 237 else { 264 else { 238 fname = name; 265 fname = name; 239 } 266 } 240 return fname; 267 return fname; 241 } 268 } 242 269 243 //....oooOO0OOooo........oooOO0OOooo........oo 270 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 244 271