Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:14:55

0001 //==========================================================================
0002 //  AIDA Detector description implementation 
0003 //--------------------------------------------------------------------------
0004 // Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN)
0005 // All rights reserved.
0006 //
0007 // For the licensing terms see $DD4hepINSTALL/LICENSE.
0008 // For the list of contributors see $DD4hepINSTALL/doc/CREDITS.
0009 //
0010 // Author     : M.Frank
0011 //
0012 //==========================================================================
0013 
0014 // Framework include files
0015 #include <XML/XMLElements.h>
0016 #include <DDG4/Factories.h>
0017 #include <DD4hep/ComponentProperties.h>
0018 
0019 // Geant4 include files
0020 #include <G4SystemOfUnits.hh>
0021 #include <G4ExtendedMaterial.hh>
0022 #include <G4CrystalExtension.hh>
0023 #include <G4ChannelingMaterialData.hh>
0024 #include <G4ChannelingOptrMultiParticleChangeCrossSection.hh>
0025 
0026 // Forward declarations
0027 namespace {  class ChannelingCrystalMaterial;  }
0028 
0029 /// Namespace example name of the user
0030 namespace dd4hep   {
0031 
0032   /// Class member specialization to create G4ExtendedMaterial
0033   /** Class member specialization to create G4ExtendedMaterial
0034    *
0035    *  \author  M.Frank
0036    *  \version 1.0
0037    *  \ingroup DD4HEP_SIMULATION
0038    */
0039   template <>  G4Material* 
0040   Geant4MaterialFactory<ChannelingCrystalMaterial>::create(dd4hep::Detector& /* description */,
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     /// Set crystal orientation
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 }      // End namespace dd4hep
0081 DECLARE_GEANT4EXTENDEDMATERIAL(ChannelingCrystalMaterial)