Changeset 1477 for trunk/MagicSoft/Mars/mhist
- Timestamp:
- 08/02/02 15:20:53 (22 years ago)
- Location:
- trunk/MagicSoft/Mars/mhist
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/mhist/MBinning.cc
r1476 r1477 50 50 51 51 SetEdges(10, 0, 1); 52 53 fType = kIsDefault; 52 54 } 53 55 56 // -------------------------------------------------------------------------- 57 // 58 // Specify the number of bins (not the number of edges), the lowest and 59 // highest Edge. 60 // 61 void MBinning::SetEdges(const Int_t nbins, const Axis_t lo, Axis_t up) 62 { 63 const Double_t binsize = (up-lo)/nbins; 64 fEdges.Set(nbins+1); 65 for (int i=0; i<=nbins; i++) 66 fEdges[i] = binsize*i + lo; 67 68 fType = kIsLinear; 69 } 70 71 // -------------------------------------------------------------------------- 72 // 73 // Specify the number of bins (not the number of edges), the lowest and 74 // highest Edge. 75 // 76 void MBinning::SetEdgesLog(const Int_t nbins, const Axis_t lo, Axis_t up) 77 { 78 // if (lo==0) ... 79 80 const Double_t binsize = log10(up/lo)/nbins; 81 fEdges.Set(nbins+1); 82 for (int i=0; i<=nbins; i++) 83 fEdges[i] = pow(10, binsize*i) * lo; 84 85 fType = kIsLogarithmic; 86 } 54 87 55 88 // -------------------------------------------------------------------------- … … 70 103 // gui elements to a macro-file. 71 104 // 72 void MBinning::S avePrimitive(ofstream &out, Option_t *o)105 void MBinning::StreamPrimitive(ofstream &out) const 73 106 { 74 out << " TArrayD dummy;" << endl;75 for (int i=0; i<fEdges.GetSize(); i++)76 out << " dummy[" << i << "]=" << fEdges[i] << ";" << endl;77 107 out << " MBinning " << ToLower(fName) << "(\""; 78 108 out << fName << "\", \"" << fTitle << "\");" << endl; 79 out << " " << ToLower(fName) << ".SetEdges(dummy);" << endl; 109 110 if (IsDefault()) 111 return; 112 113 if (IsLinear() || IsLogarithmic()) 114 { 115 out << " " << ToLower(fName) << ".SetEdges"; 116 if (IsLogarithmic()) 117 out << "Log"; 118 out << "(" << GetNumBins() << ", " << GetEdgeLo() << ", " << GetEdgeHi() << ");" << endl; 119 return; 120 } 121 122 out << " {" << endl; 123 out << " TArrayD dummy;" << endl; 124 for (int i=0; i<GetNumEdges(); i++) 125 out << " dummy[" << i << "]=" << GetEdges()[i] << ";" << endl; 126 out << " " << ToLower(fName) << ".SetEdges(dummy);" << endl; 127 out << " }" << endl; 80 128 } -
trunk/MagicSoft/Mars/mhist/MBinning.h
r1474 r1477 17 17 TArrayD fEdges; 18 18 19 Byte_t fType; 20 21 void StreamPrimitive(ofstream &out) const; 22 23 enum { 24 kIsDefault, 25 kIsLinear, 26 kIsLogarithmic, 27 kIsUserArray 28 }; 29 19 30 public: 20 31 MBinning(const char *name=NULL, const char *title=NULL); … … 23 34 { 24 35 fEdges = arr; 36 fType = kIsUserArray; 25 37 } 26 38 27 void SetEdges(const Int_t nbins, const Axis_t lo, Axis_t up) 28 { 29 const Double_t binsize = (up-lo)/nbins; 30 fEdges.Set(nbins+1); 31 for (int i=0; i<=nbins; i++) 32 fEdges[i] = binsize*i + lo; 33 } 34 35 void SetEdgesLog(const Int_t nbins, const Axis_t lo, Axis_t up) 36 { 37 // if (lo==0) ... 38 39 const Double_t binsize = log10(up/lo)/nbins; 40 fEdges.Set(nbins+1); 41 for (int i=0; i<=nbins; i++) 42 fEdges[i] = pow(10, binsize*i) * lo; 43 } 39 void SetEdges(const Int_t nbins, const Axis_t lo, Axis_t up); 40 void SetEdgesLog(const Int_t nbins, const Axis_t lo, Axis_t up); 44 41 45 42 // FIXME: ROOT workaround: "operator[] const" missing 46 Double_t GetEdgeLo() const { return ( *(TArrayD*)(&fEdges))[0]; }47 Double_t GetEdgeHi() const { return ( *(TArrayD*)(&fEdges))[fEdges.GetSize()-1]; }43 Double_t GetEdgeLo() const { return ((TArrayD)fEdges)[0]; } 44 Double_t GetEdgeHi() const { return ((TArrayD)fEdges)[fEdges.GetSize()-1]; } 48 45 49 46 Int_t GetNumEdges() const { return fEdges.GetSize(); } … … 52 49 Double_t *GetEdges() const { return fEdges.GetArray(); } 53 50 51 Bool_t IsLinear() const { return fType==kIsLinear; } 52 Bool_t IsLogarithmic() const { return fType==kIsLogarithmic; } 53 Bool_t IsDefault() const { return fType==kIsDefault; } 54 Bool_t IsUserArray() const { return fType==kIsUserArray; } 55 54 56 void Apply(TH1 &); 55 56 void SavePrimitive(ofstream &out, Option_t *o="");57 57 58 58 ClassDef(MBinning, 1) //Container to store the binning of a histogram -
trunk/MagicSoft/Mars/mhist/MFillH.cc
r1476 r1477 156 156 // 157 157 // 158 MFillH::MFillH(const char *hist, constMParContainer *par, const char *name, const char *title)158 MFillH::MFillH(const char *hist, MParContainer *par, const char *name, const char *title) 159 159 { 160 160 Init(name, title); … … 192 192 // derived from MH) 193 193 // 194 MFillH::MFillH(MH *hist, constMParContainer *par, const char *name, const char *title)194 MFillH::MFillH(MH *hist, MParContainer *par, const char *name, const char *title) 195 195 { 196 196 Init(name, title); … … 350 350 // gui elements to a macro-file. 351 351 // 352 void MFillH::SavePrimitive(ofstream &out, Option_t *o) 353 { 354 out << " MFillH " << ToLower(fName) << "(\""; 355 out << fHName << "\", \"" << fParContainerName << "\");" << endl; 356 } 352 void MFillH::StreamPrimitive(ofstream &out) const 353 { 354 if (fH) 355 fH->SavePrimitive(out); 356 357 if (fParContainer) 358 fParContainer->SavePrimitive(out); 359 360 out << " MFillH " << ToLower(fName) << "("; 361 362 if (fH) 363 out << "&" << ToLower(fH->GetName()); 364 else 365 out << "\"" << fHName << "\""; 366 out << ", "; 367 368 if (fParContainer) 369 out << "&" << ToLower(fParContainer->GetName()); 370 else 371 out << "\"" << fParContainerName << "\""; 372 373 out << ");" << endl; 374 } -
trunk/MagicSoft/Mars/mhist/MFillH.h
r1472 r1477 12 12 { 13 13 private: 14 const MParContainer *fParContainer; //!14 MParContainer *fParContainer; 15 15 TString fParContainerName; 16 16 17 MH* fH; //!17 MH* fH; 18 18 TString fHName; 19 19 … … 23 23 void Init(const char *name, const char *title); 24 24 25 void StreamPrimitive(ofstream &out) const; 26 25 27 public: 26 28 MFillH(); 27 MFillH(const char *hist, const char *par=NULL, 28 MFillH(const char *hist, const MParContainer *par,const char *name=NULL, const char *title=NULL);29 MFillH(MH *hist, const char *par=NULL, 30 MFillH(MH *hist, const MParContainer *par,const char *name=NULL, const char *title=NULL);29 MFillH(const char *hist, const char *par=NULL, const char *name=NULL, const char *title=NULL); 30 MFillH(const char *hist, MParContainer *par, const char *name=NULL, const char *title=NULL); 31 MFillH(MH *hist, const char *par=NULL, const char *name=NULL, const char *title=NULL); 32 MFillH(MH *hist, MParContainer *par, const char *name=NULL, const char *title=NULL); 31 33 32 34 Bool_t PreProcess(MParList *pList); 33 35 Bool_t Process(); 34 36 Bool_t PostProcess(); 35 36 void SavePrimitive(ofstream &out, Option_t *o="");37 37 38 38 ClassDef(MFillH, 1) // Task to fill a histogram with data from a parameter container -
trunk/MagicSoft/Mars/mhist/MH3.cc
r1476 r1477 384 384 // gui elements to a macro-file. 385 385 // 386 void MH3::S avePrimitive(ofstream &out, Option_t *o)386 void MH3::StreamPrimitive(ofstream &out) 387 387 { 388 388 TString name = ToLower(fName); -
trunk/MagicSoft/Mars/mhist/MH3.h
r1474 r1477 23 23 MDataChain *fData[3]; // Object from which the data is filled 24 24 Double_t fScale[3]; 25 26 void StreamPrimitive(ofstream &out); 25 27 26 28 public: … … 49 51 TObject *DrawClone(Option_t *opt=NULL) const; 50 52 51 void SavePrimitive(ofstream &out, Option_t *o="");52 53 53 ClassDef(MH3, 1) // Generalized 1/2/3D-histogram for Mars variables 54 54 };
Note:
See TracChangeset
for help on using the changeset viewer.