CMS 3D CMS Logo

CMSG4RegionReporter.cc
Go to the documentation of this file.
3 
4 #include "G4Region.hh"
5 #include "G4RegionStore.hh"
6 #include "G4LogicalVolume.hh"
7 #include "G4ProductionCuts.hh"
8 #include "G4SystemOfUnits.hh"
9 
10 #include <iostream>
11 #include <iomanip>
12 #include <fstream>
13 
15 
17 
19  std::ofstream fout(ss.c_str(), std::ios::out);
20  if (fout.fail()) {
21  edm::LogWarning("SimG4CoreGeometry") << "CMSG4RegionReporter: file <" << ss
22  << "> is not opened - no report provided";
23  return;
24  }
25  G4RegionStore* regStore = G4RegionStore::GetInstance();
26 
27  unsigned int numRegions = regStore->size();
28 
29  unsigned int i;
30 
31  fout << "\n";
32  fout << "#---------------------------------------------------------------------";
33  fout << "------------------------------------"
34  << "\n";
35  fout << "## List of Regions, root logical volumes and cuts. "
36  << "\n";
37  fout << "## Number of regions = " << numRegions << "\n";
38 
39  // Banner
40  fout << "# " << std::setw(24) << " Region, " << std::setw(38) << " LogicalVolume, "
41  << " Cuts:Gamma, Electron, Positron, Proton, Units"
42  << "\n";
43  fout << "#---------------------------------------------------------------------";
44  fout << "------------------------------------"
45  << "\n";
46 
47  for (i = 0; i < numRegions; ++i) {
48  G4Region* region = regStore->at(i);
49  G4ProductionCuts* prodCuts = region->GetProductionCuts();
50 
51  G4LogicalVolume* lv;
52 
53  G4double lengthUnit = CLHEP::mm;
54  G4String lengthUnitName = "mm";
55  unsigned int pmax = 4; // g, e-, e+, proton
56 
57  std::vector<G4LogicalVolume*>::iterator rootLVItr = region->GetRootLogicalVolumeIterator();
58  size_t numRootLV = region->GetNumberOfRootVolumes();
59 
60  for (size_t iLV = 0; iLV < numRootLV; ++iLV, ++rootLVItr) {
61  // Cover each root logical volume in this region
62 
63  //Set the couple to the proper logical volumes in that region
64  lv = *rootLVItr;
65 
66  // fout << " Region=" << region->GetName()
67  // << " Logical-Volume = " << lv->GetName();
68  char quote = '"';
69  std::ostringstream regName, lvName;
70  regName << quote << region->GetName() << quote;
71  lvName << quote << lv->GetName() << quote;
72  fout << " " << std::setw(26) << regName.str() << " ,";
73  fout << " " << std::setw(36) << lvName.str() << " ,";
74 
75  unsigned int ic;
76  for (ic = 0; ic < pmax; ++ic) {
77  G4double cutLength = prodCuts->GetProductionCut(ic);
78  fout << " " << std::setw(5) << cutLength / lengthUnit;
79  if (ic < pmax - 1) {
80  fout << " , ";
81  } else {
82  fout << " , " << lengthUnitName;
83  }
84  }
85  fout << "\n";
86  }
87  }
88  fout << "#---------------------------------------------------------------------";
89  fout << "------------------------------------"
90  << "\n";
91  fout << "\n";
92  fout.close();
93 }
void ReportRegions(const std::string &ss)
Log< level::Warning, false > LogWarning