Geant4 Cross Reference |
1 // 1 2 // ******************************************* 3 // * License and Disclaimer 4 // * 5 // * The Geant4 software is copyright of th 6 // * the Geant4 Collaboration. It is provided 7 // * conditions of the Geant4 Software License 8 // * LICENSE and available at http://cern.ch/ 9 // * include a list of copyright holders. 10 // * 11 // * Neither the authors of this software syst 12 // * institutes,nor the agencies providing fin 13 // * work make any representation or warran 14 // * regarding this software system or assum 15 // * use. Please see the license in the file 16 // * for the full disclaimer and the limitatio 17 // * 18 // * This code implementation is the result 19 // * technical work of the GEANT4 collaboratio 20 // * By using, copying, modifying or distri 21 // * any work based on the software) you ag 22 // * use in resulting scientific publicati 23 // * acceptance of all terms of the Geant4 Sof 24 // ******************************************* 25 // 26 /// \file biasing/B01/src/B01RunAction.cc 27 /// \brief Implementation of the B01RunAction 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........oo 43 // 44 // B01RunAction 45 // 46 // 47 // 48 //....oooOO0OOooo........oooOO0OOooo........oo 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 MultiFuncti 58 fSDName.push_back(G4String("ConcreteSD")); 59 } 60 61 //....oooOO0OOooo........oooOO0OOooo........oo 62 63 // Destructor. 64 B01RunAction::~B01RunAction() 65 { 66 fSDName.clear(); 67 } 68 69 //....oooOO0OOooo........oooOO0OOooo........oo 70 71 G4Run* B01RunAction::GenerateRun() 72 { 73 // Generate new RUN object, which is special 74 // dedicated for MultiFunctionalDetector sch 75 // Detail description can be found in B01Ru 76 return new B01Run(fSDName); 77 } 78 79 //....oooOO0OOooo........oooOO0OOooo........oo 80 81 void B01RunAction::BeginOfRunAction(const G4Ru 82 { 83 G4cout << "### Run " << aRun->GetRunID() << 84 } 85 86 //....oooOO0OOooo........oooOO0OOooo........oo 87 88 void B01RunAction::EndOfRunAction(const G4Run* 89 { 90 G4cout << " ###### EndOfRunAction " << G4en 91 //- B01Run object. 92 B01Run* b01Run = (B01Run*)aRun; 93 //--- Dump all socred quantities involved in 94 // re02Run->DumpAllScorer(); 95 //--- 96 G4RunManager* mgr = G4RunManager::GetRunMana 97 // 98 99 for (G4int i = 0; i < (G4int)fSDName.size(); 100 const G4VUserDetectorConstruction* vdet = 101 B01DetectorConstruction* bdet = (B01Detect 102 // 103 104 //---------------------------------------- 105 // Dump accumulated quantities for this RU 106 // (Display only central region of x-y pl 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- 118 G4THitsMap<G4double>* CollWeight = b01Run- 119 G4THitsMap<G4double>* Population = b01Run- 120 G4THitsMap<G4double>* TrackEnter = b01Run- 121 G4THitsMap<G4double>* SL = b01Run->GetHits 122 G4THitsMap<G4double>* SLW = b01Run->GetHit 123 G4THitsMap<G4double>* SLWE = b01Run->GetHi 124 G4THitsMap<G4double>* SLW_V = b01Run->GetH 125 G4THitsMap<G4double>* SLWE_V = b01Run->Get 126 127 if (IsMaster()) { 128 G4cout << "\n--------------------End of 129 G4cout << " Number of event processed : 130 } 131 else { 132 G4cout << "\n--------------------End of 133 G4cout << " Number of event processed : 134 } 135 136 G4cout << "=============================== 137 G4cout << "=============================== 138 139 std::ostream* myout = &G4cout; 140 PrintHeader(myout); 141 142 for (G4int iz = 0; iz < 20; iz++) { 143 G4double* SumCollisions = (*Collisions)[ 144 G4double* SumCollWeight = (*CollWeight)[ 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 153 if (!SumCollWeight) SumCollWeight = new 154 if (!Populations) Populations = new G4do 155 if (!TrackEnters) TrackEnters = new G4do 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 = ( 165 if (*SLWs != 0.) FluxWeightedEnergy = (* 166 if (*SLs != 0.) AverageTrackWeight = (*S 167 G4String cname = bdet->GetCellName(iz); 168 G4cout << std::setw(fFieldValue) << cnam 169 << " |" << std::setw(fFieldValue) 170 << (*SumCollisions) << " |" << st 171 << std::setw(fFieldValue) << NumW 172 << FluxWeightedEnergy << " |" << 173 << std::setw(fFieldValue) << (*SL 174 << " |" << std::setw(fFieldValue) 175 << (*SLWEs) << " |" << std::setw( 176 } 177 G4cout << "=============================== 178 } 179 } 180 181 //....oooOO0OOooo........oooOO0OOooo........oo 182 183 void B01RunAction::PrintHeader(std::ostream* o 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", ' ', fFiel 202 //*out << vname << '|'; 203 *out << std::setw(fFieldValue) << "Volume" 204 << " |"; 205 for (std::vector<G4String>::iterator it = ve 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........oo 217 218 std::string B01RunAction::FillString(const std 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........oo 239