TGeoElement.h

Go to the documentation of this file.
00001 // @(#)root/geom:$Id: TGeoElement.h 33465 2010-05-11 09:58:19Z agheata $
00002 // Author: Andrei Gheata   17/06/04
00003 // Added support for radionuclides: Mihaela Gheata 24/08/2006
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 #ifndef ROOT_TGeoElement
00013 #define ROOT_TGeoElement
00014 
00015 #ifndef ROOT_TNamed
00016 #include "TNamed.h"
00017 #endif
00018 
00019 #ifndef ROOT_TAttLine
00020 #include "TAttLine.h"
00021 #endif
00022 
00023 #ifndef ROOT_TAttFill
00024 #include "TAttFill.h"
00025 #endif
00026 
00027 #ifndef ROOT_TAttMarker
00028 #include "TAttMarker.h"
00029 #endif
00030 
00031 #ifndef ROOT_TObjArray
00032 #include "TObjArray.h"
00033 #endif
00034 
00035 #include <map>
00036 
00037 class TGeoElementTable;
00038 class TGeoIsotope;
00039 
00040 ////////////////////////////////////////////////////////////////////////////
00041 //                                                                        //
00042 // TGeoElement - a chemical element                                       //
00043 //                                                                        //
00044 ////////////////////////////////////////////////////////////////////////////
00045 
00046 class TGeoElement : public TNamed
00047 {
00048 protected:
00049    enum EGeoElement {
00050       kElemUsed    =   BIT(17),
00051       kElemDefined =   BIT(18),
00052       kElementChecked = BIT(19)
00053    };
00054 
00055    Int_t                    fZ;          // Z of element
00056    Int_t                    fN;          // Number of nucleons
00057    Int_t                    fNisotopes;  // Number of isotopes for the element
00058    Double_t                 fA;          // A of element
00059    TObjArray               *fIsotopes;   // List of isotopes
00060    Double_t                *fAbundances; //[fNisotopes] Array of relative isotope abundances
00061 
00062 private:
00063   TGeoElement(const TGeoElement &other);
00064   TGeoElement &operator=(const TGeoElement &other);
00065 
00066 public:
00067    // constructors
00068    TGeoElement();
00069    TGeoElement(const char *name, const char *title, Int_t z, Double_t a);
00070    TGeoElement(const char *name, const char *title, Int_t nisotopes);
00071    TGeoElement(const char *name, const char *title, Int_t z, Int_t n, Double_t a);
00072    // destructor
00073    virtual ~TGeoElement()             {;}
00074    // methods
00075    virtual Int_t            ENDFCode()    const { return 0;}
00076    Int_t                    Z() const {return fZ;}
00077    Int_t                    N() const {return fN;}
00078    Double_t                 Neff() const;
00079    Double_t                 A() const {return fA;}
00080    void                     AddIsotope(TGeoIsotope *isotope, Double_t relativeAbundance);
00081    Int_t                    GetNisotopes() const {return fNisotopes;}
00082    TGeoIsotope             *GetIsotope(Int_t i) const;
00083    Double_t                 GetRelativeAbundance(Int_t i) const;
00084    Bool_t                   HasIsotopes() const {return (fNisotopes==0)?kFALSE:kTRUE;}
00085    Bool_t                   IsDefined() const {return TObject::TestBit(kElemDefined);}   
00086    virtual Bool_t           IsRadioNuclide() const {return kFALSE;}
00087    Bool_t                   IsUsed() const {return TObject::TestBit(kElemUsed);}
00088    virtual void             Print(Option_t *option = "") const;
00089    void                     SetDefined(Bool_t flag=kTRUE) {TObject::SetBit(kElemDefined,flag);}                    
00090    void                     SetUsed(Bool_t flag=kTRUE) {TObject::SetBit(kElemUsed,flag);}                    
00091    static TGeoElementTable *GetElementTable();
00092    
00093 
00094    ClassDef(TGeoElement, 2)              // base element class
00095 };
00096 
00097 ////////////////////////////////////////////////////////////////////////////
00098 //                                                                        //
00099 // TGeoIsotope - a isotope defined by the atomic number, number of        //
00100 // nucleons and atomic weight (g/mole)                                    //
00101 //                                                                        //
00102 ////////////////////////////////////////////////////////////////////////////
00103 
00104 class TGeoIsotope : public TNamed
00105 {
00106 protected:
00107    Int_t                    fZ;           // atomic number
00108    Int_t                    fN;           // number of nucleons
00109    Double_t                 fA;           // atomic mass (g/mole)
00110 
00111 public:
00112    TGeoIsotope();
00113    TGeoIsotope(const char *name, Int_t z, Int_t n, Double_t a);
00114    virtual ~TGeoIsotope() {}
00115    
00116    Int_t                    GetZ() const {return fZ;}
00117    Int_t                    GetN() const {return fN;}
00118    Double_t                 GetA() const {return fA;}
00119    static TGeoIsotope      *FindIsotope(const char *name);
00120    virtual void             Print(Option_t *option = "") const;
00121 
00122    ClassDef(TGeoIsotope, 1)              // Isotope class defined by Z,N,A
00123 };   
00124 
00125 ////////////////////////////////////////////////////////////////////////////
00126 //                                                                        //
00127 // TGeoElementRN - a radionuclide.                                        //
00128 //                                                                        //
00129 ////////////////////////////////////////////////////////////////////////////
00130 
00131 class TGeoDecayChannel;
00132 class TGeoBatemanSol;
00133 
00134 class TGeoElementRN : public TGeoElement
00135 {
00136 protected:
00137    Int_t                    fENDFcode; // ENDF element code
00138    Int_t                    fIso;      // Isomer number
00139    Double_t                 fLevel;    // Isomeric level
00140    Double_t                 fDeltaM;   // Mass excess
00141    Double_t                 fHalfLife; // Half life
00142    Double_t                 fNatAbun;  // Natural Abundance
00143 //   char                     fJP[11];   // Spin-parity
00144    Double_t                 fTH_F;     // Hynalation toxicity
00145    Double_t                 fTG_F;     // Ingestion toxicity
00146    Double_t                 fTH_S;     // Hynalation toxicity
00147    Double_t                 fTG_S;     // Ingestion toxicity
00148    Int_t                    fStatus;   // Status code
00149    TGeoBatemanSol          *fRatio;    // Time evolution of proportion by number
00150 
00151    TObjArray               *fDecays;   // List of decay modes
00152    
00153    void                     MakeName(Int_t a, Int_t z, Int_t iso);
00154 
00155 private:
00156    TGeoElementRN(const TGeoElementRN& elem); 
00157    TGeoElementRN& operator=(const TGeoElementRN& elem); 
00158 
00159 public:
00160    TGeoElementRN();
00161    TGeoElementRN(Int_t A, Int_t Z, Int_t iso, Double_t level, 
00162          Double_t deltaM, Double_t halfLife, const char* JP,
00163          Double_t natAbun, Double_t th_f, Double_t tg_f, Double_t th_s,
00164          Double_t tg_s, Int_t status); 
00165    virtual ~TGeoElementRN();
00166 
00167    void                     AddDecay(Int_t decay, Int_t diso, Double_t branchingRatio, Double_t qValue);
00168    void                     AddDecay(TGeoDecayChannel *dc);
00169    void                     AddRatio(TGeoBatemanSol &ratio);
00170    void                     ResetRatio();
00171    static Int_t             ENDF(Int_t a, Int_t z, Int_t iso) {return 10000*z+10*a+iso;}
00172 
00173    // Getters
00174    virtual Int_t            ENDFCode()    const {return fENDFcode;}
00175    virtual Bool_t           IsRadioNuclide() const {return kTRUE;}
00176    Int_t                    MassNo()      const {return (Int_t)fA;}
00177    Int_t                    AtomicNo()    const {return fZ;}
00178    Int_t                    IsoNo()       const {return fIso;}
00179    Double_t                 Level()       const {return fLevel;}    
00180    Double_t                 MassEx()      const {return fDeltaM;}   
00181    Double_t                 HalfLife()    const {return fHalfLife;}
00182    Double_t                 NatAbun()     const {return fNatAbun;}  
00183    const char*              PJ()          const {return fTitle.Data();}   
00184    Double_t                 TH_F()        const {return fTH_F;}     
00185    Double_t                 TG_F()        const {return fTG_F;}     
00186    Double_t                 TH_S()        const {return fTH_S;}     
00187    Double_t                 TG_S()        const {return fTG_S;}     
00188    Double_t                 Status()      const {return fStatus;}
00189    Bool_t                   Stable()      const {return !fDecays;}
00190    TObjArray               *Decays()      const {return fDecays;}
00191    Int_t                    GetNdecays()  const;
00192    TGeoBatemanSol          *Ratio()       const {return fRatio;}
00193 
00194    // Utilities
00195    Bool_t                   CheckDecays() const;
00196    Int_t                    DecayResult(TGeoDecayChannel *dc) const;
00197    void                     FillPopulation(TObjArray *population, Double_t precision=0.001, Double_t factor=1.);
00198    virtual void             Print(Option_t *option = "") const;
00199    static TGeoElementRN    *ReadElementRN(const char *record, Int_t &ndecays);
00200    virtual void             SavePrimitive(ostream &out, Option_t *option = "");
00201   
00202    ClassDef(TGeoElementRN, 2)           // radionuclides class
00203 };
00204 
00205 ////////////////////////////////////////////////////////////////////////////
00206 //                                                                        //
00207 // TGeoDecayChannel - decay channel utility class.                        //
00208 //                                                                        //
00209 ////////////////////////////////////////////////////////////////////////////
00210 
00211 class TGeoDecayChannel : public TObject
00212 {
00213 private:
00214    UInt_t                   fDecay;          // Decay mode
00215    Int_t                    fDiso;           // Delta isomeric number
00216    Double_t                 fBranchingRatio; // Branching Ratio
00217    Double_t                 fQvalue;         // Qvalue in GeV
00218    TGeoElementRN           *fParent;         // Parent element
00219    TGeoElementRN           *fDaughter;       // Daughter element
00220 public:
00221    enum ENuclearDecayMode {
00222       kBitMask32  = 0xffffffff,
00223       k2BetaMinus   = BIT(0),
00224       kBetaMinus    = BIT(1),
00225       kNeutronEm    = BIT(2), 
00226       kProtonEm     = BIT(3),
00227       kAlpha        = BIT(4),
00228       kECF          = BIT(5),
00229       kElecCapt     = BIT(6),
00230       kIsoTrans     = BIT(7),
00231       kI            = BIT(8),
00232       kSpontFiss    = BIT(9),
00233       k2P           = BIT(10),
00234       k2N           = BIT(11),
00235       k2A           = BIT(12),
00236       kCarbon12     = BIT(13),
00237       kCarbon14     = BIT(14)
00238    };
00239    TGeoDecayChannel() : fDecay(0), fDiso(0), fBranchingRatio(0), fQvalue(0), fParent(0), fDaughter(0) {}
00240    TGeoDecayChannel(Int_t decay, Int_t diso, Double_t branchingRatio, Double_t qValue)
00241                   : fDecay(decay), fDiso(diso), fBranchingRatio(branchingRatio), fQvalue(qValue), fParent(0), fDaughter(0) {}
00242    TGeoDecayChannel(const TGeoDecayChannel &dc) : TObject(dc),fDecay(dc.fDecay),fDiso(dc.fDiso),fBranchingRatio(dc.fBranchingRatio),
00243                                                   fQvalue(dc.fQvalue),fParent(dc.fParent),fDaughter(dc.fDaughter) {}
00244    virtual ~TGeoDecayChannel() {}
00245 
00246    TGeoDecayChannel& operator=(const TGeoDecayChannel& dc);
00247 
00248    // Getters
00249    Int_t                    GetIndex()       const;
00250    virtual const char      *GetName()        const;
00251    UInt_t                   Decay()          const {return fDecay;}
00252    Double_t                 BranchingRatio() const {return fBranchingRatio;}
00253    Double_t                 Qvalue()         const {return fQvalue;}
00254    Int_t                    DeltaIso()       const {return fDiso;}
00255    TGeoElementRN           *Daughter()       const {return fDaughter;}
00256    TGeoElementRN           *Parent()         const {return fParent;}
00257    static void              DecayName(UInt_t decay, TString &name);
00258    // Setters
00259    void                     SetParent(TGeoElementRN *parent) {fParent = parent;}
00260    void                     SetDaughter(TGeoElementRN *daughter) {fDaughter = daughter;}
00261    // Services
00262    virtual void             Print(Option_t *opt = " ") const;
00263    static TGeoDecayChannel *ReadDecay(const char *record);
00264    virtual void             SavePrimitive(ostream &out, Option_t *option = "");
00265    virtual void             DecayShift(Int_t &dA, Int_t &dZ, Int_t &dI) const ;
00266 
00267    ClassDef(TGeoDecayChannel,1)    // Decay channel for Elements
00268 };
00269 
00270 ////////////////////////////////////////////////////////////////////////////////
00271 //                                                                            //
00272 // TGeoBatemanSol -Class representing the Bateman solution for a decay branch //
00273 //                                                                            //
00274 ////////////////////////////////////////////////////////////////////////////////
00275 
00276 class TGeoBatemanSol : public TObject, public TAttLine, public TAttFill, public TAttMarker
00277 {
00278 private:
00279    typedef struct {
00280       Double_t   cn;     // Concentration for element 'i': Ni/Ntop
00281       Double_t   lambda; // Decay coef. for element 'i'
00282    } BtCoef_t;     
00283    TGeoElementRN           *fElem;            // Referred RN element
00284    TGeoElementRN           *fElemTop;         // Top RN element
00285    Int_t                    fCsize;           // Size of the array of coefficients
00286    Int_t                    fNcoeff;          // Number of coefficients
00287    Double_t                 fFactor;          // Constant factor that applies to all coefficients
00288    Double_t                 fTmin;            // Minimum value of the time interval
00289    Double_t                 fTmax;            // Maximum value of the time interval
00290    BtCoef_t                *fCoeff;           //[fNcoeff] Array of coefficients
00291 public:
00292    TGeoBatemanSol() : TObject(), TAttLine(), TAttFill(), TAttMarker(), fElem(NULL), fElemTop(NULL), fCsize(0), fNcoeff(0), fFactor(1.), fTmin(0.), fTmax(0), fCoeff(NULL) {}
00293    TGeoBatemanSol(TGeoElementRN *elem);
00294    TGeoBatemanSol(const TObjArray *chain);
00295    TGeoBatemanSol(const TGeoBatemanSol& other);
00296    ~TGeoBatemanSol();
00297 
00298    TGeoBatemanSol& operator=(const TGeoBatemanSol& other);
00299    TGeoBatemanSol& operator+=(const TGeoBatemanSol& other);
00300    
00301    Double_t                 Concentration(Double_t time) const;
00302    virtual void             Draw(Option_t *option="");
00303    void                     GetCoeff(Int_t i, Double_t &cn, Double_t &lambda) const {cn=fCoeff[i].cn; lambda=fCoeff[i].lambda;}
00304    void                     GetRange(Double_t &tmin, Double_t &tmax) const {tmin=fTmin; tmax=fTmax;}
00305    TGeoElementRN           *GetElement()    const {return fElem;}
00306    TGeoElementRN           *GetTopElement() const {return fElemTop;}
00307    Int_t                    GetNcoeff()     const  {return fNcoeff;}
00308    virtual void             Print(Option_t *option = "") const;
00309    void                     SetRange(Double_t tmin=0., Double_t tmax=0.) {fTmin=tmin; fTmax=tmax;}
00310    void                     SetFactor(Double_t factor) {fFactor = factor;}
00311    void                     FindSolution(const TObjArray *array);
00312    void                     Normalize(Double_t factor);
00313 
00314    ClassDef(TGeoBatemanSol,1)       // Solution for the Bateman equation
00315 };   
00316    
00317 ////////////////////////////////////////////////////////////////////////////
00318 //                                                                        //
00319 // TGeoElemIter - iterator for decay chains.                              //
00320 //                                                                        //
00321 ////////////////////////////////////////////////////////////////////////////
00322 
00323 class TGeoElemIter
00324 {
00325 private:
00326    const TGeoElementRN     *fTop;            // Top element of the iteration
00327    const TGeoElementRN     *fElem;           // Current element
00328    TObjArray               *fBranch;         // Current branch
00329    Int_t                    fLevel;          // Current level
00330    Double_t                 fLimitRatio;     // Minimum cumulative branching ratio
00331    Double_t                 fRatio;          // Current ratio
00332 
00333 protected:
00334    TGeoElemIter() : fTop(0), fElem(0), fBranch(0), fLevel(0), fLimitRatio(0), fRatio(0) {}
00335    TGeoElementRN           *Down(Int_t ibranch);
00336    TGeoElementRN           *Up();
00337 
00338 public:
00339    TGeoElemIter(TGeoElementRN *top, Double_t limit=1.e-4);
00340    TGeoElemIter(const TGeoElemIter &iter); 
00341    virtual ~TGeoElemIter();
00342    
00343    TGeoElemIter   &operator=(const TGeoElemIter &iter);
00344    TGeoElementRN  *operator()();
00345    TGeoElementRN           *Next();
00346 
00347    TObjArray               *GetBranch() const              {return fBranch;}
00348    const TGeoElementRN     *GetTop() const                 {return fTop;}
00349    const TGeoElementRN     *GetElement() const             {return fElem;}
00350    Int_t                    GetLevel() const               {return fLevel;}
00351    Double_t                 GetRatio() const               {return fRatio;}
00352    virtual void             Print(Option_t *option="") const;
00353    void                     SetLimitRatio(Double_t limit)  {fLimitRatio = limit;}
00354    
00355    ClassDef(TGeoElemIter,0)    // Iterator for radionuclide chains.
00356 };
00357 
00358 ////////////////////////////////////////////////////////////////////////////
00359 //                                                                        //
00360 // TGeoElementTable - table of elements                                   //
00361 //                                                                        //
00362 ////////////////////////////////////////////////////////////////////////////
00363 
00364 class TGeoElementTable : public TObject
00365 {
00366 private:
00367 // data members
00368    Int_t                    fNelements;    // number of elements
00369    Int_t                    fNelementsRN;  // number of RN elements
00370    Int_t                    fNisotopes;    // number of isotopes
00371    TObjArray               *fList;         // list of elements
00372    TObjArray               *fListRN;       // list of RN elements
00373    TObjArray               *fIsotopes;     // list of user-defined isotopes
00374    // Map of radionuclides
00375    typedef std::map<Int_t, TGeoElementRN *>   ElementRNMap_t;
00376    typedef ElementRNMap_t::iterator           ElementRNMapIt_t;
00377    ElementRNMap_t           fElementsRN; //! map of RN elements with ENDF key
00378 
00379 protected:
00380    TGeoElementTable(const TGeoElementTable&); 
00381    TGeoElementTable& operator=(const TGeoElementTable&); 
00382 
00383 public:
00384    // constructors
00385    TGeoElementTable();
00386    TGeoElementTable(Int_t nelements);
00387    // destructor
00388    virtual ~TGeoElementTable();
00389    // methods
00390 
00391    enum EGeoETStatus {
00392       kETDefaultElements = BIT(14),
00393       kETRNElements      = BIT(15)
00394    };      
00395    void                     AddElement(const char *name, const char *title, Int_t z, Double_t a);
00396    void                     AddElement(const char *name, const char *title, Int_t z, Int_t n, Double_t a);
00397    void                     AddElementRN(TGeoElementRN *elem);
00398    void                     AddIsotope(TGeoIsotope *isotope);
00399    void                     BuildDefaultElements();
00400    void                     ImportElementsRN();
00401    Bool_t                   CheckTable() const;
00402    TGeoElement             *FindElement(const char *name) const;
00403    TGeoIsotope             *FindIsotope(const char *name) const;
00404    TGeoElement             *GetElement(Int_t z) {return (TGeoElement*)fList->At(z);}
00405    TGeoElementRN           *GetElementRN(Int_t ENDFcode) const;
00406    TGeoElementRN           *GetElementRN(Int_t a, Int_t z, Int_t iso=0) const;
00407    TObjArray               *GetElementsRN() const {return fListRN;}
00408    Bool_t                   HasDefaultElements() const {return TObject::TestBit(kETDefaultElements);}
00409    Bool_t                   HasRNElements() const {return TObject::TestBit(kETRNElements);}
00410 
00411    Int_t                    GetNelements() const {return fNelements;}
00412    Int_t                    GetNelementsRN() const {return fNelementsRN;}
00413    void                     ExportElementsRN(const char *filename="");
00414 
00415    ClassDef(TGeoElementTable,4)              // table of elements
00416 };
00417 
00418 #endif
00419 

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