CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
PrintSensitive.cc
Go to the documentation of this file.
2 
5 
6 #include "G4Run.hh"
7 #include "G4VPhysicalVolume.hh"
8 #include "G4LogicalVolume.hh"
9 #include "G4TransportationManager.hh"
10 
11 #include <set>
12 #include <map>
13 
15  name = p.getUntrackedParameter<std::string>("Name","*");
16  nchar = name.find("*");
17  name.assign(name,0,nchar);
18  std::cout << "PrintSensitive:: Print position of all Sensitive Touchables: "
19  << " for names (0-" << nchar << ") = " << name << "\n";
20 }
21 
23 
25 
26  G4VPhysicalVolume * theTopPV = getTopPV();
27  dumpTouch(theTopPV, 0, false, std::cout);
28 }
29 
30 void PrintSensitive::dumpTouch(G4VPhysicalVolume * pv, unsigned int leafDepth,
31  bool printIt, std::ostream & out) {
32 
33  if (leafDepth == 0) fHistory.SetFirstEntry(pv);
34  else fHistory.NewLevel(pv, kNormal, pv->GetCopyNo());
35 
36  G4ThreeVector globalpoint = fHistory.GetTopTransform().Inverse().
37  TransformPoint(G4ThreeVector(0,0,0));
38  G4LogicalVolume * lv = pv->GetLogicalVolume();
39 
40  std::string mother = "World";
41  if (pv->GetMotherLogical()) mother = pv->GetMotherLogical()->GetName();
42  std::string lvname = lv->GetName();
43  lvname.assign(lvname,0,nchar);
44  if (lvname == name) printIt = true;
45 
46  if (lv->GetSensitiveDetector() && printIt) {
47  out << leafDepth << " ### VOLUME = " << lv->GetName()
48  << " Copy No " << pv->GetCopyNo() << " in " << mother
49  << " global position of centre " << globalpoint << " (r="
50  << globalpoint.perp() << ", phi=" << globalpoint.phi()/deg
51  << ")\n";
52  }
53 
54  int NoDaughters = lv->GetNoDaughters();
55  while ((NoDaughters--)>0) {
56  G4VPhysicalVolume * pvD = lv->GetDaughter(NoDaughters);
57  if (!pvD->IsReplicated()) dumpTouch(pvD, leafDepth+1, printIt, out);
58  }
59 
60  if (leafDepth > 0) fHistory.BackLevel();
61 }
62 
63 G4VPhysicalVolume * PrintSensitive::getTopPV() {
64  return G4TransportationManager::GetTransportationManager()
65  ->GetNavigatorForTracking()->GetWorldVolume();
66 }
T getUntrackedParameter(std::string const &, T const &) const
std::string name
G4NavigationHistory fHistory
PrintSensitive(edm::ParameterSet const &p)
G4VPhysicalVolume * getTopPV()
tuple out
Definition: dbtoconf.py:99
void dumpTouch(G4VPhysicalVolume *pv, unsigned int leafDepth, bool printIt, std::ostream &out=std::cout)
void update(const BeginOfRun *run)
This routine will be called when the appropriate signal arrives.
tuple cout
Definition: gather_cfg.py:41