Skip to content

Commit

Permalink
Revert "Revert "Implement TH1::Clone""
Browse files Browse the repository at this point in the history
This reverts commit 9b16f29.
  • Loading branch information
Dr15Jones committed Oct 22, 2014
1 parent 04ffc30 commit f27274a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
1 change: 1 addition & 0 deletions hist/hist/inc/TH1.h
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ class TH1 : public TNamed, public TAttLine, public TAttFill, public TAttMarker {

virtual Double_t Chisquare(TF1 * f1, Option_t *option = "") const;
virtual Double_t ComputeIntegral(Bool_t onlyPositive = false);
TObject* Clone(const char* newname=0) const;
virtual void Copy(TObject &hnew) const;
virtual void DirectoryAutoAdd(TDirectory *);
virtual Int_t DistancetoPrimitive(Int_t px, Int_t py);
Expand Down
19 changes: 19 additions & 0 deletions hist/hist/src/TH1.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -2485,6 +2485,25 @@ void TH1::Copy(TObject &obj) const

}

//______________________________________________________________________________
TObject* TH1::Clone(const char* newname) const
{
TH1* obj = (TH1*)IsA()->GetNew()(0);
Copy(*obj);

//Now handle the parts that Copy doesn't do
if(fFunctions) {
if(not obj->fFunctions) {
obj->fFunctions = new TList;
}
fFunctions->Copy( *(obj->fFunctions) );
}
if(newname and strlen(newname) ) {
obj->SetName(newname);
}
return obj;
}

//______________________________________________________________________________
void TH1::DirectoryAutoAdd(TDirectory *dir)
{
Expand Down

0 comments on commit f27274a

Please sign in to comment.