CMS 3D CMS Logo

EcalDumpGeometry.cc
Go to the documentation of this file.
7 
8 #include "DD4hep/Filter.h"
9 
10 #include <iostream>
11 
12 //#define EDM_ML_DEBUG
13 
14 EcalDumpGeometry::EcalDumpGeometry(const std::vector<std::string_view>& names,
15  const std::string& name1,
16  const std::string& name2,
17  int type)
18  : name1_(name1), name2_(name2), type_(type) {
19  std::stringstream ss;
20  for (const auto& lvname : names)
21  ss << " " << lvname;
22  edm::LogVerbatim("EcalGeom") << " Type: " << type << " Depth Names " << name1_ << ":" << name2_ << " with "
23  << names.size() << " LVs: " << ss.str();
24  for (const auto& name : names) {
25  std::string namex = (static_cast<std::string>(dd4hep::dd::noNamespace(name))).substr(0, 4);
26  if (std::find(names_.begin(), names_.end(), namex) == names_.end())
27  names_.emplace_back(namex);
28  }
29  edm::LogVerbatim("EcalGeom") << "EcalDumpGeometry:: dump geometry information for detector of type " << type_
30  << " with " << names_.size() << " elements:";
31  for (unsigned int k = 0; k < names_.size(); ++k)
32  edm::LogVerbatim("EcalGeom") << "[" << k << "] : " << names_[k];
33 }
34 
36  G4VPhysicalVolume* theTopPV =
37  G4TransportationManager::GetTransportationManager()->GetNavigatorForTracking()->GetWorldVolume();
38  edm::LogVerbatim("EcalGeom") << "EcalDumpGeometry entered with entry of top PV at " << theTopPV;
39 
40  dumpTouch(theTopPV, 0);
41  fHistory_.SetFirstEntry(theTopPV);
42  edm::LogVerbatim("EcalGeom") << "EcalDumpGeometry finds " << infoVec_.size() << " touchables";
43  sort(infoVec_.begin(), infoVec_.end(), CaloDetInfoLess());
44  unsigned int k(0);
45  for (const auto& info : infoVec_) {
46  edm::LogVerbatim("EcalGeom") << "[" << k << "] " << info;
47  if (info.flag() && (info.solid() != nullptr)) {
48  info.solid()->DumpInfo();
49  G4cout << G4endl;
50  }
51  ++k;
52  }
53 }
54 
55 void EcalDumpGeometry::dumpTouch(G4VPhysicalVolume* pv, unsigned int leafDepth) {
56  if (leafDepth == 0)
57  fHistory_.SetFirstEntry(pv);
58  else
59  fHistory_.NewLevel(pv, kNormal, pv->GetCopyNo());
60 
61  G4ThreeVector globalpoint = fHistory_.GetTopTransform().Inverse().TransformPoint(G4ThreeVector(0, 0, 0));
62  G4LogicalVolume* lv = pv->GetLogicalVolume();
63 
64  bool flag = ((type_ / 10) % 10 > 0);
65  std::string lvname = (static_cast<std::string>(dd4hep::dd::noNamespace(lv->GetName())));
66  std::string namex = lvname.substr(0, 4);
67  EcalBaseNumber theBaseNumber;
68  for (unsigned int k = 0; k < names_.size(); ++k) {
69  if (namex == names_[k]) {
70  int theSize = fHistory_.GetDepth();
71  //Get name and copy numbers
72  if (theSize > 5) {
73  theBaseNumber.reset();
74  if (theBaseNumber.getCapacity() < theSize + 1)
75  theBaseNumber.setSize(theSize + 1);
76 #ifdef EDM_ML_DEBUG
77  std::stringstream ss;
78 #endif
79  for (int ii = theSize; ii >= 0; --ii) {
80  std::string_view name = dd4hep::dd::noNamespace(fHistory_.GetVolume(ii)->GetName());
81  theBaseNumber.addLevel(static_cast<std::string>(name), fHistory_.GetVolume(ii)->GetCopyNo());
82 #ifdef EDM_ML_DEBUG
83  ss << " " << ii << " " << name << ":" << fHistory_.GetVolume(ii)->GetCopyNo();
84 #endif
85  }
86  uint32_t id = (((type_ % 10) == 0) ? ebNumbering_.getUnitID(theBaseNumber)
87  : (((type_ % 10) == 1) ? eeNumbering_.getUnitID(theBaseNumber)
88  : esNumbering_.getUnitID(theBaseNumber)));
89  uint32_t depth(0);
90  if ((!name1_.empty()) && (namex == name1_))
91  depth = 1;
92  if ((!name2_.empty()) && (namex == name2_))
93  depth = 2;
94  double r = globalpoint.rho();
95 #ifdef EDM_ML_DEBUG
96  edm::LogVerbatim("EcalGeom") << " Field: " << ss.str() << " ID " << std::hex << id << std::dec << ":" << depth
97  << ":" << r;
98 #endif
99  G4VSolid* solid = (lv->GetSolid());
100  if (((type_ / 100) % 10) != 0)
101  infoVec_.emplace_back(CaloDetInfo(id, depth, r, noRefl(lvname), globalpoint, solid, flag));
102  else
103  infoVec_.emplace_back(CaloDetInfo(id, depth, r, lvname, globalpoint, solid, flag));
104  }
105  break;
106  }
107  }
108 
109  int NoDaughters = lv->GetNoDaughters();
110  while ((NoDaughters--) > 0) {
111  G4VPhysicalVolume* pvD = lv->GetDaughter(NoDaughters);
112  if (!pvD->IsReplicated())
113  dumpTouch(pvD, leafDepth + 1);
114  }
115 
116  if (leafDepth > 0)
117  fHistory_.BackLevel();
118 }
119 
121  if (name.find("_refl") == std::string::npos) {
122  return name;
123  } else {
124  size_t n = name.size();
125  return name.substr(0, n - 5);
126  }
127 }
EcalDumpGeometry.h
MessageLogger.h
dqmiodumpmetadata.n
n
Definition: dqmiodumpmetadata.py:28
EcalDumpGeometry::fHistory_
G4NavigationHistory fHistory_
Definition: EcalDumpGeometry.h:39
EcalDumpGeometry::infoVec_
std::vector< CaloDetInfo > infoVec_
Definition: EcalDumpGeometry.h:40
EcalDumpGeometry::eeNumbering_
EcalEndcapNumberingScheme eeNumbering_
Definition: EcalDumpGeometry.h:35
EcalEndcapNumberingScheme::getUnitID
uint32_t getUnitID(const EcalBaseNumber &baseNumber) const override
Definition: EcalEndcapNumberingScheme.cc:17
EcalDumpGeometry::names_
std::vector< std::string > names_
Definition: EcalDumpGeometry.h:37
EcalBaseNumber::getCapacity
int getCapacity()
Definition: EcalBaseNumber.cc:37
CaloDetInfoLess
Definition: CaloDetInfo.h:42
EcalBaseNumber::addLevel
void addLevel(const std::string &name, const int &copyNumber)
Definition: EcalBaseNumber.cc:16
info
static const TGPicture * info(bool iBackgroundIsBlack)
Definition: FWCollectionSummaryWidget.cc:153
EcalBaseNumber
Definition: EcalBaseNumber.h:12
EcalDumpGeometry::update
void update()
Definition: EcalDumpGeometry.cc:35
EcalPreshowerNumberingScheme::getUnitID
uint32_t getUnitID(const EcalBaseNumber &baseNumber) const override
Definition: EcalPreshowerNumberingScheme.cc:99
spr::find
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
EcalDumpGeometry::name1_
const std::string name1_
Definition: EcalDumpGeometry.h:33
EcalDumpGeometry::ebNumbering_
EcalBarrelNumberingScheme ebNumbering_
Definition: EcalDumpGeometry.h:34
contentValuesCheck.ss
ss
Definition: contentValuesCheck.py:33
names
const std::string names[nVars_]
Definition: PhotonIDValueMapProducer.cc:124
EcalDumpGeometry::name2_
const std::string name2_
Definition: EcalDumpGeometry.h:33
EcalBarrelNumberingScheme::getUnitID
uint32_t getUnitID(const EcalBaseNumber &baseNumber) const override
Definition: EcalBarrelNumberingScheme.cc:19
dqmdumpme.k
k
Definition: dqmdumpme.py:60
LEDCalibrationChannels.depth
depth
Definition: LEDCalibrationChannels.py:65
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
EcalDumpGeometry::type_
int type_
Definition: EcalDumpGeometry.h:38
EcalBarrelNumberingScheme.h
type
type
Definition: SiPixelVCal_PayloadInspector.cc:37
jetUpdater_cfi.sort
sort
Definition: jetUpdater_cfi.py:29
EcalBaseNumber::reset
void reset()
Definition: EcalBaseNumber.cc:39
MetAnalyzer.pv
def pv(vc)
Definition: MetAnalyzer.py:7
CaloDetInfo
Definition: CaloDetInfo.h:9
EcalDumpGeometry::esNumbering_
EcalPreshowerNumberingScheme esNumbering_
Definition: EcalDumpGeometry.h:36
EcalBaseNumber.h
alignCSCRings.r
r
Definition: alignCSCRings.py:93
EcalDumpGeometry::noRefl
std::string noRefl(const std::string &name)
Definition: EcalDumpGeometry.cc:120
edm::LogVerbatim
Log< level::Info, true > LogVerbatim
Definition: MessageLogger.h:128
EcalDumpGeometry::EcalDumpGeometry
EcalDumpGeometry(const std::vector< std::string_view > &, const std::string &, const std::string &, int)
Definition: EcalDumpGeometry.cc:14
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
EcalPreshowerNumberingScheme.h
EcalDumpGeometry::dumpTouch
void dumpTouch(G4VPhysicalVolume *pv, unsigned int leafDepth)
Definition: EcalDumpGeometry.cc:55
ecalTB2006H4_GenSimDigiReco_cfg.G4cout
G4cout
Definition: ecalTB2006H4_GenSimDigiReco_cfg.py:285
hfnoseParametersInitialization_cfi.name2
name2
Definition: hfnoseParametersInitialization_cfi.py:8
EcalEndcapNumberingScheme.h
EcalBaseNumber::setSize
void setSize(const int &size)
Definition: EcalBaseNumber.cc:11
edm::Log
Definition: MessageLogger.h:70
TauDecayModes.dec
dec
Definition: TauDecayModes.py:143
cuy.ii
ii
Definition: cuy.py:590
RemoveAddSevLevel.flag
flag
Definition: RemoveAddSevLevel.py:116