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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.6)


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