CDF II
CDF KITS
source navigation ]
diff markup ]
identifier search ]
freetext search ]
file search ]
 
Architecture: i386 ]
Version: 4.10.4 ] [ 4.10.5 ] [ 4.8.4 ] [ 4.8.4l3s ] [ 4.8.5 ] [ 4.9.0 ] [ 4.9.1 ] [ 4.9.1.hpt3 ] [ 4.9.1hpt3 ] [ 4.9.1top1 ] [ 5.0.0 ] [ 5.1.0 ] [ 5.1.0beamonly ] [ 5.1.1 ] [ 5.2.0 ] [ 5.3.0 ] [ 5.3.1 ] [ 5.3.1dsp ] [ 5.3.3 ] [ 5.3.3_nt ] [ 5.3.4 ] [ 6.1.1 ] [ 6.1.1b ] [ 6.1.2 ] [ 6.1.3 ] [ 6.1.4 ] [ 6.1.4int3 ] [ 6.1.4mc ] [ 6.1.4mc_a ] [ 6.1.6 ] [ development ]

001 #ifndef HEPROOTFILEMANAGER_H
002 #define HEPROOTFILEMANAGER_H
003 
004 // ----------------------------------------------------------------------
005 //
006 // HepRootFileManager.h - header file for the wrapper for the Nirvana
007 //   Rootscope package
008 //
009 // HepRootFileManager is a C++ wrapper class that controls the
010 // initialization and creation of histograms and ntuples and allows
011 // them to be written to a file in the Root format.
012 //
013 // This class is derived from the HepFileManager, and is not an abstract
014 // class. It should be instantiated before any histograms or ntuples - a
015 // pointer to the manager is passed to every histogram and ntuple upon
016 // creation.
017 //
018 // Usage of the class:
019 //
020 //   HepFileManager* m = new HepRootFileManager("filename", "rootDirName");
021 //    :
022 //    :
023 //   [create histograms]
024 //
025 // write() writes the managed Root objects to a file, as does the
026 // destructor.
027 // dumpAllData() and clearAllData()  initiate calls of dumpData() or
028 // clearData() to all managed objects.
029 //
030 //
031 // History
032 //   30-Nov-1998  Philippe Canal   Initial draft
033 //   19-Mar-2001  Mark Fischler    hepFileFormat()
034 //
035 // ----------------------------------------------------------------------
036 
037 #ifndef ZMENVIRONMENT_H
038   #include "ZMutility/ZMenvironment.h"
039 #endif
040 
041 #include <string>
042 
043 #include "HepTuple/HepFileManager.h"
044 
045 #ifndef FIXEDTYPES_H
046   #include "ZMutility/FixedTypes.h"
047 #endif
048   
049 ZM_BEGIN_NAMESPACE( zmht )      /*  namespace zmht  {  */
050 
051 class HepHist;
052 class HepRootHist1D;
053 class HepRootHist2D;
054 class HepRootHistProf;
055 class HepRootNtuple;
056 class HepFileSwitch;
057 
058 class TFile;
059 class TDirectory;
060 class TObject;
061 
062 class HepRootFileManager : public HepFileManager  {
063 
064   friend class HepTFile;
065 
066 public:
067 
068   // constructor/destructor:   -----------------------------------------
069 
070   HepRootFileManager(               // constructor
071     const std::string& fName        //   desired file name
072   , const std::string& rootDir = "" //   desired name of root directory
073   , int compression = 0             //   desired compression level
074   );
075 
076   HepRootFileManager(               // constructor
077     const std::string& fName        //   desired file name
078   , HepFileManager::mode req_mode   //   desired opening mode
079   , const std::string& rootDir = "" //   desired name of root directory
080   , int compression = 0             //   desired compression level
081   );
082 
083   virtual ~HepRootFileManager();   // destructor
084 
085   static void initialiseRoot();
086 
087   // directory manipulation a la HepRoot:  -------------------------------
088 
089   virtual void cd( const std::string & path = "" );    // change dir
090 
091   virtual void mkdir( const std::string & path ); // create a dir
092 
093   virtual std::string ls(                       // list a dir
094     const std::string & path = ""
095   , const std::string & opts = ""
096   )  const;
097 
098   virtual void rmdir( const std::string & path, bool recursive = false ); 
099   // delete a dir
100 
101   virtual void rm( int hid = 0 );          // delete a histogram or ntuple
102   virtual void rm( const std::string & what );  // delete a histogram or ntuple
103 
104   virtual TFile* file() const;  // Return a pointer the manager file structure.
105 
106   // File Format: ---------------------------------------------------------
107 
108   HepTupleFileFormat hepFileFormat() const;
109 
110   // HepRoot file manipulation:  -----------------------------------------
111 
112   virtual void writeDirectory();     // write the managed objects to the file
113   virtual int write();         // write the managed objects to the file
114 #ifdef LATER
115   virtual void dumpAllData();  // call dumpData() for all tuples in the list
116   virtual void clearAllData(); // call clearData() for all tuples in the list
117 #endif // LATER
118 
119 
120   // Create HepRoot-specific histograms & Ntuples:  ----------------------
121 
122   virtual HepHist1D & hist1D(
123     const std::string& title,
124     const int nBins, const float low, const float high,
125     const int id = 0
126   );
127   virtual HepHist2D & hist2D(
128     const std::string& title,
129     const int nBinsX, const float lowX, const float highX,
130     const int nBinsY, const float lowY, const float highY,
131     const int id = 0
132   );
133   virtual HepHistProf & histProf(
134     const std::string& title,
135     const int nBinsX, const float lowX, const float highX,
136     const float lowY, const float highY, const std::string& chopt,
137     const int id = 0
138   );
139   virtual HepHistProf & histProf(
140     const std::string& title,
141     const int nBinsX, const float lowX, const float highX,
142     const float lowY, const float highY,
143     const int id = 0
144   );
145   virtual HepNtuple & ntuple(
146     const std::string& title,
147     const int hid = 0
148   );
149 
150   // attach to existing histograms & Ntuples:
151   virtual HepHist1D & retrieveHist1D(        // 1-D
152     const std::string& title,
153     const int hid = 0
154   );
155   virtual HepHist2D & retrieveHist2D(        // 2-D
156     const std::string& title,
157     const int hid = 0
158   );
159   virtual HepHistProf & retrieveHistProf(    // profile plot
160     const std::string& title,
161     const int hid = 0
162   );
163   virtual HepNtuple & retrieveNtuple(
164     const std::string& title,
165     const int hid = 0
166   );
167 
168   // user is finished with the indicated object
169   virtual void release( HepObj & me );
170 
171   // For Unmanaged Root Items.
172 
173   static HepRootNtuple& deadRootNtuple() ;
174   static HepRootHist1D& deadRootHist1D() ;
175   static HepRootHist2D& deadRootHist2D() ;
176   static HepRootHistProf& deadRootHistProf() ;
177 
178   // For transparently switching output files at user request.
179   // Implemented for the Root manager only!
180   virtual bool switchFile( const std::string& newFileName,
181                            const bool resetHists );
182 
183   // For transparently switching output files at user request with a user
184   // supplied handler to deal with stray TObjects.
185   // Implemented for the Root manager only!
186   virtual bool switchFile( const std::string& newFileName,
187                            const bool resetHists,
188                            HepFileSwitch& userHandler );
189 
190 protected:
191   void init(              // constructor body (shared by both constructors)
192     const std::string& fName        //   desired file name
193   , HepFileManager::mode req_mode   //   desired opening mode
194   , const std::string& rootDir      //   desired name of root directory
195   , int compression                 //   desired compression level
196   );
197 
198   static bool init_done;
199   void retrieveExistingItems();        // make C++ objects out of items in
200                                        // an existing file
201   virtual void writeOne( HepObj * o );
202 
203   // Root specific helper routines.
204 
205   std::string inFileRootPath( const std::string& path ) const;
206   const std::string& CurrentRootPath() const;
207 
208   // Dead Object creators
209   virtual HepNtuple& deadNtuple() const;
210   virtual HepHist1D& deadHist1D() const;
211   virtual HepHist2D& deadHist2D() const;
212   virtual HepHistProf& deadHistProf() const;
213 
214   bool cloneDir( TDirectory* oldFile, TDirectory* newFile,
215                  std::vector<void*>& strays, bool resetHists );
216 
217   TFile * filep_;
218 
219 private:
220 
221   Int4 compression_;
222   Int4 writeOption_;
223 
224 };  // HepRootFileManager
225 
226 
227 ZM_END_NAMESPACE( zmht )        /*  }  // namespace zmht  */
228 
229 
230 #endif  // HEPROOTFILEMANAGER_H
231 

source navigation ] diff markup ] identifier search ] freetext search ] file search ]

This page was automatically generated by the LXR engine.
The LXR team
Valid HTML 4.01!

Send problems or questions to cdfcode@fnal.gov