test
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 
14 using namespace CLHEP;
15 
17  name = p.getUntrackedParameter<std::string>("Name","*");
18  nchar = name.find("*");
19  name.assign(name,0,nchar);
20  std::cout << "PrintSensitive:: Print position of all Sensitive Touchables: "
21  << " for names (0-" << nchar << ") = " << name << "\n";
22 }
23 
25 
27 
28  G4VPhysicalVolume * theTopPV = getTopPV();
29  dumpTouch(theTopPV, 0, false, std::cout);
30 }
31 
32 void PrintSensitive::dumpTouch(G4VPhysicalVolume * pv, unsigned int leafDepth,
33  bool printIt, std::ostream & out) {
34 
35  if (leafDepth == 0) fHistory.SetFirstEntry(pv);
36  else fHistory.NewLevel(pv, kNormal, pv->GetCopyNo());
37 
38  G4ThreeVector globalpoint = fHistory.GetTopTransform().Inverse().
39  TransformPoint(G4ThreeVector(0,0,0));
40  G4LogicalVolume * lv = pv->GetLogicalVolume();
41 
42  std::string mother = "World";
43  if (pv->GetMotherLogical()) mother = pv->GetMotherLogical()->GetName();
44  std::string lvname = lv->GetName();
45  lvname.assign(lvname,0,nchar);
46  if (lvname == name) printIt = true;
47 
48  if (lv->GetSensitiveDetector() && printIt) {
49  out << leafDepth << " ### VOLUME = " << lv->GetName()
50  << " Copy No " << pv->GetCopyNo() << " in " << mother
51  << " global position of centre " << globalpoint << " (r="
52  << globalpoint.perp() << ", phi=" << globalpoint.phi()/deg
53  << ")\n";
54  }
55 
56  int NoDaughters = lv->GetNoDaughters();
57  while ((NoDaughters--)>0) {
58  G4VPhysicalVolume * pvD = lv->GetDaughter(NoDaughters);
59  if (!pvD->IsReplicated()) dumpTouch(pvD, leafDepth+1, printIt, out);
60  }
61 
62  if (leafDepth > 0) fHistory.BackLevel();
63 }
64 
65 G4VPhysicalVolume * PrintSensitive::getTopPV() {
66  return G4TransportationManager::GetTransportationManager()
67  ->GetNavigatorForTracking()->GetWorldVolume();
68 }
T getUntrackedParameter(std::string const &, T const &) const
PrintSensitive(edm::ParameterSet const &p)
G4VPhysicalVolume * getTopPV()
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:145