17 #include "G4PhysicalVolumeStore.hh" 18 #include "G4LogicalVolumeStore.hh" 19 #include "G4VPhysicalVolume.hh" 20 #include "G4LogicalVolume.hh" 21 #include "G4VSolid.hh" 22 #include "G4Material.hh" 23 #include "G4NavigationHistory.hh" 25 #include "G4VisAttributes.hh" 26 #include "G4UserLimits.hh" 27 #include "G4TransportationManager.hh" 28 #include "G4UnitsTable.hh" 29 #include "Randomize.hh" 37 typedef std::map<G4VPhysicalVolume*, G4VPhysicalVolume*, std::less<G4VPhysicalVolume*> >
mpvpv;
38 typedef std::multimap<G4LogicalVolume*, G4VPhysicalVolume*, std::less<G4LogicalVolume*> >
mmlvpv;
54 unsigned int leafDepth,
55 std::ostream& weightOut =
G4cout,
56 std::ostream& texOut =
G4cout);
59 unsigned int leafDepth,
60 std::ostream& weightOut =
G4cout,
61 std::ostream& texOut =
G4cout);
88 G4cout <<
"PrintMaterialBudget selected volume " <<
name << G4endl;
96 G4cout <<
"PrintMaterialBudget output file " << weightFileName << G4endl;
97 G4cout <<
"PrintMaterialBudget output file " << elementFileName << G4endl;
98 G4cout <<
"PrintMaterialBudget output file " << texFileName << G4endl;
107 G4Random::setTheEngine(
new CLHEP::RanecuEngine);
109 theTopPV = G4TransportationManager::GetTransportationManager()->GetNavigatorForTracking()->GetWorldVolume();
112 G4LogicalVolume* lv =
theTopPV->GetLogicalVolume();
113 unsigned int leafDepth = 0;
116 for (
unsigned int iElement = 0; iElement < G4Element::GetNumberOfElements();
172 out <<
"\\begin{table}[h!]" << G4endl <<
" \\caption{\\textsf {" <<
name <<
"} volume list.}" << G4endl
173 <<
" \\label{tab: " <<
name <<
"}" << G4endl <<
" \\begin{center}" << G4endl <<
" \\begin{tabular}{ccccccc}" 174 << G4endl <<
" \\hline" << G4endl;
188 <<
"\t \\\\ " << G4endl;
202 <<
"\t \\\\ " << G4endl <<
" \\hline\\hline" << G4endl;
206 out <<
" \\hline" << G4endl <<
" \\end{tabular}" << G4endl <<
" \\end{center}" << G4endl <<
"\\end{table}" 211 G4VPhysicalVolume*
pv, G4LogicalVolume* lv,
unsigned int leafDepth, std::ostream& weightOut, std::ostream& texOut) {
219 lvname.assign(lvname, 0,
nchar);
220 if (lvname ==
name) {
224 texOut <<
" \\hline" << G4endl;
229 std::set<G4LogicalVolume*> lvDaughters;
230 int NoDaughters = lv->GetNoDaughters();
231 while ((NoDaughters--) > 0) {
232 G4VPhysicalVolume* pvD = lv->GetDaughter(NoDaughters);
234 lvDaughters.insert(pvD->GetLogicalVolume());
237 std::set<G4LogicalVolume*>::const_iterator scite;
238 mmlvpv::const_iterator mmcite;
241 for (scite = lvDaughters.begin(); scite != lvDaughters.end(); scite++) {
242 std::pair<mmlvpv::iterator, mmlvpv::iterator> mmER = lvpvDaughters.equal_range(*scite);
244 for (mmcite = mmER.first; mmcite != mmER.second; mmcite++)
250 G4VPhysicalVolume*
pv, G4LogicalVolume* lv,
unsigned int leafDepth, std::ostream& weightOut, std::ostream& texOut) {
251 double density = lv->GetMaterial()->GetDensity();
252 double weight = lv->GetMass(
false,
false);
255 if (volumeName.size() < 8)
256 volumeName.append(
"\t");
259 if (solidName.size() < 8)
260 solidName.append(
"\t");
262 std::string materialName = lv->GetMaterial()->GetName();
263 if (materialName.size() < 8)
264 materialName.append(
"\t");
267 weightOut << leafDepth <<
"\t" << volumeName <<
"\t" <<
pv->GetCopyNo() <<
"\t" << solidName <<
"\t" << materialName
268 <<
"\t" << G4BestUnit(
density,
"Volumic Mass") <<
"\t" << G4BestUnit(
weight,
"Mass") <<
"\t" << G4endl;
270 texOut <<
"\t" << leafDepth <<
"\t & " <<
stringLaTeXUnderscore(volumeName) <<
"\t & " <<
pv->GetCopyNo() <<
"\t & " 275 for (
unsigned int iElement = 0; iElement < (
unsigned int)lv->GetMaterial()->GetNumberOfElements(); iElement++) {
277 if (materialName.find(
"Air")) {
278 std::string elementName = lv->GetMaterial()->GetElement(iElement)->GetName();
279 double elementMassFraction = lv->GetMaterial()->GetFractionVector()[iElement];
280 double elementWeight =
weight * elementMassFraction;
281 unsigned int elementIndex = (
unsigned int)lv->GetMaterial()->GetElement(iElement)->GetIndex();
291 double totalFraction = 0.0;
301 elementOut <<
"Element" 314 elementOut <<
elementNames[iElement] <<
"\t" << iElement <<
"\t" 319 elementOut <<
"\n\t\tTotal Weight without Air " << G4BestUnit(
totalWeight,
"Mass") <<
"\tTotal Fraction " 320 << totalFraction << G4endl;
327 for (
unsigned int i = 0;
i < stringname.length();
i++) {
328 if (stringname.substr(
i, 1) ==
"_") {
329 stringoutput +=
"\\_";
331 stringoutput += stringname.substr(
i, 1);
340 std::string stringoutput = stringname.substr(0, 1);
342 for (
unsigned int i = 1;
i < stringname.length();
i++) {
343 if (stringname.substr(
i - 1, 1) ==
"m" && stringname.substr(
i, 1) ==
"3") {
344 stringoutput +=
"$^3$";
346 stringoutput += stringname.substr(
i, 1);
std::multimap< G4LogicalVolume *, G4VPhysicalVolume *, std::less< G4LogicalVolume * > > mmlvpv
#define DEFINE_SIMWATCHER(type)
~PrintMaterialBudgetInfo() override
void dumpLaTeXFooter(std::ostream &out=G4cout)
std::vector< std::string > elementNames
void dumpLaTeXHeader(std::ostream &out=G4cout)
std::vector< double > elementWeightFraction
std::vector< double > elementTotalWeight
Container::value_type value_type
void dumpElementMassFraction(std::ostream &elementOut=G4cout)
void dumpHierarchyLeaf(G4VPhysicalVolume *pv, G4LogicalVolume *lv, unsigned int leafDepth, std::ostream &weightOut=G4cout, std::ostream &texOut=G4cout)
G4NavigationHistory fHistory
PrintMaterialBudgetInfo(edm::ParameterSet const &p)
std::multimap< G4LogicalVolume *, G4VPhysicalVolume *, std::less< G4LogicalVolume * > > mmlvpv
G4VPhysicalVolume * theTopPV
std::ofstream weightOutputFile
std::ofstream elementOutputFile
std::string stringLaTeXSuperscript(std::string stringname)
std::string stringLaTeXUnderscore(std::string stringname)
void update(const BeginOfJob *job) override
This routine will be called when the appropriate signal arrives.
void printInfo(G4VPhysicalVolume *pv, G4LogicalVolume *lv, unsigned int leafDepth, std::ostream &weightOut=G4cout, std::ostream &texOut=G4cout)
std::map< G4VPhysicalVolume *, G4VPhysicalVolume *, std::less< G4VPhysicalVolume * > > mpvpv
std::ofstream texOutputFile
void dumpHeader(std::ostream &out=G4cout)