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5 ] [ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

Diff markup

Differences between /examples/extended/biasing/B01/src/B01RunAction.cc (Version 11.3.0) and /examples/extended/biasing/B01/src/B01RunAction.cc (Version 9.3.p2)


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