CMS 3D CMS Logo

MuonG4Numbering.cc
Go to the documentation of this file.
6 
7 #include "DD4hep/Filter.h"
8 #include "G4VPhysicalVolume.hh"
9 #include "G4VTouchable.hh"
10 #include "G4Step.hh"
11 
12 #include <iostream>
13 
14 //#define EDM_ML_DEBUG
15 
17  : offMap_(offMap), dd4hep_(dd4hep) {
18  theLevelPart = muonConstants.getValue("level");
19  theSuperPart = muonConstants.getValue("super");
20  theBasePart = muonConstants.getValue("base");
21  theStartCopyNo = muonConstants.getValue("xml_starts_with_copyno");
22 
23  // some consistency checks
24 
25  if (theBasePart != 1) {
26  edm::LogVerbatim("MuonSim") << "MuonGeometryNumbering finds unusual base constant:" << theBasePart;
27  }
28  if (theSuperPart < 100) {
29  edm::LogVerbatim("MuonSim") << "MuonGeometryNumbering finds unusual super constant:" << theSuperPart;
30  }
31  if (theLevelPart < 10 * theSuperPart) {
32  edm::LogVerbatim("MuonSim") << "MuonGeometryNumbering finds unusual level constant:" << theLevelPart;
33  }
34  if ((theStartCopyNo != 0) && (theStartCopyNo != 1)) {
35  std::cout << "MuonGeometryNumbering finds unusual start value for copy numbers:" << theStartCopyNo << std::endl;
36  }
37 
38 #ifdef EDM_ML_DEBUG
39  edm::LogVerbatim("MuonSim") << "StartCopyNo = " << theStartCopyNo;
40  edm::LogVerbatim("MuonSim") << "MuonG4Numbering configured with"
41  << "Level = " << theLevelPart << " Super = " << theSuperPart << " Base = " << theBasePart
42  << " StartCopyNo = " << theStartCopyNo;
43  edm::LogVerbatim("MuonSim") << "dd4hep flag set to " << dd4hep_ << " and offsetmap at " << offMap_;
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  int extra(0);
55  if (dd4hep_ && (offMap_ != nullptr)) {
56  std::string namx = static_cast<std::string>(dd4hep::dd::noNamespace(vol->GetName()));
57  std::size_t last = namx.rfind('_');
58  std::string name = ((last == std::string::npos) ? namx : (namx.substr(0, last)));
59  auto itr = offMap_->muonMap_.find(name);
60  if (itr != offMap_->muonMap_.end())
61  extra = (itr->second).first + (itr->second).second;
62 #ifdef EDM_ML_DEBUG
63  edm::LogVerbatim("MuonSim") << "MuonG4Numbering: " << namx << ":" << name << " iterator "
64  << (itr != offMap_->muonMap_.end()) << " Extra " << extra;
65 #endif
66  }
67  copyno += extra;
68 #ifdef EDM_ML_DEBUG
69  edm::LogVerbatim("MuonSim") << "MuonG4Numbering: " << vol->GetName() << " " << copyno << " Split "
70  << copyNoRelevant(copyno) << ":" << theLevelPart << ":" << theSuperPart << " ";
71 #endif
72  if (copyNoRelevant(copyno)) {
73  num.addBase(getCopyNoLevel(copyno), getCopyNoSuperNo(copyno), getCopyNoBaseNo(copyno) - theStartCopyNo);
74 #ifdef EDM_ML_DEBUG
75  edm::LogVerbatim("MuonSim") << " NoLevel " << getCopyNoLevel(copyno) << " Super " << getCopyNoSuperNo(copyno)
76  << " Base " << getCopyNoBaseNo(copyno) << " Start " << theStartCopyNo;
77 #endif
78  }
79  }
80 
81  return num;
82 }
83 
84 const int MuonG4Numbering::getCopyNoLevel(const int copyno) { return copyno / theLevelPart; }
85 
86 const int MuonG4Numbering::getCopyNoSuperNo(const int copyno) { return (copyno % theLevelPart) / theSuperPart; }
87 
88 const int MuonG4Numbering::getCopyNoBaseNo(const int copyno) { return copyno % theSuperPart; }
89 
90 const bool MuonG4Numbering::copyNoRelevant(const int copyno) { return (copyno / theLevelPart) > 0; }
MuonGeometryConstants
Definition: MuonGeometryConstants.h:20
MuonOffsetMap.h
MuonG4Numbering.h
MessageLogger.h
MuonG4Numbering::theSuperPart
int theSuperPart
Definition: MuonG4Numbering.h:42
MuonG4Numbering::dd4hep_
const bool dd4hep_
Definition: MuonG4Numbering.h:40
MuonG4Numbering::getCopyNoBaseNo
const int getCopyNoBaseNo(const int)
Definition: MuonG4Numbering.cc:88
MuonGeometryConstants.h
gather_cfg.cout
cout
Definition: gather_cfg.py:144
MuonG4Numbering::getCopyNoLevel
const int getCopyNoLevel(const int)
Definition: MuonG4Numbering.cc:84
edm::second
U second(std::pair< T, U > const &p)
Definition: ParameterSet.cc:222
MuonG4Numbering::theStartCopyNo
int theStartCopyNo
Definition: MuonG4Numbering.h:44
MuonOffsetMap
Definition: MuonOffsetMap.h:9
dqmdumpme.last
last
Definition: dqmdumpme.py:56
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
MuonG4Numbering::MuonG4Numbering
MuonG4Numbering(const MuonGeometryConstants &muonConstants, const MuonOffsetMap *offMap, bool dd4hep)
Definition: MuonG4Numbering.cc:16
MuonG4Numbering::theBasePart
int theBasePart
Definition: MuonG4Numbering.h:43
MuonBaseNumber.h
MuonG4Numbering::theLevelPart
int theLevelPart
Definition: MuonG4Numbering.h:41
MuonGeometryConstants::getValue
int getValue(const std::string &name) const
Definition: MuonGeometryConstants.cc:8
itr
std::vector< std::pair< float, float > >::iterator itr
Definition: HGCDigitizer.cc:29
MuonG4Numbering::PhysicalVolumeToBaseNumber
MuonBaseNumber PhysicalVolumeToBaseNumber(const G4Step *aStep)
Definition: MuonG4Numbering.cc:47
EgammaValidation_cff.num
num
Definition: EgammaValidation_cff.py:34
MuonBaseNumber
Definition: MuonBaseNumber.h:21
edm::LogVerbatim
Log< level::Info, true > LogVerbatim
Definition: MessageLogger.h:128
dd4hep
Definition: DDPlugins.h:8
MuonG4Numbering::copyNoRelevant
const bool copyNoRelevant(const int)
Definition: MuonG4Numbering.cc:90
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
MuonG4Numbering::offMap_
const MuonOffsetMap * offMap_
Definition: MuonG4Numbering.h:39
MuonG4Numbering::getCopyNoSuperNo
const int getCopyNoSuperNo(const int)
Definition: MuonG4Numbering.cc:86
MuonOffsetMap::muonMap_
std::unordered_map< std::string, std::pair< int, int > > muonMap_
Definition: MuonOffsetMap.h:14
cuy.ii
ii
Definition: cuy.py:590