CHistogram Class Reference

#include <CHistogram.h>

Inheritance diagram for CHistogram:
CObject

List of all members.

Public Member Functions

 CHistogram (TH1 *h1, const TObject *inputsource, TH1 *subtracthisto=0, TH1 *refhisto=0)
 CHistogram (const CHistogram &chisto)
 CHistogram (const CObject &cobj)
 CHistogram ()
virtual ~CHistogram ()
TH1 * GetSubtractHisto () const
TH1 * GetRefHisto () const
void SetSubtractHisto (TH1 *)
void SetRefHisto (TH1 *)
TH1 * SubtractedHisto ()
virtual void Draw (Option_t *option="")
virtual void Paint (Option_t *option="")
TH1 * GetHistoDrawn () const
CHistogramoperator= (const CHistogram &chisto)

Protected Member Functions

virtual void UpdateHisto ()

Protected Attributes

TH1 * fSubtractHisto
TH1 * fRefHisto
TH1 * fHistoDrawn

Private Member Functions

void free ()
void copy (const CHistogram &chisto)

Detailed Description

Definition at line 22 of file CHistogram.h.


Constructor & Destructor Documentation

CHistogram::CHistogram ( TH1 *  h1,
const TObject *  inputsource,
TH1 *  subtracthisto = 0,
TH1 *  refhisto = 0 
)

Definition at line 28 of file CHistogram.cxx.

References SetSubtractHisto(), and UpdateHisto().

00030   : CObject(h1, inputsource),fSubtractHisto(NULL), fRefHisto(refhisto),
00031     fHistoDrawn(NULL)
00032 {
00033   SetSubtractHisto( subtracthisto );
00034   UpdateHisto();
00035 }

CHistogram::CHistogram ( const CHistogram chisto  ) 

Definition at line 37 of file CHistogram.cxx.

References copy().

00038     :CObject()
00039 {
00040   if (this != &chisto) copy(chisto);
00041 }

CHistogram::CHistogram ( const CObject cobj  ) 

Definition at line 44 of file CHistogram.cxx.

References CHistogram(), CObject::GetInputSource(), and CObject::GetTObject().

00045     :CObject()
00046 {
00047   TObject *obj = cobj.GetTObject();
00048   if ( obj && obj->InheritsFrom(TH1::Class()) ) 
00049     CHistogram( (TH1*)obj, cobj.GetInputSource(), 0, 0);
00050 }

CHistogram::CHistogram (  ) 

Definition at line 52 of file CHistogram.cxx.

Referenced by CHistogram().

00052 :CObject(){}

CHistogram::~CHistogram (  )  [virtual]

Definition at line 93 of file CHistogram.cxx.

References free().

00093                        {
00094   free();
00095 }


Member Function Documentation

void CHistogram::copy ( const CHistogram chisto  )  [private]

Definition at line 55 of file CHistogram.cxx.

References CObject::fInputSource, fRefHisto, CObject::fTObject, CObject::GetInputSource(), GetRefHisto(), GetSubtractHisto(), CObject::GetTObject(), SetSubtractHisto(), and UpdateHisto().

Referenced by CHistogram(), and operator=().

00056 {
00057   TH1 *histo = (TH1*) chisto.GetTObject();
00058 
00059   if ( !histo ) return;
00060 
00061   if ( fTObject && fTObject != chisto.fTObject ) delete fTObject;
00062   //fTObject = histo->Clone();
00063   fTObject = histo;
00064 
00065   fInputSource = chisto.GetInputSource();
00066 
00067   TH1 *subtracthisto =  (TH1*) chisto.GetSubtractHisto() ;
00068   SetSubtractHisto( subtracthisto );
00069 
00070   fRefHisto = chisto.GetRefHisto();
00071 
00072   UpdateHisto();
00073 
00074 }

void CHistogram::Draw ( Option_t *  option = ""  )  [virtual]

Reimplemented from CObject.

Definition at line 176 of file CHistogram.cxx.

References CObject::fTObject.

00177 {
00178   //if ( fHistoDrawn ) fHistoDrawn->Draw( option );
00179 
00180   if ( std::string(option) == "" ) option = fTObject->GetOption();
00181 
00182   TString opt = option;
00183   opt.ToLower();
00184   if (gPad && !opt.Contains("same")) {
00185     //the following statement is necessary in case one attempts to draw
00186     //a temporary histogram already in the current pad
00187     if ( TestBit(kCanDelete) ) gPad->GetListOfPrimitives()->Remove(this);
00188     gPad->Clear();
00189   }
00190   AppendPad(opt.Data());
00191 
00192 }

void CHistogram::free (  )  [private]

Reimplemented from CObject.

Definition at line 76 of file CHistogram.cxx.

References fHistoDrawn, and fSubtractHisto.

Referenced by operator=(), and ~CHistogram().

00077 {
00078   if ( fSubtractHisto ) {
00079     delete fSubtractHisto;
00080     fSubtractHisto = 0;
00081   }
00082 
00083   if ( fHistoDrawn ) {
00084     delete fHistoDrawn;
00085     fHistoDrawn = 0;
00086   }
00087 
00088   //if ( fTObject ) delete fTObject; // done by ~CObject()
00089 
00090 }

