25 {
26
27
28 G4LogicalVolumeStore* g4_logical_volume_store = G4LogicalVolumeStore::GetInstance();
29 G4PhysicalVolumeStore* g4_physical_volume_store = G4PhysicalVolumeStore::GetInstance();
30 G4RegionStore* g4_region_store = G4RegionStore::GetInstance();
31
32
33
34
35
36
38
40 for (std::string line; std::getline(infile, line); ){
41 std::istringstream in(line);
44
45 if ("Counts"==id){
46 unsigned int lvs=0,pvs=0,
regs=0;
47 in >> lvs >> pvs >>
regs;
48 if (lvs!=g4_logical_volume_store->size()){
49 G4ExceptionDescription ed;
50 ed << "ERROR! Reference had " << lvs << " and this setup has " << g4_logical_volume_store->size() << " logical volumes" << G4endl;
51 G4Exception("Geant4SetupChecker","LogVolMismatch",FatalException,ed);
52 abort();
53 }
54 if (pvs!=g4_physical_volume_store->size()){
55 G4ExceptionDescription ed;
56 ed << "ERROR! Reference had " << pvs << " and this setup has " << g4_physical_volume_store->size() << " physical volumes" << G4endl;
57 G4Exception("Geant4SetupChecker","PhysVolMismatch",FatalException,ed);
58 abort();
59 }
60 if (regs!=g4_region_store->size()){
61 G4ExceptionDescription ed;
62 ed <<
"ERROR! Reference had " <<
regs <<
" and this setup has " << g4_region_store->size() <<
" regions" << G4endl;
63 G4Exception("Geant4SetupChecker","RegionMismatch",FatalException,ed);
64 abort();
65 }
66 }
67 else {
68 G4Region* areg = g4_region_store->GetRegion(id);
69 if (!areg){
70 G4ExceptionDescription ed;
71 ed << "ERROR! Reference had region named " << id << "that is not in this configuration, or has changed name" << G4endl;
72 G4Exception("Geant4SetupChecker","RegionNotFound",FatalException,ed);
73 abort();
74 }
75 unsigned int nmat=0, nfs=0;
76 in >> nmat >> nfs;
77 if (nmat!=areg->GetNumberOfMaterials()){
78 G4ExceptionDescription ed;
79 ed << "ERROR! Region " << id << " had " << nmat << " materials in ref and " << areg->GetNumberOfMaterials() << " in this setup" << G4endl;
80 G4Exception("Geant4SetupChecker","MaterialMismatch",FatalException,ed);
81 abort();
82 }
83 if ( (!areg->GetFastSimulationManager() && nfs!=0) ||
84 ( areg->GetFastSimulationManager() && nfs!=areg->GetFastSimulationManager()->GetFastSimulationModelList().size()) ){
85 G4ExceptionDescription ed;
86 ed << "ERROR! Region " << id << " had " << nfs << " fast sims in ref and " << (areg->GetFastSimulationManager()?areg->GetFastSimulationManager()->GetFastSimulationModelList().size():0) << " in this setup" << G4endl;
87 G4Exception("Geant4SetupChecker","FastSimMismatch",FatalException,ed);
88 abort();
89 }
90 }
91 }
93 G4cout << "All ok!" << G4endl;
94 }
95 else {
97 outfile <<
"Counts " << g4_logical_volume_store->size() <<
" " << g4_physical_volume_store->size() <<
" " << g4_region_store->size() << std::endl;
98
99 for (auto* areg : *g4_region_store){
100 outfile << areg->GetName() <<
" " << areg->GetNumberOfMaterials() <<
" " << (areg->GetFastSimulationManager()?areg->GetFastSimulationManager()->GetFastSimulationModelList().size():0) << std::endl;
101 }
103 }
104}