53 fName(fDetector->GetMFDName())
88 std::ofstream fileout;
90 std::stringstream separator;
93 <<
"============================================================";
95 typedef std::set<G4int> IDSet_t;
99 const TSRun* tsRun =
static_cast<const TSRun*
>(aRun);
105 std::vector<G4String> primScorerNames {
"EnergyDeposit",
107 std::vector<G4String> fnames {
"mfd_tl",
"mfd_tg" };
109 std::vector<G4String> unitstr {
"keV",
"steps" };
111 for(
unsigned i = 0; i < primScorerNames.size(); ++i)
113 for(
unsigned j = 0; j < fnames.size(); ++j)
116 auto print = [] (std::ostream& fout,
122 <<
" " << second/unit1
126 <<
" " << std::setw(10) << first
127 <<
" " << std::setw(15) << std::setprecision(6)
128 << std::fixed << second/unit2 <<
" " << unit2str
130 G4cout.unsetf(std::ios::fixed);
134 fname = fnames.at(j) +
"_" + primScorerNames.at(i) +
".out";
137 G4cout <<
" opened file " << fname <<
" for output" <<
G4endl;
145 if(hitmap && hitmap->
GetMap()->size() != 0)
147 for(
auto itr = hitmap->
GetMap()->begin();
148 itr != hitmap->
GetMap()->end(); itr++)
150 IDs.insert(itr->first);
151 std::get<0>(
fTypeCompare[primScorerNames.at(i)][itr->first])
152 = *itr->second/units.at(i);
153 print(fileout, itr->first, *itr->second,
154 units.at(i), units.at(i+1), unitstr.at(i));
162 primScorerNames.at(i));
163 if(hitmap && hitmap->GetMap()->size() != 0)
165 for(
auto itr = hitmap->GetMap()->begin();
166 itr != hitmap->GetMap()->end(); itr++)
168 IDs.insert(itr->first);
169 std::get<1>(
fTypeCompare[primScorerNames.at(i)][itr->first])
170 = *itr->second/units.at(i);
171 print(fileout, itr->first, *itr->second,
172 units.at(i), units.at(i+1), unitstr.at(i));
181 " HitsMap is either not "
182 "created or the HitsMap was empty").c_str());
188 G4cout <<
" closed file " << fname <<
" for output" <<
G4endl;
193 primScorerNames.at(i));
194 if(hitmap && hitmap->size() != 0)
196 for(
auto itr = hitmap->begin();
197 itr != hitmap->end(); itr++)
199 IDs.insert(itr->first);
200 std::get<2>(
fTypeCompare[primScorerNames.at(i)][itr->first])
201 = itr->second/units.at(i);
212 fname =
"mfd_diff.out";
216 G4cout <<
" opened file " << fname <<
" for difference output" <<
G4endl;
220 <<
" " << std::setw(10) <<
"ID"
222 << std::setw(30) << std::setprecision(12) << std::fixed
225 << std::setw(30) << std::setprecision(12) << std::fixed
226 <<
"Atomic Hits Map value"
228 << std::setw(30) << std::setprecision(12) << std::fixed
231 << std::setw(30) << std::setprecision(12) << std::fixed
232 <<
"Diff (MFD - MUTEXED)"
234 << std::setw(30) << std::setprecision(12) << std::fixed
235 <<
"Diff (ATOM_HIT_MAP - MUTEXED)"
241 fileout <<
"\n\nType = " << itr1->first <<
"\n" <<
G4endl;
242 for(
auto itr2 = itr1->second.begin();
243 itr2 != itr1->second.end(); ++itr2)
246 <<
" " << std::setw(10) << itr2->first
248 << std::setw(30) << std::setprecision(12) << std::fixed
249 << std::get<0>(itr2->second)
251 << std::setw(30) << std::setprecision(12) << std::fixed
252 << std::get<1>(itr2->second)
254 << std::setw(30) << std::setprecision(12) << std::fixed
255 << (std::fabs(std::get<0>(itr2->second) - std::get<1>(itr2->second)))
257 << std::setw(30) << std::setprecision(12) << std::fixed
258 << (std::fabs(std::get<0>(itr2->second) - std::get<2>(itr2->second)))
260 << std::setw(30) << std::setprecision(12) << std::fixed
261 << (std::fabs(std::get<1>(itr2->second) - std::get<2>(itr2->second)))
268 G4cout <<
" closed file " << fname <<
" for difference output" <<
G4endl;
virtual void BeginOfRunAction(const G4Run *)
void SetPrintProgress(G4int i)
Definition of the TSActionInitialization class.
MutexHitsMap_t * GetMutexHitsMap(const G4String &) const
Definition of the TSRun class.
virtual void EndOfRunAction(const G4Run *)
G4THitsMap< G4double > * GetHitsMap(const G4String &collname) const
virtual G4Run * GenerateRun()
G4GLOB_DLL std::ostream G4cout
Definition of the TSRunAction class.
G4int GetNumberOfEvent() const
std::map< G4int, G4double > MutexHitsMap_t
static const double second
void print(G4double elem)
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
TypeCompare_t fTypeCompare
static G4RunManager * GetRunManager()
This is an implementation of G4THitsMap where the underlying type is G4atomic, not just T. A static assert is provided to ensure that T is fundamental. This class should be used in lieu of G4THitsMap when memory is a concern. Atomics are thread-safe and generally faster that mutexes (as long as the STL implementation is lock-free) but the synchronization does not come without a cost. If performance is the primary concern, use G4THitsMap in thread-local instances.
std::map< G4int, T * > * GetMap() const
G4int GetNumberOfEventToBeProcessed() const
Definition of the TSDetectorConstruction class.
G4TAtomicHitsMap< G4double > * GetAtomicHitsMap(const G4String &) const