File indexing completed on 2025-01-18 09:14:55
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015 #include <XML/XMLElements.h>
0016 #include <DDG4/Factories.h>
0017 #include <DD4hep/ComponentProperties.h>
0018
0019
0020 #include <G4SystemOfUnits.hh>
0021 #include <G4ExtendedMaterial.hh>
0022 #include <G4CrystalExtension.hh>
0023 #include <G4ChannelingMaterialData.hh>
0024 #include <G4ChannelingOptrMultiParticleChangeCrossSection.hh>
0025
0026
0027 namespace { class ChannelingCrystalMaterial; }
0028
0029
0030 namespace dd4hep {
0031
0032
0033
0034
0035
0036
0037
0038
0039 template <> G4Material*
0040 Geant4MaterialFactory<ChannelingCrystalMaterial>::create(dd4hep::Detector& ,
0041 Material mat,
0042 G4Material* base_material)
0043 {
0044 std::string crystal_data, orientation, name = base_material->GetName();
0045 auto* material = new G4ExtendedMaterial(name+".extended", base_material);
0046 material->RegisterExtension(std::unique_ptr<G4CrystalExtension>(new G4CrystalExtension(material)));
0047 auto* ext = (G4CrystalExtension*)material->RetrieveExtension("crystal");
0048 ext->SetUnitCell(new G4CrystalUnitCell(5.43 * CLHEP::angstrom,
0049 5.43 * CLHEP::angstrom,
0050 5.43 * CLHEP::angstrom,
0051 CLHEP::halfpi,
0052 CLHEP::halfpi,
0053 CLHEP::halfpi,
0054 227));
0055
0056 material->RegisterExtension(std::unique_ptr<G4ChannelingMaterialData>(new G4ChannelingMaterialData("channeling")));
0057 auto* channelingData =(G4ChannelingMaterialData*)material->RetrieveExtension("channeling");
0058 crystal_data = mat.constPropertyRef("Geant4-ignore:crystal_data");
0059 if ( crystal_data.empty() ) {
0060 except("ChannelingCrystalMaterial",
0061 "====> Extended material: %s misses channeling data file.",
0062 name.c_str());
0063 }
0064 channelingData->SetFilename(crystal_data);
0065
0066
0067 orientation = mat.constPropertyRef("Geant4-ignore:crystal_orientation");
0068 if ( !orientation.empty() ) {
0069 Direction direction;
0070 Property prop(direction);
0071 prop.str(orientation);
0072 channelingData->SetBR(direction.X());
0073 }
0074
0075 printout(ALWAYS,"ChannelingCrystalMaterial",
0076 "====> Created extended material: %s Data: %s Orientation: %s",
0077 name.c_str(), crystal_data.c_str(), orientation.c_str());
0078 return material;
0079 }
0080 }
0081 DECLARE_GEANT4EXTENDEDMATERIAL(ChannelingCrystalMaterial)