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

Public Types | |
| INIT | |
| Process is @ the initialization stage. | |
| READY | |
| Process is ready to start data processing. | |
| PROCESSING | |
| Process is processing data. | |
| FINISHED | |
| Process has finished processing allevents. | |
| enum | PROCESS_FLAG { INIT, READY, PROCESSING, FINISHED } |
| Process flag enum. More... | |
Public Member Functions | |
| ana_processor () | |
| Default constructor. | |
| ~ana_processor () | |
| Default destructor. | |
| virtual void | set_verbosity (MSG::Level level) |
| It changes the verbosity level of not just this class but also owned other class instances. | |
| void | add_input_file (std::string name) |
| Setter for an input DATA file name. | |
| void | set_output_file (std::string name) |
| Setter for an output DATA file name. | |
| void | set_ana_output_file (std::string name) |
| Setter for an analysis output root file name. | |
| void | set_io_mode (storage_manager::MODE mode) |
| Setter for I/O mode ... READ or WRITE or BOTH. | |
| 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 write in output. | |
| bool | get_ana_status (ana_base *ptr) const |
| Getter of running analysis status. | |
| bool | run (UInt_t start_index=0, UInt_t nevents=0) |
| A method to run a batch process. | |
| bool | process_event (UInt_t index=0) |
| A method to process just one event. | |
| size_t | add_process (ana_base *ana) |
| A method to append analysis class instance. Returns index number. | |
| ana_base * | get_process (size_t loc) |
| A method to inquir attached analysis class instance. | |
| PROCESS_FLAG | get_process_status () |
| A method to inquire the process status. | |
| MSG::Level | get_verbosity () const |
| Getter for the verbosity level. | |
| const std::string | class_name () const |
| Getter for the class name. | |
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 | reset () |
| A method to reset members. | |
| bool | initialize () |
| A method to initialize and prepare for running analysis. | |
| bool | finalize () |
| A method to finalize data processing. | |
Private Attributes | |
| std::vector< ana_base * > | _analyzers |
| A vector of analysis modules. | |
| std::map< ana_base *, bool > | _ana_status |
| A map of analysis module status. | |
| PROCESS_FLAG | _process |
| Processing status flag. | |
| UInt_t | _nevents |
| Number of events being processed. | |
| UInt_t | _index |
| Index of currently processing event. | |
| std::string | _ofile_name |
| Output file name. | |
| TFile * | _fout |
| Output file pointer. | |
| storage_manager * | _storage |
| Storage manager pointer. | |
This class process data by applying loaded analysis modules in consecutive order.
Definition at line 28 of file ana_processor.hh.
Process flag enum.
| INIT | Process is @ the initialization stage. |
| READY | Process is ready to start data processing. |
| PROCESSING | Process is processing data. |
| FINISHED | Process has finished processing allevents. |
Definition at line 33 of file ana_processor.hh.
00033 { 00034 INIT, 00035 READY, 00036 PROCESSING, 00037 FINISHED 00038 };
| ana_processor::ana_processor | ( | ) |
Default constructor.
Definition at line 6 of file ana_processor.cc.
References _fout, decoder_base::_name, _ofile_name, _storage, storage_manager::get(), and reset().
00006 { 00007 _name="ana_processor"; 00008 _ofile_name=""; 00009 //_mode=storage_manager::READ; // default I/O mode is to produce no output 00010 _storage=storage_manager::get(); 00011 _fout=0; 00012 reset(); 00013 }
| ana_processor::~ana_processor | ( | ) | [inline] |
| void ana_processor::add_input_file | ( | std::string | name | ) | [inline] |
Setter for an input DATA file name.
Definition at line 54 of file ana_processor.hh.
References _storage, and storage_manager::add_in_filename().
Referenced by main().
00054 {_storage->add_in_filename(name);};
| size_t ana_processor::add_process | ( | ana_base * | ana | ) | [inline] |
A method to append analysis class instance. Returns index number.
Definition at line 83 of file ana_processor.hh.
References _analyzers.
Referenced by main().
00083 {_analyzers.push_back(ana); return _analyzers.size()-1;};
| 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 ana_processor::finalize | ( | ) | [private] |
A method to finalize data processing.
Definition at line 201 of file ana_processor.cc.
References _ana_status, _analyzers, _process, decoder_base::_verbosity, MSG::DEBUG, MSG::ERROR, FINISHED, PROCESSING, READY, reset(), and Message::send().
Referenced by process_event(), and run().
00201 { 00202 00203 if(_verbosity[MSG::DEBUG]) 00204 Message::send(MSG::DEBUG,__PRETTY_FUNCTION__,"called..."); 00205 00206 if(_process!=PROCESSING && _process!=READY) { 00207 Message::send(MSG::ERROR,__FUNCTION__, 00208 "Logic error: the function should not be called."); 00209 return false; 00210 } 00211 00212 bool status=true; 00213 for(std::vector<ana_base*>::iterator iter(_analyzers.begin()); 00214 iter!=_analyzers.end(); 00215 ++iter) { 00216 00217 _ana_status[(*iter)]=_ana_status[(*iter)] && (*iter)->finalize(); 00218 00219 status = status && _ana_status[(*iter)]; 00220 } 00221 00222 _process=FINISHED; 00223 reset(); 00224 return status; 00225 }
| bool ana_processor::get_ana_status | ( | ana_base * | ptr | ) | const |
Getter of running analysis status.
Definition at line 227 of file ana_processor.cc.
References _ana_status.
00227 { 00228 00229 std::map<ana_base*,bool>::const_iterator iter(_ana_status.find(ptr)); 00230 if(iter==_ana_status.end()) return false; 00231 00232 else return (*iter).second; 00233 00234 }
| ana_base* ana_processor::get_process | ( | size_t | loc | ) | [inline] |
A method to inquir attached analysis class instance.
Definition at line 86 of file ana_processor.hh.
References _analyzers.
00086 {return (_analyzers.size() > loc) ? _analyzers[loc] : 0;};
| PROCESS_FLAG ana_processor::get_process_status | ( | ) | [inline] |
A method to inquire the process status.
Definition at line 89 of file ana_processor.hh.
References _process.
00089 {return _process;};
| 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 ana_processor::initialize | ( | ) | [private] |
A method to initialize and prepare for running analysis.
Definition at line 47 of file ana_processor.cc.
References _analyzers, decoder_base::_buf, _fout, _index, _nevents, _ofile_name, _process, _storage, decoder_base::_verbosity, decoder_base::_verbosity_level, MSG::DEBUG, MSG::ERROR, INIT, storage_manager::open(), READY, Message::send(), and set_verbosity().
Referenced by process_event(), and run().
00047 { 00048 00049 set_verbosity(_verbosity_level); 00050 00051 if(_verbosity[MSG::DEBUG]) 00052 Message::send(MSG::DEBUG,__PRETTY_FUNCTION__,"called..."); 00053 00054 if(_process!=INIT){ 00055 Message::send(MSG::ERROR,__FUNCTION__, 00056 "Logic error: the function should not be called."); 00057 return false; 00058 } 00059 00060 _fout=TFile::Open(_ofile_name.c_str(),"RECREATE"); 00061 00062 if(!_fout){ 00063 00064 sprintf(_buf,"Failed to open an output file: %s",_ofile_name.c_str()); 00065 00066 Message::send(MSG::ERROR,__FUNCTION__,_buf); 00067 00068 return false; 00069 00070 } 00071 00072 //_storage->set_io_mode(storage_manager::READ); 00073 if(!_storage->open()) { 00074 00075 Message::send(MSG::ERROR,__FUNCTION__,"File I/O failure..."); 00076 00077 return false; 00078 00079 } 00080 00081 if(_ofile_name.size()==0){ 00082 00083 Message::send(MSG::ERROR,__FUNCTION__, 00084 "Must provide an output filename!"); 00085 return false; 00086 } 00087 00088 bool status = true; 00089 _fout->cd(); 00090 for(std::vector<ana_base*>::iterator iter(_analyzers.begin()); 00091 iter!=_analyzers.end(); 00092 ++iter) { 00093 00094 (*iter)->set_output_file(_fout); 00095 00096 if(!((*iter)->initialize())){ 00097 00098 Message::send(MSG::ERROR,__PRETTY_FUNCTION__, 00099 Form("Failed to initialize: %s",(*iter)->class_name().c_str())); 00100 00101 status = false; 00102 } 00103 00104 } 00105 _process=READY; 00106 _index=0; 00107 _nevents=0; 00108 return status; 00109 }
| bool ana_processor::process_event | ( | UInt_t | index = 0 |
) |
A method to process just one event.
Definition at line 111 of file ana_processor.cc.
References _ana_status, _analyzers, _index, _nevents, _process, _storage, MSG::ERROR, finalize(), storage_manager::go_to(), INIT, initialize(), storage_manager::next_event(), PROCESSING, READY, and Message::send().
Referenced by run().
00111 { 00112 00113 if(_process==INIT) { 00114 00115 if(!initialize()) { 00116 Message::send(MSG::ERROR,__FUNCTION__,"Aborting."); 00117 return false; 00118 } 00119 else 00120 _process=PROCESSING; 00121 } 00122 00123 if(_process==READY) 00124 _process=PROCESSING; 00125 00126 bool event_found = index ? _storage->go_to(index) : _storage->next_event(); 00127 00128 if(event_found){ 00129 00130 for(std::vector<ana_base*>::iterator iter(_analyzers.begin()); 00131 iter!=_analyzers.end(); 00132 ++iter) 00133 _ana_status[(*iter)]=(*iter)->analyze(_storage); 00134 00135 _index++; 00136 _nevents++; 00137 00138 return true; 00139 00140 } 00141 else 00142 return finalize(); 00143 }
| void ana_processor::reset | ( | ) | [private] |
A method to reset members.
Definition at line 26 of file ana_processor.cc.
References _ana_status, _analyzers, _fout, _index, _nevents, _process, _storage, decoder_base::_verbosity, MSG::DEBUG, INIT, storage_manager::reset(), and Message::send().
Referenced by ana_processor(), and finalize().
00026 { 00027 00028 if(_verbosity[MSG::DEBUG]) 00029 Message::send(MSG::DEBUG,__PRETTY_FUNCTION__,"called..."); 00030 00031 if(_storage) 00032 _storage->reset(); 00033 00034 if(_fout){ 00035 _fout->Close(); 00036 _fout=0; 00037 } 00038 00039 _analyzers.clear(); 00040 _ana_status.clear(); 00041 _nevents=0; 00042 _index=0; 00043 00044 _process=INIT; 00045 }
| bool ana_processor::run | ( | UInt_t | start_index = 0, |
|
| UInt_t | nevents = 0 | |||
| ) |
A method to run a batch process.
Definition at line 145 of file ana_processor.cc.
References decoder_base::_buf, _index, _nevents, _process, _storage, decoder_base::_verbosity, MSG::DEBUG, MSG::ERROR, finalize(), storage_manager::get_entries(), storage_manager::go_to(), INIT, initialize(), MSG::NORMAL, process_event(), PROCESSING, and Message::send().
Referenced by main().
00145 { 00146 00147 if(_verbosity[MSG::DEBUG]) 00148 Message::send(MSG::DEBUG,__PRETTY_FUNCTION__,"called..."); 00149 00150 bool status=true; 00151 00152 if(_process==INIT) status = initialize(); 00153 00154 if(!status){ 00155 00156 Message::send(MSG::ERROR,__PRETTY_FUNCTION__,"Aborting."); 00157 00158 return false; 00159 } 00160 00161 _index=start_index; 00162 00163 if(start_index) 00164 _storage->go_to(start_index); 00165 00166 if(!nevents) 00167 nevents=_storage->get_entries(); 00168 if(nevents > (_storage->get_entries() - start_index)) 00169 nevents=_storage->get_entries() - start_index; 00170 00171 sprintf(_buf,"Processing %d events...",nevents); 00172 Message::send(MSG::NORMAL,__FUNCTION__,_buf); 00173 00174 int ten_percent_ctr=0; 00175 00176 while(status){ 00177 00178 status=process_event(); 00179 00180 if(nevents && nevents < _nevents){ 00181 Message::send(MSG::NORMAL,__FUNCTION__,Form("Processed %d/%d events! Aborting...",_nevents,nevents)); 00182 finalize(); 00183 break; 00184 } 00185 00186 if(nevents > 10 && (_nevents >= ten_percent_ctr * nevents/10)) { 00187 00188 sprintf(_buf," ... %3d%% done ...",ten_percent_ctr*10); 00189 Message::send(MSG::NORMAL,__FUNCTION__,_buf); 00190 ten_percent_ctr++; 00191 } 00192 00193 if(_process!=PROCESSING) break; 00194 00195 } 00196 00197 return status; 00198 00199 }
| void ana_processor::set_ana_output_file | ( | std::string | name | ) | [inline] |
Setter for an analysis output root file name.
Definition at line 60 of file ana_processor.hh.
References _ofile_name.
Referenced by main().
00060 {_ofile_name=name;};
| void ana_processor::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 66 of file ana_processor.hh.
References _storage, and storage_manager::set_data_to_read().
00067 {_storage->set_data_to_read(type,read);};
| void ana_processor::set_data_to_write | ( | DATA_STRUCT::DATA_TYPE | type, | |
| bool | write = true | |||
| ) | [inline] |
Setter to specify a certain data class to be write in output.
Definition at line 70 of file ana_processor.hh.
References _storage, and storage_manager::set_data_to_write().
00071 {_storage->set_data_to_write(type,write);};
| void ana_processor::set_io_mode | ( | storage_manager::MODE | mode | ) | [inline] |
Setter for I/O mode ... READ or WRITE or BOTH.
Definition at line 63 of file ana_processor.hh.
References _storage, and storage_manager::set_io_mode().
Referenced by main().
00063 {_storage->set_io_mode(mode);};
| void ana_processor::set_output_file | ( | std::string | name | ) | [inline] |
Setter for an output DATA file name.
Definition at line 57 of file ana_processor.hh.
References _storage, and storage_manager::set_out_filename().
Referenced by main().
00057 {_storage->set_out_filename(name);};
| void ana_processor::set_verbosity | ( | MSG::Level | level | ) | [virtual] |
It changes the verbosity level of not just this class but also owned other class instances.
Reimplemented from decoder_base.
Definition at line 15 of file ana_processor.cc.
References _analyzers, _storage, and decoder_base::set_verbosity().
Referenced by initialize().
00015 { 00016 decoder_base::set_verbosity(level); 00017 if(_storage) 00018 _storage->set_verbosity(level); 00019 for(std::vector<ana_base*>::const_iterator iter(_analyzers.begin()); 00020 iter!=_analyzers.end(); 00021 ++iter){ 00022 (*iter)->set_verbosity(level); 00023 } 00024 }
std::map<ana_base*,bool> ana_processor::_ana_status [private] |
A map of analysis module status.
Definition at line 103 of file ana_processor.hh.
Referenced by finalize(), get_ana_status(), process_event(), and reset().
std::vector<ana_base*> ana_processor::_analyzers [private] |
A vector of analysis modules.
Definition at line 102 of file ana_processor.hh.
Referenced by add_process(), finalize(), get_process(), initialize(), process_event(), reset(), and set_verbosity().
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(), storage_manager::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(), initialize(), pulse_viewer::next_pulse(), storage_manager::open(), bin_io_handler::open(), storage_manager::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 run().
TFile* ana_processor::_fout [private] |
Output file pointer.
Definition at line 109 of file ana_processor.hh.
Referenced by ana_processor(), initialize(), and reset().
UInt_t ana_processor::_index [private] |
Index of currently processing event.
Definition at line 107 of file ana_processor.hh.
Referenced by initialize(), process_event(), reset(), and run().
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(), 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::storage_manager(), and waveform_sampler::waveform_sampler().
UInt_t ana_processor::_nevents [private] |
Number of events being processed.
Definition at line 106 of file ana_processor.hh.
Referenced by initialize(), process_event(), reset(), and run().
std::string ana_processor::_ofile_name [private] |
Output file name.
Definition at line 108 of file ana_processor.hh.
Referenced by ana_processor(), initialize(), and set_ana_output_file().
PROCESS_FLAG ana_processor::_process [private] |
Processing status flag.
Definition at line 105 of file ana_processor.hh.
Referenced by finalize(), get_process_status(), initialize(), process_event(), reset(), and run().
storage_manager* ana_processor::_storage [private] |
Storage manager pointer.
Definition at line 110 of file ana_processor.hh.
Referenced by add_input_file(), ana_processor(), initialize(), process_event(), reset(), run(), set_data_to_read(), set_data_to_write(), set_io_mode(), set_output_file(), and set_verbosity().
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(), storage_manager::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(), finalize(), decoder_manager::initialize(), beamgate_debugger::initialize(), initialize(), storage_manager::open(), beamgate_debugger::prepare_histo(), storage_manager::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(), storage_manager::reset(), beamgate_debugger::reset(), reset(), decoder_manager::run(), 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(), initialize(), bin_io_handler::read_multi_word(), bin_io_handler::read_word(), and decoder_base::set_verbosity().
1.4.7