Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
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 = nullptr;
30 fZmixt = nullptr;
31 fWmixt = nullptr;
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 = nullptr;
57 fZmixt = nullptr;
58 fWmixt = nullptr;
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 = nullptr;
79 fZmixt = nullptr;
80 fWmixt = nullptr;
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
98{
99 UInt_t R__s, R__c;
100 if (b.IsReading()) {
101 b.ReadVersion(&R__s, &R__c);
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);
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
#define a(i)
Definition RSha256.hxx:99
float Float_t
Definition RtypesCore.h:57
constexpr Bool_t kTRUE
Definition RtypesCore.h:93
#define ClassImp(name)
Definition Rtypes.h:382
char name[80]
Definition TGX11.cxx:110
Buffer base class used for serializing objects.
Definition TBuffer.h:43
Manages a detector material.
Definition TMaterial.h:28
void Streamer(TBuffer &) override
Stream an object of class TMaterial.
Definition TMaterial.cxx:81
Manages a detector mixture.
Definition TMixture.h:27
Int_t fNmixt
Definition TMixture.h:29
~TMixture() override
Mixture default destructor.
Definition TMixture.cxx:73
void Streamer(TBuffer &) override
Stream a class object.
Definition TMixture.cxx:97
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
TClass * IsA() const override
Definition TMixture.h:45
TMixture()
Mixture default constructor.
Definition TMixture.cxx:27
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition TObject.cxx:993
const Int_t n
Definition legend1.C:16
Short_t Abs(Short_t d)
Returns the absolute value of parameter Short_t d.
Definition TMathBase.h:123