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" 38 typedef std::map<G4VPhysicalVolume*, G4VPhysicalVolume*, std::less<G4VPhysicalVolume*> >
mpvpv;
39 typedef std::multimap<G4LogicalVolume*, G4VPhysicalVolume*, std::less<G4LogicalVolume*> >
mmlvpv;
55 unsigned int leafDepth,
56 std::ostream& weightOut =
G4cout,
57 std::ostream& texOut =
G4cout);
60 unsigned int leafDepth,
61 std::ostream& weightOut =
G4cout,
62 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 G4VPhysicalVolume* theTopPV =
110 G4TransportationManager::GetTransportationManager()->GetNavigatorForTracking()->GetWorldVolume();
113 G4LogicalVolume* lv = theTopPV->GetLogicalVolume();
114 unsigned int leafDepth = 0;
117 for (
unsigned int iElement = 0; iElement < G4Element::GetNumberOfElements();
173 out <<
"\\begin{table}[h!]" << G4endl <<
" \\caption{\\textsf {" <<
name <<
"} volume list.}" << G4endl
174 <<
" \\label{tab: " <<
name <<
"}" << G4endl <<
" \\begin{center}" << G4endl <<
" \\begin{tabular}{ccccccc}" 175 << G4endl <<
" \\hline" << G4endl;
189 <<
"\t \\\\ " << G4endl;
203 <<
"\t \\\\ " << G4endl <<
" \\hline\\hline" << G4endl;
207 out <<
" \\hline" << G4endl <<
" \\end{tabular}" << G4endl <<
" \\end{center}" << G4endl <<
"\\end{table}" 212 G4VPhysicalVolume*
pv, G4LogicalVolume* lv,
unsigned int leafDepth, std::ostream& weightOut, std::ostream& texOut) {
220 lvname.assign(lvname, 0,
nchar);
221 if (lvname ==
name) {
225 texOut <<
" \\hline" << G4endl;
230 std::set<G4LogicalVolume*> lvDaughters;
231 int NoDaughters = lv->GetNoDaughters();
232 while ((NoDaughters--) > 0) {
233 G4VPhysicalVolume* pvD = lv->GetDaughter(NoDaughters);
235 lvDaughters.insert(pvD->GetLogicalVolume());
238 std::set<G4LogicalVolume*>::const_iterator scite;
239 mmlvpv::const_iterator mmcite;
242 for (scite = lvDaughters.begin(); scite != lvDaughters.end(); scite++) {
243 std::pair<mmlvpv::iterator, mmlvpv::iterator> mmER = lvpvDaughters.equal_range(*scite);
245 for (mmcite = mmER.first; mmcite != mmER.second; mmcite++)
251 G4VPhysicalVolume*
pv, G4LogicalVolume* lv,
unsigned int leafDepth, std::ostream& weightOut, std::ostream& texOut) {
252 double density = lv->GetMaterial()->GetDensity();
253 double weight = lv->GetMass(
false,
false);
256 if (volumeName.size() < 8)
257 volumeName.append(
"\t");
260 if (solidName.size() < 8)
261 solidName.append(
"\t");
263 std::string materialName = lv->GetMaterial()->GetName();
264 if (materialName.size() < 8)
265 materialName.append(
"\t");
268 weightOut << leafDepth <<
"\t" << volumeName <<
"\t" <<
pv->GetCopyNo() <<
"\t" << solidName <<
"\t" << materialName
269 <<
"\t" << G4BestUnit(
density,
"Volumic Mass") <<
"\t" << G4BestUnit(
weight,
"Mass") <<
"\t" << G4endl;
271 texOut <<
"\t" << leafDepth <<
"\t & " <<
stringLaTeXUnderscore(volumeName) <<
"\t & " <<
pv->GetCopyNo() <<
"\t & " 276 for (
unsigned int iElement = 0; iElement < (
unsigned int)lv->GetMaterial()->GetNumberOfElements(); iElement++) {
278 if (materialName.find(
"Air")) {
279 std::string elementName = lv->GetMaterial()->GetElement(iElement)->GetName();
280 double elementMassFraction = lv->GetMaterial()->GetFractionVector()[iElement];
281 double elementWeight =
weight * elementMassFraction;
282 unsigned int elementIndex = (
unsigned int)lv->GetMaterial()->GetElement(iElement)->GetIndex();
292 double totalFraction = 0.0;
302 elementOut <<
"Element" 315 elementOut <<
elementNames[iElement] <<
"\t" << iElement <<
"\t" 320 elementOut <<
"\n\t\tTotal Weight without Air " << G4BestUnit(
totalWeight,
"Mass") <<
"\tTotal Fraction " 321 << totalFraction << G4endl;
328 for (
unsigned int i = 0;
i < stringname.length();
i++) {
329 if (stringname.substr(
i, 1) ==
"_") {
330 stringoutput +=
"\\_";
332 stringoutput += stringname.substr(
i, 1);
341 std::string stringoutput = stringname.substr(0, 1);
343 for (
unsigned int i = 1;
i < stringname.length();
i++) {
344 if (stringname.substr(
i - 1, 1) ==
"m" && stringname.substr(
i, 1) ==
"3") {
345 stringoutput +=
"$^3$";
347 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
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)