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