Logo ROOT   6.12/07
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 
14 #include "TBuffer.h"
15 #include "TMath.h"
16 
18 
19 /** \class TMixture
20 \ingroup g3d
21 Manages a detector mixture. See class TGeometry.
22 */
23 
24 ////////////////////////////////////////////////////////////////////////////////
25 /// Mixture default constructor.
26 
28 {
29  fAmixt = 0;
30  fZmixt = 0;
31  fWmixt = 0;
32  fNmixt = 0;
33 }
34 
35 ////////////////////////////////////////////////////////////////////////////////
36 /// Mixture normal constructor
37 ///
38 /// Defines mixture OR COMPOUND as composed by
39 /// the basic nmixt materials defined later by DefineElement.
40 ///
41 /// If nmixt > 0 then Wmixt contains the PROPORTION BY WEIGHTS
42 /// of each basic material in the mixture.
43 ///
44 /// If nmixt < 0 then Wmixt contains the number of atoms
45 /// of a given kind into the molecule of the COMPOUND
46 /// In this case, Wmixt is changed to relative weights.
47 ///
48 /// nb : the radiation length is computed according
49 /// the EGS manual slac-210 uc-32 June-78
50 /// formula 2-6-8 (37)
51 
52 TMixture::TMixture(const char *name, const char *title, Int_t nmixt)
53  :TMaterial(name,title,0,0,0)
54 {
55  if (nmixt == 0) {
56  fAmixt = 0;
57  fZmixt = 0;
58  fWmixt = 0;
59  fNmixt = 0;
60  Error("TMixture", "mixture number is 0");
61  return;
62  }
63  Int_t nm = TMath::Abs(nmixt);
64  fNmixt = nmixt;
65  fAmixt = new Float_t[nm];
66  fZmixt = new Float_t[nm];
67  fWmixt = new Float_t[nm];
68 }
69 
70 ////////////////////////////////////////////////////////////////////////////////
71 /// Mixture default destructor.
72 
74 {
75  delete [] fAmixt;
76  delete [] fZmixt;
77  delete [] fWmixt;
78  fAmixt = 0;
79  fZmixt = 0;
80  fWmixt = 0;
81 }
82 
83 ////////////////////////////////////////////////////////////////////////////////
84 /// Define one mixture element.
85 
87 {
88  if (n < 0 || n >= TMath::Abs(fNmixt)) return;
89  fAmixt[n] = a;
90  fZmixt[n] = z;
91  fWmixt[n] = w;
92 }
93 
94 ////////////////////////////////////////////////////////////////////////////////
95 /// Stream a class object.
96 
97 void TMixture::Streamer(TBuffer &b)
98 {
99  UInt_t R__s, R__c;
100  if (b.IsReading()) {
101  b.ReadVersion(&R__s, &R__c);
102  TMaterial::Streamer(b);
103  b >> fNmixt;
104  Int_t nmixt = TMath::Abs(fNmixt);
105  fAmixt = new Float_t[nmixt];
106  fZmixt = new Float_t[nmixt];
107  fWmixt = new Float_t[nmixt];
108  b.ReadArray(fAmixt);
109  b.ReadArray(fZmixt);
110  b.ReadArray(fWmixt);
111  b.CheckByteCount(R__s, R__c, TMixture::IsA());
112  } else {
113  R__c = b.WriteVersion(TMixture::IsA(), kTRUE);
114  TMaterial::Streamer(b);
115  b << fNmixt;
116  Int_t nmixt = TMath::Abs(fNmixt);
117  b.WriteArray(fAmixt, nmixt);
118  b.WriteArray(fZmixt, nmixt);
119  b.WriteArray(fWmixt, nmixt);
120  b.SetByteCount(R__c, kTRUE);
121  }
122 }
Bool_t IsReading() const
Definition: TBuffer.h:83
Manages a detector mixture.
Definition: TMixture.h:27
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:32
int Int_t
Definition: RtypesCore.h:41
virtual UInt_t WriteVersion(const TClass *cl, Bool_t useBcnt=kFALSE)=0
Short_t Abs(Short_t d)
Definition: TMathBase.h:108
TMixture()
Mixture default constructor.
Definition: TMixture.cxx:27
virtual void WriteArray(const Bool_t *b, Int_t n)=0
Manages a detector material.
Definition: TMaterial.h:28
auto * a
Definition: textangle.C:12
unsigned int UInt_t
Definition: RtypesCore.h:42
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition: TObject.cxx:880
Int_t fNmixt
Definition: TMixture.h:29
virtual void SetByteCount(UInt_t cntpos, Bool_t packInVersion=kFALSE)=0
static constexpr double nm
Float_t * fAmixt
Definition: TMixture.h:30
#define ClassImp(name)
Definition: Rtypes.h:359
Float_t * fZmixt
Definition: TMixture.h:31
virtual void DefineElement(Int_t n, Float_t a, Float_t z, Float_t w)
Define one mixture element.
Definition: TMixture.cxx:86
you should not use this method at all Int_t Int_t z
Definition: TRolke.cxx:630
virtual ~TMixture()
Mixture default destructor.
Definition: TMixture.cxx:73
you should not use this method at all Int_t Int_t Double_t Double_t Double_t Int_t Double_t Double_t Double_t Double_t b
Definition: TRolke.cxx:630
const Bool_t kTRUE
Definition: RtypesCore.h:87
const Int_t n
Definition: legend1.C:16
char name[80]
Definition: TGX11.cxx:109
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