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  MuonDDDConstants muonConstants(cpv);
16  theLevelPart=muonConstants.getValue("level");
17  theSuperPart=muonConstants.getValue("super");
18  theBasePart=muonConstants.getValue("base");
19  theStartCopyNo=muonConstants.getValue("xml_starts_with_copyno");
20 
21  // some consistency checks
22 
23  if (theBasePart!=1) {
24  std::cout << "MuonDDDNumbering finds unusual base constant:"
25  <<theBasePart<<std::endl;
26  }
27  if (theSuperPart<100) {
28  std::cout << "MuonDDDNumbering finds unusual super constant:"
29  <<theSuperPart<<std::endl;
30  }
31  if (theLevelPart<10*theSuperPart) {
32  std::cout << "MuonDDDNumbering finds unusual level constant:"
33  <<theLevelPart<<std::endl;
34  }
35  if ((theStartCopyNo!=0)&&(theStartCopyNo!=1)) {
36  std::cout << "MuonDDDNumbering finds unusual start value for copy numbers:"
37  <<theStartCopyNo<<std::endl;
38  }
39 
40 #ifdef LOCAL_DEBUG
41  std::cout << "StartCopyNo = "<<theStartCopyNo<<std::endl;
42  std::cout << "MuonG4Numbering configured with"<<std::endl;
43  std::cout << "Level = "<<theLevelPart<<" ";
44  std::cout << "Super = "<<theSuperPart<<" ";
45  std::cout << "Base = "<<theBasePart<<" ";
46  std::cout << "StartCopyNo = "<<theStartCopyNo<<std::endl;
47 #endif
48 }
49 
51 {
52 
54  const G4VTouchable* touch = aStep->GetPreStepPoint()->GetTouchable();
55 
56  for( int ii = 0; ii < touch->GetHistoryDepth(); ii++ ){
57  G4VPhysicalVolume* vol = touch->GetVolume(ii);
58  int copyno=vol->GetCopyNo();
59 #ifdef LOCAL_DEBUG
60  std::cout << "MuonG4Numbering: " << vol->GetName() << " " << copyno
61  << std::endl << "Split " << copyNoRelevant(copyno) << ":"
62  << theLevelPart << ":" << theSuperPart << " ";
63 #endif
64  if (copyNoRelevant(copyno)) {
65  num.addBase(getCopyNoLevel(copyno),
66  getCopyNoSuperNo(copyno),
68 #ifdef LOCAL_DEBUG
69  std::cout << " NoLevel " << getCopyNoLevel(copyno) << " Super "
70  << getCopyNoSuperNo(copyno) << " Base "
71  << getCopyNoBaseNo(copyno) << " Start " << theStartCopyNo;
72 #endif
73  }
74 #ifdef LOCAL_DEBUG
75  std::cout << std::endl;
76 #endif
77  }
78 
79  return num;
80 }
81 
82 const int MuonG4Numbering::getCopyNoLevel(const int copyno){
83  return copyno/theLevelPart;
84 }
85 
86 const int MuonG4Numbering::getCopyNoSuperNo(const int copyno){
87  return (copyno%theLevelPart)/theSuperPart;
88 }
89 
90 const int MuonG4Numbering::getCopyNoBaseNo(const int copyno){
91  return copyno%theSuperPart;
92 }
93 
94 const bool MuonG4Numbering::copyNoRelevant(const int copyno){
95  return (copyno/theLevelPart)>0;
96 }
97 
const int getCopyNoLevel(const int)
void addBase(const int level, const int super, const int base)
const int getCopyNoBaseNo(const int)
type of data representation of DDCompactView
Definition: DDCompactView.h:90
int getValue(const std::string &name) const
MuonG4Numbering(const DDCompactView &cpv)
ii
Definition: cuy.py:588
MuonBaseNumber PhysicalVolumeToBaseNumber(const G4Step *aStep)
const bool copyNoRelevant(const int)
const int getCopyNoSuperNo(const int)