TH1* CHistogram::GetHistoDrawn (  )  const [inline]

Definition at line 61 of file CHistogram.h.

References fHistoDrawn.

00061 { return fHistoDrawn; }

TH1* CHistogram::GetRefHisto (  )  const [inline]

Definition at line 50 of file CHistogram.h.

References fRefHisto.

Referenced by copy().

00050 { return fRefHisto; }

TH1* CHistogram::GetSubtractHisto (  )  const [inline]

Definition at line 49 of file CHistogram.h.

References fSubtractHisto.

Referenced by copy().

00049 { return fSubtractHisto; }

CHistogram & CHistogram::operator= ( const CHistogram chisto  ) 

Reimplemented from CObject.

Definition at line 98 of file CHistogram.cxx.

References copy(), and free().

00098                                                           {
00099   if (this != &chisto) {
00100     free();
00101     copy(chisto);
00102   }
00103   return *this;
00104 }

void CHistogram::Paint ( Option_t *  option = ""  )  [virtual]

Reimplemented from CObject.

Definition at line 195 of file CHistogram.cxx.

References fHistoDrawn.

00196 {
00197   if ( fHistoDrawn ) fHistoDrawn->Paint( option );
00198 }

void CHistogram::SetRefHisto ( TH1 *  refhisto  ) 

Definition at line 124 of file CHistogram.cxx.

References fRefHisto.

00124                                          {
00125   fRefHisto = refhisto;
00126 }

void CHistogram::SetSubtractHisto ( TH1 *  subtracthisto  ) 

Definition at line 106 of file CHistogram.cxx.

References fSubtractHisto, and UpdateHisto().

Referenced by HistoDisplay::AddSubtractHisto(), CHistogram(), and copy().

00106                                                    {
00107   // Set histo to be subtracted.
00108   // subtracthisto's clone is stored internally.
00109 
00110   if ( fSubtractHisto && fSubtractHisto != subtracthisto )
00111     delete fSubtractHisto;
00112 
00113   if ( subtracthisto ) {
00114     fSubtractHisto = (TH1*) subtracthisto->Clone();
00115   }
00116   else {
00117     fSubtractHisto = 0;
00118   }
00119 
00120   UpdateHisto();
00121 
00122 }

TH1 * CHistogram::SubtractedHisto (  ) 

Definition at line 129 of file CHistogram.cxx.

References fSubtractHisto, and CObject::fTObject.

Referenced by HistoDisplay::DrawHisto(), HistoDisplay::ReplacePad(), and UpdateHisto().

00130 {
00131   // return subtracted histogram.
00132 
00133   TH1 *histo;
00134   if ( fTObject && fTObject->InheritsFrom( TH1::Class() ) ) {
00135     histo = (TH1*)fTObject;
00136   }
00137   else {
00138     return 0;
00139   }
00140 
00141   TH1* histonew = (TH1*)( histo->Clone() );
00142 
00143   TH1 *subtracthisto = fSubtractHisto;
00144 
00145   if ( histonew && subtracthisto) {
00146 
00147     histonew->Add(subtracthisto, -1.);
00148 
00149     histonew
00150       ->SetEntries( histo->GetEntries() 
00151                     - subtracthisto->GetEntries() );
00152 
00153    // After Root Version 2.23.12
00154     Stat_t s1[10], s2[10];
00155     Int_t i;
00156     for (i=0;i<10;i++) {s1[i] = s2[i] = 0;}
00157     histo->GetStats(s1);
00158     subtracthisto->GetStats(s2);
00159     for (i=0;i<10;i++) s1[i] -= s2[i];
00160     histonew->PutStats(s1);
00161     //-
00162 
00163   } //if (histonew && subtracthisto) 
00164 
00165   return histonew;
00166 }

void CHistogram::UpdateHisto (  )  [protected, virtual]

Definition at line 169 of file CHistogram.cxx.

References fHistoDrawn, and SubtractedHisto().

Referenced by CHistogram(), copy(), and SetSubtractHisto().

00170 {
00171   if ( fHistoDrawn ) delete fHistoDrawn;
00172   fHistoDrawn = SubtractedHisto();
00173 }


Member Data Documentation

TH1* CHistogram::fHistoDrawn [protected]

Definition at line 28 of file CHistogram.h.

Referenced by free(), GetHistoDrawn(), Paint(), and UpdateHisto().

TH1* CHistogram::fRefHisto [protected]

Definition at line 26 of file CHistogram.h.

Referenced by copy(), GetRefHisto(), and SetRefHisto().

TH1* CHistogram::fSubtractHisto [protected]

Definition at line 25 of file CHistogram.h.

Referenced by free(), GetSubtractHisto(), SetSubtractHisto(), and SubtractedHisto().


The documentation for this class was generated from the following files:

Generated on 22 Nov 2017 for loon by  doxygen 1.6.1