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"
29 #include "Randomize.hh"
37 std::cout <<
"PrintMaterialBudget selected volume " <<
name << std::endl;
45 std::cout <<
"PrintMaterialBudget output file " << weightFileName << std::endl;
46 std::cout <<
"PrintMaterialBudget output file " << elementFileName << std::endl;
47 std::cout <<
"PrintMaterialBudget output file " << texFileName << std::endl;
57 G4Random::setTheEngine(
new CLHEP::RanecuEngine);
59 theTopPV = G4TransportationManager::GetTransportationManager()->GetNavigatorForTracking()->GetWorldVolume();
62 G4LogicalVolume* lv =
theTopPV->GetLogicalVolume();
63 unsigned int leafDepth = 0;
66 for(
unsigned int iElement = 0;
67 iElement < G4Element::GetNumberOfElements();
83 out <<
"Geom." <<
"\t"
84 <<
"Volume" <<
"\t" <<
"\t"
86 <<
"Solid" <<
"\t" <<
"\t"
88 <<
"Density" <<
"\t" <<
"\t"
89 <<
"Mass" <<
"\t" <<
"\t"
91 out <<
"Level" <<
"\t"
92 <<
"Name" <<
"\t" <<
"\t"
94 <<
"Name" <<
"\t" <<
"\t"
95 <<
"Name" <<
"\t" <<
"\t"
96 <<
"[g/cm3]" <<
"\t" <<
"\t"
97 <<
"[g] " <<
"\t" <<
"\t"
102 out <<
"\\begin{table}[h!]" << std::endl
103 <<
" \\caption{\\textsf {" <<
name <<
"} volume list.}" << std::endl
104 <<
" \\label{tab: " <<
name <<
"}" << std::endl
105 <<
" \\begin{center}" << std::endl
106 <<
" \\begin{tabular}{ccccccc}" << std::endl
107 <<
" \\hline" << std::endl;
108 out <<
" Geom." <<
"\t & "
109 <<
" Volume" <<
"\t & "
110 <<
" Copy" <<
"\t & "
111 <<
" Solid" <<
"\t & "
112 <<
" Material" <<
"\t & "
113 <<
" Density" <<
"\t & "
114 <<
" Mass" <<
"\t \\\\ "
116 out <<
" Level" <<
"\t & "
117 <<
" Name" <<
"\t & "
118 <<
" Number" <<
"\t & "
119 <<
" Name" <<
"\t & "
120 <<
" Name" <<
"\t & "
129 out <<
" \\hline" << std::endl
130 <<
" \\end{tabular}" << std::endl
131 <<
" \\end{center}" << std::endl
132 <<
"\\end{table}" << std::endl;
136 unsigned int leafDepth,
137 std::ostream& weightOut,
138 std::ostream& texOut ) {
145 lvname.assign(lvname,0,
nchar);
146 if (lvname ==
name) {
149 printInfo(pv, lv, leafDepth, weightOut, texOut);
150 texOut <<
" \\hline" << std::endl;
155 std::set< G4LogicalVolume* > lvDaughters;
156 int NoDaughters = lv->GetNoDaughters();
157 while ((NoDaughters--)>0)
159 G4VPhysicalVolume* pvD = lv->GetDaughter(NoDaughters);
161 lvDaughters.insert(pvD->GetLogicalVolume());
164 std::set< G4LogicalVolume* >::const_iterator scite;
165 mmlvpv::const_iterator mmcite;
168 for (scite = lvDaughters.begin(); scite != lvDaughters.end(); scite++) {
169 std::pair< mmlvpv::iterator, mmlvpv::iterator > mmER = lvpvDaughters.equal_range(*scite);
171 for (mmcite = mmER.first ; mmcite != mmER.second; mmcite++)
178 std::ostream& weightOut, std::ostream& texOut ) {
180 double density = lv->GetMaterial()->GetDensity();
181 double weight = lv->GetMass(
false,
false);
184 if(volumeName.size()<8) volumeName.append(
"\t");
187 if(solidName.size()<8) solidName.append(
"\t");
189 std::string materialName = lv->GetMaterial()->GetName();
190 if(materialName.size()<8) materialName.append(
"\t");
193 weightOut << leafDepth <<
"\t"
194 << volumeName <<
"\t"
195 << pv->GetCopyNo() <<
"\t"
197 << materialName <<
"\t"
198 << G4BestUnit(density,
"Volumic Mass") <<
"\t"
199 << G4BestUnit(weight,
"Mass") <<
"\t"
203 << leafDepth <<
"\t & "
205 << pv->GetCopyNo() <<
"\t & "
212 for(
unsigned int iElement = 0; iElement<(
unsigned int)lv->GetMaterial()->GetNumberOfElements(); iElement++) {
214 if(materialName.find(
"Air")) {
215 std::string elementName = lv->GetMaterial()->GetElement(iElement)->GetName();
216 double elementMassFraction = lv->GetMaterial()->GetFractionVector()[iElement];
217 double elementWeight = weight*elementMassFraction;
218 unsigned int elementIndex = (
unsigned int)lv->GetMaterial()->GetElement(iElement)->GetIndex();
227 double totalWeight = 0.0;
228 double totalFraction = 0.0;
229 for(
unsigned int iElement = 0; iElement<(
unsigned int)
elementTotalWeight.size(); iElement++) {
233 for(
unsigned int iElement = 0; iElement<(
unsigned int)
elementTotalWeight.size(); iElement++) {
238 elementOut <<
"Element" <<
"\t\t"
240 <<
"Total Mass" <<
"\t"
241 <<
"Mass Fraction " <<
"\t"
244 for(
unsigned int iElement = 0; iElement<(
unsigned int)
elementTotalWeight.size(); iElement++) {
254 elementOut <<
"\n\t\tTotal Weight without Air " << G4BestUnit(totalWeight,
"Mass")
255 <<
"\tTotal Fraction " << totalFraction
263 for (
unsigned int i=0;
i<stringname.length() ;
i++) {
264 if (stringname.substr(
i,1) ==
"_") {
265 stringoutput +=
"\\_";
267 stringoutput += stringname.substr(
i,1);
279 for (
unsigned int i=1;
i<stringname.length() ;
i++) {
280 if (stringname.substr(
i-1,1) ==
"m" && stringname.substr(
i,1) ==
"3") {
281 stringoutput +=
"$^3$";
283 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