File indexing completed on 2024-04-06 12:30:11
0001
0002
0003
0004
0005
0006 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0007 #include "SimG4CMS/PPS/interface/PPSDiamondOrganization.h"
0008 #include "DataFormats/CTPPSDetId/interface/CTPPSDiamondDetId.h"
0009 #include "G4VPhysicalVolume.hh"
0010 #include "G4VTouchable.hh"
0011 #include "G4Step.hh"
0012
0013 #include <iostream>
0014
0015
0016
0017 PPSDiamondOrganization ::PPSDiamondOrganization()
0018 : theArm_(0), theStation_(0), theRoman_pot_(0), thePlane_(0), theDetector_(0) {}
0019
0020 uint32_t PPSDiamondOrganization::unitID(const G4Step* aStep) {
0021 const G4VTouchable* touch = aStep->GetPreStepPoint()->GetTouchable();
0022 G4VPhysicalVolume* physVol = touch->GetVolume(0);
0023 int coNum = physVol->GetCopyNo();
0024 edm::LogVerbatim("PPSSimDiamond") << " %%%% PhysVol: " << physVol->GetName() << " coNum=" << coNum;
0025 theDetector_ = coNum % 100;
0026 thePlane_ = coNum / 100;
0027
0028 G4VPhysicalVolume* physVolVac = touch->GetVolume(3);
0029 if (nullptr == physVolVac) {
0030 edm::LogError("PPSSimDiamond") << "Physical volume Primary_Vacuum not found for " << physVol->GetName()
0031 << "; cannot determine CTPPSDiamondDetId.";
0032 } else {
0033 int cpy_no = physVolVac->GetCopyNo();
0034 theArm_ = (cpy_no / 100) % 10;
0035 theStation_ = (cpy_no / 10) % 10;
0036 theRoman_pot_ = cpy_no % 10;
0037 }
0038 return CTPPSDiamondDetId(theArm_, theStation_, theRoman_pot_, thePlane_, theDetector_).rawId();
0039 }