CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
MuonG4Numbering Class Reference

#include <MuonG4Numbering.h>

Public Member Functions

 MuonG4Numbering (const MuonGeometryConstants &muonConstants, const MuonOffsetMap *offMap, bool dd4hep)
 
MuonBaseNumber PhysicalVolumeToBaseNumber (const G4Step *aStep)
 
 ~MuonG4Numbering ()
 

Private Member Functions

const bool copyNoRelevant (const int)
 
const int getCopyNoBaseNo (const int)
 
const int getCopyNoLevel (const int)
 
const int getCopyNoSuperNo (const int)
 

Private Attributes

const bool dd4hep_
 
const MuonOffsetMapoffMap_
 
int theBasePart
 
int theLevelPart
 
int theStartCopyNo
 
int theSuperPart
 

Detailed Description

class to handle the conversion to MuonBaseNumber from tree of G4 copy numbers extracted from G4VPhysicalVolume; needs DDD compatible format of G4 copy numbers; the format itself may in a later version also be defined by DDD constants

in the xml muon constant section one has to define level, super and base constants (eg. 1000,100,1) and the start value of the copy numbers (0 or 1)

Author
Arno Straessner, CERN arno..nosp@m.stra.nosp@m.essne.nosp@m.r@ce.nosp@m.rn.ch

Modification:

Definition at line 26 of file MuonG4Numbering.h.

Constructor & Destructor Documentation

◆ MuonG4Numbering()

MuonG4Numbering::MuonG4Numbering ( const MuonGeometryConstants muonConstants,
const MuonOffsetMap offMap,
bool  dd4hep 
)

Definition at line 16 of file MuonG4Numbering.cc.

References dd4hep_, MuonGeometryConstants::getValue(), offMap_, theBasePart, theLevelPart, theStartCopyNo, and theSuperPart.

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  edm::LogVerbatim("MuonSim") << "MuonGeometryNumbering finds unusual start value for copy numbers:"
36  << theStartCopyNo;
37  }
38 
39 #ifdef EDM_ML_DEBUG
40  edm::LogVerbatim("MuonSim") << "StartCopyNo = " << theStartCopyNo;
41  edm::LogVerbatim("MuonSim") << "MuonG4Numbering configured with Level = " << theLevelPart
42  << " Super = " << theSuperPart << " Base = " << theBasePart
43  << " StartCopyNo = " << theStartCopyNo;
44  edm::LogVerbatim("MuonSim") << "dd4hep flag set to " << dd4hep_ << " and offsetmap at " << offMap_;
45 #endif
46 }
int getValue(const std::string &name) const
Log< level::Info, true > LogVerbatim
const MuonOffsetMap * offMap_
const bool dd4hep_

◆ ~MuonG4Numbering()

MuonG4Numbering::~MuonG4Numbering ( )
inline

Definition at line 29 of file MuonG4Numbering.h.

29 {}

Member Function Documentation

◆ copyNoRelevant()

const bool MuonG4Numbering::copyNoRelevant ( const int  copyno)
private

Definition at line 91 of file MuonG4Numbering.cc.

References theLevelPart.

Referenced by PhysicalVolumeToBaseNumber().

91 { return (copyno / theLevelPart) > 0; }

◆ getCopyNoBaseNo()

const int MuonG4Numbering::getCopyNoBaseNo ( const int  copyno)
private

Definition at line 89 of file MuonG4Numbering.cc.

References theSuperPart.

Referenced by PhysicalVolumeToBaseNumber().

89 { return copyno % theSuperPart; }

◆ getCopyNoLevel()

const int MuonG4Numbering::getCopyNoLevel ( const int  copyno)
private

Definition at line 85 of file MuonG4Numbering.cc.

References theLevelPart.

Referenced by PhysicalVolumeToBaseNumber().

85 { return copyno / theLevelPart; }

◆ getCopyNoSuperNo()

const int MuonG4Numbering::getCopyNoSuperNo ( const int  copyno)
private

Definition at line 87 of file MuonG4Numbering.cc.

References theLevelPart, and theSuperPart.

Referenced by PhysicalVolumeToBaseNumber().

87 { return (copyno % theLevelPart) / theSuperPart; }

◆ PhysicalVolumeToBaseNumber()

MuonBaseNumber MuonG4Numbering::PhysicalVolumeToBaseNumber ( const G4Step *  aStep)

