Logo ROOT   6.08/07
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 "TBuffer.h"
15 #include "TH1.h"
16 
18 
19 namespace ROOT {
20 
21  namespace v5 {
22 
23 ////////////////////////////////////////////////////////////////////////////////
24 /// F1 default constructor.
25 
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 
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 
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 
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
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;
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 
Bool_t IsReading() const
Definition: TBuffer.h:83
void Streamer(TBuffer &b, const TClass *onfile_class)
Stream a class object.
float xmin
Definition: THbookFile.cxx:93
virtual Int_t WriteClassBuffer(const TClass *cl, void *pointer)=0
This namespace contains pre-defined functions to be used in conjuction with TExecutor::Map and TExecu...
Definition: StringConv.hxx:21
short Version_t
Definition: RtypesCore.h:61
float Float_t
Definition: RtypesCore.h:53
Double_t fXmax
Definition: TF1Data.h:48
Double_t * fParErrors
Definition: TF1Data.h:55
Buffer base class used for serializing objects.
Definition: TBuffer.h:42
virtual Int_t CheckByteCount(UInt_t startpos, UInt_t bcnt, const TClass *clss)=0
int Int_t
Definition: RtypesCore.h:41
virtual void SetFillStyle(Style_t fstyle)
Set the fill area style.
Definition: TAttFill.h:44
const char * Class
Definition: TXMLSetup.cxx:64
Marker Attributes class.
Definition: TAttMarker.h:24
Fill Area Attributes class.
Definition: TAttFill.h:24
SVector< double, 2 > v
Definition: Dict.h:5
virtual ~TF1Data()
TF1 default destructor.
Definition: TF1Data_v5.cxx:48
unsigned int UInt_t
Definition: RtypesCore.h:42
Double_t * fParMax
Definition: TF1Data.h:57
The ROOT global object gROOT contains a list of all defined classes.
Definition: TClass.h:81
float xmax
Definition: THbookFile.cxx:93
virtual Int_t ReadClassBuffer(const TClass *cl, void *pointer, const TClass *onfile_class=0)=0
#define ClassImp(name)
Definition: Rtypes.h:279
double Double_t
Definition: RtypesCore.h:55
The FORMULA class (ROOT version 5)
Definition: TFormula.h:71
void Streamer(TBuffer &b, Int_t version, UInt_t start, UInt_t count, const TClass *onfile_class=0)
Stream a class object.
Definition: TF1Data_v5.cxx:59
The TH1 histogram class.
Definition: TH1.h:80
Double_t fXmin
Definition: TF1Data.h:47
Double_t * fParMin
Definition: TF1Data.h:56
Double_t fChisquare
Definition: TF1Data.h:54
Double_t fMaximum
Definition: TF1Data.h:59
TF1Data()
F1 default constructor.
Definition: TF1Data_v5.cxx:26
you should not use this method at all Int_t Int_t Double_t Double_t Double_t Int_t Double_t Double_t Double_t Double_t b
Definition: TRolke.cxx:630
Double_t * fSave
Definition: TF1Data.h:58
Line Attributes class.
Definition: TAttLine.h:24
virtual Version_t ReadVersion(UInt_t *start=0, UInt_t *bcnt=0, const TClass *cl=0)=0
Double_t fMinimum
Definition: TF1Data.h:60
virtual Int_t ReadArray(Bool_t *&b)=0