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;
55 G4Random::setTheEngine(
new CLHEP::RanecuEngine);
57 theTopPV = G4TransportationManager::GetTransportationManager()->GetNavigatorForTracking()->GetWorldVolume();
60 G4LogicalVolume* lv =
theTopPV->GetLogicalVolume();
61 unsigned int leafDepth = 0;
64 for (
unsigned int iElement = 0; iElement < G4Element::GetNumberOfElements();
116 <<
"\t" << std::endl;
120 out <<
"\\begin{table}[h!]" << std::endl
121 <<
" \\caption{\\textsf {" <<
name <<
"} volume list.}" << std::endl
122 <<
" \\label{tab: " <<
name <<
"}" << std::endl
123 <<
" \\begin{center}" << std::endl
124 <<
" \\begin{tabular}{ccccccc}" << std::endl
125 <<
" \\hline" << std::endl;
139 <<
"\t \\\\ " << std::endl;
153 <<
"\t \\\\ " << std::endl
154 <<
" \\hline\\hline" << std::endl;
158 out <<
" \\hline" << std::endl
159 <<
" \\end{tabular}" << std::endl
160 <<
" \\end{center}" << std::endl
161 <<
"\\end{table}" << std::endl;
165 G4VPhysicalVolume*
pv, G4LogicalVolume* lv,
unsigned int leafDepth, std::ostream& weightOut, std::ostream& texOut) {
169 printInfo(pv, lv, leafDepth, weightOut, texOut);
173 lvname.assign(lvname, 0,
nchar);
174 if (lvname ==
name) {
177 printInfo(pv, lv, leafDepth, weightOut, texOut);
178 texOut <<
" \\hline" << std::endl;
183 std::set<G4LogicalVolume*> lvDaughters;
184 int NoDaughters = lv->GetNoDaughters();
185 while ((NoDaughters--) > 0) {
186 G4VPhysicalVolume* pvD = lv->GetDaughter(NoDaughters);
188 lvDaughters.insert(pvD->GetLogicalVolume());
191 std::set<G4LogicalVolume*>::const_iterator scite;
192 mmlvpv::const_iterator mmcite;
195 for (scite = lvDaughters.begin(); scite != lvDaughters.end(); scite++) {
196 std::pair<mmlvpv::iterator, mmlvpv::iterator> mmER = lvpvDaughters.equal_range(*scite);
198 for (mmcite = mmER.first; mmcite != mmER.second; mmcite++)
204 G4VPhysicalVolume*
pv, G4LogicalVolume* lv,
unsigned int leafDepth, std::ostream& weightOut, std::ostream& texOut) {
205 double density = lv->GetMaterial()->GetDensity();
206 double weight = lv->GetMass(
false,
false);
209 if (volumeName.size() < 8)
210 volumeName.append(
"\t");
213 if (solidName.size() < 8)
214 solidName.append(
"\t");
216 std::string materialName = lv->GetMaterial()->GetName();
217 if (materialName.size() < 8)
218 materialName.append(
"\t");
221 weightOut << leafDepth <<
"\t" << volumeName <<
"\t" << pv->GetCopyNo() <<
"\t" << solidName <<
"\t" << materialName
222 <<
"\t" << G4BestUnit(density,
"Volumic Mass") <<
"\t" << G4BestUnit(weight,
"Mass") <<
"\t" << std::endl;
224 texOut <<
"\t" << leafDepth <<
"\t & " <<
stringLaTeXUnderscore(volumeName) <<
"\t & " << pv->GetCopyNo() <<
"\t & " 229 for (
unsigned int iElement = 0; iElement < (
unsigned int)lv->GetMaterial()->GetNumberOfElements(); iElement++) {
231 if (materialName.find(
"Air")) {
232 std::string elementName = lv->GetMaterial()->GetElement(iElement)->GetName();
233 double elementMassFraction = lv->GetMaterial()->GetFractionVector()[iElement];
234 double elementWeight = weight * elementMassFraction;
235 unsigned int elementIndex = (
unsigned int)lv->GetMaterial()->GetElement(iElement)->GetIndex();
245 double totalFraction = 0.0;
255 elementOut <<
"Element" 262 <<
"\t" << std::endl;
268 elementOut <<
elementNames[iElement] <<
"\t" << iElement <<
"\t" 273 elementOut <<
"\n\t\tTotal Weight without Air " << G4BestUnit(totalWeight,
"Mass") <<
"\tTotal Fraction " 274 << totalFraction << std::endl;
281 for (
unsigned int i = 0;
i < stringname.length();
i++) {
282 if (stringname.substr(
i, 1) ==
"_") {
283 stringoutput +=
"\\_";
285 stringoutput += stringname.substr(
i, 1);
294 std::string stringoutput = stringname.substr(0, 1);
296 for (
unsigned int i = 1;
i < stringname.length();
i++) {
297 if (stringname.substr(
i - 1, 1) ==
"m" && stringname.substr(
i, 1) ==
"3") {
298 stringoutput +=
"$^3$";
300 stringoutput += stringname.substr(
i, 1);
std::multimap< G4LogicalVolume *, G4VPhysicalVolume *, std::less< G4LogicalVolume * > > mmlvpv
T getUntrackedParameter(std::string const &, T const &) const
~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