Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
TF1Data_v5.cxx
Go to the documentation of this file.
1 // @(#)root/hist:$Id$
2 // Author: Rene Brun 18/08/95
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 #include "v5/TF1Data.h"
13 
14 #include "TBuffer.h"
15 #include "TH1.h"
16 
17 ClassImp(ROOT::v5::TF1Data);
18 
19 namespace ROOT {
20 
21  namespace v5 {
22 
23 ////////////////////////////////////////////////////////////////////////////////
24 /// F1 default constructor.
25 
26 TF1Data::TF1Data(): ROOT::v5::TFormula(), TAttLine(), TAttFill(), TAttMarker()
27 {
28  fXmin = 0;
29  fXmax = 0;
30  fNpx = 100;
31  fType = 0;
32  fNpfits = 0;
33  fNDF = 0;
34  fNsave = 0;
35  fChisquare = 0;
36  fParErrors = 0;
37  fParMin = 0;
38  fParMax = 0;
39  fSave = 0;
40  fMinimum = -1111;
41  fMaximum = -1111;
42  SetFillStyle(0);
43 }
44 
45 ////////////////////////////////////////////////////////////////////////////////
46 /// TF1 default destructor.
47 
48 TF1Data::~TF1Data()
49 {
50  if (fParMin) delete [] fParMin;
51  if (fParMax) delete [] fParMax;
52  if (fParErrors) delete [] fParErrors;
53  if (fSave) delete [] fSave;
54 }
55 
56 ////////////////////////////////////////////////////////////////////////////////
57 /// Stream a class object.
58 
59 void TF1Data::Streamer(TBuffer &b)
60 {
61  if (b.IsReading()) {
62  UInt_t R__s, R__c;
63  Version_t v = b.ReadVersion(&R__s, &R__c);
64  Streamer(b, v, R__s, R__c, nullptr);
65 
66  } else {
67  // this will be needed if we want to write in old format
68  //Int_t saved = 0;
69  // if (fType > 0 && fNsave <= 0) { saved = 1; Save(fXmin,fXmax,0,0,0,0);}
70 
71  b.WriteClassBuffer(TF1Data::Class(),this);
72 
73  //if (saved) {delete [] fSave; fSave = 0; fNsave = 0;}
74  }
75 
76 }
77 
78 ////////////////////////////////////////////////////////////////////////////////
79 /// specialized streamer function being able to read old TF1 versions as TF1Data in memory
80 
81 void TF1Data::Streamer(TBuffer &b, Int_t v, UInt_t R__s, UInt_t R__c, const TClass *onfile_class)
82 {
83  //printf("reading TF1Data ..- version %d..\n",v);
84  if (v > 4) {
85  b.ReadClassBuffer(ROOT::v5::TF1Data::Class(), this, v, R__s, R__c, onfile_class);
86  if (v == 5 && fNsave > 0) {
87  //correct badly saved fSave in 3.00/06
88  Int_t np = fNsave - 3;
89  fSave[np] = fSave[np-1];
90  fSave[np+1] = fXmin;
91  fSave[np+2] = fXmax;
92  }
93  return;
94  }
95  //====process old versions before automatic schema evolution
96  ROOT::v5::TFormula::Streamer(b);
97  TAttLine::Streamer(b);
98  TAttFill::Streamer(b);
99  TAttMarker::Streamer(b);
100  if (v < 4) {
101  Float_t xmin,xmax;
102  b >> xmin; fXmin = xmin;
103  b >> xmax; fXmax = xmax;
104  } else {
105  b >> fXmin;
106  b >> fXmax;
107  }
108  b >> fNpx;
109  b >> fType;
110  b >> fChisquare;
111  b.ReadArray(fParErrors);
112  if (v > 1) {
113  b.ReadArray(fParMin);
114  b.ReadArray(fParMax);
115  } else {
116  fParMin = new Double_t[fNpar+1];
117  fParMax = new Double_t[fNpar+1];
118  }
119  b >> fNpfits;
120  if (v == 1) {
121  TH1 * histogram;
122  b >> histogram;
123  delete histogram; //fHistogram = 0;
124  }
125  if (v > 1) {
126  if (v < 4) {
127  Float_t minimum,maximum;
128  b >> minimum; fMinimum =minimum;
129  b >> maximum; fMaximum =maximum;
130  } else {
131  b >> fMinimum;
132  b >> fMaximum;
133  }
134  }
135  if (v > 2) {
136  b >> fNsave;
137  if (fNsave > 0) {
138  fSave = new Double_t[fNsave+10];
139  b.ReadArray(fSave);
140  //correct fSave limits to match new version
141  fSave[fNsave] = fSave[fNsave-1];
142  fSave[fNsave+1] = fSave[fNsave+2];
143  fSave[fNsave+2] = fSave[fNsave+3];
144  fNsave += 3;
145  } else fSave = 0;
146  }
147  b.CheckByteCount(R__s, R__c, TF1Data::IsA());
148  //====end of old versions
149 }
150 
151  } // end namespace v5
152 } // end namespace ROOT
153