storage_manager.hh

Go to the documentation of this file.
00001 
00014 #ifndef STORAGE_MANAGER_HH
00015 #define STORAGE_MANAGER_HH
00016 #include <set>
00017 #include <TFile.h>
00018 #include <TChain.h>
00019 
00020 #include "decoder_base.hh"
00021 #include "trig_info.hh"
00022 #include "pulse_info.hh"
00023 #include "user_info.hh"
00024 #include "pmt_waveform.hh"
00025 #include "tpc_waveform.hh"
00026 
00031 class storage_manager : public decoder_base {
00032 
00033 public:
00034 
00036   enum MODE{
00037     READ,       
00038     WRITE,      
00039     BOTH,       
00040     UNDEFINED   
00041   };
00042 
00044   enum STATUS{
00045     INIT,       
00046     OPENED,     
00047     READY_IO,   
00048     OPERATING,  
00049     CLOSED      
00050   };
00051 
00053   storage_manager(MODE mode=UNDEFINED);
00054 
00056   virtual ~storage_manager(){};
00057 
00059   void set_data_to_read(DATA_STRUCT::DATA_TYPE type,bool read=true)
00060   {_read_data_array[type]=read;};
00061 
00063   void set_data_to_write(DATA_STRUCT::DATA_TYPE type,bool write=true)
00064   {_write_data_array[type]=write;};
00065 
00067   void set_io_mode(MODE mode)         {_mode=mode;};
00068 
00070   //void set_in_filename(std::string name) {_in_fname=name;};
00071   void add_in_filename(std::string name) {_in_fnames.push_back(name);};
00072 
00074   void set_out_filename(std::string name) {_out_fname=name;};
00075 
00077   MODE io_mode() const         {return _mode;};
00078 
00080   std::vector<std::string> input_filename() const {return _in_fnames;};
00081 
00083   std::string output_filename() const {return _out_fname;};
00084 
00086   STATUS status() const        {return _status;};
00087 
00089   void reset();
00090 
00092   bool open();  
00093 
00095   bool is_open();
00096 
00098   bool is_ready_io();
00099 
00101   bool next_event(); 
00102 
00104   bool go_to(UInt_t index);
00105 
00107   bool close(); 
00108 
00112   data_base* get_data(DATA_STRUCT::DATA_TYPE type);
00113 
00115   static storage_manager* get() 
00116   { if(!me) me= new storage_manager(); return me; };
00117   
00119   static void kill() 
00120   { if(me) delete me;};
00121 
00123   inline UInt_t get_entries() const {return _nevents;};
00124 
00126   inline UInt_t get_index()   const {return _index;};
00127 
00129   inline UInt_t get_entries_read() const {return _nevents_read;};
00130 
00132   inline UInt_t get_entires_written() const {return _nevents_written;};
00133   
00134 private:
00135 
00136   static storage_manager* me; 
00137 
00139   void create_data_ptr(DATA_STRUCT::DATA_TYPE type);
00140 
00141   void delete_data_ptr(DATA_STRUCT::DATA_TYPE type);
00142 
00144   bool read_event();
00145   
00147   bool write_event();
00148 
00150   bool prepare_tree();
00151 
00153   UInt_t _index;
00154 
00156   UInt_t _nevents, _nevents_read, _nevents_written;
00157 
00159   STATUS _status;
00160 
00162   MODE _mode;
00163 
00165   bool _read_data_array[DATA_STRUCT::DATA_TYPE_MAX];
00166 
00168   bool _write_data_array[DATA_STRUCT::DATA_TYPE_MAX];
00169 
00171   data_base *_ptr_data_array[DATA_STRUCT::DATA_TYPE_MAX];
00172 
00174   std::string _out_fname;
00175   std::vector<std::string> _in_fnames;
00176 
00178   const std::string _treename;
00179 
00181   //TFile *_fin, *_fout;
00182   TFile *_fout;
00183 
00185   //TTree *_in_tree, *_out_tree;  
00186   TChain *_in_ch[DATA_STRUCT::DATA_TYPE_MAX];
00187   TTree  *_out_ch[DATA_STRUCT::DATA_TYPE_MAX];
00188 
00189 };
00190 
00191 #endif
00192  // end of doxygen group storage_manager

Generated on Mon Apr 7 15:35:12 2014 for MyProject by  doxygen 1.4.7