SFrame 3.6
plug-ins/include/SH1.h
Go to the documentation of this file.
00001 // Dear emacs, this is -*- c++ -*-
00002 // $Id: SH1.h 313 2012-04-21 19:03:42Z krasznaa $
00003 /***************************************************************************
00004  * @Project: SFrame - ROOT-based analysis framework for ATLAS
00005  * @Package: Plug-ins
00006  *
00007  * @author Stefan Ask       <Stefan.Ask@cern.ch>           - Manchester
00008  * @author David Berge      <David.Berge@cern.ch>          - CERN
00009  * @author Johannes Haller  <Johannes.Haller@cern.ch>      - Hamburg
00010  * @author A. Krasznahorkay <Attila.Krasznahorkay@cern.ch> - CERN/Debrecen
00011  *
00012  ***************************************************************************/
00013 
00014 #ifndef SFRAME_PLUGINS_SH1_H
00015 #define SFRAME_PLUGINS_SH1_H
00016 
00017 // ROOT include(s):
00018 #include <TNamed.h>
00019 
00020 // SFrame include(s):
00021 #include "core/include/SError.h"
00022 
00023 // Forward declaration(s):
00024 class TCollection;
00025 class TH1;
00026 
00050 template< typename Type >
00051 class SH1 : public TNamed {
00052 
00053 public:
00055    SH1();
00057    template< typename T > SH1( const SH1< T >& parent );
00059    SH1( const char* name, const char* title, Int_t bins,
00060         Double_t low, Double_t high, Bool_t computeErrors = kTRUE );
00062    virtual ~SH1();
00063 
00065    void Fill( Double_t pos, Type weight = 1 ) throw( SError );
00066 
00068    Int_t GetNBins() const;
00070    Int_t FindBin( Double_t pos ) const;
00071 
00073    Type GetBinContent( Int_t bin ) const;
00075    void SetBinContent( Int_t bin, Type content );
00076 
00078    Type GetBinError( Int_t bin ) const;
00080    void SetBinError( Int_t bin, Type error );
00081 
00083    Int_t GetEntries() const;
00085    void SetEntries( Int_t entries );
00086 
00088    TH1* ToHist() const;
00089 
00091    virtual Int_t Merge( TCollection* coll );
00093    virtual Int_t Write( const char* name = 0, Int_t option = 0,
00094                         Int_t bufsize = 0 ) const;
00096    virtual Int_t Write( const char* name = 0, Int_t option = 0,
00097                         Int_t bufsize = 0 );
00098 
00099 private:
00101    const Int_t m_arraySize;
00103    Type* m_content; //[m_arraySize]
00105    Type* m_errors; //[m_arraySize]
00107    Int_t m_entries;
00109    const Int_t    m_bins;
00111    const Double_t m_low;
00113    const Double_t m_high;
00115    const Bool_t m_computeErrors;
00116 
00117 #ifndef DOXYGEN_IGNORE
00118    ClassDef( SH1, 1 );
00119 #endif // DOXYGEN_IGNORE
00120 
00121 }; // class SH1
00122 
00123 //
00124 // Include the template implementation:
00125 //
00126 #ifndef __CINT__
00127 #include "SH1.icc"
00128 #endif // __CINT__
00129 
00130 //
00131 // Define the supported template specialisations:
00132 //
00133 typedef SH1< Float_t >  SH1F;
00134 typedef SH1< Double_t > SH1D;
00135 typedef SH1< Int_t >    SH1I;
00136 
00137 #ifndef DOXYGEN_IGNORE
00138 ClassImp( SH1F );
00139 ClassImp( SH1D );
00140 ClassImp( SH1I );
00141 #endif // DOXYGEN_IGNORE
00142 
00143 #endif // SFRAME_PLUGINS_SH1_H