CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
G4RegionReporter.cc
Go to the documentation of this file.
2 
3 #include "G4Region.hh"
4 #include "G4RegionStore.hh"
5 #include "G4LogicalVolume.hh"
6 #include "G4ProductionCuts.hh"
7 #include "G4SystemOfUnits.hh"
8 
9 #include <iostream>
10 #include <iomanip>
11 #include <fstream>
12 
14 {}
15 
17 {}
18 
20 {
21  std::ofstream fout(ss.c_str(), std::ios::out);
22  if(fout.fail()){
23  std::cout << "SimG4CoreApplication ReportRegions WARNING : "
24  << "error opening file <" << ss << ">" << std::endl;
25  return;
26  }
27  G4RegionStore* regStore = G4RegionStore::GetInstance();
28 
29  unsigned int numRegions= regStore->size();
30 
31  unsigned int i;
32 
33  fout << std::endl;
34  fout << "#---------------------------------------------------------------------";
35  fout << "------------------------------------" << std::endl;
36  fout << "## List of Regions, root logical volumes and cuts. " << std::endl;
37  fout << "## Number of regions = " << numRegions << std::endl;
38 
39  // Banner
40  fout << "# " << std::setw(24) << " Region, "
41  << std::setw(38) << " LogicalVolume, "
42  << " Cuts:Gamma, Electron, Positron, Proton, Units" << std::endl;
43  fout << "#---------------------------------------------------------------------";
44  fout << "------------------------------------" << std::endl;
45 
46  for( i=0; i<numRegions; ++i)
47  {
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
58  = region->GetRootLogicalVolumeIterator();
59  size_t numRootLV = region->GetNumberOfRootVolumes();
60 
61  for(size_t iLV=0; iLV < numRootLV; ++iLV, ++rootLVItr )
62  {
63  // Cover each root logical volume in this region
64 
65  //Set the couple to the proper logical volumes in that region
66  lv = *rootLVItr;
67 
68  // fout << " Region=" << region->GetName()
69  // << " Logical-Volume = " << lv->GetName();
70  char quote='"';
71  std::ostringstream regName, lvName;
72  regName << quote << region->GetName() << quote;
73  lvName << quote << lv->GetName() << quote;
74  fout << " " << std::setw(26) << regName.str() << " ,";
75  fout << " " << std::setw(36) << lvName.str() << " ,";
76 
77  unsigned int ic;
78  for( ic= 0; ic< pmax; ++ic)
79  {
80  G4double cutLength = prodCuts->GetProductionCut(ic);
81  fout << " " << std::setw(5) << cutLength / lengthUnit;
82  if (ic < pmax-1) {
83  fout << " , ";
84  } else {
85  fout << " , " << lengthUnitName;
86  }
87  }
88  fout << std::endl;
89  }
90  }
91  fout << "#---------------------------------------------------------------------";
92  fout << "------------------------------------" << std::endl;
93  fout << std::endl;
94  fout.close();
95 }
int i
Definition: DBlmapReader.cc:9
tuple out
Definition: dbtoconf.py:99
void ReportRegions(const std::string &ss)
tuple cout
Definition: gather_cfg.py:121