ROOT  6.06/09
Reference Guide
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 "TH1.h"
15 
17 
18 namespace ROOT {
19 
20  namespace v5 {
21 
22 ////////////////////////////////////////////////////////////////////////////////
23 /// F1 default constructor.
24 
25 TF1Data::TF1Data(): ROOT::v5::TFormula(), TAttLine(), TAttFill(), TAttMarker()
26 {
27  fXmin = 0;
28  fXmax = 0;
29  fNpx = 100;
30  fType = 0;
31  fNpfits = 0;
32  fNDF = 0;
33  fNsave = 0;
34  fChisquare = 0;
35  fParErrors = 0;
36  fParMin = 0;
37  fParMax = 0;
38  fSave = 0;
39  fMinimum = -1111;
40  fMaximum = -1111;
41  SetFillStyle(0);
42 }
43 
44 ////////////////////////////////////////////////////////////////////////////////
45 /// TF1 default destructor.
46 
47 TF1Data::~TF1Data()
48 {
49  if (fParMin) delete [] fParMin;
50  if (fParMax) delete [] fParMax;
51  if (fParErrors) delete [] fParErrors;
52  if (fSave) delete [] fSave;
53 }
54 
55 ////////////////////////////////////////////////////////////////////////////////
56 /// Stream a class object.
57 
58 void TF1Data::Streamer(TBuffer &b)
59 {
60  if (b.IsReading()) {
61  UInt_t R__s, R__c;
62  Version_t v = b.ReadVersion(&R__s, &R__c);
63  Streamer(b, v, R__s, R__c, nullptr);
64 
65  } else {
66  // this will be needed if we want to write in old format
67  //Int_t saved = 0;
68  // if (fType > 0 && fNsave <= 0) { saved = 1; Save(fXmin,fXmax,0,0,0,0);}
69 
71 
72  //if (saved) {delete [] fSave; fSave = 0; fNsave = 0;}
73  }
74 
75 }
76 
77 ////////////////////////////////////////////////////////////////////////////////
78 /// specialized streamer function being able to read old TF1 versions as TF1Data in memory
79 
80 void TF1Data::Streamer(TBuffer &b, Int_t v, UInt_t R__s, UInt_t R__c, const TClass *onfile_class)
81 {
82  //printf("reading TF1Data ..- version %d..\n",v);
83  if (v > 4) {
84  b.ReadClassBuffer(ROOT::v5::TF1Data::Class(), this, v, R__s, R__c, onfile_class);
85  if (v == 5 && fNsave > 0) {
86  //correct badly saved fSave in 3.00/06
87  Int_t np = fNsave - 3;
88  fSave[np] = fSave[np-1];
89  fSave[np+1] = fXmin;
90  fSave[np+2] = fXmax;
91  }
92  return;
93  }
94  //====process old versions before automatic schema evolution
96  TAttLine::Streamer(b);
97  TAttFill::Streamer(b);
98  TAttMarker::Streamer(b);
99  if (v < 4) {
100  Float_t xmin,xmax;
101  b >> xmin; fXmin = xmin;
102  b >> xmax; fXmax = xmax;
103  } else {
104  b >> fXmin;
105  b >> fXmax;
106  }
107  b >> fNpx;
108  b >> fType;
109  b >> fChisquare;
110  b.ReadArray(fParErrors);
111  if (v > 1) {
112  b.ReadArray(fParMin);
113  b.ReadArray(fParMax);
114  } else {
115  fParMin = new Double_t[fNpar+1];
116  fParMax = new Double_t[fNpar+1];
117  }
118  b >> fNpfits;
119  if (v == 1) {
120  TH1 * histogram;
121  b >> histogram;
122  delete histogram; //fHistogram = 0;
123  }
124  if (v > 1) {
125  if (v < 4) {
126  Float_t minimum,maximum;
127  b >> minimum; fMinimum =minimum;
128  b >> maximum; fMaximum =maximum;
129  } else {
130  b >> fMinimum;
131  b >> fMaximum;
132  }
133  }
134  if (v > 2) {
135  b >> fNsave;
136  if (fNsave > 0) {
137  fSave = new Double_t[fNsave+10];
138  b.ReadArray(fSave);
139  //correct fSave limits to match new version
140  fSave[fNsave] = fSave[fNsave-1];
141  fSave[fNsave+1] = fSave[fNsave+2];
142  fSave[fNsave+2] = fSave[fNsave+3];
143  fNsave += 3;
144  } else fSave = 0;
145  }
146  b.CheckByteCount(R__s, R__c, TF1Data::IsA());
147  //====end of old versions
148 }
149 
150  } // end namespace v5
151 } // end namespace ROOT
152 
float xmin
Definition: THbookFile.cxx:93
virtual Int_t WriteClassBuffer(const TClass *cl, void *pointer)=0
Namespace for new ROOT classes and functions.
Definition: ROOT.py:1
Bool_t IsReading() const
Definition: TBuffer.h:81
short Version_t
Definition: RtypesCore.h:61
float Float_t
Definition: RtypesCore.h:53
ClassImp(ROOT::v5::TF1Data) namespace ROOT
Definition: TF1Data_v5.cxx:16
Buffer base class used for serializing objects.
Definition: TBuffer.h:40
virtual Int_t CheckByteCount(UInt_t startpos, UInt_t bcnt, const TClass *clss)=0
int Int_t
Definition: RtypesCore.h:41
Marker Attributes class.
Definition: TAttMarker.h:32
Fill Area Attributes class.
Definition: TAttFill.h:32
void Class()
Definition: Class.C:29
SVector< double, 2 > v
Definition: Dict.h:5
a SetFillStyle(0)
TClass * IsA() const
unsigned int UInt_t
Definition: RtypesCore.h:42
The ROOT global object gROOT contains a list of all defined classes.
Definition: TClass.h:81
float xmax
Definition: THbookFile.cxx:93
PyObject * fType
virtual Int_t ReadClassBuffer(const TClass *cl, void *pointer, const TClass *onfile_class=0)=0
double Double_t
Definition: RtypesCore.h:55
The TH1 histogram class.
Definition: TH1.h:80
void Streamer(TBuffer &b, const TClass *onfile_class)
Line Attributes class.
Definition: TAttLine.h:32
virtual Version_t ReadVersion(UInt_t *start=0, UInt_t *bcnt=0, const TClass *cl=0)=0
virtual Int_t ReadArray(Bool_t *&b)=0