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