#include <storage_manager.hh>
Inheritance diagram for storage_manager:

Public Types | |
| READ | |
| I/O mode: READ. | |
| WRITE | |
| I/O mode: WRITE. | |
| BOTH | |
| I/O mode both read & write. | |
| UNDEFINED | |
| I/O mode: undefined ... | |
| INIT | |
| I/O operation status: initiated. | |
| OPENED | |
| I/O file opened. | |
| READY_IO | |
| All pre-I/O process finished (making TTrees, etc.). | |
| OPERATING | |
| Reading/Writing events. | |
| CLOSED | |
| I/O finished and file closed already. | |
| enum | MODE { READ, WRITE, BOTH, UNDEFINED } |
| Defines I/O mode ... currently only read OR write. More... | |
| enum | STATUS { INIT, OPENED, READY_IO, OPERATING, CLOSED } |
| Defines I/O process status flags. More... | |
Public Member Functions | |
| storage_manager (MODE mode=UNDEFINED) | |
| Default constructor. Allow user to specify the I/O mode here. | |
| virtual | ~storage_manager () |
| Default destructor. | |
| void | set_data_to_read (DATA_STRUCT::DATA_TYPE type, bool read=true) |
| Setter to specify a certain data class to be read from input. | |
| void | set_data_to_write (DATA_STRUCT::DATA_TYPE type, bool write=true) |
| Setter to specify a certain data class to be written in the output. | |
| void | set_io_mode (MODE mode) |
| Setter for I/O mode. | |
| void | add_in_filename (std::string name) |
| Setter for input filename. | |
| void | set_out_filename (std::string name) |
| Setter for output filename. | |
| MODE | io_mode () const |
| Getter for I/O mode. | |
| std::vector< std::string > | input_filename () const |
| Getter for an array of input files set by the user. | |
| std::string | output_filename () const |
| Getter for I/O file name. | |
| STATUS | status () const |
| Getter for process status stamp. See storage_manager::STATUS. | |
| void | reset () |
| Reset variables and I/O process to prepare for a new I/O. | |
| bool | open () |
| Open I/O file. Return true upon success. | |
| bool | is_open () |
| Utility boolean to check if file is opened. | |
| bool | is_ready_io () |
| Utility boolean to check if file is opened and ready for I/O. | |
| bool | next_event () |
| Stores an event to the output in WRITE mode, and loads an event to local memory in READ mode. | |
| bool | go_to (UInt_t index) |
| Move to the TTree entry with the provided index number. | |
| bool | close () |
| Close I/O file. | |
| data_base * | get_data (DATA_STRUCT::DATA_TYPE type) |
| Universal data pointer getter to return data_base* pointer for specified data type. | |
| UInt_t | get_entries () const |
| Getter for a number of events in the file. | |
| UInt_t | get_index () const |
| Getter for a TTree index. | |
| UInt_t | get_entries_read () const |
| Getter for a counter of read-out events. | |
| UInt_t | get_entires_written () const |
| Getter for a counter of written-out events. | |
| void | set_verbosity (MSG::Level level) |
| Setter for the verbosity level. | |
| MSG::Level | get_verbosity () const |
| Getter for the verbosity level. | |
| const std::string | class_name () const |
| Getter for the class name. | |
Static Public Member Functions | |
| static storage_manager * | get () |
| Getter for a shared object instance pointer. Not limited to be a singleton. | |
| static void | kill () |
| killer for a shared object instance. | |
Protected Attributes | |
| char | _buf [200] |
| char buffer for message manipulation | |
| bool | _verbosity [MSG::MSG_TYPE_MAX] |
| holder for enabled message levels | |
| MSG::Level | _verbosity_level |
| holder for specified verbosity level | |
| std::string | _name |
| class name holder | |
Private Member Functions | |
| void | create_data_ptr (DATA_STRUCT::DATA_TYPE type) |
| void | delete_data_ptr (DATA_STRUCT::DATA_TYPE type) |
| bool | read_event () |
| Load next event from imput. | |
| bool | write_event () |
| Write the current event into output. | |
| bool | prepare_tree () |
| Called upon opening a file to prepare read/write events in TTree. | |
Private Attributes | |
| UInt_t | _index |
| tree index marker | |
| UInt_t | _nevents |
| number of events read/written | |
| UInt_t | _nevents_read |
| UInt_t | _nevents_written |
| STATUS | _status |
| status control stamp | |
| MODE | _mode |
| I/O mode. | |
| bool | _read_data_array [DATA_STRUCT::DATA_TYPE_MAX] |
| Boolean to record what data to be read out from a file. | |
| bool | _write_data_array [DATA_STRUCT::DATA_TYPE_MAX] |
| Boolean to record what data to be written out from a file. | |
| data_base * | _ptr_data_array [DATA_STRUCT::DATA_TYPE_MAX] |
| Data pointer array. | |
| std::string | _out_fname |
| I/O filename. | |
| std::vector< std::string > | _in_fnames |
| const std::string | _treename |
| TTree name. | |
| TFile * | _fout |
| ROOT file instance. | |
| TChain * | _in_ch [DATA_STRUCT::DATA_TYPE_MAX] |
| TTree instance. | |
| TTree * | _out_ch [DATA_STRUCT::DATA_TYPE_MAX] |
Static Private Attributes | |
| static storage_manager * | me = 0 |
| shared object instance pointer | |
Definition at line 31 of file storage_manager.hh.
Defines I/O process status flags.
Definition at line 44 of file storage_manager.hh.
| storage_manager::storage_manager | ( | MODE | mode = UNDEFINED |
) |
Default constructor. Allow user to specify the I/O mode here.
Definition at line 7 of file storage_manager.cc.
References _fout, _mode, decoder_base::_name, _out_fname, _status, INIT, and reset().
Referenced by get().
00008 : decoder_base(), _treename("pmt_data") 00009 { 00010 _name="storage_manager"; 00011 //_event_wf=0; 00012 _fout=0; 00013 _out_fname=""; 00014 _status=INIT; 00015 00016 reset(); 00017 _mode=mode; 00018 00019 };
| virtual storage_manager::~storage_manager | ( | ) | [inline, virtual] |
| void storage_manager::add_in_filename | ( | std::string | name | ) | [inline] |
Setter for input filename.
Definition at line 71 of file storage_manager.hh.
References _in_fnames.
Referenced by ana_processor::add_input_file(), and main().
00071 {_in_fnames.push_back(name);};
| const std::string decoder_base::class_name | ( | ) | const [inline, inherited] |
Getter for the class name.
Definition at line 46 of file decoder_base.hh.
References decoder_base::_name.
00046 {return _name;};
| bool storage_manager::close | ( | ) |
Close I/O file.
Definition at line 327 of file storage_manager.cc.
References decoder_base::_buf, _in_ch, _mode, _out_ch, _out_fname, _ptr_data_array, _status, decoder_base::_verbosity, CLOSED, DATA_STRUCT::DATA_TREE_NAME, DATA_STRUCT::DATA_TYPE_MAX, MSG::DEBUG, delete_data_ptr(), MSG::ERROR, MSG::INFO, INIT, MSG::NORMAL, OPENED, OPERATING, READ, READY_IO, Message::send(), status(), and MSG::WARNING.
Referenced by decoder_manager::finalize(), main(), prepare_tree(), reset(), and decoder_manager::reset().
00327 { 00328 00329 if(_verbosity[MSG::DEBUG]) 00330 Message::send(MSG::DEBUG,__PRETTY_FUNCTION__,"called ..."); 00331 00332 bool status=true; 00333 std::set<TFile*> outfile_set; 00334 switch(_status){ 00335 case INIT: 00336 case CLOSED: 00337 Message::send(MSG::ERROR,__FUNCTION__,"Attempt to close file while not operating I/O!"); 00338 status=false; 00339 break; 00340 case OPENED: 00341 case READY_IO: 00342 Message::send(MSG::WARNING,__FUNCTION__,"Closing a file without any I/O operation done!"); 00343 break; 00344 case OPERATING: 00345 if(_mode!=READ){ 00346 00347 //_fout->cd(); 00348 00349 for(size_t i=0; i<DATA_STRUCT::DATA_TYPE_MAX; i++) { 00350 00351 if(!_out_ch[i]) { 00352 00353 if(_verbosity[MSG::DEBUG]) 00354 00355 Message::send(MSG::DEBUG,__FUNCTION__, 00356 Form("Skipping to write a Tree %s_tree...", 00357 DATA_STRUCT::DATA_TREE_NAME[(DATA_STRUCT::DATA_TYPE)i].c_str())); 00358 00359 continue; 00360 } 00361 00362 if(_verbosity[MSG::INFO]) 00363 00364 Message::send(MSG::INFO,__FUNCTION__,Form("Writing TTree: %s",_out_ch[i]->GetName())); 00365 00366 if(outfile_set.find(_out_ch[i]->GetCurrentFile()) == outfile_set.end()){ 00367 00368 _out_ch[i]->GetCurrentFile()->Write(); 00369 00370 outfile_set.insert(_out_ch[i]->GetCurrentFile()); 00371 00372 } 00373 00374 Message::send(MSG::NORMAL,__FUNCTION__, 00375 Form("TTree \"%s\" written with %lld events...", 00376 _out_ch[i]->GetName(), 00377 _out_ch[i]->GetEntries())); 00378 } 00379 } 00380 break; 00381 } 00382 00383 if(status) { 00384 00385 sprintf(_buf,"Closing the output: %s",_out_fname.c_str()); 00386 Message::send(MSG::NORMAL,__FUNCTION__,_buf); 00387 00388 for(std::set<TFile*>::iterator iter(outfile_set.begin()); 00389 iter!=outfile_set.end(); 00390 ++iter) 00391 00392 (*iter)->Close(); 00393 00394 for(size_t i=0; i<DATA_STRUCT::DATA_TYPE_MAX; ++i) { 00395 00396 if(_in_ch[i]) { delete _in_ch[i]; _in_ch[i]=0; } 00397 if(_out_ch[i]) { _out_ch[i]=0; } 00398 if(_ptr_data_array[i]) delete_data_ptr((DATA_STRUCT::DATA_TYPE)i); 00399 00400 } 00401 00402 } 00403 00404 if(_verbosity[MSG::DEBUG]) 00405 Message::send(MSG::DEBUG,__PRETTY_FUNCTION__,"ends ..."); 00406 00407 _status=CLOSED; 00408 return status; 00409 }
| void storage_manager::create_data_ptr | ( | DATA_STRUCT::DATA_TYPE | type | ) | [private] |
Definition at line 280 of file storage_manager.cc.
References _ptr_data_array, DATA_STRUCT::DATA_TYPE_MAX, DATA_STRUCT::FIXED_WIN_PULSE_COLLECTION, DATA_STRUCT::PMT_WF_COLLECTION, DATA_STRUCT::PULSE_COLLECTION, DATA_STRUCT::SLIDE_WIN_PULSE_COLLECTION, DATA_STRUCT::THRES_WIN_PULSE_COLLECTION, DATA_STRUCT::TPC_WF_COLLECTION, DATA_STRUCT::TRIG_INFO, and DATA_STRUCT::USER_COLLECTION.
Referenced by get_data(), and prepare_tree().
00280 { 00281 00282 if(_ptr_data_array[type]) return; 00283 00284 switch(type){ 00285 case DATA_STRUCT::PMT_WF_COLLECTION: 00286 _ptr_data_array[type] = (data_base*)(new pmt_wf_collection()); 00287 break; 00288 case DATA_STRUCT::TRIG_INFO: 00289 _ptr_data_array[type] = (data_base*)(new trig_info()); 00290 break; 00291 case DATA_STRUCT::PULSE_COLLECTION: 00292 _ptr_data_array[type] = (data_base*)(new pulse_collection()); 00293 break; 00294 case DATA_STRUCT::THRES_WIN_PULSE_COLLECTION: 00295 _ptr_data_array[type] = (data_base*)(new pulse_collection()); 00296 break; 00297 case DATA_STRUCT::FIXED_WIN_PULSE_COLLECTION: 00298 _ptr_data_array[type] = (data_base*)(new pulse_collection()); 00299 break; 00300 case DATA_STRUCT::SLIDE_WIN_PULSE_COLLECTION: 00301 _ptr_data_array[type] = (data_base*)(new pulse_collection()); 00302 break; 00303 case DATA_STRUCT::USER_COLLECTION: 00304 _ptr_data_array[type] = (data_base*)(new user_collection()); 00305 break; 00306 case DATA_STRUCT::TPC_WF_COLLECTION: 00307 _ptr_data_array[type] = (data_base*)(new tpc_wf_collection()); 00308 break; 00309 case DATA_STRUCT::DATA_TYPE_MAX: 00310 break; 00311 } 00312 00313 return; 00314 }
| void storage_manager::delete_data_ptr | ( | DATA_STRUCT::DATA_TYPE | type | ) | [private] |
Definition at line 316 of file storage_manager.cc.
References _ptr_data_array.
Referenced by close().
00316 { 00317 00318 if(!_ptr_data_array[type]) return; 00319 00320 delete _ptr_data_array[type]; 00321 00322 _ptr_data_array[type]=0; 00323 00324 return; 00325 }
| static storage_manager* storage_manager::get | ( | ) | [inline, static] |
Getter for a shared object instance pointer. Not limited to be a singleton.
Definition at line 115 of file storage_manager.hh.
References me, and storage_manager().
Referenced by ana_processor::ana_processor(), and decoder_manager::decoder_manager().
00116 { if(!me) me= new storage_manager(); return me; };
| data_base * storage_manager::get_data | ( | DATA_STRUCT::DATA_TYPE | type | ) |
Universal data pointer getter to return data_base* pointer for specified data type.
A user then cast the pointer type to whatever the relevant data class pointer type to access members.
Definition at line 21 of file storage_manager.cc.
References _fout, _mode, _out_ch, _ptr_data_array, _write_data_array, create_data_ptr(), DATA_STRUCT::DATA_TREE_NAME, READ, Message::send(), and MSG::WARNING.
Referenced by waveform_sampler::analyze(), reco_wf::analyze(), pulse_viewer::analyze(), pulse_reco::analyze(), pulse_analyzer::analyze(), pmtbaseline_ana::analyze(), pmtbaseline::analyze(), pmt_slow_encoder::analyze(), led_pulse_selector::analyze(), led_pulse_analyzer::analyze(), beamgate_debugger::analyze(), main(), algo_tpc_xmit::process_event_header(), algo_tpc_huffman::process_event_header(), algo_pmt_xmit::process_event_header(), algo_trig_decoder::process_word(), and algo_slow_readout_decoder::process_word().
00021 { 00022 00023 // If data class object does not exist, and if it's either WRITE or BOTH mode, create it. 00024 if(!_ptr_data_array[type] && _mode != READ){ 00025 00026 _fout->cd(); 00027 00028 _out_ch[(size_t)type]=new TTree(Form("%s_tree",DATA_STRUCT::DATA_TREE_NAME[type].c_str()), 00029 Form("%s Tree",DATA_STRUCT::DATA_TREE_NAME[type].c_str())); 00030 _out_ch[(size_t)type]->SetMaxTreeSize (1024*1024*1024); 00031 _out_ch[(size_t)type]->SetMaxVirtualSize (1024*1024*1024); 00032 00033 create_data_ptr(type); 00034 00035 _out_ch[(size_t)type]->Branch(Form("%s_branch",DATA_STRUCT::DATA_TREE_NAME[type].c_str()), 00036 _ptr_data_array[(size_t)type]->GetName(), 00037 &(_ptr_data_array[(size_t)type])); 00038 00039 Message::send(MSG::WARNING,__FUNCTION__, 00040 Form("Requested tree %s which does not exists yet. Created a new one.", 00041 _out_ch[(size_t)type]->GetName()) 00042 ); 00043 00044 _write_data_array[(size_t)type]=true; 00045 00046 } 00047 00048 return _ptr_data_array[type]; 00049 00050 }
| UInt_t storage_manager::get_entires_written | ( | ) | const [inline] |
Getter for a counter of written-out events.
Definition at line 132 of file storage_manager.hh.
00132 {return _nevents_written;};
| UInt_t storage_manager::get_entries | ( | ) | const [inline] |
Getter for a number of events in the file.
Definition at line 123 of file storage_manager.hh.
References _nevents.
Referenced by decoder_manager::decode(), and ana_processor::run().
00123 {return _nevents;};
| UInt_t storage_manager::get_entries_read | ( | ) | const [inline] |
Getter for a counter of read-out events.
Definition at line 129 of file storage_manager.hh.
References _nevents_read.
00129 {return _nevents_read;};
| UInt_t storage_manager::get_index | ( | ) | const [inline] |
Getter for a TTree index.
Definition at line 126 of file storage_manager.hh.
References _index.
Referenced by decoder_manager::decode().
00126 {return _index;};
| MSG::Level decoder_base::get_verbosity | ( | ) | const [inline, inherited] |
Getter for the verbosity level.
Definition at line 43 of file decoder_base.hh.
References decoder_base::_verbosity_level.
00043 {return _verbosity_level;};
| bool storage_manager::go_to | ( | UInt_t | index | ) |
Move to the TTree entry with the provided index number.
Referenced by ana_processor::process_event(), and ana_processor::run().
| std::vector<std::string> storage_manager::input_filename | ( | ) | const [inline] |
Getter for an array of input files set by the user.
Definition at line 80 of file storage_manager.hh.
References _in_fnames.
00080 {return _in_fnames;};
| MODE storage_manager::io_mode | ( | ) | const [inline] |
Getter for I/O mode.
Definition at line 77 of file storage_manager.hh.
References _mode.
00077 {return _mode;};
| bool storage_manager::is_open | ( | ) |
Utility boolean to check if file is opened.
Definition at line 88 of file storage_manager.cc.
References _status, CLOSED, INIT, OPENED, OPERATING, READY_IO, and status().
Referenced by decoder_manager::initialize(), main(), and decoder_manager::reset().
00089 { 00090 bool status=true; 00091 switch(_status){ 00092 case OPENED: 00093 case READY_IO: 00094 case OPERATING: 00095 break; 00096 case INIT: 00097 case CLOSED: 00098 status=false; 00099 } 00100 00101 return status; 00102 }
| bool storage_manager::is_ready_io | ( | ) |
Utility boolean to check if file is opened and ready for I/O.
Definition at line 104 of file storage_manager.cc.
References _status, CLOSED, INIT, OPENED, OPERATING, READY_IO, and status().
Referenced by decoder_manager::initialize(), and main().
00105 { 00106 bool status=true; 00107 switch(_status){ 00108 case READY_IO: 00109 case OPERATING: 00110 break; 00111 case INIT: 00112 case OPENED: 00113 case CLOSED: 00114 status=false; 00115 } 00116 return status; 00117 }
| static void storage_manager::kill | ( | ) | [inline, static] |
killer for a shared object instance.
Definition at line 119 of file storage_manager.hh.
References me.
| bool storage_manager::next_event | ( | ) |
Stores an event to the output in WRITE mode, and loads an event to local memory in READ mode.
Definition at line 431 of file storage_manager.cc.
References _mode, _nevents_read, _status, BOTH, CLOSED, MSG::ERROR, INIT, OPENED, OPERATING, READ, read_event(), READY_IO, Message::send(), UNDEFINED, WRITE, and write_event().
Referenced by decoder_manager::decode(), main(), algo_slow_readout_decoder::process_ch_word(), ana_processor::process_event(), algo_trig_decoder::process_word(), algo_slow_readout_decoder::process_word(), algo_tpc_xmit::store_event(), and algo_pmt_xmit::store_event().
00431 { 00432 00433 bool status=true; 00434 00435 switch(_status){ 00436 case READY_IO: 00437 // first event 00438 _status=OPERATING; 00439 case OPERATING: 00440 switch(_mode) { 00441 case READ: 00442 status=read_event(); 00443 break; 00444 case WRITE: 00445 status=write_event(); 00446 break; 00447 case BOTH: 00448 if(_nevents_read) 00449 status = write_event(); 00450 if(status) status = read_event(); 00451 break; 00452 case UNDEFINED: 00453 break; 00454 } 00455 break; 00456 case INIT: 00457 case OPENED: 00458 case CLOSED: 00459 Message::send(MSG::ERROR,__FUNCTION__,"Cannot perform I/O on a closed file!"); 00460 status=false; 00461 break; 00462 } 00463 return status; 00464 }
| bool storage_manager::open | ( | ) |
Open I/O file. Return true upon success.
Definition at line 119 of file storage_manager.cc.
References decoder_base::_buf, _fout, _in_fnames, _mode, _out_fname, _status, decoder_base::_verbosity, BOTH, MSG::DEBUG, MSG::ERROR, MSG::NORMAL, OPENED, prepare_tree(), READ, Message::send(), status(), UNDEFINED, and WRITE.
Referenced by decoder_manager::initialize(), ana_processor::initialize(), and main().
00120 { 00121 bool status=true; 00122 00123 if(_verbosity[MSG::DEBUG]) 00124 Message::send(MSG::DEBUG,__PRETTY_FUNCTION__,"called ..."); 00125 00126 if((_mode==READ || _mode==BOTH) && _in_fnames.size()==0){ 00127 Message::send(MSG::ERROR, 00128 __FUNCTION__, 00129 "Open attempt w/o specifing a file name!"); 00130 return false; 00131 } 00132 00133 if((_mode==WRITE || _mode==BOTH) && _out_fname.size()==0){ 00134 Message::send(MSG::ERROR, 00135 __FUNCTION__, 00136 "Open attempt w/o specifing a file name!"); 00137 return false; 00138 } 00139 00140 switch(_mode){ 00141 00142 case BOTH: 00143 case READ: 00144 00145 for(std::vector<std::string>::const_iterator iter(_in_fnames.begin()); 00146 iter!=_in_fnames.end(); 00147 ++iter) { 00148 00149 TFile *fin = TFile::Open((*iter).c_str(),"READ"); 00150 if(!fin) { 00151 sprintf(_buf,"Open attempt failed for a file: %s", (*iter).c_str()); 00152 Message::send(MSG::ERROR,__FUNCTION__,_buf); 00153 status=false; 00154 }else{ 00155 sprintf(_buf,"Opening a file in READ mode: %s", (*iter).c_str()); 00156 Message::send(MSG::NORMAL,__FUNCTION__,_buf); 00157 fin->Close(); 00158 } 00159 00160 } 00161 00162 if(_mode==READ) break; 00163 case WRITE: 00164 sprintf(_buf,"Opening a file in WRITE mode: %s",_out_fname.c_str()); 00165 Message::send(MSG::NORMAL,__FUNCTION__,_buf); 00166 _fout=TFile::Open(_out_fname.c_str(),"RECREATE"); 00167 if(!_fout) { 00168 sprintf(_buf,"Open attempt failed for a file: %s", _out_fname.c_str()); 00169 Message::send(MSG::ERROR,__FUNCTION__,_buf); 00170 status=false; 00171 } 00172 break; 00173 00174 case UNDEFINED: 00175 Message::send(MSG::ERROR, 00176 __FUNCTION__, 00177 "Open attempt w/o specifing I/O mode!"); 00178 status=false; 00179 break; 00180 } 00181 00182 if(!status) return status; 00183 00184 if(_verbosity[MSG::DEBUG]) 00185 Message::send(MSG::DEBUG,__PRETTY_FUNCTION__,"ends ..."); 00186 00187 _status=OPENED; 00188 return prepare_tree(); 00189 };
| std::string storage_manager::output_filename | ( | ) | const [inline] |
Getter for I/O file name.
Definition at line 83 of file storage_manager.hh.
References _out_fname.
00083 {return _out_fname;};
| bool storage_manager::prepare_tree | ( | ) | [private] |
Called upon opening a file to prepare read/write events in TTree.
Definition at line 191 of file storage_manager.cc.
References decoder_base::_buf, _fout, _in_ch, _in_fnames, _index, _mode, _nevents, _nevents_read, _nevents_written, _out_ch, _ptr_data_array, _read_data_array, _status, decoder_base::_verbosity, _write_data_array, close(), create_data_ptr(), DATA_STRUCT::DATA_TREE_NAME, DATA_STRUCT::DATA_TYPE_MAX, MSG::DEBUG, MSG::ERROR, OPENED, READ, READY_IO, Message::send(), status(), and WRITE.
Referenced by open().
00191 { 00192 00193 bool status=true; 00194 00195 std::vector<uint64_t> nevents_array(DATA_STRUCT::DATA_TYPE_MAX,0); 00196 00197 if(_verbosity[MSG::DEBUG]) 00198 Message::send(MSG::DEBUG,__PRETTY_FUNCTION__,"called ..."); 00199 00200 if(!_status==OPENED) { 00201 sprintf(_buf,"Unexpected function call @ _status=%d!",_status); 00202 Message::send(MSG::ERROR,__FUNCTION__,_buf); 00203 status=false; 00204 } 00205 00206 for(size_t i=0; i<DATA_STRUCT::DATA_TYPE_MAX && _status; ++i){ 00207 00208 if(_mode!=WRITE && _read_data_array[i]) { 00209 00210 _in_ch[i]=new TChain(Form("%s_tree",DATA_STRUCT::DATA_TREE_NAME[(DATA_STRUCT::DATA_TYPE)i].c_str()), 00211 Form("%s Tree",DATA_STRUCT::DATA_TREE_NAME[(DATA_STRUCT::DATA_TYPE)i].c_str())); 00212 00213 for(size_t j=0; j<_in_fnames.size(); ++j) 00214 00215 _in_ch[i]->AddFile(_in_fnames[j].c_str()); 00216 00217 nevents_array[i]=_in_ch[i]->GetEntries(); 00218 00219 if(nevents_array[i]) { 00220 00221 create_data_ptr((DATA_STRUCT::DATA_TYPE)i); 00222 00223 _in_ch[i]->SetBranchAddress(Form("%s_branch",DATA_STRUCT::DATA_TREE_NAME[(DATA_STRUCT::DATA_TYPE)i].c_str()),&(_ptr_data_array[i])); 00224 00225 if(!_nevents) _nevents = nevents_array[i]; 00226 00227 }else{ 00228 delete _in_ch[i]; 00229 _in_ch[i]=0; 00230 } 00231 } 00232 00233 if(_mode!=READ && _write_data_array[i] ) { 00234 00235 _fout->cd(); 00236 00237 _out_ch[i]=new TTree(Form("%s_tree",DATA_STRUCT::DATA_TREE_NAME[(DATA_STRUCT::DATA_TYPE)i].c_str()), 00238 Form("%s Tree",DATA_STRUCT::DATA_TREE_NAME[(DATA_STRUCT::DATA_TYPE)i].c_str())); 00239 _out_ch[i]->SetMaxTreeSize (1024*1024*1024); 00240 _out_ch[i]->SetMaxVirtualSize (1024*1024*1024); 00241 00242 create_data_ptr((DATA_STRUCT::DATA_TYPE)i); 00243 00244 _out_ch[i]->Branch(Form("%s_branch",DATA_STRUCT::DATA_TREE_NAME[(DATA_STRUCT::DATA_TYPE)i].c_str()), 00245 _ptr_data_array[i]->GetName(), 00246 &(_ptr_data_array[i])); 00247 00248 } 00249 } 00250 00251 _nevents_written=0; 00252 _nevents_read=0; 00253 _index=0; 00254 00255 if( _mode!=WRITE && _nevents==0) { 00256 Message::send(MSG::ERROR,__FUNCTION__,"Did not find any relevant data tree!"); 00257 status=false; 00258 } 00259 00260 for(size_t i=0; i<DATA_STRUCT::DATA_TYPE_MAX; ++i) { 00261 00262 if(nevents_array[i] && _nevents!=nevents_array[i]) { 00263 sprintf(_buf,"Different number of entries found on tree: %s",DATA_STRUCT::DATA_TREE_NAME[(DATA_STRUCT::DATA_TYPE)i].c_str()); 00264 Message::send(MSG::ERROR,__FUNCTION__,_buf); 00265 status=false; 00266 } 00267 00268 } 00269 00270 if(status) _status=READY_IO; 00271 00272 else close(); 00273 00274 if(_verbosity[MSG::DEBUG]) 00275 Message::send(MSG::DEBUG,__PRETTY_FUNCTION__,"ends ..."); 00276 00277 return status; 00278 }
| bool storage_manager::read_event | ( | ) | [private] |
Load next event from imput.
Definition at line 466 of file storage_manager.cc.
References _in_ch, _index, _nevents, _nevents_read, and DATA_STRUCT::DATA_TYPE_MAX.
Referenced by next_event().
00466 { 00467 00468 if(_index>=_nevents) 00469 return false; 00470 00471 for(size_t i=0; i<DATA_STRUCT::DATA_TYPE_MAX; ++i) { 00472 00473 if(_in_ch[i]) 00474 _in_ch[i]->GetEntry(_index); 00475 00476 } 00477 00478 _index++; 00479 _nevents_read++; 00480 return true; 00481 }
| void storage_manager::reset | ( | ) |
Reset variables and I/O process to prepare for a new I/O.
Definition at line 52 of file storage_manager.cc.
References _in_ch, _in_fnames, _index, _mode, _nevents, _nevents_read, _nevents_written, _out_ch, _ptr_data_array, _read_data_array, _status, decoder_base::_verbosity, _write_data_array, close(), CLOSED, DATA_STRUCT::DATA_TYPE_MAX, MSG::DEBUG, INIT, OPENED, OPERATING, READY_IO, Message::send(), and UNDEFINED.
Referenced by decoder_manager::reset(), ana_processor::reset(), and storage_manager().
00053 { 00054 if(_verbosity[MSG::DEBUG]) 00055 Message::send(MSG::DEBUG,__PRETTY_FUNCTION__,"called ..."); 00056 00057 switch(_status){ 00058 case READY_IO: 00059 case OPENED: 00060 case OPERATING: 00061 close(); 00062 break; 00063 case INIT: 00064 case CLOSED: 00065 break; 00066 } 00067 00068 _index=0; 00069 _nevents=0; 00070 _nevents_written=0; 00071 _nevents_read=0; 00072 _mode=UNDEFINED; 00073 _status=INIT; 00074 _in_fnames.clear(); 00075 00076 for(size_t i=0; i<DATA_STRUCT::DATA_TYPE_MAX; ++i) { 00077 _read_data_array[i]=false; 00078 _write_data_array[i]=false; 00079 _in_ch[i]=0; 00080 _out_ch[i]=0; 00081 _ptr_data_array[i]=0; 00082 } 00083 00084 if(_verbosity[MSG::DEBUG]) 00085 Message::send(MSG::DEBUG,__PRETTY_FUNCTION__,"ends ..."); 00086 };
| void storage_manager::set_data_to_read | ( | DATA_STRUCT::DATA_TYPE | type, | |
| bool | read = true | |||
| ) | [inline] |
Setter to specify a certain data class to be read from input.
Definition at line 59 of file storage_manager.hh.
References _read_data_array.
Referenced by ana_processor::set_data_to_read().
00060 {_read_data_array[type]=read;};
| void storage_manager::set_data_to_write | ( | DATA_STRUCT::DATA_TYPE | type, | |
| bool | write = true | |||
| ) | [inline] |
Setter to specify a certain data class to be written in the output.
Definition at line 63 of file storage_manager.hh.
References _write_data_array.
Referenced by decoder_manager::set_data_to_write(), and ana_processor::set_data_to_write().
00064 {_write_data_array[type]=write;};
| void storage_manager::set_io_mode | ( | MODE | mode | ) | [inline] |
Setter for I/O mode.
Definition at line 67 of file storage_manager.hh.
References _mode.
Referenced by decoder_manager::decoder_manager(), main(), and ana_processor::set_io_mode().
00067 {_mode=mode;};
| void storage_manager::set_out_filename | ( | std::string | name | ) | [inline] |
Setter for output filename.
Definition at line 74 of file storage_manager.hh.
References _out_fname.
Referenced by ana_processor::set_output_file(), and decoder_manager::set_output_filename().
00074 {_out_fname=name;};
| void decoder_base::set_verbosity | ( | MSG::Level | level | ) | [inherited] |
Setter for the verbosity level.
Reimplemented in ana_processor.
Definition at line 11 of file decoder_base.cc.
References decoder_base::_verbosity, decoder_base::_verbosity_level, MSG::DEBUG, MSG::ERROR, MSG::INFO, MSG::MSG_TYPE_MAX, MSG::NORMAL, and MSG::WARNING.
Referenced by algo_slow_readout_decoder::algo_slow_readout_decoder(), compare_content(), decoder_base::decoder_base(), decoder_manager::decoder_manager(), decoder_manager::initialize(), main(), xmit_event_search::run(), bin_word_search::run(), and ana_processor::set_verbosity().
00011 { 00012 00013 _verbosity_level=level; 00014 00015 for(size_t i=(size_t)(MSG::DEBUG); i<(size_t)(MSG::MSG_TYPE_MAX); ++i) 00016 _verbosity[i]=false; 00017 00018 switch(level){ 00019 case MSG::DEBUG: 00020 _verbosity[MSG::DEBUG]=true; 00021 case MSG::INFO: 00022 _verbosity[MSG::INFO]=true; 00023 case MSG::NORMAL: 00024 _verbosity[MSG::NORMAL]=true; 00025 case MSG::WARNING: 00026 _verbosity[MSG::WARNING]=true; 00027 case MSG::ERROR: 00028 _verbosity[MSG::ERROR]=true; 00029 case MSG::MSG_TYPE_MAX: 00030 break; 00031 } 00032 00033 }
| STATUS storage_manager::status | ( | ) | const [inline] |
Getter for process status stamp. See storage_manager::STATUS.
Definition at line 86 of file storage_manager.hh.
References _status.
Referenced by close(), is_open(), is_ready_io(), open(), and prepare_tree().
00086 {return _status;};
| bool storage_manager::write_event | ( | ) | [private] |
Write the current event into output.
Definition at line 483 of file storage_manager.cc.
References _index, _mode, _nevents_written, _out_ch, _ptr_data_array, data_base::clear_data(), DATA_STRUCT::DATA_TYPE_MAX, and WRITE.
Referenced by next_event().
00483 { 00484 00485 for(size_t i=0; i<DATA_STRUCT::DATA_TYPE_MAX; ++i) { 00486 00487 if(!_out_ch[i]) continue; 00488 00489 _out_ch[i]->Fill(); 00490 _ptr_data_array[i]->clear_data(); 00491 00492 } 00493 00494 if(_mode==WRITE) 00495 _index++; 00496 _nevents_written++; 00497 //_event_wf->clear_data(); 00498 return true; 00499 }
char decoder_base::_buf[200] [protected, inherited] |
char buffer for message manipulation
Definition at line 46 of file decoder_base.hh.
Referenced by reco_wf::analyze(), pulse_viewer::analyze(), algo_slow_readout_decoder::check_event_quality(), close(), bin_io_handler::close(), decoder_manager::decode(), algo_slow_readout_decoder::decode_ch_word(), algo_pmt_xmit::decode_ch_word(), algo_slow_readout_decoder::decode_event_header(), pulse_viewer::get_waveform(), ana_processor::initialize(), pulse_viewer::next_pulse(), open(), bin_io_handler::open(), prepare_tree(), pulse_viewer::previous_pulse(), algo_slow_readout_decoder::print_adc_values(), algo_tpc_xmit::process_ch_word(), algo_slow_readout_decoder::process_ch_word(), algo_pmt_xmit::process_ch_word(), algo_fem_decoder_base::process_fem_header(), algo_xmit_decoder::process_header(), algo_slow_readout_decoder::process_header(), algo_slow_readout_decoder::process_word(), bin_io_handler::read_multi_word(), bin_io_handler::read_word(), and ana_processor::run().
TFile* storage_manager::_fout [private] |
ROOT file instance.
Definition at line 182 of file storage_manager.hh.
Referenced by get_data(), open(), prepare_tree(), and storage_manager().
TChain* storage_manager::_in_ch[DATA_STRUCT::DATA_TYPE_MAX] [private] |
TTree instance.
Definition at line 186 of file storage_manager.hh.
Referenced by close(), prepare_tree(), read_event(), and reset().
std::vector<std::string> storage_manager::_in_fnames [private] |
Definition at line 175 of file storage_manager.hh.
Referenced by add_in_filename(), input_filename(), open(), prepare_tree(), and reset().
UInt_t storage_manager::_index [private] |
tree index marker
Definition at line 153 of file storage_manager.hh.
Referenced by get_index(), prepare_tree(), read_event(), reset(), and write_event().
MODE storage_manager::_mode [private] |
I/O mode.
Definition at line 162 of file storage_manager.hh.
Referenced by close(), get_data(), io_mode(), next_event(), open(), prepare_tree(), reset(), set_io_mode(), storage_manager(), and write_event().
std::string decoder_base::_name [protected, inherited] |
class name holder
Definition at line 53 of file decoder_base.hh.
Referenced by algo_base::algo_base(), algo_fem_decoder_base::algo_fem_decoder_base(), algo_fixed_window::algo_fixed_window(), algo_slow_readout_decoder::algo_slow_readout_decoder(), algo_threshold::algo_threshold(), algo_tpc_huffman::algo_tpc_huffman(), algo_trig_decoder::algo_trig_decoder(), ana_base::ana_base(), ana_processor::ana_processor(), beamgate_debugger::beamgate_debugger(), bin_io_handler::bin_io_handler(), decoder_base::class_name(), led_pulse_analyzer::led_pulse_analyzer(), led_pulse_selector::led_pulse_selector(), pmt_slow_encoder::pmt_slow_encoder(), pmtbaseline::pmtbaseline(), pmtbaseline_ana::pmtbaseline_ana(), preco_algo_base::preco_algo_base(), pulse_analyzer::pulse_analyzer(), pulse_reco::pulse_reco(), pulse_selector_base::pulse_selector_base(), pulse_selector_simple::pulse_selector_simple(), pulse_viewer::pulse_viewer(), reco_wf::reco_wf(), storage_manager(), and waveform_sampler::waveform_sampler().
UInt_t storage_manager::_nevents [private] |
number of events read/written
Definition at line 156 of file storage_manager.hh.
Referenced by get_entries(), prepare_tree(), read_event(), and reset().
UInt_t storage_manager::_nevents_read [private] |
Definition at line 156 of file storage_manager.hh.
Referenced by get_entries_read(), next_event(), prepare_tree(), read_event(), and reset().
UInt_t storage_manager::_nevents_written [private] |
Definition at line 156 of file storage_manager.hh.
Referenced by prepare_tree(), reset(), and write_event().
TTree* storage_manager::_out_ch[DATA_STRUCT::DATA_TYPE_MAX] [private] |
Definition at line 187 of file storage_manager.hh.
Referenced by close(), get_data(), prepare_tree(), reset(), and write_event().
std::string storage_manager::_out_fname [private] |
I/O filename.
Definition at line 174 of file storage_manager.hh.
Referenced by close(), open(), output_filename(), set_out_filename(), and storage_manager().
data_base* storage_manager::_ptr_data_array[DATA_STRUCT::DATA_TYPE_MAX] [private] |
Data pointer array.
Definition at line 171 of file storage_manager.hh.
Referenced by close(), create_data_ptr(), delete_data_ptr(), get_data(), prepare_tree(), reset(), and write_event().
bool storage_manager::_read_data_array[DATA_STRUCT::DATA_TYPE_MAX] [private] |
Boolean to record what data to be read out from a file.
Definition at line 165 of file storage_manager.hh.
Referenced by prepare_tree(), reset(), and set_data_to_read().
STATUS storage_manager::_status [private] |
status control stamp
Definition at line 159 of file storage_manager.hh.
Referenced by close(), is_open(), is_ready_io(), next_event(), open(), prepare_tree(), reset(), status(), and storage_manager().
const std::string storage_manager::_treename [private] |
bool decoder_base::_verbosity[MSG::MSG_TYPE_MAX] [protected, inherited] |
holder for enabled message levels
Definition at line 51 of file decoder_base.hh.
Referenced by reco_wf::analyze(), algo_slow_readout_decoder::check_event_quality(), close(), decoder_manager::decode(), algo_slow_readout_decoder::decode_ch_word(), algo_pmt_xmit::decode_ch_word(), algo_slow_readout_decoder::decode_event_header(), algo_fem_decoder_base::decode_fem_header(), algo_trig_decoder::decode_trigger_words(), decoder_manager::finalize(), beamgate_debugger::finalize(), ana_processor::finalize(), decoder_manager::initialize(), beamgate_debugger::initialize(), ana_processor::initialize(), open(), beamgate_debugger::prepare_histo(), prepare_tree(), algo_tpc_xmit::process_ch_word(), algo_tpc_huffman::process_ch_word(), algo_slow_readout_decoder::process_ch_word(), algo_pmt_xmit::process_ch_word(), algo_tpc_xmit::process_event_last_word(), algo_pmt_xmit::process_event_last_word(), algo_fem_decoder_base::process_fem_header(), algo_pmt_xmit::process_fem_last_word(), algo_xmit_decoder::process_header(), algo_slow_readout_decoder::process_header(), algo_fem_decoder_base::process_word(), bin_io_handler::read_multi_word(), reset(), beamgate_debugger::reset(), ana_processor::reset(), decoder_manager::run(), ana_processor::run(), decoder_base::set_verbosity(), algo_tpc_xmit::store_event(), and algo_pmt_xmit::store_event().
MSG::Level decoder_base::_verbosity_level [protected, inherited] |
holder for specified verbosity level
Definition at line 52 of file decoder_base.hh.
Referenced by pulse_viewer::analyze(), decoder_base::get_verbosity(), pulse_viewer::initialize(), decoder_manager::initialize(), ana_processor::initialize(), bin_io_handler::read_multi_word(), bin_io_handler::read_word(), and decoder_base::set_verbosity().
bool storage_manager::_write_data_array[DATA_STRUCT::DATA_TYPE_MAX] [private] |
Boolean to record what data to be written out from a file.
Definition at line 168 of file storage_manager.hh.
Referenced by get_data(), prepare_tree(), reset(), and set_data_to_write().
storage_manager * storage_manager::me = 0 [static, private] |
1.4.7