Changeset 2608 in Sophya for trunk/SophyaLib/HiStats/histerr.cc
- Timestamp:
- Sep 7, 2004, 12:50:35 PM (21 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaLib/HiStats/histerr.cc
r2604 r2608 23 23 /*! Constructeur d'un histo de nBin bins allant de xMin a xMax */ 24 24 HistoErr::HistoErr(r_8 xMin, r_8 xMax, int_4 nBin) 25 : Histo(xMin,xMax,nBin), mNData( (nBin>0) ? new uint_4[nBin] :NULL)25 : Histo(xMin,xMax,nBin), mNData(NULL) 26 26 { 27 27 this->Errors(); 28 if(mNData) memset(mNData,0,mBins*sizeof(uint_4)); 28 allocate_mNData(nBin); 29 Zero(); 29 30 } 30 31 … … 32 33 /*! Constructeur par copie */ 33 34 HistoErr::HistoErr(const HistoErr& H) 34 : Histo(H), mNData((H.mBins>0)? new uint_4[H.mBins] : NULL) 35 { 35 : Histo(H), mNData(NULL) 36 { 37 allocate_mNData(H.mBins); 36 38 if(mBins>0) memcpy(mNData,H.mNData,mBins*sizeof(uint_4)); 37 39 } … … 42 44 { 43 45 if(mNData) {delete [] mNData; mNData=NULL;} 46 } 47 /********* Methode *********/ 48 /*! Allocation du tableau mNData */ 49 void HistoErr::allocate_mNData(int nbin) 50 { 51 if(nbin<=0) return; 52 if(mNData) {delete [] mNData; mNData=NULL;} 53 mNData = new uint_4[nbin]; 44 54 } 45 55 … … 126 136 } 127 137 138 /********* Methode *********/ 139 /*! 140 Recompute XMin and XMax so that 141 the center of the first bin is exactly xcmin and 142 the center of the last bin is exactly xcmax 143 */ 144 void HistoErr::ReCenterBin(r_8 xcmin,r_8 xcmax) 145 { 146 if(xcmax<=xcmin) return; 147 if(mBins<=1) return; 148 double dx = (mMax-mMin)/(mBins-1); 149 mMin -= dx/2.; 150 mMax += dx/2.; 151 binWidth = (mMax-mMin)/mBins; 152 } 128 153 129 154 /********* Methode *********/ … … 155 180 void ObjFileIO<HistoErr>::ReadSelf(PInPersist& is) 156 181 { 157 char strg[256];182 string strg; 158 183 159 184 if(dobj==NULL) dobj=new HistoErr; … … 161 186 162 187 // Lecture entete 163 is.Get Line(strg, 255);188 is.GetStr(strg); 164 189 165 190 // Lecture des donnees HistoErr 166 191 is.Get(dobj->mBins); 167 is.GetLine(strg, 255);192 dobj->allocate_mNData(dobj->mBins); 168 193 is.Get(dobj->mNData, dobj->mBins); 169 194 … … 178 203 { 179 204 if(dobj == NULL) return; 180 char strg[256];181 182 s printf(strg,"HistErr");183 os.Put Line(strg);205 string strg; 206 207 strg = "HistErr"; 208 os.PutStr(strg); 184 209 185 210 // Ecriture des valeurs … … 187 212 188 213 // Ecriture des donnees HistoErr nombre d entree par bin 189 sprintf(strg,"Tableau du nombre d entree par bin");190 os.PutLine(strg);191 214 os.Put(dobj->mNData, dobj->mBins); 192 215
Note:
See TracChangeset
for help on using the changeset viewer.