CMS 3D CMS Logo

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