CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
PPSPixelOrganization.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: PPS
4 // Class : PPSPixelOrganization
5 //
6 // Implementation:
7 // <Notes on implementation>
8 //
9 
10 // user include files
14 #include "G4VPhysicalVolume.hh"
15 #include "G4VTouchable.hh"
16 
17 //
18 // constructors and destructor
19 //
21  : currentUnitID_(0), currentArm_(0), currentStation_(0), currentRP_(0), currentPlane_(0) {
22  edm::LogInfo("PPSSim") << "Creating PPSPixelOrganization";
23 }
24 
25 //
26 // member functions
27 //
28 
29 uint32_t PPSPixelOrganization ::unitID(const G4Step* aStep) {
30  const G4VTouchable* touch = aStep->GetPreStepPoint()->GetTouchable();
31  G4VPhysicalVolume* physVol;
32  int ii = 0;
33  bool foundEnvelop = false;
34  bool foundPhysVol = false;
35 
36  while (ii < touch->GetHistoryDepth() && (foundEnvelop == false || foundPhysVol == false)) {
37  physVol = touch->GetVolume(ii);
38 
39  edm::LogInfo("PPSSim") << "physVol=" << physVol->GetName() << ", level=" << ii
40  << ", physVol->GetCopyNo()=" << physVol->GetCopyNo();
41 
42  if (physVol->GetName().contains("Envelop")) {
43  currentPlane_ = physVol->GetCopyNo() - 1;
44  foundEnvelop = true;
45  } else if (physVol->GetName().contains("RP_box_primary_vacuum")) {
46  int cpy_no = physVol->GetCopyNo();
47  currentArm_ = (cpy_no / 100) % 10;
48  currentStation_ = (cpy_no / 10) % 10;
49  currentRP_ = cpy_no % 10;
50  foundPhysVol = true;
51  }
52  ++ii;
53  }
54 
55  if (foundPhysVol) {
56  edm::LogInfo("PPSSim") << "Arm, RP, plane = " << currentArm_ << " " << currentRP_ << " " << currentPlane_;
57  } else {
58  edm::LogError("PPSSim") << "Physical volume RP_box_primary_vacuum not found. Cannot determine CTPPSPixelDetId.";
59  }
60 
62  uint32_t kk = id.rawId();
63  edm::LogInfo("PPSSim") << " ID " << kk;
64  return id.rawId();
65 }
uint32_t unitID(const G4Step *aStep) override
uint16_t *__restrict__ id
Log< level::Error, false > LogError
int ii
Definition: cuy.py:589
Log< level::Info, false > LogInfo