Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
12 changes: 11 additions & 1 deletion hist/hist/src/TAxis.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,17 @@ void TAxis::Copy(TObject &obj) const
axis.fLabels = 0;
}
if (fLabels) {
for (Int_t i=1;i<=fNbins;i++) axis.SetBinLabel(i,this->GetBinLabel(i));
//Properly handle case where not all bins have labels
TIter next(fLabels);
TObjString *label;
if(! axis.fLabels) {
axis.fLabels = new THashList(axis.fNbins, 3);
}
while( (label=(TObjString*)next()) ) {
TObjString *copyLabel = new TObjString(*label);
axis.fLabels->Add(copyLabel);
copyLabel->SetUniqueID(label->GetUniqueID());
}
}
}

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 @@ -2487,6 +2487,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