17 #include "G4PhysicalVolumeStore.hh" 18 #include "G4LogicalVolumeStore.hh" 19 #include "G4VPhysicalVolume.hh" 20 #include "G4LogicalVolume.hh" 21 #include "G4VSolid.hh" 22 #include "G4Material.hh" 24 #include "G4VisAttributes.hh" 25 #include "G4UserLimits.hh" 26 #include "G4TransportationManager.hh" 27 #include "G4UnitsTable.hh" 28 #include "Randomize.hh" 36 std::cout <<
"PrintMaterialBudget selected volume " <<
name << std::endl;
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;
56 G4Random::setTheEngine(
new CLHEP::RanecuEngine);
58 theTopPV = G4TransportationManager::GetTransportationManager()->GetNavigatorForTracking()->GetWorldVolume();
61 G4LogicalVolume* lv =
theTopPV->GetLogicalVolume();
62 unsigned int leafDepth = 0;
65 for(
unsigned int iElement = 0;
66 iElement < G4Element::GetNumberOfElements();
82 out <<
"Geom." <<
"\t" 83 <<
"Volume" <<
"\t" <<
"\t" 85 <<
"Solid" <<
"\t" <<
"\t" 87 <<
"Density" <<
"\t" <<
"\t" 88 <<
"Mass" <<
"\t" <<
"\t" 90 out <<
"Level" <<
"\t" 91 <<
"Name" <<
"\t" <<
"\t" 93 <<
"Name" <<
"\t" <<
"\t" 94 <<
"Name" <<
"\t" <<
"\t" 95 <<
"[g/cm3]" <<
"\t" <<
"\t" 96 <<
"[g] " <<
"\t" <<
"\t" 101 out <<
"\\begin{table}[h!]" << std::endl
102 <<
" \\caption{\\textsf {" <<
name <<
"} volume list.}" << std::endl
103 <<
" \\label{tab: " <<
name <<
"}" << std::endl
104 <<
" \\begin{center}" << std::endl
105 <<
" \\begin{tabular}{ccccccc}" << std::endl
106 <<
" \\hline" << std::endl;
107 out <<
" Geom." <<
"\t & " 108 <<
" Volume" <<
"\t & " 109 <<
" Copy" <<
"\t & " 110 <<
" Solid" <<
"\t & " 111 <<
" Material" <<
"\t & " 112 <<
" Density" <<
"\t & " 113 <<
" Mass" <<
"\t \\\\ " 115 out <<
" Level" <<
"\t & " 116 <<
" Name" <<
"\t & " 117 <<
" Number" <<
"\t & " 118 <<
" Name" <<
"\t & " 119 <<
" Name" <<
"\t & " 128 out <<
" \\hline" << std::endl
129 <<
" \\end{tabular}" << std::endl
130 <<
" \\end{center}" << std::endl
131 <<
"\\end{table}" << std::endl;
135 unsigned int leafDepth,
136 std::ostream& weightOut,
137 std::ostream& texOut ) {
144 lvname.assign(lvname,0,
nchar);
145 if (lvname ==
name) {
148 printInfo(pv, lv, leafDepth, weightOut, texOut);
149 texOut <<
" \\hline" << std::endl;
154 std::set< G4LogicalVolume* > lvDaughters;
155 int NoDaughters = lv->GetNoDaughters();
156 while ((NoDaughters--)>0)
158 G4VPhysicalVolume* pvD = lv->GetDaughter(NoDaughters);
160 lvDaughters.insert(pvD->GetLogicalVolume());
163 std::set< G4LogicalVolume* >::const_iterator scite;
164 mmlvpv::const_iterator mmcite;
167 for (scite = lvDaughters.begin(); scite != lvDaughters.end(); scite++) {
168 std::pair< mmlvpv::iterator, mmlvpv::iterator > mmER = lvpvDaughters.equal_range(*scite);
170 for (mmcite = mmER.first ; mmcite != mmER.second; mmcite++)
177 std::ostream& weightOut, std::ostream& texOut ) {
179 double density = lv->GetMaterial()->GetDensity();
180 double weight = lv->GetMass(
false,
false);
183 if(volumeName.size()<8) volumeName.append(
"\t");
186 if(solidName.size()<8) solidName.append(
"\t");
188 std::string materialName = lv->GetMaterial()->GetName();
189 if(materialName.size()<8) materialName.append(
"\t");
192 weightOut << leafDepth <<
"\t" 193 << volumeName <<
"\t" 194 << pv->GetCopyNo() <<
"\t" 196 << materialName <<
"\t" 197 << G4BestUnit(density,
"Volumic Mass") <<
"\t" 198 << G4BestUnit(weight,
"Mass") <<
"\t" 202 << leafDepth <<
"\t & " 204 << pv->GetCopyNo() <<
"\t & " 211 for(
unsigned int iElement = 0; iElement<(
unsigned int)lv->GetMaterial()->GetNumberOfElements(); iElement++) {
213 if(materialName.find(
"Air")) {
214 std::string elementName = lv->GetMaterial()->GetElement(iElement)->GetName();
215 double elementMassFraction = lv->GetMaterial()->GetFractionVector()[iElement];
216 double elementWeight = weight*elementMassFraction;
217 unsigned int elementIndex = (
unsigned int)lv->GetMaterial()->GetElement(iElement)->GetIndex();
226 double totalWeight = 0.0;
227 double totalFraction = 0.0;
237 elementOut <<
"Element" <<
"\t\t" 239 <<
"Total Mass" <<
"\t" 240 <<
"Mass Fraction " <<
"\t" 253 elementOut <<
"\n\t\tTotal Weight without Air " << G4BestUnit(totalWeight,
"Mass")
254 <<
"\tTotal Fraction " << totalFraction
262 for (
unsigned int i=0;
i<stringname.length() ;
i++) {
263 if (stringname.substr(
i,1) ==
"_") {
264 stringoutput +=
"\\_";
266 stringoutput += stringname.substr(
i,1);
278 for (
unsigned int i=1;
i<stringname.length() ;
i++) {
279 if (stringname.substr(
i-1,1) ==
"m" && stringname.substr(
i,1) ==
"3") {
280 stringoutput +=
"$^3$";
282 stringoutput += stringname.substr(
i,1);
T getUntrackedParameter(std::string const &, T const &) const
std::multimap< G4LogicalVolume *, G4VPhysicalVolume *, std::less< G4LogicalVolume * > > mmlvpv
~PrintMaterialBudgetInfo() override
std::vector< std::string > elementNames
std::vector< double > elementWeightFraction
std::vector< double > elementTotalWeight
Container::value_type value_type
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)
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)
std::string stringLaTeXUnderscore(std::string stringname)
void update(const BeginOfJob *job) override
This routine will be called when the appropriate signal arrives.
void dumpLaTeXHeader(std::ostream &out=std::cout)
std::ofstream texOutputFile