Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-05-05 01:48:39

0001 #include "SimG4CMS/PPS/interface/PPSStripOrganization.h"
0002 #include "DataFormats/CTPPSDetId/interface/TotemRPDetId.h"
0003 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0004 
0005 #include "G4VPhysicalVolume.hh"
0006 #include "G4VTouchable.hh"
0007 #include "G4Step.hh"
0008 
0009 #include <iostream>
0010 
0011 uint32_t PPSStripOrganization::unitID(const G4Step* aStep) {
0012   unsigned int arm = 0;
0013   unsigned int station = 0;
0014   unsigned int roman_pot = 0;
0015 
0016   const G4VTouchable* touch = aStep->GetPreStepPoint()->GetTouchable();
0017   G4VPhysicalVolume* physVol = touch->GetVolume(0);
0018   unsigned int detector = physVol->GetCopyNo();
0019   edm::LogVerbatim("PPSStripSim") << "PPSStripSim: PhysVol= " << physVol->GetName() << " coNum=" << detector;
0020 
0021   G4VPhysicalVolume* physVolVac = touch->GetVolume(2);
0022   if (nullptr == physVolVac) {
0023     edm::LogError("PPSStripSim") << "Physical volume RP_box_primary_vacuum not found for " << physVol->GetName()
0024                                  << "; cannot determine TotemRPDetId.";
0025   } else {
0026     int cpy_no = physVolVac->GetCopyNo();
0027     arm = (cpy_no / 100) % 10;
0028     station = (cpy_no / 10) % 10;
0029     roman_pot = cpy_no % 10;
0030   }
0031   edm::LogVerbatim("PPSStripSim") << "    arm=" << arm << " station=" << station << " roman_pot=" << roman_pot
0032                                   << " detector=" << detector;
0033   return TotemRPDetId(arm, station, roman_pot, detector).rawId();
0034 }