18 #include "G4PhysicalVolumeStore.hh"
19 #include "G4LogicalVolumeStore.hh"
20 #include "G4VPhysicalVolume.hh"
21 #include "G4LogicalVolume.hh"
22 #include "G4VSolid.hh"
23 #include "G4Material.hh"
25 #include "G4VisAttributes.hh"
26 #include "G4UserLimits.hh"
27 #include "G4TransportationManager.hh"
28 #include "G4UnitsTable.hh"
36 std::cout <<
"PrintMaterialBudget selected volume " <<
name << std::endl;
38 std::string weightFileName =
name+
".weight";
40 std::string elementFileName =
name+
".element";
42 std::string texFileName =
name+
"_table.tex";
44 std::cout <<
"PrintMaterialBudget output file " << weightFileName << std::endl;
45 std::cout <<
"PrintMaterialBudget output file " << elementFileName << std::endl;
46 std::cout <<
"PrintMaterialBudget output file " << texFileName << std::endl;
57 theTopPV = G4TransportationManager::GetTransportationManager()->GetNavigatorForTracking()->GetWorldVolume();
59 G4LogicalVolume* lv =
theTopPV->GetLogicalVolume();
60 unsigned int leafDepth = 0;
63 for(
unsigned int iElement = 0;
64 iElement < lv->GetMaterial()->GetElement(iElement)->GetElementTable()->size();
80 out <<
"Geom." <<
"\t"
81 <<
"Volume" <<
"\t" <<
"\t"
83 <<
"Solid" <<
"\t" <<
"\t"
85 <<
"Density" <<
"\t" <<
"\t"
86 <<
"Mass" <<
"\t" <<
"\t"
88 out <<
"Level" <<
"\t"
89 <<
"Name" <<
"\t" <<
"\t"
91 <<
"Name" <<
"\t" <<
"\t"
92 <<
"Name" <<
"\t" <<
"\t"
93 <<
"[g/cm3]" <<
"\t" <<
"\t"
94 <<
"[g] " <<
"\t" <<
"\t"
99 out <<
"\\begin{table}[h!]" << std::endl
100 <<
" \\caption{\\textsf {" <<
name <<
"} volume list.}" << std::endl
101 <<
" \\label{tab: " <<
name <<
"}" << std::endl
102 <<
" \\begin{center}" << std::endl
103 <<
" \\begin{tabular}{ccccccc}" << std::endl
104 <<
" \\hline" << std::endl;
105 out <<
" Geom." <<
"\t & "
106 <<
" Volume" <<
"\t & "
107 <<
" Copy" <<
"\t & "
108 <<
" Solid" <<
"\t & "
109 <<
" Material" <<
"\t & "
110 <<
" Density" <<
"\t & "
111 <<
" Mass" <<
"\t \\\\ "
113 out <<
" Level" <<
"\t & "
114 <<
" Name" <<
"\t & "
115 <<
" Number" <<
"\t & "
116 <<
" Name" <<
"\t & "
117 <<
" Name" <<
"\t & "
126 out <<
" \\hline" << std::endl
127 <<
" \\end{tabular}" << std::endl
128 <<
" \\end{center}" << std::endl
129 <<
"\\end{table}" << std::endl;
133 unsigned int leafDepth,
134 std::ostream& weightOut,
135 std::ostream& texOut ) {
141 std::string lvname = lv->GetName();
142 lvname.assign(lvname,0,
nchar);
143 if (lvname ==
name) {
146 printInfo(pv, lv, leafDepth, weightOut, texOut);
147 texOut <<
" \\hline" << std::endl;
152 std::set< G4LogicalVolume* > lvDaughters;
153 int NoDaughters = lv->GetNoDaughters();
154 while ((NoDaughters--)>0)
156 G4VPhysicalVolume* pvD = lv->GetDaughter(NoDaughters);
158 lvDaughters.insert(pvD->GetLogicalVolume());
161 std::set< G4LogicalVolume* >::const_iterator scite;
162 mmlvpv::const_iterator mmcite;
165 for (scite = lvDaughters.begin(); scite != lvDaughters.end(); scite++) {
166 std::pair< mmlvpv::iterator, mmlvpv::iterator > mmER = lvpvDaughters.equal_range(*scite);
168 for (mmcite = mmER.first ; mmcite != mmER.second; mmcite++)
175 std::ostream& weightOut, std::ostream& texOut ) {
177 double density = lv->GetMaterial()->GetDensity();
178 double weight = lv->GetMass(
false,
false);
180 std::string volumeName = lv->GetName();
181 if(volumeName.size()<8) volumeName.append(
"\t");
183 std::string solidName = lv->GetSolid()->GetName();
184 if(solidName.size()<8) solidName.append(
"\t");
186 std::string materialName = lv->GetMaterial()->GetName();
187 if(materialName.size()<8) materialName.append(
"\t");
190 weightOut << leafDepth <<
"\t"
191 << volumeName <<
"\t"
192 << pv->GetCopyNo() <<
"\t"
194 << materialName <<
"\t"
195 << G4BestUnit(density,
"Volumic Mass") <<
"\t"
196 << G4BestUnit(weight,
"Mass") <<
"\t"
200 << leafDepth <<
"\t & "
202 << pv->GetCopyNo() <<
"\t & "
209 for(
unsigned int iElement = 0; iElement<(
unsigned int)lv->GetMaterial()->GetNumberOfElements(); iElement++) {
211 if(materialName.find(
"Air")) {
212 std::string elementName = lv->GetMaterial()->GetElement(iElement)->GetName();
213 double elementMassFraction = lv->GetMaterial()->GetFractionVector()[iElement];
214 double elementWeight = weight*elementMassFraction;
215 unsigned int elementIndex = (
unsigned int)lv->GetMaterial()->GetElement(iElement)->GetIndex();
224 double totalWeight = 0.0;
225 double totalFraction = 0.0;
226 for(
unsigned int iElement = 0; iElement<(
unsigned int)
elementTotalWeight.size(); iElement++) {
230 for(
unsigned int iElement = 0; iElement<(
unsigned int)
elementTotalWeight.size(); iElement++) {
235 elementOut <<
"Element" <<
"\t\t"
237 <<
"Total Mass" <<
"\t"
238 <<
"Mass Fraction " <<
"\t"
241 for(
unsigned int iElement = 0; iElement<(
unsigned int)
elementTotalWeight.size(); iElement++) {
251 elementOut <<
"\n\t\tTotal Weight without Air " << G4BestUnit(totalWeight,
"Mass")
252 <<
"\tTotal Fraction " << totalFraction
258 std::string stringoutput;
260 for (
unsigned int i=0;
i<stringname.length() ;
i++) {
261 if (stringname.substr(
i,1) ==
"_") {
262 stringoutput +=
"\\_";
264 stringoutput += stringname.substr(
i,1);
274 std::string stringoutput = stringname.substr(0,1);
276 for (
unsigned int i=1;
i<stringname.length() ;
i++) {
277 if (stringname.substr(
i-1,1) ==
"m" && stringname.substr(
i,1) ==
"3") {
278 stringoutput +=
"$^3$";
280 stringoutput += stringname.substr(
i,1);
T getUntrackedParameter(std::string const &, T const &) const
std::multimap< G4LogicalVolume *, G4VPhysicalVolume *, std::less< G4LogicalVolume * > > mmlvpv
std::vector< std::string > elementNames
std::vector< double > elementWeightFraction
std::vector< double > elementTotalWeight
~PrintMaterialBudgetInfo()
void dumpElementMassFraction(std::ostream &elementOut=std::cout)
void dumpHierarchyLeaf(G4VPhysicalVolume *pv, G4LogicalVolume *lv, unsigned int leafDepth, std::ostream &weightOut=std::cout, std::ostream &texOut=std::cout)
void printInfo(G4VPhysicalVolume *pv, G4LogicalVolume *lv, unsigned int leafDepth, std::ostream &weightOut=std::cout, std::ostream &texOut=std::cout)
PrintMaterialBudgetInfo(edm::ParameterSet const &p)
Container::value_type value_type
void dumpLaTeXFooter(std::ostream &out=std::cout)
G4VPhysicalVolume * theTopPV
std::ofstream weightOutputFile
std::ofstream elementOutputFile
std::string stringLaTeXSuperscript(std::string stringname)
void dumpHeader(std::ostream &out=std::cout)
void update(const BeginOfJob *job)
This routine will be called when the appropriate signal arrives.
std::string stringLaTeXUnderscore(std::string stringname)
tuple size
Write out results.
void dumpLaTeXHeader(std::ostream &out=std::cout)
std::ofstream texOutputFile