ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/CmsHi/HafHistogram/interface/HTupleManager.h
Revision: 1.1
Committed: Wed Sep 29 15:44:21 2010 UTC (14 years, 7 months ago) by yjlee
Content type: text/plain
Branch: MAIN
CVS Tags: HEAD
Log Message:
HafHistogram tool

File Contents

# User Rev Content
1 yjlee 1.1 #ifndef HTUPLEMANAGER_H
2     #define HTUPLEMANAGER_H
3    
4     /** \class HTupleManager Ganzhur/HafHistogram/interface/HTupleManager.h
5     *
6     * Description:
7     * Analysis code of the CMS experiment;
8     * Original version is a part of HAF package developed for CMS: UserCode/HAF
9     * Persistence manager for analysis histograms and ntuples
10     *
11     * \author Marcel Kunze, Ruhr-University Bochum, Germany
12     * \author Serguei Ganjour, CEA-Saclay/IRFU, FR
13     *
14     * \version $Id: HTupleManager.h,v 1.3 2009/11/19 09:40:31 ganzhur Exp $
15     *
16     */
17    
18     #include <iostream>
19     #include "TFile.h"
20     #include "TDirectory.h"
21     #include "TString.h"
22     #include "THashList.h"
23     #include "TH1.h"
24     #include "TH2.h"
25     #include "UserCode/HafHistogram/interface/HHistID.h"
26     #include "UserCode/HafHistogram/interface/HHistogram.h"
27     #include "UserCode/HafHistogram/interface/HTuple.h"
28    
29     class HTupleManager : public TObject {
30    
31     public:
32     //Constructor
33     HTupleManager(const char* file= "framework.root",const char* fmode= "RECREATE");
34     //Destructor
35     virtual ~HTupleManager();
36     void SetHepTupleMode(Bool_t yesNo=kTRUE) { fHepTuple = yesNo; }
37     Bool_t SetFileName( const char* );
38     int Save();
39     int Store() { return Save(); }
40     Bool_t SetDir( const char* path= "/" );
41     const char* GetDir() const;
42     size_t GetNumDir() const;
43     const char* GetDirName( size_t ) const;
44     Bool_t GetDirIndex( const char*, size_t & ) const;
45     size_t GetNumHist() const;
46     size_t GetNumHist( const char* path ) const;
47     void PrintOn ( ostream & out= cout ) const;
48     TObject* Add(TObject* item);
49     TObject* Put(TObject* item) { return Add(item); }
50     TObject* Get(const char *name);
51     void Remove(TObject* item);
52     void Remove(const char *name);
53     void ClearAll();
54     HTupleManager(const HTupleManager &h) : rtfilep(h.rtfilep), olist(0) {}
55     HTupleManager& operator=(const HTupleManager &v ) { return *this; }
56     // 1D histogram without id
57     HHistogram* Histogram( const char*, int, float, float );
58     // Create a 1D histogram. Behaves generally like ntuple().
59     HHistogram* Histogram( const char*, int, float, float, HHistID );
60     // 2D histogram without id:
61     HHistogram* Histogram( const char*, int, float, float, int, float, float );
62     // 2D histogram with ID:
63     HHistogram* Histogram( const char*, int, float, float, int, float, float, HHistID );
64     // Profile histogram without ID:
65     HHistogram* Profile( const char*, int, float, float, float, float );
66     // Profile histogram with ID:
67     HHistogram* Profile( const char*, int, float, float, float, float, HHistID );
68     // Ntuple
69     HTuple* Ntuple( const char* nttitle );
70     HTuple* Ntuple( const char* nttitle,HHistID hhid );
71     void DumpAllData();
72     // Specific histograms
73     HMassHistogram* MassHistogram(const Text_t *name,const Text_t *title,Int_t nbins,Axis_t xlow,Axis_t xup);
74     HEnergyHistogram* EnergyHistogram(const Text_t *name,const Text_t *title,Int_t nbins,Axis_t xlow,Axis_t xup);
75     HMomentumHistogram* MomentumHistogram(const Text_t *name,const Text_t *title,Int_t nbins,Axis_t xlow,Axis_t xup);
76     HEoverPHistogram* EoverPHistogram(const Text_t *name,const Text_t *title,Int_t nbinsx,Axis_t xlow,Axis_t xup
77     ,Int_t nbinsy,Axis_t ylow,Axis_t yup);
78     HMoverPHistogram* MoverPHistogram(const Text_t *name,const Text_t *title,Int_t nbinsx,Axis_t xlow,Axis_t xup
79     ,Int_t nbinsy,Axis_t ylow,Axis_t yup);
80     protected:
81     TFile* rtfilep;
82     THashList *olist; //! List of external objects
83     THashList *hlist; //! List of internal histograms
84     THashList *ntlist; //! List of internal ntuples
85     Bool_t fHepTuple; //! HepTuple mode for names
86    
87     // Helper function to compose ROOT names:
88     const char* makeName( const char*, HHistID );
89    
90     // Helper function to set directory according to PicoTuple's weird
91     // indexing scheme:
92     // void setDirFromIndexList( const THepCList<size_t> & ) const;
93    
94     // Helper function to reset current ROOT-file to this manager:
95     void checkFile( const char* opt= "" ) const;
96    
97     // Helper function for setFileName, moves directories and contents
98     void movedir( TDirectory* olddir, TDirectory* newdir );
99    
100     HHistogram* getHistByName( const char* );
101     HHistogram* getHistByTitle( const char* );
102    
103     public:
104     ClassDef(HTupleManager,1) // Histogram and ntuple manager
105     };
106    
107     // standalone print
108     ostream& operator << (ostream& o, const HTupleManager&);
109    
110     #endif
111