Logo ROOT  
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
21Manages 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
52TMixture::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
97void 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}
#define b(i)
Definition: RSha256.hxx:100
int Int_t
Definition: RtypesCore.h:43
unsigned int UInt_t
Definition: RtypesCore.h:44
float Float_t
Definition: RtypesCore.h:55
const Bool_t kTRUE
Definition: RtypesCore.h:89
#define ClassImp(name)
Definition: Rtypes.h:361
char name[80]
Definition: TGX11.cxx:109
Buffer base class used for serializing objects.
Definition: TBuffer.h:42
Manages a detector material.
Definition: TMaterial.h:28
Manages a detector mixture.
Definition: TMixture.h:27
Int_t fNmixt
Definition: TMixture.h:29
virtual ~TMixture()
Mixture default destructor.
Definition: TMixture.cxx:73
Float_t * fZmixt
Definition: TMixture.h:31
Float_t * fWmixt
Definition: TMixture.h:32
Float_t * fAmixt
Definition: TMixture.h:30
virtual void DefineElement(Int_t n, Float_t a, Float_t z, Float_t w)
Define one mixture element.
Definition: TMixture.cxx:86
TMixture()
Mixture default constructor.
Definition: TMixture.cxx:27
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition: TObject.cxx:891
const Int_t n
Definition: legend1.C:16
static constexpr double nm
Short_t Abs(Short_t d)
Definition: TMathBase.h:120
auto * a
Definition: textangle.C:12