CMS 3D CMS Logo

MuonG4Numbering.cc
Go to the documentation of this file.
5 
6 #include "G4VPhysicalVolume.hh"
7 #include "G4VTouchable.hh"
8 #include "G4Step.hh"
9 
10 #include <iostream>
11 
12 //#define LOCAL_DEBUG
13 
15 
17  theLevelPart = muonConstants.getValue("level");
18  theSuperPart = muonConstants.getValue("super");
19  theBasePart = muonConstants.getValue("base");
20  theStartCopyNo = muonConstants.getValue("xml_starts_with_copyno");
21 
22  // some consistency checks
23 
24  if (theBasePart != 1) {
25  std::cout << "MuonDDDNumbering finds unusual base constant:" << theBasePart << std::endl;
26  }
27  if (theSuperPart < 100) {
28  std::cout << "MuonDDDNumbering finds unusual super constant:" << theSuperPart << std::endl;
29  }
30  if (theLevelPart < 10 * theSuperPart) {
31  std::cout << "MuonDDDNumbering finds unusual level constant:" << theLevelPart << std::endl;
32  }
33  if ((theStartCopyNo != 0) && (theStartCopyNo != 1)) {
34  std::cout << "MuonDDDNumbering finds unusual start value for copy numbers:" << theStartCopyNo << std::endl;
35  }
36 
37 #ifdef LOCAL_DEBUG
38  std::cout << "StartCopyNo = " << theStartCopyNo << std::endl;
39  std::cout << "MuonG4Numbering configured with" << std::endl;
40  std::cout << "Level = " << theLevelPart << " ";
41  std::cout << "Super = " << theSuperPart << " ";
42  std::cout << "Base = " << theBasePart << " ";
43  std::cout << "StartCopyNo = " << theStartCopyNo << std::endl;
44 #endif
45 }
46 
49  const G4VTouchable* touch = aStep->GetPreStepPoint()->GetTouchable();
50 
51  for (int ii = 0; ii < touch->GetHistoryDepth(); ii++) {
52  G4VPhysicalVolume* vol = touch->GetVolume(ii);
53  int copyno = vol->GetCopyNo();
54 #ifdef LOCAL_DEBUG
55  std::cout << "MuonG4Numbering: " << vol->GetName() << " " << copyno << std::endl
56  << "Split " << copyNoRelevant(copyno) << ":" << theLevelPart << ":" << theSuperPart << " ";
57 #endif
58  if (copyNoRelevant(copyno)) {
59  num.addBase(getCopyNoLevel(copyno), getCopyNoSuperNo(copyno), getCopyNoBaseNo(copyno) - theStartCopyNo);
60 #ifdef LOCAL_DEBUG
61  std::cout << " NoLevel " << getCopyNoLevel(copyno) << " Super " << getCopyNoSuperNo(copyno) << " Base "
62  << getCopyNoBaseNo(copyno) << " Start " << theStartCopyNo;
63 #endif
64  }
65 #ifdef LOCAL_DEBUG
66  std::cout << std::endl;
67 #endif
68  }
69 
70  return num;
71 }
72 
73 const int MuonG4Numbering::getCopyNoLevel(const int copyno) { return copyno / theLevelPart; }
74 
75 const int MuonG4Numbering::getCopyNoSuperNo(const int copyno) { return (copyno % theLevelPart) / theSuperPart; }
76 
77 const int MuonG4Numbering::getCopyNoBaseNo(const int copyno) { return copyno % theSuperPart; }
78 
79 const bool MuonG4Numbering::copyNoRelevant(const int copyno) { return (copyno / theLevelPart) > 0; }
const int getCopyNoLevel(const int)
void addBase(const int level, const int super, const int base)
const int getCopyNoBaseNo(const int)
Compact representation of the geometrical detector hierarchy.
Definition: DDCompactView.h:80
int getValue(const std::string &name) const
MuonG4Numbering(const DDCompactView &cpv)
ii
Definition: cuy.py:590
MuonBaseNumber PhysicalVolumeToBaseNumber(const G4Step *aStep)
const bool copyNoRelevant(const int)
const int getCopyNoSuperNo(const int)