ROOT  6.06/09
Reference Guide
TMixture.cxx
Go to the documentation of this file.
1 // @(#)root/g3d:$Id$
2 // Author: Rene Brun 03/10/95
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 #include "TMixture.h"
13 #include "TMath.h"
14 
16 
17 /** \class TMixture
18 \ingroup g3d
19 Manages a detector mixture. See class TGeometry.
20 */
21 
22 ////////////////////////////////////////////////////////////////////////////////
23 /// Mixture default constructor.
24 
26 {
27  fAmixt = 0;
28  fZmixt = 0;
29  fWmixt = 0;
30  fNmixt = 0;
31 }
32 
33 ////////////////////////////////////////////////////////////////////////////////
34 /// Mixture normal constructor
35 ///
36 /// Defines mixture OR COMPOUND as composed by
37 /// the basic nmixt materials defined later by DefineElement.
38 ///
39 /// If nmixt > 0 then Wmixt contains the PROPORTION BY WEIGHTS
40 /// of each basic material in the mixture.
41 ///
42 /// If nmixt < 0 then Wmixt contains the number of atoms
43 /// of a given kind into the molecule of the COMPOUND
44 /// In this case, Wmixt is changed to relative weights.
45 ///
46 /// nb : the radiation length is computed according
47 /// the EGS manual slac-210 uc-32 June-78
48 /// formula 2-6-8 (37)
49 
50 TMixture::TMixture(const char *name, const char *title, Int_t nmixt)
51  :TMaterial(name,title,0,0,0)
52 {
53  if (nmixt == 0) {
54  fAmixt = 0;
55  fZmixt = 0;
56  fWmixt = 0;
57  fNmixt = 0;
58  Error("TMixture", "mixture number is 0");
59  return;
60  }
61  Int_t nm = TMath::Abs(nmixt);
62  fNmixt = nmixt;
63  fAmixt = new Float_t[nm];
64  fZmixt = new Float_t[nm];
65  fWmixt = new Float_t[nm];
66 }
67 
68 ////////////////////////////////////////////////////////////////////////////////
69 /// Mixture default destructor.
70 
72 {
73  delete [] fAmixt;
74  delete [] fZmixt;
75  delete [] fWmixt;
76  fAmixt = 0;
77  fZmixt = 0;
78  fWmixt = 0;
79 }
80 
81 ////////////////////////////////////////////////////////////////////////////////
82 /// Define one mixture element.
83 
85 {
86  if (n < 0 || n >= TMath::Abs(fNmixt)) return;
87  fAmixt[n] = a;
88  fZmixt[n] = z;
89  fWmixt[n] = w;
90 }
91 
92 ////////////////////////////////////////////////////////////////////////////////
93 /// Stream a class object.
94 
95 void TMixture::Streamer(TBuffer &b)
96 {
97  UInt_t R__s, R__c;
98  if (b.IsReading()) {
99  b.ReadVersion(&R__s, &R__c);
100  TMaterial::Streamer(b);
101  b >> fNmixt;
102  Int_t nmixt = TMath::Abs(fNmixt);
103  fAmixt = new Float_t[nmixt];
104  fZmixt = new Float_t[nmixt];
105  fWmixt = new Float_t[nmixt];
106  b.ReadArray(fAmixt);
107  b.ReadArray(fZmixt);
108  b.ReadArray(fWmixt);
109  b.CheckByteCount(R__s, R__c, TMixture::IsA());
110  } else {
111  R__c = b.WriteVersion(TMixture::IsA(), kTRUE);
112  TMaterial::Streamer(b);
113  b << fNmixt;
114  Int_t nmixt = TMath::Abs(fNmixt);
115  b.WriteArray(fAmixt, nmixt);
116  b.WriteArray(fZmixt, nmixt);
117  b.WriteArray(fWmixt, nmixt);
118  b.SetByteCount(R__c, kTRUE);
119  }
120 }
Manages a detector mixture.
Definition: TMixture.h:29
Bool_t IsReading() const
Definition: TBuffer.h:81
float Float_t
Definition: RtypesCore.h:53
Buffer base class used for serializing objects.
Definition: TBuffer.h:40
virtual Int_t CheckByteCount(UInt_t startpos, UInt_t bcnt, const TClass *clss)=0
Float_t * fWmixt
Definition: TMixture.h:34
int Int_t
Definition: RtypesCore.h:41
TArc * a
Definition: textangle.C:12
virtual UInt_t WriteVersion(const TClass *cl, Bool_t useBcnt=kFALSE)=0
Short_t Abs(Short_t d)
Definition: TMathBase.h:110
virtual void WriteArray(const Bool_t *b, Int_t n)=0
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition: TObject.cxx:918
Manages a detector material.
Definition: TMaterial.h:32
TClass * IsA() const
unsigned int UInt_t
Definition: RtypesCore.h:42
Int_t fNmixt
Definition: TMixture.h:31
virtual void SetByteCount(UInt_t cntpos, Bool_t packInVersion=kFALSE)=0
Float_t * fAmixt
Definition: TMixture.h:32
#define ClassImp(name)
Definition: Rtypes.h:279
Float_t * fZmixt
Definition: TMixture.h:33
virtual void DefineElement(Int_t n, Float_t a, Float_t z, Float_t w)
Define one mixture element.
Definition: TMixture.cxx:84
#define name(a, b)
Definition: linkTestLib0.cpp:5
virtual ~TMixture()
Mixture default destructor.
Definition: TMixture.cxx:71
const Bool_t kTRUE
Definition: Rtypes.h:91
const Int_t n
Definition: legend1.C:16
virtual Version_t ReadVersion(UInt_t *start=0, UInt_t *bcnt=0, const TClass *cl=0)=0
virtual Int_t ReadArray(Bool_t *&b)=0