TMixture.cxx

Go to the documentation of this file.
00001 // @(#)root/g3d:$Id: TMixture.cxx 31811 2009-12-10 15:45:31Z couet $
00002 // Author: Rene Brun   03/10/95
00003 
00004 /*************************************************************************
00005  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers.               *
00006  * All rights reserved.                                                  *
00007  *                                                                       *
00008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
00009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
00010  *************************************************************************/
00011 
00012 #include "TMixture.h"
00013 #include "TMath.h"
00014 
00015 ClassImp(TMixture)
00016 
00017 //______________________________________________________________________________
00018 //
00019 // Manages a detector mixture. See class TGeometry.
00020 //
00021 
00022 
00023 //______________________________________________________________________________
00024 TMixture::TMixture()
00025 {
00026    // Mixture default constructor.
00027 
00028    fAmixt = 0;
00029    fZmixt = 0;
00030    fWmixt = 0;
00031    fNmixt = 0;
00032 }
00033 
00034 
00035 //______________________________________________________________________________
00036 TMixture::TMixture(const char *name, const char *title, Int_t nmixt)
00037            :TMaterial(name,title,0,0,0)
00038 {
00039    // Mixture normal constructor
00040    //
00041    //       Defines mixture OR COMPOUND as composed by
00042    //       the basic nmixt materials defined later by DefineElement.
00043    //
00044    //       If nmixt > 0 then Wmixt contains the PROPORTION BY WEIGHTS
00045    //       of each basic material in the mixture.
00046    //
00047    //       If nmixt < 0 then Wmixt contains the number of atoms
00048    //       of a given kind into the molecule of the COMPOUND
00049    //       In this case, Wmixt is changed to relative weights.
00050    //
00051    //       nb : the radiation length is computed according
00052    //            the EGS manual slac-210 uc-32 June-78
00053    //                          formula  2-6-8 (37)
00054 
00055    if (nmixt == 0) {
00056       fAmixt = 0;
00057       fZmixt = 0;
00058       fWmixt = 0;
00059       fNmixt = 0;
00060       Error("TMixture", "mixture number is 0");
00061       return;
00062    }
00063    Int_t nm = TMath::Abs(nmixt);
00064    fNmixt   = nmixt;
00065    fAmixt   = new Float_t[nm];
00066    fZmixt   = new Float_t[nm];
00067    fWmixt   = new Float_t[nm];
00068 }
00069 
00070 
00071 //______________________________________________________________________________
00072 TMixture::~TMixture()
00073 {
00074    // Mixture default destructor.
00075 
00076    delete [] fAmixt;
00077    delete [] fZmixt;
00078    delete [] fWmixt;
00079    fAmixt = 0;
00080    fZmixt = 0;
00081    fWmixt = 0;
00082 }
00083 
00084 
00085 //______________________________________________________________________________
00086 void TMixture::DefineElement(Int_t n, Float_t a, Float_t z, Float_t w)
00087 {
00088    // Define one mixture element.
00089 
00090    if (n < 0 || n >= TMath::Abs(fNmixt)) return;
00091    fAmixt[n] = a;
00092    fZmixt[n] = z;
00093    fWmixt[n] = w;
00094 }
00095 
00096 
00097 //______________________________________________________________________________
00098 void TMixture::Streamer(TBuffer &b)
00099 {
00100    // Stream a class object.
00101 
00102    UInt_t R__s, R__c;
00103    if (b.IsReading()) {
00104       b.ReadVersion(&R__s, &R__c);
00105       TMaterial::Streamer(b);
00106       b >> fNmixt;
00107       Int_t nmixt = TMath::Abs(fNmixt);
00108       fAmixt   = new Float_t[nmixt];
00109       fZmixt   = new Float_t[nmixt];
00110       fWmixt   = new Float_t[nmixt];
00111       b.ReadArray(fAmixt);
00112       b.ReadArray(fZmixt);
00113       b.ReadArray(fWmixt);
00114       b.CheckByteCount(R__s, R__c, TMixture::IsA());
00115    } else {
00116       R__c = b.WriteVersion(TMixture::IsA(), kTRUE);
00117       TMaterial::Streamer(b);
00118       b << fNmixt;
00119       Int_t nmixt = TMath::Abs(fNmixt);
00120       b.WriteArray(fAmixt, nmixt);
00121       b.WriteArray(fZmixt, nmixt);
00122       b.WriteArray(fWmixt, nmixt);
00123       b.SetByteCount(R__c, kTRUE);
00124    }
00125 }

Generated on Tue Jul 5 14:16:40 2011 for ROOT_528-00b_version by  doxygen 1.5.1