Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:05:24

0001 #ifndef DDMaterial_h
0002 #define DDMaterial_h
0003 
0004 #include <iostream>
0005 #include <memory>
0006 #include <vector>
0007 #include <utility>
0008 #include "DetectorDescription/Core/interface/DDName.h"
0009 #include "DetectorDescription/Core/interface/DDBase.h"
0010 
0011 namespace DDI {
0012   class Material;
0013 }
0014 
0015 //! DDMaterial is used to define and access material information
0016 /**
0017     An object of this class is a reference-object and thus leightweighted.
0018     It is uniquely identified by its DDName. Further details concerning
0019     reference-objects can be found in the documentation of DDLogicalPart.
0020     
0021     A DDMaterial can recursively consist of compound materials (which are 
0022     DDMaterials as well). Materials consisting of compound materials are called
0023     \b mixtures. Mixtures are defined by their Materials which do not consist of compound materials are called
0024     \b elementary materials.
0025 
0026     To define an \b elementray material, use it like this:
0027     \code
0028     DDMaterial hydrogen("Hydrogen", 
0029                         double z=1, 
0030             double a=1.1*g/mole, 
0031             density=2*g/cm3);
0032     \endcode
0033     
0034     To define a mixture: 
0035     \code
0036     DDMaterial mixt("Mix", double density = 5*g/cm3);
0037     mixt.addMaterial(hydrogen,0.3);
0038     // code for additional compounds belonging to the mixture ...
0039     \endcode
0040     
0041     Note the usage DDUnits replacing CLHEP/SystemOfUnits
0042     to specify the units of the quantities
0043     making up a material.
0044 */
0045 class DDMaterial : public DDBase<DDName, std::unique_ptr<DDI::Material>> {
0046   friend std::ostream &operator<<(std::ostream &, const DDMaterial &);
0047 
0048 public:
0049   using FractionV = std::vector<std::pair<DDMaterial, double>>;
0050 
0051   //! Creates a uninitialized reference-object (see DDLogicalPart documentation for details on reference objects)
0052   DDMaterial();
0053 
0054   //! Creates a initialized reference-object or a reference to an allready defined material.
0055   DDMaterial(const DDName &name);
0056 
0057   //! Constructor for construction of an \b elementary material
0058   DDMaterial(const DDName &name, double z, double a, double d);
0059 
0060   //! Constructor for \b mixtures
0061   DDMaterial(const DDName &name, double density);
0062 
0063   //! returns the number of compound materials or 0 for elementary materials
0064   int noOfConstituents() const;
0065 
0066   //! returns the i-th compound material and its fraction-mass
0067   FractionV::value_type constituent(int i) const;
0068 
0069   //! adds a material to the mixture proportional to its fraction-mass \a fm.
0070   int addMaterial(const DDMaterial &m, double fm);
0071 
0072   //! returns the atomic mass
0073   double a() const;
0074 
0075   //! retruns the atomic number
0076   double z() const;
0077 
0078   //! returns the density
0079   double density() const;
0080 };
0081 
0082 std::ostream &operator<<(std::ostream &, const DDMaterial &);
0083 
0084 #endif