Import Geant4 10.5.0 source tree
This commit is contained in:
@@ -27,7 +27,6 @@
|
||||
/// \brief Implementation of the TSActionInitialization class
|
||||
//
|
||||
//
|
||||
// $Id: TSActionInitialization.cc 93110 2015-11-05 08:37:42Z jmadsen $
|
||||
//
|
||||
//
|
||||
/// Standard ActionInitialization class creating a RunAction instance for the
|
||||
|
||||
@@ -27,7 +27,6 @@
|
||||
/// \brief Implementation of the TSDetectorConstruction class
|
||||
//
|
||||
//
|
||||
// $Id: TSDetectorConstruction.cc 93110 2015-11-05 08:37:42Z jmadsen $
|
||||
//
|
||||
//
|
||||
/// Construction of a target material (default = boron) surrounded by a
|
||||
@@ -138,7 +137,7 @@ TSDetectorConstruction::ConstructWorld(const MaterialCollection_t& materials)
|
||||
{
|
||||
G4UserLimits* steplimit = new G4UserLimits(0.1*(fTargetDim.z()
|
||||
/fTargetSections.z()));
|
||||
G4bool check_overlap = true;
|
||||
G4bool check_overlap = false;
|
||||
|
||||
G4Box* world_solid = new G4Box("World",
|
||||
0.5*fWorldDim.x(),
|
||||
|
||||
@@ -27,7 +27,6 @@
|
||||
/// \brief Implementation of the TSPhysicsList class
|
||||
//
|
||||
//
|
||||
// $Id: TSPhysicsList.cc 93110 2015-11-05 08:37:42Z jmadsen $
|
||||
//
|
||||
//
|
||||
/// This is a very, very extensive physics list and step-limiters are applied
|
||||
|
||||
@@ -27,7 +27,6 @@
|
||||
/// \brief Implementation of the TSPrimaryGeneratorAction class
|
||||
//
|
||||
//
|
||||
// $Id: TSPrimaryGeneratorAction.cc 93110 2015-11-05 08:37:42Z jmadsen $
|
||||
//
|
||||
//
|
||||
/// Simple PrimaryGeneratorAction that produces a -Z surface flux of 1 MeV
|
||||
|
||||
@@ -27,26 +27,42 @@
|
||||
/// \brief Implementation of the TSRun class
|
||||
//
|
||||
//
|
||||
// $Id: TSRun.cc 93110 2015-11-05 08:37:42Z jmadsen $
|
||||
//
|
||||
//
|
||||
/// TSRun contains three collections of hits maps: a thread-local hits map,
|
||||
/// a global atomic hits map (implemented as a static since TSRun is
|
||||
/// implemented as a thread-local instance), and a global "mutex" hits map
|
||||
/// (also implemented as a static). The thread-local hits map is the
|
||||
/// same as you will find in many other examples. The atomics hits map
|
||||
/// is the purpose of this example. Code-wise, the implementation looks
|
||||
/// extremely similar to the thread-local version with the 3 primary
|
||||
/// exceptions: (1) construction - there should only be one instance so
|
||||
/// it should be a static member variable or a pointer/reference to a
|
||||
/// single instance elsewhere in the code (stored in ActionInitialization,
|
||||
/// for instance); (2) It does not need to, nor should be, summed in
|
||||
/// G4Run::Merge(); and (3) destruction -- it should only be cleared by
|
||||
/// the master thread since there is only one instance.
|
||||
/// A "mutex" hits map is also included as reference for checking the results
|
||||
/// TSRun contains five hits collections types:
|
||||
/// 1) a thread-local hits map,
|
||||
/// 2) a global atomic hits map
|
||||
/// 3) a global "mutex" hits map
|
||||
/// 4) a global G4StatAnalysis hits deque
|
||||
/// 5) a global G4ConvergenceTester hits deque
|
||||
///
|
||||
/// The thread-local hits map is the same as you will find in many other
|
||||
/// examples.
|
||||
///
|
||||
/// The atomics hits map is the purpose of this example. Code-wise, the
|
||||
/// implementation looks extremely similar to the thread-local version with
|
||||
/// 3 primary exceptions:
|
||||
/// (1) construction - there should only be one instance so it should be a
|
||||
/// static member variable or a pointer/reference to a single instance
|
||||
/// (2) It does not need to, nor should be, summed in G4Run::Merge()
|
||||
/// (3) destruction -- it should only be cleared by the master thread since
|
||||
/// there is only one instance.
|
||||
///
|
||||
/// The "mutex" hits map is also included as reference for checking the results
|
||||
/// accumulated by the thread-local hits maps and atomic hits maps. The
|
||||
/// differences w.r.t. this hits maps are computed in
|
||||
/// TSRunAction::EndOfRunAction
|
||||
///
|
||||
/// The "G4StatAnalysis" and "G4ConvergenceTester" hits deques are
|
||||
/// memory-efficient version of the standard G4THitsMap. While maps are
|
||||
/// ideal for scoring at the G4Event-level, where sparsity w.r.t. indices
|
||||
/// is common; at the G4Run-level, these data structures require much
|
||||
/// less memory overhead. Due to a lack of
|
||||
/// G4ConvergenceTester::operator+=(G4ConvergenceTester), the static version
|
||||
/// of G4ConvergenceTester is the only valid way to use G4ConvergenceTester
|
||||
/// in a scoring container. This is not the case for G4StatAnalysis, which
|
||||
/// can be used in lieu of G4double.
|
||||
///
|
||||
//
|
||||
//
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
@@ -59,6 +75,7 @@
|
||||
#include "G4MultiFunctionalDetector.hh"
|
||||
#include "G4VPrimitiveScorer.hh"
|
||||
#include "G4TiMemory.hh"
|
||||
#include "TSDetectorConstruction.hh"
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
@@ -66,6 +83,8 @@ std::vector<G4TAtomicHitsMap<G4double>*> TSRun::fAtomicRunMaps;
|
||||
|
||||
std::map<G4String, TSRun::MutexHitsMap_t> TSRun::fMutexRunMaps;
|
||||
|
||||
std::vector<G4StatContainer<G4ConvergenceTester>*> TSRun::fConvMaps;
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
TSRun::TSRun(const G4String& mfd_name)
|
||||
@@ -87,8 +106,12 @@ TSRun::~TSRun()
|
||||
for(unsigned i = 0; i < fAtomicRunMaps.size(); ++i)
|
||||
delete fAtomicRunMaps[i];
|
||||
|
||||
for(auto& itr: fConvMaps)
|
||||
delete itr;
|
||||
|
||||
fAtomicRunMaps.clear();
|
||||
fMutexRunMaps.clear();
|
||||
fConvMaps.clear();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -130,11 +153,19 @@ void TSRun::ConstructMFD(const G4String& mfdName)
|
||||
fCollIDs.push_back(collectionID);
|
||||
fRunMaps.push_back(new G4THitsMap<G4double>(mfdName,
|
||||
collectionName));
|
||||
fStatMaps.push_back(new G4StatContainer<G4StatAnalysis>(
|
||||
mfdName,
|
||||
collectionName,
|
||||
TSDetectorConstruction::Instance()->GetTotalTargets()));
|
||||
if(!G4Threading::IsWorkerThread())
|
||||
{
|
||||
fAtomicRunMaps.push_back(new G4TAtomicHitsMap<G4double>
|
||||
(mfdName, collectionName));
|
||||
fMutexRunMaps[fCollNames[collectionID]].clear();
|
||||
fConvMaps.push_back(new G4StatContainer<G4ConvergenceTester>(
|
||||
mfdName,
|
||||
collectionName,
|
||||
TSDetectorConstruction::Instance()->GetTotalTargets()));
|
||||
}
|
||||
} else {
|
||||
G4cout << "** collection " << fullCollectionName << " not found. "
|
||||
@@ -158,7 +189,8 @@ void TSRun::RecordEvent(const G4Event* aEvent)
|
||||
// HitsCollection of This Event
|
||||
//============================
|
||||
G4HCofThisEvent* HCE = aEvent->GetHCofThisEvent();
|
||||
if (!HCE) return;
|
||||
if (!HCE)
|
||||
return;
|
||||
|
||||
for(unsigned i = 0; i < fCollIDs.size(); ++i)
|
||||
{
|
||||
@@ -172,33 +204,46 @@ void TSRun::RecordEvent(const G4Event* aEvent)
|
||||
else
|
||||
G4cout <<" Error EvtMap Not Found " << G4endl;
|
||||
|
||||
TIMEMORY_AUTO_TIMER("[" + fCollNames.at(i) + "]");
|
||||
|
||||
if ( EvtMap )
|
||||
{
|
||||
//=== Sum up HitsMap of this event to HitsMap of RUN.===
|
||||
{
|
||||
TIMEMORY_AUTO_TIMER("[standard_run_map]");
|
||||
TIMEMORY_BASIC_AUTO_TIMER("[standard_run_map]");
|
||||
*fRunMaps[fCollID] += *EvtMap;
|
||||
}
|
||||
// atomic run map
|
||||
//=== Sum up HitsMap of this event to atomic HitsMap of RUN.===
|
||||
{
|
||||
TIMEMORY_AUTO_TIMER("[atomic_run_map]");
|
||||
TIMEMORY_BASIC_AUTO_TIMER("[atomic_run_map]");
|
||||
*fAtomicRunMaps[fCollID] += *EvtMap;
|
||||
}
|
||||
TIMEMORY_AUTO_TIMER("[mutex_run_map]");
|
||||
// mutex run map
|
||||
static G4Mutex mtx = G4MUTEX_INITIALIZER;
|
||||
//=== Sum up HitsMap of this event to StatMap of RUN.===
|
||||
{
|
||||
TIMEMORY_BASIC_AUTO_TIMER("[stat_analysis_map]");
|
||||
// G4StatAnalysis map
|
||||
*fStatMaps[fCollID] += *EvtMap;
|
||||
}
|
||||
//=== Sum up HitsMap of this event to MutexMap of RUN.===
|
||||
{
|
||||
TIMEMORY_BASIC_AUTO_TIMER("[convergence_test_map]");
|
||||
// G4ConvergenceTester run map
|
||||
static G4Mutex mtx = G4MUTEX_INITIALIZER;
|
||||
G4AutoLock lock(&mtx);
|
||||
*fConvMaps[fCollID] += *EvtMap;
|
||||
}
|
||||
//=== Sum up HitsMap of this event to MutexMap of RUN.===
|
||||
{
|
||||
TIMEMORY_BASIC_AUTO_TIMER("[mutex_run_map]");
|
||||
// mutex run map
|
||||
static G4Mutex mtx = G4MUTEX_INITIALIZER;
|
||||
G4AutoLock lock(&mtx);
|
||||
for(const auto& itr : *EvtMap)
|
||||
{
|
||||
fMutexRunMaps[fCollNames[fCollID]][itr.first]
|
||||
+= *itr.second;
|
||||
}
|
||||
}
|
||||
//----------------------------------------------------------------//
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
@@ -209,7 +254,10 @@ void TSRun::Merge(const G4Run* aTSRun)
|
||||
const TSRun* localTSRun = static_cast<const TSRun*>(aTSRun);
|
||||
|
||||
for(unsigned i = 0; i < fRunMaps.size(); ++i)
|
||||
*fRunMaps[i] += *localTSRun->fRunMaps[i];
|
||||
{
|
||||
*fRunMaps[i] += *localTSRun->fRunMaps[i];
|
||||
*fStatMaps[i] += *localTSRun->fStatMaps[i];
|
||||
}
|
||||
|
||||
G4Run::Merge(aTSRun);
|
||||
}
|
||||
@@ -268,3 +316,36 @@ TSRun::GetMutexHitsMap(const G4String& collName) const
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
// Access StatMap.
|
||||
// by full description of collection name, that is
|
||||
// <MultiFunctional Detector Name>/<Primitive Scorer Name>
|
||||
G4StatContainer<G4StatAnalysis>*
|
||||
TSRun::GetStatMap(const G4String& collName) const
|
||||
{
|
||||
for(unsigned i = 0; i < fCollNames.size(); ++i)
|
||||
{
|
||||
if(collName == fCollNames[i])
|
||||
return fStatMaps[i];
|
||||
}
|
||||
|
||||
G4Exception("TSRun", collName.c_str(), JustWarning,
|
||||
"GetStatMap failed to locate the requested StatMap");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
G4StatContainer<G4ConvergenceTester>*
|
||||
TSRun::GetConvMap(const G4String& collName) const
|
||||
{
|
||||
for(unsigned i = 0; i < fCollNames.size(); ++i)
|
||||
{
|
||||
if(collName == fCollNames[i])
|
||||
return fConvMaps[i];
|
||||
}
|
||||
|
||||
G4Exception("TSRun", collName.c_str(), JustWarning,
|
||||
"GetHitsMap failed to locate the requested AtomicHitsMap");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -27,7 +27,6 @@
|
||||
/// \brief Implementation of the TSRunAction class
|
||||
//
|
||||
//
|
||||
// $Id: TSRunAction.cc 93110 2015-11-05 08:37:42Z jmadsen $
|
||||
//
|
||||
//
|
||||
//
|
||||
@@ -45,6 +44,7 @@
|
||||
|
||||
#include "TSRun.hh"
|
||||
#include "TSDetectorConstruction.hh"
|
||||
#include "G4StatAnalysis.hh"
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
@@ -73,6 +73,8 @@ void TSRunAction::BeginOfRunAction(const G4Run* aRun)
|
||||
G4RunManager::GetRunManager()->SetPrintProgress((evts_to_process > 100)
|
||||
? evts_to_process/100
|
||||
: 1);
|
||||
if(IsMaster())
|
||||
G4PrintEnv();
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
@@ -108,105 +110,174 @@ void TSRunAction::EndOfRunAction(const G4Run* aRun)
|
||||
std::vector<G4double> units { CLHEP::eV, CLHEP::keV, 1, 1 };
|
||||
std::vector<G4String> unitstr { "keV", "steps" };
|
||||
|
||||
for(unsigned i = 0; i < primScorerNames.size(); ++i)
|
||||
{
|
||||
for(unsigned j = 0; j < fnames.size(); ++j)
|
||||
{
|
||||
//----------------------------------------------------------------//
|
||||
auto print = [] (std::ostream& fout,
|
||||
//----------------------------------------------------------------------//
|
||||
// lambda to print double value
|
||||
auto print = [] (std::ostream& fout,
|
||||
G4int first, G4double second,
|
||||
G4double unit1, G4double unit2, G4String unit2str)
|
||||
{
|
||||
if(fout)
|
||||
{
|
||||
if(fout)
|
||||
fout << first
|
||||
<< " " << second/unit1
|
||||
<< G4endl;
|
||||
|
||||
G4cout
|
||||
<< " " << std::setw(10) << first
|
||||
<< " " << std::setw(15) << std::setprecision(6)
|
||||
<< std::fixed << second/unit2 << " " << unit2str
|
||||
<< G4endl;
|
||||
G4cout.unsetf(std::ios::fixed);
|
||||
};
|
||||
//----------------------------------------------------------------//
|
||||
|
||||
fname = fnames.at(j) + "_" + primScorerNames.at(i) + ".out";
|
||||
fileout.open(fname);
|
||||
G4cout << separator.str() << G4endl;
|
||||
G4cout << " opened file " << fname << " for output" << G4endl;
|
||||
G4cout << separator.str() << G4endl;
|
||||
|
||||
G4bool valid = true;
|
||||
if(j == 0)
|
||||
G4cout
|
||||
<< " " << std::setw(10) << first
|
||||
<< " " << std::setw(15) << std::setprecision(6)
|
||||
<< std::fixed << second/unit2 << " " << unit2str
|
||||
<< G4endl;
|
||||
G4cout.unsetf(std::ios::fixed);
|
||||
};
|
||||
//----------------------------------------------------------------------//
|
||||
// lambda to print statistics
|
||||
auto stat_print = [] (std::ostream& fout,
|
||||
G4int first, G4StatAnalysis* stat, G4ConvergenceTester* conv,
|
||||
G4double unit1, G4double unit2, G4String unit2str)
|
||||
{
|
||||
if(!stat || !conv)
|
||||
return;
|
||||
auto fsecond = (*stat);
|
||||
auto psecond = (*stat);
|
||||
fsecond /= unit1;
|
||||
psecond /= unit2;
|
||||
if(fout)
|
||||
{
|
||||
G4THitsMap<G4double>* hitmap
|
||||
= tsRun->GetHitsMap(fName + "/" + primScorerNames.at(i));
|
||||
if(hitmap && hitmap->GetMap()->size() != 0)
|
||||
{
|
||||
for(auto itr = hitmap->GetMap()->begin();
|
||||
itr != hitmap->GetMap()->end(); itr++)
|
||||
{
|
||||
IDs.insert(itr->first);
|
||||
std::get<0>(fTypeCompare[primScorerNames.at(i)][itr->first])
|
||||
= *itr->second/units.at(i);
|
||||
print(fileout, itr->first, *itr->second,
|
||||
units.at(i), units.at(i+1), unitstr.at(i));
|
||||
}
|
||||
} else {
|
||||
valid = false;
|
||||
}
|
||||
if(!valid)
|
||||
{
|
||||
G4Exception("TSRunAction", "000", JustWarning,
|
||||
G4String(primScorerNames.at(i) +
|
||||
" HitsMap is either not "
|
||||
"created or the HitsMap was empty").c_str());
|
||||
}
|
||||
} else {
|
||||
G4TAtomicHitsMap<G4double>* hitmap
|
||||
= tsRun->GetAtomicHitsMap(fName + "/" +
|
||||
primScorerNames.at(i));
|
||||
if(hitmap && hitmap->GetMap()->size() != 0)
|
||||
{
|
||||
for(auto itr = hitmap->GetMap()->begin();
|
||||
itr != hitmap->GetMap()->end(); itr++)
|
||||
{
|
||||
IDs.insert(itr->first);
|
||||
std::get<1>(fTypeCompare[primScorerNames.at(i)][itr->first])
|
||||
= *itr->second/units.at(i);
|
||||
print(fileout, itr->first, *itr->second,
|
||||
units.at(i), units.at(i+1), unitstr.at(i));
|
||||
}
|
||||
} else {
|
||||
valid = false;
|
||||
}
|
||||
if(!valid)
|
||||
{
|
||||
G4Exception("TSRunAction", "001", JustWarning,
|
||||
G4String(primScorerNames.at(i) +
|
||||
" HitsMap is either not "
|
||||
"created or the HitsMap was empty").c_str());
|
||||
}
|
||||
fout << first << " " << fsecond << G4endl;
|
||||
conv->ShowResult(fout);
|
||||
}
|
||||
std::stringstream ss;
|
||||
ss << " " << std::setw(10) << first
|
||||
<< " " << std::setw(15) << std::setprecision(6)
|
||||
<< std::fixed << psecond << " " << unit2str;
|
||||
// skip print of ConvergenceTester to stdout
|
||||
G4cout << ss.str() << G4endl;
|
||||
};
|
||||
//----------------------------------------------------------------------//
|
||||
|
||||
fileout.close();
|
||||
G4cout << separator.str() << G4endl;
|
||||
G4cout << " closed file " << fname << " for output" << G4endl;
|
||||
for(unsigned i = 0; i < primScorerNames.size(); ++i)
|
||||
{
|
||||
for(unsigned j = 0; j < fnames.size(); ++j)
|
||||
{
|
||||
fname = fnames.at(j) + "_" + primScorerNames.at(i) + ".out";
|
||||
fileout.open(fname);
|
||||
G4cout << separator.str() << G4endl;
|
||||
G4cout << " opened file " << fname << " for output" << G4endl;
|
||||
G4cout << separator.str() << G4endl;
|
||||
|
||||
G4bool valid = true;
|
||||
if(j == 0)
|
||||
{
|
||||
G4THitsMap<G4double>* hitmap
|
||||
= tsRun->GetHitsMap(fName + "/" + primScorerNames.at(i));
|
||||
G4StatContainer<G4StatAnalysis>* statmap
|
||||
= tsRun->GetStatMap(fName + "/" + primScorerNames.at(i));
|
||||
G4StatContainer<G4ConvergenceTester>* convmap
|
||||
= tsRun->GetConvMap(fName + "/" + primScorerNames.at(i));
|
||||
|
||||
if(hitmap && hitmap->size() != 0)
|
||||
{
|
||||
for(auto itr = hitmap->begin(); itr != hitmap->end(); itr++)
|
||||
{
|
||||
if(!hitmap->GetObject(itr))
|
||||
continue;
|
||||
IDs.insert(itr->first);
|
||||
std::get<0>(fTypeCompare[primScorerNames.at(i)][itr->first])
|
||||
= *itr->second/units.at(i);
|
||||
print(fileout, itr->first, *itr->second,
|
||||
units.at(i), units.at(i+1), unitstr.at(i));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
valid = false;
|
||||
}
|
||||
|
||||
if(statmap && statmap->size() != 0 &&
|
||||
convmap && convmap->size() != 0)
|
||||
{
|
||||
auto stat_fname = "stat_" + fname;
|
||||
std::ofstream statout;
|
||||
statout.open(stat_fname);
|
||||
for(auto itr = statmap->begin(); itr != statmap->end(); itr++)
|
||||
{
|
||||
G4int _f = statmap->GetIndex(itr);
|
||||
G4StatAnalysis* _s = statmap->GetObject(itr);
|
||||
G4ConvergenceTester* _c = convmap->GetObject(_f);
|
||||
stat_print(statout, _f, _s, _c,
|
||||
units.at(i), units.at(i+1), unitstr.at(i));
|
||||
}
|
||||
statout.close();
|
||||
}
|
||||
else
|
||||
{
|
||||
std::stringstream ss;
|
||||
ss << " StatMap/ConvMap is either not "
|
||||
<< "created or the StatMap/ConvMap was empty";
|
||||
if(statmap)
|
||||
ss << " (StatMap size == " << statmap->size() << ")";
|
||||
if(convmap)
|
||||
ss << " (ConvMap size == " << convmap->size() << ")";
|
||||
|
||||
G4Exception("TSRunAction", "002", JustWarning,
|
||||
G4String(primScorerNames.at(i) +
|
||||
ss.str()).c_str());
|
||||
}
|
||||
|
||||
if(!valid)
|
||||
{
|
||||
G4Exception("TSRunAction", "000", JustWarning,
|
||||
G4String(primScorerNames.at(i) +
|
||||
" HitsMap is either not "
|
||||
"created or the HitsMap was empty").c_str());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
G4TAtomicHitsMap<G4double>* hitmap
|
||||
= tsRun->GetAtomicHitsMap(fName + "/" +
|
||||
primScorerNames.at(i));
|
||||
if(hitmap && hitmap->size() != 0)
|
||||
{
|
||||
for(auto itr = hitmap->begin(); itr != hitmap->end(); itr++)
|
||||
{
|
||||
IDs.insert(itr->first);
|
||||
std::get<1>(fTypeCompare[primScorerNames.at(i)][itr->first])
|
||||
= *itr->second/units.at(i);
|
||||
print(fileout, itr->first, *itr->second,
|
||||
units.at(i), units.at(i+1), unitstr.at(i));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
valid = false;
|
||||
}
|
||||
|
||||
if(!valid)
|
||||
{
|
||||
G4Exception("TSRunAction", "001", JustWarning,
|
||||
G4String(primScorerNames.at(i) +
|
||||
" HitsMap is either not "
|
||||
"created or the HitsMap was empty").c_str());
|
||||
}
|
||||
}
|
||||
|
||||
fileout.close();
|
||||
G4cout << separator.str() << G4endl;
|
||||
G4cout << " closed file " << fname << " for output" << G4endl;
|
||||
}
|
||||
// add the mutex data
|
||||
TSRun::MutexHitsMap_t* hitmap
|
||||
= tsRun->GetMutexHitsMap(fName + "/" +
|
||||
primScorerNames.at(i));
|
||||
= tsRun->GetMutexHitsMap(fName + "/" +
|
||||
primScorerNames.at(i));
|
||||
if(hitmap && hitmap->size() != 0)
|
||||
{
|
||||
for(auto itr = hitmap->begin();
|
||||
itr != hitmap->end(); itr++)
|
||||
{
|
||||
IDs.insert(itr->first);
|
||||
std::get<2>(fTypeCompare[primScorerNames.at(i)][itr->first])
|
||||
= itr->second/units.at(i);
|
||||
}
|
||||
for(auto itr = hitmap->begin();
|
||||
itr != hitmap->end(); itr++)
|
||||
{
|
||||
IDs.insert(itr->first);
|
||||
std::get<2>(fTypeCompare[primScorerNames.at(i)][itr->first])
|
||||
= itr->second/units.at(i);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -223,70 +294,69 @@ void TSRunAction::EndOfRunAction(const G4Run* aRun)
|
||||
G4cout << " opened file " << fname << " for difference output" << G4endl;
|
||||
G4cout << separator.str() << G4endl;
|
||||
|
||||
fileout
|
||||
<< " " << std::setw(10) << "ID"
|
||||
<< " "
|
||||
<< std::setw(30) << std::setprecision(12) << std::fixed
|
||||
<< "MFD value"
|
||||
<< " "
|
||||
<< std::setw(30) << std::setprecision(12) << std::fixed
|
||||
<< "Atomic Hits Map value"
|
||||
<< " "
|
||||
<< std::setw(30) << std::setprecision(8) << std::scientific
|
||||
<< "Difference"
|
||||
<< " "
|
||||
<< std::setw(30) << std::setprecision(8) << std::scientific
|
||||
<< "Diff (MFD - MUTEXED)"
|
||||
<< " "
|
||||
<< std::setw(30) << std::setprecision(8) << std::scientific
|
||||
<< "Diff (ATOM_HIT_MAP - MUTEXED)"
|
||||
<< G4endl << G4endl;
|
||||
fileout << " " << std::setw(10) << "ID"
|
||||
<< " "
|
||||
<< std::setw(30) << std::setprecision(12) << std::fixed
|
||||
<< "MFD value"
|
||||
<< " "
|
||||
<< std::setw(30) << std::setprecision(12) << std::fixed
|
||||
<< "Atomic Hits Map value"
|
||||
<< " "
|
||||
<< std::setw(30) << std::setprecision(8) << std::scientific
|
||||
<< "Difference"
|
||||
<< " "
|
||||
<< std::setw(30) << std::setprecision(8) << std::scientific
|
||||
<< "Diff (MFD - MUTEXED)"
|
||||
<< " "
|
||||
<< std::setw(30) << std::setprecision(8) << std::scientific
|
||||
<< "Diff (ATOM_HIT_MAP - MUTEXED)"
|
||||
<< G4endl << G4endl;
|
||||
|
||||
for(auto itr1 = fTypeCompare.begin();
|
||||
itr1 != fTypeCompare.end(); ++itr1)
|
||||
{
|
||||
fileout << "\n\nType = " << itr1->first << "\n" << G4endl;
|
||||
for(auto itr2 = itr1->second.begin();
|
||||
itr2 != itr1->second.end(); ++itr2)
|
||||
{
|
||||
G4double d01
|
||||
= std::fabs(std::get<0>(itr2->second) -
|
||||
std::get<1>(itr2->second));
|
||||
G4double d02
|
||||
= std::fabs(std::get<0>(itr2->second) -
|
||||
std::get<2>(itr2->second));
|
||||
G4double d03
|
||||
= std::fabs(std::get<1>(itr2->second) -
|
||||
std::get<2>(itr2->second));
|
||||
|
||||
|
||||
auto _print_diff = [&] (const G4double& _dval)
|
||||
fileout << "\n\nType = " << itr1->first << "\n" << G4endl;
|
||||
for(auto itr2 = itr1->second.begin();
|
||||
itr2 != itr1->second.end(); ++itr2)
|
||||
{
|
||||
if(_dval > 0.0)
|
||||
fileout << std::setprecision(8) << std::scientific
|
||||
<< std::setw(30) << _dval << " ";
|
||||
else
|
||||
fileout << std::setprecision(1) << std::fixed
|
||||
<< std::setw(30) << _dval << " ";
|
||||
};
|
||||
G4double d01
|
||||
= std::fabs(std::get<0>(itr2->second) -
|
||||
std::get<1>(itr2->second));
|
||||
G4double d02
|
||||
= std::fabs(std::get<0>(itr2->second) -
|
||||
std::get<2>(itr2->second));
|
||||
G4double d03
|
||||
= std::fabs(std::get<1>(itr2->second) -
|
||||
std::get<2>(itr2->second));
|
||||
|
||||
fileout
|
||||
<< " " << std::setw(10) << itr2->first
|
||||
<< " "
|
||||
<< std::setw(30) << std::setprecision(12) << std::fixed
|
||||
<< std::get<0>(itr2->second)
|
||||
<< " "
|
||||
<< std::setw(30) << std::setprecision(12) << std::fixed
|
||||
<< std::get<1>(itr2->second)
|
||||
<< " ";
|
||||
|
||||
_print_diff(d01);
|
||||
_print_diff(d02);
|
||||
_print_diff(d03);
|
||||
auto _print_diff = [&] (const G4double& _dval)
|
||||
{
|
||||
if(_dval > 0.0)
|
||||
fileout << std::setprecision(8) << std::scientific
|
||||
<< std::setw(30) << _dval << " ";
|
||||
else
|
||||
fileout << std::setprecision(1) << std::fixed
|
||||
<< std::setw(30) << _dval << " ";
|
||||
};
|
||||
|
||||
fileout << G4endl;
|
||||
fileout
|
||||
<< " " << std::setw(10) << itr2->first
|
||||
<< " "
|
||||
<< std::setw(30) << std::setprecision(12) << std::fixed
|
||||
<< std::get<0>(itr2->second)
|
||||
<< " "
|
||||
<< std::setw(30) << std::setprecision(12) << std::fixed
|
||||
<< std::get<1>(itr2->second)
|
||||
<< " ";
|
||||
|
||||
}
|
||||
_print_diff(d01);
|
||||
_print_diff(d02);
|
||||
_print_diff(d03);
|
||||
|
||||
fileout << G4endl;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
fileout.close();
|
||||
|
||||
Reference in New Issue
Block a user