Changeset 3601 in Sophya for trunk/SophyaLib/NTools/tsfunran.cc
- Timestamp:
- Apr 28, 2009, 5:23:19 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaLib/NTools/tsfunran.cc
r3600 r3601 1 1 #include "sopnamsp.h" 2 2 #include "machdefs.h" 3 #include <iostream> 3 4 #include "pexceptions.h" 5 #include "randr48.h" 4 6 #include "tsfunran.h" 5 #include <iostream>6 7 7 8 … … 43 44 */ 44 45 TsFunRan::TsFunRan(TsFunRan::Func f, r_8 xMin, r_8 xMax, int_4 nBin, bool pdf) 45 : Histo(xMin,xMax,nBin) 46 : Histo(xMin,xMax,nBin), rg_(NULL), internal_rg_(false) 46 47 { 47 48 if(nBin<=1) 48 49 throw RangeCheckError("TsFunRan::TsFunRan less than 2 bins requested"); 49 50 for(int_4 i=0;i<nBin;i++) (*this)(i) = f(BinCenter(i)); 50 rg_ = new RandomGenerator(1,false);51 rg_ = new DR48RandGen(); 51 52 create_DF(pdf); 52 53 } … … 57 58 */ 58 59 TsFunRan::TsFunRan(ClassFunc& f, r_8 xMin, r_8 xMax, int_4 nBin, bool pdf) 59 : Histo(xMin,xMax,nBin) 60 : Histo(xMin,xMax,nBin), rg_(NULL), internal_rg_(false) 60 61 { 61 62 if(nBin<=1) 62 63 throw RangeCheckError("TsFunRan::TsFunRan less than 2 bins requested"); 63 64 for(int_4 i=0;i<nBin;i++) (*this)(i) = f(BinCenter(i)); 64 rg_ = new RandomGenerator(1,false);65 rg_ = new DR48RandGen(); 65 66 create_DF(pdf); 66 67 } … … 74 75 */ 75 76 TsFunRan::TsFunRan(r_8 *tab, int_4 nBin, bool pdf) 76 : Histo(-0.5,nBin-0.5,nBin) 77 : Histo(-0.5,nBin-0.5,nBin), rg_(NULL), internal_rg_(false) 77 78 { 78 79 if(nBin<=1) 79 80 throw RangeCheckError("TsFunRan::TsFunRan less than 2 bins requested"); 80 81 for(int_4 i=0;i<nBin;i++) (*this)(i) = tab[i]; 81 rg_ = new RandomGenerator(1,false);82 rg_ = new DR48RandGen(); 82 83 create_DF(pdf); 83 84 } … … 92 93 */ 93 94 TsFunRan::TsFunRan(r_8 *tab, int_4 nBin, r_8 xMin, r_8 xMax, bool pdf) 94 : Histo(xMin,xMax,nBin) 95 : Histo(xMin,xMax,nBin), rg_(NULL), internal_rg_(false) 95 96 { 96 97 if(nBin<=1) 97 98 throw RangeCheckError("TsFunRan::TsFunRan less than 2 bins requested"); 98 99 for(int_4 i=0;i<nBin;i++) (*this)(i) = tab[i]; 99 rg_ = new RandomGenerator(1,false);100 rg_ = new DR48RandGen(); 100 101 create_DF(pdf); 101 102 } … … 105 106 */ 106 107 TsFunRan::TsFunRan(TVector<r_8>& tab, int_4 nBin, bool pdf) 107 : Histo(-0.5,nBin-0.5,nBin) 108 : Histo(-0.5,nBin-0.5,nBin), rg_(NULL), internal_rg_(false) 108 109 { 109 110 if(nBin<=1) 110 111 throw RangeCheckError("TsFunRan::TsFunRan less than 2 bins requested"); 111 112 for(int_4 i=0;i<nBin;i++) (*this)(i) = tab(i); 112 rg_ = new RandomGenerator(1,false);113 rg_ = new DR48RandGen(); 113 114 create_DF(pdf); 114 115 } … … 118 119 */ 119 120 TsFunRan::TsFunRan(TVector<r_8>& tab, int_4 nBin, r_8 xMin, r_8 xMax, bool pdf) 120 : Histo(xMin,xMax,nBin) 121 : Histo(xMin,xMax,nBin), rg_(NULL), internal_rg_(false) 121 122 { 122 123 if(nBin<=1) 123 124 throw RangeCheckError("TsFunRan::TsFunRan less than 2 bins requested"); 124 125 for(int_4 i=0;i<nBin;i++) (*this)(i) = tab(i); 125 rg_ = new RandomGenerator(1,false);126 rg_ = new DR48RandGen(); 126 127 create_DF(pdf); 127 128 } … … 134 135 */ 135 136 TsFunRan::TsFunRan(Histo &h, bool pdf) 136 : Histo(h) 137 : Histo(h), rg_(NULL), internal_rg_(false) 137 138 { 138 139 if(mBins<=1) 139 140 throw RangeCheckError("TsFunRan::TsFunRan less than 2 bins requested"); 140 rg_ = new RandomGenerator(1,false);141 rg_ = new DR48RandGen(); 141 142 create_DF(pdf); 142 143 } … … 145 146 /*! Creator by copy */ 146 147 TsFunRan::TsFunRan(const TsFunRan& fh) 147 : Histo(fh) 148 { 149 rg_ = new RandomGenerator(*fh.rg_); 148 : Histo(fh), rg_(fh.rg_), internal_rg_(false) 149 { 150 150 } 151 151 … … 153 153 /*! Creator by default */ 154 154 TsFunRan::TsFunRan(void) 155 { 156 rg_ = new RandomGenerator(1,false); 155 : rg_(NULL), internal_rg_(false) 156 { 157 157 } 158 158 … … 160 160 TsFunRan::~TsFunRan(void) 161 161 { 162 if(rg_!=NULL ) delete rg_;162 if(rg_!=NULL && internal_rg_) delete rg_; 163 163 } 164 164 … … 180 180 181 181 /********* Methode *********/ 182 void TsFunRan::SetRandomGenerator(RandomGenerator &rg)183 { 184 if(rg_!=NULL ) delete rg_;185 rg_ = new RandomGenerator(rg);182 void TsFunRan::SetRandomGenerator(RandomGeneratorInterface* rg) 183 { 184 if(rg_!=NULL && internal_rg_) delete rg_; 185 rg_ = rg; 186 186 } 187 187
Note:
See TracChangeset
for help on using the changeset viewer.