Definition at line 48 of file MuonG4Numbering.cc.

References copyNoRelevant(), dd4hep_, getCopyNoBaseNo(), getCopyNoLevel(), getCopyNoSuperNo(), cuy::ii, dqmdumpme::last, MuonOffsetMap::muonMap_, mergeVDriftHistosByStation::name, DD4hep2DDDName::noNameSpace(), EgammaValidation_cff::num, offMap_, edm::second(), AlCaHLTBitMon_QueryRunRegistry::string, theLevelPart, theStartCopyNo, and theSuperPart.

Referenced by MuonSensitiveDetector::setDetUnitId(), and MuonRPCFrameRotation::transformPoint().

48  {
50  const G4VTouchable* touch = aStep->GetPreStepPoint()->GetTouchable();
51 
52  for (int ii = 0; ii < touch->GetHistoryDepth(); ii++) {
53  G4VPhysicalVolume* vol = touch->GetVolume(ii);
54  int copyno = vol->GetCopyNo();
55  int extra(0);
56  if (dd4hep_ && (offMap_ != nullptr)) {
57  std::string namx = DD4hep2DDDName::noNameSpace(static_cast<std::string>(vol->GetName()));
58  std::size_t last = namx.rfind('_');
59  std::string name = ((last == std::string::npos) ? namx : (namx.substr(0, last)));
60  auto itr = offMap_->muonMap_.find(name);
61  if (itr != offMap_->muonMap_.end())
62  extra = (itr->second).first + (itr->second).second;
63 #ifdef EDM_ML_DEBUG
64  edm::LogVerbatim("MuonSim") << "MuonG4Numbering: " << namx << ":" << name << " iterator "
65  << (itr != offMap_->muonMap_.end()) << " Extra " << extra;
66 #endif
67  }
68  copyno += extra;
69 #ifdef EDM_ML_DEBUG
70  edm::LogVerbatim("MuonSim") << "MuonG4Numbering: " << vol->GetName() << " " << copyno << " Split "
71  << copyNoRelevant(copyno) << ":" << theLevelPart << ":" << theSuperPart << " ";
72 #endif
73  if (copyNoRelevant(copyno)) {
74  num.addBase(getCopyNoLevel(copyno), getCopyNoSuperNo(copyno), getCopyNoBaseNo(copyno) - theStartCopyNo);
75 #ifdef EDM_ML_DEBUG
76  edm::LogVerbatim("MuonSim") << " NoLevel " << getCopyNoLevel(copyno) << " Super " << getCopyNoSuperNo(copyno)
77  << " Base " << getCopyNoBaseNo(copyno) << " Start " << theStartCopyNo;
78 #endif
79  }
80  }
81 
82  return num;
83 }
Log< level::Info, true > LogVerbatim
const int getCopyNoLevel(const int)
const MuonOffsetMap * offMap_
const int getCopyNoBaseNo(const int)
U second(std::pair< T, U > const &p)
const bool dd4hep_
ii
Definition: cuy.py:589
const bool copyNoRelevant(const int)
std::string noNameSpace(const std::string &name)
const int getCopyNoSuperNo(const int)
std::unordered_map< std::string, std::pair< int, int > > muonMap_
Definition: MuonOffsetMap.h:14

Member Data Documentation

◆ dd4hep_

const bool MuonG4Numbering::dd4hep_
private

Definition at line 40 of file MuonG4Numbering.h.

Referenced by MuonG4Numbering(), and PhysicalVolumeToBaseNumber().

◆ offMap_

const MuonOffsetMap* MuonG4Numbering::offMap_
private

Definition at line 39 of file MuonG4Numbering.h.

Referenced by MuonG4Numbering(), and PhysicalVolumeToBaseNumber().

◆ theBasePart

int MuonG4Numbering::theBasePart
private

Definition at line 43 of file MuonG4Numbering.h.

Referenced by MuonG4Numbering().

◆ theLevelPart

int MuonG4Numbering::theLevelPart
private

◆ theStartCopyNo

int MuonG4Numbering::theStartCopyNo
private

Definition at line 44 of file MuonG4Numbering.h.

Referenced by MuonG4Numbering(), and PhysicalVolumeToBaseNumber().

◆ theSuperPart

int MuonG4Numbering::theSuperPart
private