Exemplo n.º 1
0
void GdmlDetectorConstruction::ConstructSDandField() {
  // Example from Geant4 examples/extended/persistency/gdml/G04
  // First create and register sensitive detectors:
  std::string caloSDname = "ECal";
  TestCalorimeterSD* caloSD = new TestCalorimeterSD(caloSDname, 11);
  G4SDManager* SDman = G4SDManager::GetSDMpointer();
  SDman->AddNewDetector(caloSD);
  const G4GDMLAuxMapType* auxMap = m_parser.GetAuxMap();
  for (auto& entry : *auxMap) {
    for (auto& info : entry.second) {
      if (info.type == "SensDet") {
        // attach SD registered above
        m_log << MSG::INFO << "Attaching a sensitive detector: " << info.value
              << " to volume: " << entry.first->GetName() << endmsg;
        G4VSensitiveDetector* mydet = SDman->FindSensitiveDetector(info.value);
        if (mydet) {
          entry.first->SetSensitiveDetector(mydet);
          entry.first->GetSolid()->DumpInfo();
        } else {
          m_log << MSG::WARNING << "GDML contains sensitive detector of type: " << info.value << " but it is not found"
                << endmsg;
        }
      }
    }
  }
}
Exemplo n.º 2
0
void	GSMS::EventAction::BeginOfEventAction(const G4Event*	evt) {
	G4int	evtNb = evt->GetEventID();
//	std::cerr << "Event: " << evtNb << std::endl;

	G4SDManager*	sdman = G4SDManager::GetSDMpointer();
	colID = sdman->GetCollectionID("crystal/eDep");

//	std::cerr << "Coll ID: " << colID << std::endl;
}
Exemplo n.º 3
0
void BIEventAction::BeginOfEventAction(const G4Event *)
{
    if (fHitsCollectionID == -1) {
       G4SDManager *manager = G4SDManager::GetSDMpointer();
       fHitsCollectionID = manager->GetCollectionID("Common/CommonHitsCollection");
       if (fHitsCollectionID == -1) {
          G4cout << "Common/CommonHitsCollection not found" << G4endl;
          exit(0);
       }
    }
}