// @(#)root/g3d:$Id$
// Author: Rene Brun   03/10/95

/*************************************************************************
 * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers.               *
 * All rights reserved.                                                  *
 *                                                                       *
 * For the licensing terms see $ROOTSYS/LICENSE.                         *
 * For the list of contributors see $ROOTSYS/README/CREDITS.             *
 *************************************************************************/

#include "TGeometry.h"
#include "TMaterial.h"

ClassImp(TMaterial)

//______________________________________________________________________________
//
// Manages a detector material. See class TGeometry
//

//______________________________________________________________________________
TMaterial::TMaterial()
{
   // Material default constructor.

   fA = 0;
   fDensity = 0;
   fInterLength = 0;
   fNumber = 0;
   fRadLength = 0;
   fZ = 0;
}


//______________________________________________________________________________
TMaterial::TMaterial(const char *name, const char *title, Float_t a, Float_t z, Float_t density)
           :TNamed(name,title), TAttFill(0,1)
{
   // Material normal constructor.

   if (!gGeometry) gGeometry = new TGeometry("Geometry","Default Geometry");
   fA       = a;
   fZ       = z;
   fDensity = density;
   fNumber  = gGeometry->GetListOfMaterials()->GetSize();
   fRadLength   = 0;
   fInterLength = 0;
   gGeometry->GetListOfMaterials()->Add(this);
}


//______________________________________________________________________________
TMaterial::TMaterial(const char *name, const char *title, Float_t a, Float_t z, Float_t density, Float_t radl, Float_t inter)
           :TNamed(name,title), TAttFill(0,1)
{
   // Material normal constructor.

   if (!gGeometry) gGeometry = new TGeometry("Geometry","Default Geometry");
   fA       = a;
   fZ       = z;
   fDensity = density;
   fNumber  = gGeometry->GetListOfMaterials()->GetSize();
   fRadLength   = radl;
   fInterLength = inter;
   gGeometry->GetListOfMaterials()->Add(this);
}


//______________________________________________________________________________
TMaterial::~TMaterial()
{
   // Material default destructor.

   if (gGeometry) gGeometry->GetListOfMaterials()->Remove(this);

}


//______________________________________________________________________________
void TMaterial::Streamer(TBuffer &R__b)
{
   // Stream an object of class TMaterial.

   UInt_t R__s, R__c;
   if (R__b.IsReading()) {
      Version_t R__v = R__b.ReadVersion(&R__s, &R__c);
      TNamed::Streamer(R__b);
      R__b >> fNumber;
      R__b >> fA;
      R__b >> fZ;
      R__b >> fDensity;
      if (R__v > 2) {
         TAttFill::Streamer(R__b);
         R__b >> fRadLength;
         R__b >> fInterLength;
      } else {
         fRadLength   = 0;
         fInterLength = 0;
      }
      R__b.CheckByteCount(R__s, R__c, TMaterial::IsA());
   } else {
      R__c = R__b.WriteVersion(TMaterial::IsA(), kTRUE);
      TNamed::Streamer(R__b);
      R__b << fNumber;
      R__b << fA;
      R__b << fZ;
      R__b << fDensity;
      TAttFill::Streamer(R__b);
      R__b << fRadLength;
      R__b << fInterLength;
      R__b.SetByteCount(R__c, kTRUE);
   }
}
 TMaterial.cxx:1
 TMaterial.cxx:2
 TMaterial.cxx:3
 TMaterial.cxx:4
 TMaterial.cxx:5
 TMaterial.cxx:6
 TMaterial.cxx:7
 TMaterial.cxx:8
 TMaterial.cxx:9
 TMaterial.cxx:10
 TMaterial.cxx:11
 TMaterial.cxx:12
 TMaterial.cxx:13
 TMaterial.cxx:14
 TMaterial.cxx:15
 TMaterial.cxx:16
 TMaterial.cxx:17
 TMaterial.cxx:18
 TMaterial.cxx:19
 TMaterial.cxx:20
 TMaterial.cxx:21
 TMaterial.cxx:22
 TMaterial.cxx:23
 TMaterial.cxx:24
 TMaterial.cxx:25
 TMaterial.cxx:26
 TMaterial.cxx:27
 TMaterial.cxx:28
 TMaterial.cxx:29
 TMaterial.cxx:30
 TMaterial.cxx:31
 TMaterial.cxx:32
 TMaterial.cxx:33
 TMaterial.cxx:34
 TMaterial.cxx:35
 TMaterial.cxx:36
 TMaterial.cxx:37
 TMaterial.cxx:38
 TMaterial.cxx:39
 TMaterial.cxx:40
 TMaterial.cxx:41
 TMaterial.cxx:42
 TMaterial.cxx:43
 TMaterial.cxx:44
 TMaterial.cxx:45
 TMaterial.cxx:46
 TMaterial.cxx:47
 TMaterial.cxx:48
 TMaterial.cxx:49
 TMaterial.cxx:50
 TMaterial.cxx:51
 TMaterial.cxx:52
 TMaterial.cxx:53
 TMaterial.cxx:54
 TMaterial.cxx:55
 TMaterial.cxx:56
 TMaterial.cxx:57
 TMaterial.cxx:58
 TMaterial.cxx:59
 TMaterial.cxx:60
 TMaterial.cxx:61
 TMaterial.cxx:62
 TMaterial.cxx:63
 TMaterial.cxx:64
 TMaterial.cxx:65
 TMaterial.cxx:66
 TMaterial.cxx:67
 TMaterial.cxx:68
 TMaterial.cxx:69
 TMaterial.cxx:70
 TMaterial.cxx:71
 TMaterial.cxx:72
 TMaterial.cxx:73
 TMaterial.cxx:74
 TMaterial.cxx:75
 TMaterial.cxx:76
 TMaterial.cxx:77
 TMaterial.cxx:78
 TMaterial.cxx:79
 TMaterial.cxx:80
 TMaterial.cxx:81
 TMaterial.cxx:82
 TMaterial.cxx:83
 TMaterial.cxx:84
 TMaterial.cxx:85
 TMaterial.cxx:86
 TMaterial.cxx:87
 TMaterial.cxx:88
 TMaterial.cxx:89
 TMaterial.cxx:90
 TMaterial.cxx:91
 TMaterial.cxx:92
 TMaterial.cxx:93
 TMaterial.cxx:94
 TMaterial.cxx:95
 TMaterial.cxx:96
 TMaterial.cxx:97
 TMaterial.cxx:98
 TMaterial.cxx:99
 TMaterial.cxx:100
 TMaterial.cxx:101
 TMaterial.cxx:102
 TMaterial.cxx:103
 TMaterial.cxx:104
 TMaterial.cxx:105
 TMaterial.cxx:106
 TMaterial.cxx:107
 TMaterial.cxx:108
 TMaterial.cxx:109
 TMaterial.cxx:110
 TMaterial.cxx:111
 TMaterial.cxx:112
 TMaterial.cxx:113
 TMaterial.cxx:114