00001
00002
00003
00004
00005
00006
00007
00008
00009
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
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;
00056 Int_t fN;
00057 Int_t fNisotopes;
00058 Double_t fA;
00059 TObjArray *fIsotopes;
00060 Double_t *fAbundances;
00061
00062 private:
00063 TGeoElement(const TGeoElement &other);
00064 TGeoElement &operator=(const TGeoElement &other);
00065
00066 public:
00067
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
00073 virtual ~TGeoElement() {;}
00074
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)
00095 };
00096
00097
00098
00099
00100
00101
00102
00103
00104 class TGeoIsotope : public TNamed
00105 {
00106 protected:
00107 Int_t fZ;
00108 Int_t fN;
00109 Double_t fA;
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)
00123 };
00124
00125
00126
00127
00128
00129
00130
00131 class TGeoDecayChannel;
00132 class TGeoBatemanSol;
00133
00134 class TGeoElementRN : public TGeoElement
00135 {
00136 protected:
00137 Int_t fENDFcode;
00138 Int_t fIso;
00139 Double_t fLevel;
00140 Double_t fDeltaM;
00141 Double_t fHalfLife;
00142 Double_t fNatAbun;
00143
00144 Double_t fTH_F;
00145 Double_t fTG_F;
00146 Double_t fTH_S;
00147 Double_t fTG_S;
00148 Int_t fStatus;
00149 TGeoBatemanSol *fRatio;
00150
00151 TObjArray *fDecays;
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
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
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)
00203 };
00204
00205
00206
00207
00208
00209
00210
00211 class TGeoDecayChannel : public TObject
00212 {
00213 private:
00214 UInt_t fDecay;
00215 Int_t fDiso;
00216 Double_t fBranchingRatio;
00217 Double_t fQvalue;
00218 TGeoElementRN *fParent;
00219 TGeoElementRN *fDaughter;
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
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
00259 void SetParent(TGeoElementRN *parent) {fParent = parent;}
00260 void SetDaughter(TGeoElementRN *daughter) {fDaughter = daughter;}
00261
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)
00268 };
00269
00270
00271
00272
00273
00274
00275
00276 class TGeoBatemanSol : public TObject, public TAttLine, public TAttFill, public TAttMarker
00277 {
00278 private:
00279 typedef struct {
00280 Double_t cn;
00281 Double_t lambda;
00282 } BtCoef_t;
00283 TGeoElementRN *fElem;
00284 TGeoElementRN *fElemTop;
00285 Int_t fCsize;
00286 Int_t fNcoeff;
00287 Double_t fFactor;
00288 Double_t fTmin;
00289 Double_t fTmax;
00290 BtCoef_t *fCoeff;
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)
00315 };
00316
00317
00318
00319
00320
00321
00322
00323 class TGeoElemIter
00324 {
00325 private:
00326 const TGeoElementRN *fTop;
00327 const TGeoElementRN *fElem;
00328 TObjArray *fBranch;
00329 Int_t fLevel;
00330 Double_t fLimitRatio;
00331 Double_t fRatio;
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)
00356 };
00357
00358
00359
00360
00361
00362
00363
00364 class TGeoElementTable : public TObject
00365 {
00366 private:
00367
00368 Int_t fNelements;
00369 Int_t fNelementsRN;
00370 Int_t fNisotopes;
00371 TObjArray *fList;
00372 TObjArray *fListRN;
00373 TObjArray *fIsotopes;
00374
00375 typedef std::map<Int_t, TGeoElementRN *> ElementRNMap_t;
00376 typedef ElementRNMap_t::iterator ElementRNMapIt_t;
00377 ElementRNMap_t fElementsRN;
00378
00379 protected:
00380 TGeoElementTable(const TGeoElementTable&);
00381 TGeoElementTable& operator=(const TGeoElementTable&);
00382
00383 public:
00384
00385 TGeoElementTable();
00386 TGeoElementTable(Int_t nelements);
00387
00388 virtual ~TGeoElementTable();
00389
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)
00416 };
00417
00418 #endif
00419