diff --git a/Simulation/DetSimAna/src/ExampleAnaElemTool.cpp b/Simulation/DetSimAna/src/ExampleAnaElemTool.cpp index f9f54489e8e4f2ff15c4a841674a278255ab8e27..d0611ef23db8c8ea8a88cb04f0d83456274f056b 100644 --- a/Simulation/DetSimAna/src/ExampleAnaElemTool.cpp +++ b/Simulation/DetSimAna/src/ExampleAnaElemTool.cpp @@ -51,7 +51,14 @@ ExampleAnaElemTool::EndOfEventAction(const G4Event* anEvent) { warning() << "Collection iCol " << icol << " is missing" << endmsg; continue; } - info() << "Collection " << collect->GetName() << endmsg; + size_t nhits = collect->GetSize(); + info() << "Collection " << collect->GetName() + << " #" << icol + << " has " << nhits << " hits." + << endmsg; + + + } } diff --git a/Simulation/DetSimGeom/src/AnExampleDetElemTool.cpp b/Simulation/DetSimGeom/src/AnExampleDetElemTool.cpp index ef1ce8d15c6fbebf593c21bcd13b1cdb0042153a..0f0a064d2607492ecef9734a5a52ac30926e6fad 100644 --- a/Simulation/DetSimGeom/src/AnExampleDetElemTool.cpp +++ b/Simulation/DetSimGeom/src/AnExampleDetElemTool.cpp @@ -29,10 +29,10 @@ DECLARE_COMPONENT(AnExampleDetElemTool) G4LogicalVolume* AnExampleDetElemTool::getLV() { - G4Material* Galactic = G4Material::GetMaterial("Galactic"); + // G4Material* Galactic = G4Material::GetMaterial("Galactic"); - G4VSolid* solidAnExample= new G4Box("sAnExample", m_x.value(), m_y.value(), m_z.value()); - G4LogicalVolume* logicAnExample= new G4LogicalVolume( solidAnExample, Galactic, "lAnExample", 0, 0, 0); + // G4VSolid* solidAnExample= new G4Box("sAnExample", m_x.value(), m_y.value(), m_z.value()); + // G4LogicalVolume* logicAnExample= new G4LogicalVolume( solidAnExample, Galactic, "lAnExample", 0, 0, 0); // Following is an example to get the DD4hep volume dd4hep::Detector* dd4hep_geo = &(dd4hep::Detector::getInstance()); @@ -48,19 +48,20 @@ AnExampleDetElemTool::getLV() { G4LogicalVolume* logicDD4hepExample = m_world->GetLogicalVolume(); if (logicDD4hepExample) { - new G4PVPlacement(0, // no rotation - G4ThreeVector(), // at (0,0,0) - logicDD4hepExample, // logical volume - "lDD4hepExampleDetElem", // name - logicAnExample, // mother volume - false, // no boolean operations - 0); // no field + // new G4PVPlacement(0, // no rotation + // G4ThreeVector(), // at (0,0,0) + // logicDD4hepExample, // logical volume + // "lDD4hepExampleDetElem", // name + // logicAnExample, // mother volume + // false, // no boolean operations + // 0); // no field } else { warning() << "Can't Find the logical volume lDD4hepExampleDetElem " << std::endl; } - return logicAnExample; + // return logicAnExample; + return logicDD4hepExample; } void @@ -89,7 +90,7 @@ AnExampleDetElemTool::ConstructSDandField() { G4VSensitiveDetector* g4sd = dd4hep::PluginService::Create<G4VSensitiveDetector*>(typ, nam, lcdd); if (g4sd == nullptr) { std::string tmp = typ; - // tmp[0] = ::toupper(tmp[0]); + tmp[0] = ::toupper(tmp[0]); typ = "Geant4" + tmp; g4sd = dd4hep::PluginService::Create<G4VSensitiveDetector*>(typ, nam, lcdd); if (g4sd == nullptr) { @@ -112,6 +113,7 @@ AnExampleDetElemTool::ConstructSDandField() { throw std::runtime_error("ConstructSDandField: Failed to access G4LogicalVolume for SD " + nam + " of type " + typ + "."); } + info() << " -> Adding " << g4v->GetName() << endmsg; G4SDManager::GetSDMpointer()->AddNewDetector(g4sd); g4v->SetSensitiveDetector(g4sd); } diff --git a/Simulation/DetSimGeom/src/WorldDetElemTool.cpp b/Simulation/DetSimGeom/src/WorldDetElemTool.cpp index 289157a85df107e5695b502fbc543c299cea4fd9..ccef28d7f00deb6252079fe3b6d039505331c0bf 100644 --- a/Simulation/DetSimGeom/src/WorldDetElemTool.cpp +++ b/Simulation/DetSimGeom/src/WorldDetElemTool.cpp @@ -27,27 +27,28 @@ DECLARE_COMPONENT(WorldDetElemTool) G4LogicalVolume* WorldDetElemTool::getLV() { - G4Material* Galactic = G4Material::GetMaterial("Galactic"); + // G4Material* Galactic = G4Material::GetMaterial("Galactic"); - G4VSolid* solidWorld= new G4Box("sWorld", 60*m, 60*m, 60*m); - G4LogicalVolume* logicWorld= new G4LogicalVolume( solidWorld, Galactic, "lWorld", 0, 0, 0); + // G4VSolid* solidWorld= new G4Box("sWorld", 60*m, 60*m, 60*m); + // G4LogicalVolume* logicWorld= new G4LogicalVolume( solidWorld, Galactic, "lWorld", 0, 0, 0); // An example, get a detelem first, then place the detector components inside world. ToolHandle<IDetElemTool> inner_detelem_tool("AnExampleDetElemTool"); G4LogicalVolume* inner_lv = inner_detelem_tool->getLV(); if (inner_lv) { - new G4PVPlacement(0, // no rotation - G4ThreeVector(), // at (0,0,0) - inner_lv, // logical volume - "pAnExampleDetElem", // name - logicWorld, // mother volume - false, // no boolean operations - 0); // no field + // new G4PVPlacement(0, // no rotation + // G4ThreeVector(), // at (0,0,0) + // inner_lv, // logical volume + // "pAnExampleDetElem", // name + // logicWorld, // mother volume + // false, // no boolean operations + // 0); // no field } else { warning() << "Can't Find the logical volume ExampleDetElem " << std::endl; } - return logicWorld; + // return logicWorld; + return inner_lv; } void