CMS 3D CMS Logo

HcalDumpGeometry.cc
Go to the documentation of this file.
4 
5 #include <iostream>
6 #include <memory>
7 
8 //#define EDM_ML_DEBUG
9 
10 HcalDumpGeometry::HcalDumpGeometry(const std::vector<std::string_view>& names,
11  const HcalNumberingFromDDD* hcn,
12  bool test,
13  bool flag)
14  : numberingFromDDD_(hcn), flag_(flag) {
15  if (test)
16  numberingScheme_.reset(dynamic_cast<HcalNumberingScheme*>(new HcalTestNumberingScheme(false)));
17  else
18  numberingScheme_ = std::make_unique<HcalNumberingScheme>();
19  std::stringstream ss;
20  for (const auto& lvname : names)
21  ss << " " << lvname;
22  edm::LogVerbatim("HCalGeom") << " Testmode: " << test << " with " << names.size() << " LVs: " << ss.str();
23  const std::vector<std::string> namg = {"HBS", "HES", "HTS", "HVQ"};
24  for (const auto& name : names) {
25  std::string namex = (getNameNoNS(static_cast<std::string>(name))).substr(0, 3);
26  if (std::find(namg.begin(), namg.end(), namex) != namg.end()) {
27  if (std::find(names_.begin(), names_.end(), namex) == names_.end())
28  names_.emplace_back(namex);
29  }
30  }
31  edm::LogVerbatim("HCalGeom") << "HcalDumpGeometry:: dump geometry information for Hcal with " << names_.size()
32  << " elements:";
33  for (unsigned int k = 0; k < names_.size(); ++k)
34  edm::LogVerbatim("HCalGeom") << "[" << k << "] : " << names_[k];
35 }
36 
38  G4VPhysicalVolume* theTopPV =
39  G4TransportationManager::GetTransportationManager()->GetNavigatorForTracking()->GetWorldVolume();
40  edm::LogVerbatim("HCalGeom") << "HcalDumpGeometry entered with entry of top PV at " << theTopPV;
41 
42  dumpTouch(theTopPV, 0);
43  fHistory_.SetFirstEntry(theTopPV);
44  edm::LogVerbatim("HCalGeom") << "HcalDumpGeometry finds " << infoVec_.size() << " touchables";
45  sort(infoVec_.begin(), infoVec_.end(), CaloDetInfoLess());
46  unsigned int k(0);
47  for (const auto& info : infoVec_) {
48  edm::LogVerbatim("HCalGeom") << "[" << k << "] " << info;
49  if (info.flag() && (info.solid() != nullptr)) {
50  info.solid()->DumpInfo();
51  G4cout << G4endl;
52  }
53  ++k;
54  }
55 }
56 
57 void HcalDumpGeometry::dumpTouch(G4VPhysicalVolume* pv, unsigned int leafDepth) {
58  if (leafDepth == 0)
59  fHistory_.SetFirstEntry(pv);
60  else
61  fHistory_.NewLevel(pv, kNormal, pv->GetCopyNo());
62 
63  G4ThreeVector globalpoint = fHistory_.GetTopTransform().Inverse().TransformPoint(G4ThreeVector(0, 0, 0));
64  G4LogicalVolume* lv = pv->GetLogicalVolume();
65 
66  const std::string& lvname = lv->GetName();
67  std::string namex = (getNameNoNS(lvname)).substr(0, 3);
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  int depth = (fHistory_.GetVolume(theSize)->GetCopyNo()) % 10 + 1;
74  int lay = (fHistory_.GetVolume(theSize)->GetCopyNo() / 10) % 100 + 1;
75  int det = (fHistory_.GetVolume(theSize - 1)->GetCopyNo()) / 1000;
77  det, math::XYZVectorD(globalpoint.x(), globalpoint.y(), globalpoint.z()), depth, lay);
78  uint32_t id = numberingScheme_->getUnitID(tmp);
79 #ifdef EDM_ML_DEBUG
80  edm::LogVerbatim("HCalGeom") << "Det " << det << " Layer " << lay << ":" << depth << " Volume "
81  << fHistory_.GetVolume(theSize)->GetName() << ":"
82  << fHistory_.GetVolume(theSize - 1)->GetName() << " ID " << std::hex << id
83  << std::dec;
84 #endif
85 
86  G4VSolid* solid = lv->GetSolid();
87  infoVec_.emplace_back(CaloDetInfo(id, 0, 0, getNameNoNS(lvname), globalpoint, solid, flag_));
88  }
89  break;
90  }
91  }
92 
93  int NoDaughters = lv->GetNoDaughters();
94  while ((NoDaughters--) > 0) {
95  G4VPhysicalVolume* pvD = lv->GetDaughter(NoDaughters);
96  if (!pvD->IsReplicated())
97  dumpTouch(pvD, leafDepth + 1);
98  }
99 
100  if (leafDepth > 0)
101  fHistory_.BackLevel();
102 }
103 
105  if (name.find(':') == std::string::npos) {
106  return name;
107  } else {
108  auto n1 = name.find(':') + 1;
109  return name.substr(n1, (name.size() - n1));
110  }
111 }
HcalDumpGeometry::getNameNoNS
std::string getNameNoNS(const std::string &name)
Definition: HcalDumpGeometry.cc:104
MessageLogger.h
HcalNumberingFromDDD::HcalID
Definition: HcalNumberingFromDDD.h:21
HcalDumpGeometry::update
void update()
Definition: HcalDumpGeometry.cc:37
HcalNumberingFromDDD
Definition: HcalNumberingFromDDD.h:16
HcalDumpGeometry::fHistory_
G4NavigationHistory fHistory_
Definition: HcalDumpGeometry.h:38
HcalDumpGeometry::infoVec_
std::vector< CaloDetInfo > infoVec_
Definition: HcalDumpGeometry.h:39
CaloDetInfoLess
Definition: CaloDetInfo.h:42
info
static const TGPicture * info(bool iBackgroundIsBlack)
Definition: FWCollectionSummaryWidget.cc:153
HcalDumpGeometry::HcalDumpGeometry
HcalDumpGeometry(const std::vector< std::string_view > &, const HcalNumberingFromDDD *, bool, bool flag=false)
Definition: HcalDumpGeometry.cc:10
HcalDumpGeometry::numberingScheme_
std::unique_ptr< HcalNumberingScheme > numberingScheme_
Definition: HcalDumpGeometry.h:35
spr::find
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
createJobs.tmp
tmp
align.sh
Definition: createJobs.py:716
contentValuesCheck.ss
ss
Definition: contentValuesCheck.py:33
HcalDumpGeometry::numberingFromDDD_
const HcalNumberingFromDDD * numberingFromDDD_
Definition: HcalDumpGeometry.h:34
test
Definition: SmallWORMDict.h:13
names
const std::string names[nVars_]
Definition: PhotonIDValueMapProducer.cc:124
HcalDumpGeometry::dumpTouch
void dumpTouch(G4VPhysicalVolume *pv, unsigned int leafDepth)
Definition: HcalDumpGeometry.cc:57
dqmdumpme.k
k
Definition: dqmdumpme.py:60
LEDCalibrationChannels.depth
depth
Definition: LEDCalibrationChannels.py:65
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
math::XYZVectorD
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > XYZVectorD
spatial vector with cartesian internal representation
Definition: Vector3D.h:8
HcalTestNumberingScheme
Definition: HcalTestNumberingScheme.h:11
HcalDetId.h
MetAnalyzer.pv
def pv(vc)
Definition: MetAnalyzer.py:7
CaloDetInfo
Definition: CaloDetInfo.h:9
HcalDumpGeometry.h
edm::LogVerbatim
Log< level::Info, true > LogVerbatim
Definition: MessageLogger.h:128
HcalNumberingFromDDD::unitID
HcalID unitID(int det, const math::XYZVectorD &pos, int depth, int lay=-1) const
Definition: HcalNumberingFromDDD.cc:30
HcalDumpGeometry::names_
std::vector< std::string > names_
Definition: HcalDumpGeometry.h:36
flag_
struct @690 flag_
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
ecalTB2006H4_GenSimDigiReco_cfg.G4cout
G4cout
Definition: ecalTB2006H4_GenSimDigiReco_cfg.py:303
edm::Log
Definition: MessageLogger.h:70
TauDecayModes.dec
dec
Definition: TauDecayModes.py:143
HcalDumpGeometry::flag_
const bool flag_
Definition: HcalDumpGeometry.h:37
RemoveAddSevLevel.flag
flag
Definition: RemoveAddSevLevel.py:116