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

Public Member Functions | |
| algo_fem_decoder_base () | |
| Default constructor. | |
| virtual | ~algo_fem_decoder_base () |
| Default destructor. | |
| virtual bool | process_word (const PMT::word_t word) |
| Implementation of algo_base::process_word. | |
| virtual PMT::PMT_WORD | get_word_class (const PMT::word_t word) const |
| Implementation of algo_base::process_word. | |
| virtual bool | check_event_quality () |
| Implementation of algo_base::check_event_quality. | |
| virtual void | reset () |
| Override function to reset the instance. | |
| PMT::word_t | round_diff (PMT::word_t ref_id, PMT::word_t subject_id, PMT::word_t diff) const |
| A simple round-diff algorithm for binary words. | |
| virtual bool | is_event_empty () |
| A simple method to inquire if the data storage buffer is currently empty or not. | |
| virtual void | finalize () |
| Function called just after processing word. | |
| void | set_debug_mode (bool doit) |
| Run utility: set debug mode. Children class defines what-to-do in debug mode. | |
| void | set_storage_ptr (storage_manager *storage) |
| Expects a storage pointer to be provided from a parent class. | |
| virtual void | set_backtrace_mode (size_t nwords=0) |
| Run utility: set back-trace mode. One should provide number of words to be stored. | |
| size_t | backtrace_mode () const |
| Getter for backtrace mode (returns # words specified to store. 0=no backtrace). | |
| void | backtrace () const |
| Function to print out stored words in buffer for back-trace purpose. | |
| 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. | |
Protected Member Functions | |
| virtual bool | store_event ()=0 |
| A method to store event-wise data. | |
| virtual void | clear_event () |
| A method to clear event-wise data. | |
| virtual bool | process_fem_header (const PMT::word_t word, PMT::word_t &last_word) |
| A method to process FEM header word passed from process_word method. | |
| virtual bool | decode_fem_header (const PMT::word_t *event_header) |
| A method to decode fem header word passed from process_header. | |
| virtual bool | process_event_header (const PMT::word_t word, PMT::word_t &last_word)=0 |
| TO BE IMPLEMENTED! A method to process event header word. | |
| virtual bool | process_ch_word (const PMT::word_t word, PMT::word_t &last_word)=0 |
| TO BE IMPLEMENTED! A method to process channel word passed from process_word method. | |
| virtual bool | process_fem_last_word (const PMT::word_t word, PMT::word_t &last_word)=0 |
| TO BE IMPLEMENTED! A method to process 32-bit end-of-fem word. | |
| virtual bool | process_event_last_word (const PMT::word_t word, PMT::word_t &last_word)=0 |
| TO BE IMPLEMENTED! A method to process 32-bit end-of-event word. | |
| virtual bool | add_huffman_adc (std::vector< UShort_t > &wf, size_t zero_count) |
| virtual void | init_checker_info () |
| Function to initialize checker information. | |
Protected Attributes | |
| PMT::word_t | _event_header_words [FEM_HEADER_COUNT] |
| Event header word holder. | |
| PMT::word_t | _last_word |
| Last word processed. | |
| size_t | _event_header_count |
| A counter for event header words. | |
| bool | _search_for_next_event |
| A run control boolean: skips any action till it finds the new event header. | |
| InfoFEM_t | _header_info |
| bool | _debug_mode |
| Debug mode boolean holder. | |
| bool | _bt_mode |
| Back-trace mode boolean holder. | |
| storage_manager * | _storage |
| Data storage pointer to be provided by a parent process. | |
| PMT::word_t | _checksum |
| data checksum | |
| PMT::word_t | _nwords |
| number of data word counts processed | |
| std::deque< PMT::word_t > | _bt_words |
| processed words to be stored event-wise for back-trace purpose | |
| size_t | _bt_nwords |
| user defined # of words to be temporarily stored in the buffer | |
| bool | _bt_nwords_filled |
| run utility boolean to keep a recored of filled buffer | |
| 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 | |
Static Protected Attributes | |
| static const size_t | FEM_HEADER_COUNT = 6 |
| Number of event header words. | |
| static const size_t | BEAM_REF_CHANNEL = 39 |
| Defines a reference channel for beamgate. | |
| static const size_t | BEAM_NWORDS = 21 |
| Defines # of minimum words to identify beamgate event. | |
| static const size_t | FRAME_WIDTH = 8192 |
| Defines # of ADC samples per readout frame. | |
Classes | |
| struct | InfoFEM_t |
| A local data holder struct for FEM header information. More... | |
It expects a stream of 32-bit words (ordered) to be fed into process_word method. This class takes care of decoding & grouping channel/event wise data & storing them.
This base class only implements the overall structure of decoding. It has two types of processing path: either event header or channel data word. The FEM header is common among TPC and PMT as they share the same FEM module. Channel data word is defined differently as data packet FPGA code is unique to each. Children class must implement channel-wise decoding methods.
Definition at line 34 of file algo_fem_decoder_base.hh.
| algo_fem_decoder_base::algo_fem_decoder_base | ( | ) |
Default constructor.
Definition at line 7 of file algo_fem_decoder_base.cc.
References decoder_base::_name, and reset().
00008 : algo_base() 00009 //################################################# 00010 { 00011 _name = "algo_fem_decoder_base"; 00012 reset(); 00013 }
| virtual algo_fem_decoder_base::~algo_fem_decoder_base | ( | ) | [inline, virtual] |
| bool algo_fem_decoder_base::add_huffman_adc | ( | std::vector< UShort_t > & | wf, | |
| size_t | zero_count | |||
| ) | [protected, virtual] |
Definition at line 396 of file algo_fem_decoder_base.cc.
Referenced by algo_tpc_xmit::decode_ch_word().
00397 { 00398 //################################################# 00399 00400 bool status = true; 00401 00402 switch(zero_count){ 00403 00404 case 0: 00405 wf.push_back( (*(wf.rbegin())) ); break; 00406 00407 case 1: 00408 wf.push_back( (*(wf.rbegin())) -1 ); break; 00409 00410 case 2: 00411 wf.push_back( (*(wf.rbegin())) +1 ); break; 00412 00413 case 3: 00414 wf.push_back( (*(wf.rbegin())) -2 ); break; 00415 00416 case 4: 00417 wf.push_back( (*(wf.rbegin())) +2 ); break; 00418 00419 case 5: 00420 wf.push_back( (*(wf.rbegin())) -3 ); break; 00421 00422 case 6: 00423 wf.push_back( (*(wf.rbegin())) +3 ); break; 00424 00425 default: 00426 00427 std::cout<<zero_count<<std::endl; 00428 00429 status = false; 00430 } 00431 00432 return status; 00433 00434 }
| void algo_base::backtrace | ( | ) | const [inline, inherited] |
Function to print out stored words in buffer for back-trace purpose.
Definition at line 82 of file algo_base.hh.
References algo_base::_bt_words, Message::send(), and MSG::WARNING.
Referenced by algo_tpc_huffman::process_word(), and process_word().
00083 { 00084 Message::send(MSG::WARNING,__FUNCTION__,"Dumping a backtrace..."); 00085 int ctr=1; 00086 for(std::deque<PMT::word_t>::const_iterator iter(_bt_words.begin()); 00087 iter!=_bt_words.end(); 00088 ++iter) { 00089 printf("%08x ",(*iter)); 00090 if(ctr%8==0 && ctr) std::cout<<std::endl; 00091 ctr++; 00092 } 00093 std::cout<<std::endl<<std::endl; 00094 };
| size_t algo_base::backtrace_mode | ( | ) | const [inline, inherited] |
Getter for backtrace mode (returns # words specified to store. 0=no backtrace).
Definition at line 71 of file algo_base.hh.
References algo_base::_bt_nwords.
00071 {return _bt_nwords;};
| virtual bool algo_fem_decoder_base::check_event_quality | ( | ) | [inline, virtual] |
Implementation of algo_base::check_event_quality.
Reimplemented from algo_base.
Reimplemented in algo_pmt_xmit, and algo_tpc_xmit.
Definition at line 98 of file algo_fem_decoder_base.hh.
| 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;};
| virtual void algo_fem_decoder_base::clear_event | ( | ) | [inline, protected, virtual] |
A method to clear event-wise data.
Reimplemented in algo_pmt_xmit, algo_tpc_huffman, and algo_tpc_xmit.
Definition at line 115 of file algo_fem_decoder_base.hh.
References _event_header_count, _header_info, and algo_fem_decoder_base::InfoFEM_t::clear_event().
Referenced by algo_tpc_xmit::clear_event(), algo_pmt_xmit::clear_event(), process_fem_header(), and process_word().
00115 {_event_header_count=0; _header_info.clear_event();};
| bool algo_fem_decoder_base::decode_fem_header | ( | const PMT::word_t * | event_header | ) | [protected, virtual] |
A method to decode fem header word passed from process_header.
Definition at line 295 of file algo_fem_decoder_base.cc.
References algo_base::_checksum, _header_info, algo_base::_nwords, decoder_base::_verbosity, algo_fem_decoder_base::InfoFEM_t::checksum, algo_fem_decoder_base::InfoFEM_t::clear_event(), MSG::ERROR, algo_fem_decoder_base::InfoFEM_t::event_frame_id, algo_fem_decoder_base::InfoFEM_t::event_id, MSG::INFO, algo_fem_decoder_base::InfoFEM_t::module_address, algo_fem_decoder_base::InfoFEM_t::module_id, algo_fem_decoder_base::InfoFEM_t::nwords, round_diff(), Message::send(), algo_fem_decoder_base::InfoFEM_t::trigger_frame_id, and algo_fem_decoder_base::InfoFEM_t::trigger_timeslice.
Referenced by algo_tpc_huffman::process_fem_header(), and process_fem_header().
00295 { 00296 //################################################# 00297 00298 bool status=true; 00299 // 00300 // Get event information 00301 // 00302 00303 // (1) check if the very first 16-bit word is as expected 00304 if(!( event_header[0] & 0xffff)) 00305 Message::send(MSG::ERROR,"Unexpected first word in event headers!"); 00306 00307 if(!status) return status; 00308 00309 // Initialize data holder 00310 _header_info.clear_event(); 00311 00312 // (2) get module address ... lowest 5 of 12 bits 00313 _header_info.module_address = ( (event_header[0]>>16 & 0xfff) & 0x1f); 00314 00315 // (3) get module ID number ... upper 7 bit of 12 bits 00316 _header_info.module_id = ( (event_header[0]>>16 & 0xfff)>>5 & 0x7f); 00317 00318 // (4) get number of 16-bit words to be read in this event. 00319 // Lower 12 bits of two 16-bit words. 00320 // The very last "last word for channel info" is not included in this. 00321 // For later checking purpose, increment by 1. 00322 _header_info.nwords = ( (((event_header[1]>>16) & 0xfff) + ((event_header[1] & 0xfff)<<12))); 00323 00324 // (5) get event ID 00325 // Lower 12 bits of two 16-bit words. 00326 _header_info.event_id = ( (((event_header[2]>>16) & 0xfff) + ((event_header[2] & 0xfff)<<12))); 00327 00328 // (6) get frame ID 00329 // Lower 12 bits of two 16-bit words. 00330 _header_info.event_frame_id = ( (((event_header[3]>>16) & 0xfff) + ((event_header[3] & 0xfff)<<12))); 00331 00332 // (7) get checksum 00333 _header_info.checksum = ( (((event_header[4]>>16) & 0xfff) + ((event_header[4] & 0xfff)<<12))); 00334 00335 00336 #ifdef INCLUDE_EXTRA_HEADER 00337 _header_info.trigger_frame_id = ( ((event_header[5] & 0xfff)>>4 & 0xf) + 00338 (((_header_info.event_frame_id)>>4)<<4)); 00339 00340 // Correct for a roll over 00341 _header_info.trigger_frame_id = round_diff(_header_info.event_frame_id, _header_info.trigger_frame_id, 0x7); 00342 00343 _header_info.trigger_timeslice = ((((event_header[5]>>16) & 0xf)<<8) + (event_header[5] & 0xff)); 00344 00345 #endif 00346 00347 // Report if verbosity is set. 00348 if(_verbosity[MSG::INFO]) 00349 { 00350 Message::send(MSG::INFO,Form("Module %d (ID=%d)", _header_info.module_address, _header_info.module_id)); 00351 Message::send(MSG::INFO,Form("Event ID %d",_header_info.event_id)); 00352 Message::send(MSG::INFO,Form("Frame ID %d",_header_info.event_frame_id)); 00353 Message::send(MSG::INFO,Form("Number of Words = %d",_header_info.nwords)); 00354 Message::send(MSG::INFO,Form("Checksum = %x", _header_info.checksum)); 00355 Message::send(MSG::INFO,Form("Trigger Frame %d",_header_info.trigger_frame_id)); 00356 Message::send(MSG::INFO,Form("Trigger Sample %d",_header_info.trigger_timeslice)); 00357 } 00358 00359 _checksum=0; 00360 00361 _nwords=0; 00362 00363 return status; 00364 }
| virtual void algo_base::finalize | ( | ) | [inline, virtual, inherited] |
| 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;};
| virtual PMT::PMT_WORD algo_fem_decoder_base::get_word_class | ( | const PMT::word_t | word | ) | const [inline, virtual] |
Implementation of algo_base::process_word.
Reimplemented from algo_base.
Reimplemented in algo_pmt_xmit, algo_tpc_huffman, and algo_tpc_xmit.
Definition at line 80 of file algo_fem_decoder_base.hh.
References PMT::CHANNEL_HEADER, PMT::CHANNEL_LAST_WORD, PMT::CHANNEL_WORD, PMT::FEM_FIRST_WORD, PMT::FEM_HEADER, PMT::FEM_LAST_WORD, and PMT::UNDEFINED_WORD.
Referenced by process_fem_header(), and process_word().
00080 { 00081 if ( (word & 0xf000) == 0xf000 ) 00082 return PMT::FEM_HEADER; 00083 else if( (word & 0xf000) == 0x4000 ) 00084 return PMT::FEM_FIRST_WORD; 00085 else if( (word & 0xf000) == 0x9000 ) 00086 return PMT::CHANNEL_HEADER; 00087 else if( (word & 0xf000) == 0xa000 ) 00088 return PMT::CHANNEL_WORD; 00089 else if( (word & 0xf000) == 0xb000 ) 00090 return PMT::CHANNEL_LAST_WORD; 00091 else if( (word & 0xf000) == 0xc000 ) 00092 return PMT::FEM_LAST_WORD; 00093 else 00094 return PMT::UNDEFINED_WORD; 00095 }
| void algo_base::init_checker_info | ( | ) | [protected, virtual, inherited] |
Function to initialize checker information.
Definition at line 6 of file algo_base.cc.
References algo_base::_checksum, and algo_base::_nwords.
Referenced by algo_slow_readout_decoder::init_event_info(), algo_trig_decoder::reset(), and algo_base::reset().
| virtual bool algo_fem_decoder_base::is_event_empty | ( | ) | [inline, virtual] |
A simple method to inquire if the data storage buffer is currently empty or not.
Implements algo_base.
Definition at line 107 of file algo_fem_decoder_base.hh.
References _header_info, algo_fem_decoder_base::InfoFEM_t::event_id, and PMT::INVALID_WORD.
00107 { return (_header_info.event_id == PMT::INVALID_WORD);};
| virtual bool algo_fem_decoder_base::process_ch_word | ( | const PMT::word_t | word, | |
| PMT::word_t & | last_word | |||
| ) | [protected, pure virtual] |
TO BE IMPLEMENTED! A method to process channel word passed from process_word method.
Channel word processing must be implemented in the children
Implemented in algo_pmt_xmit, algo_tpc_huffman, and algo_tpc_xmit.
Referenced by process_word().
| virtual bool algo_fem_decoder_base::process_event_header | ( | const PMT::word_t | word, | |
| PMT::word_t & | last_word | |||
| ) | [protected, pure virtual] |
TO BE IMPLEMENTED! A method to process event header word.
Implemented in algo_pmt_xmit, algo_tpc_huffman, and algo_tpc_xmit.
Referenced by process_word().
| virtual bool algo_fem_decoder_base::process_event_last_word | ( | const PMT::word_t | word, | |
| PMT::word_t & | last_word | |||
| ) | [protected, pure virtual] |
TO BE IMPLEMENTED! A method to process 32-bit end-of-event word.
Implemented in algo_pmt_xmit, algo_tpc_huffman, and algo_tpc_xmit.
Referenced by process_word().
| bool algo_fem_decoder_base::process_fem_header | ( | const PMT::word_t | word, | |
| PMT::word_t & | last_word | |||
| ) | [protected, virtual] |
A method to process FEM header word passed from process_word method.
Reimplemented in algo_tpc_huffman.
Definition at line 185 of file algo_fem_decoder_base.cc.
References decoder_base::_buf, algo_base::_debug_mode, _event_header_count, _event_header_words, decoder_base::_verbosity, PMT::CHANNEL_HEADER, PMT::CHANNEL_LAST_WORD, PMT::CHANNEL_WORD, clear_event(), MSG::DEBUG, decode_fem_header(), MSG::ERROR, PMT::EVENT_HEADER, PMT::EVENT_LAST_WORD, PMT::FEM_FIRST_WORD, PMT::FEM_HEADER, FEM_HEADER_COUNT, PMT::FEM_LAST_WORD, get_word_class(), Message::send(), store_event(), PMT::UNDEFINED_WORD, and MSG::WARNING.
Referenced by process_word().
00185 { 00186 //################################################# 00187 00188 bool status=true; 00189 // 00190 // Check if this is an event header word or not 00191 // 00192 PMT::PMT_WORD word_class=get_word_class(word); 00193 if(_verbosity[MSG::DEBUG]){ 00194 sprintf(_buf,"Processing Header: %x",word); 00195 Message::send(MSG::DEBUG,__FUNCTION__,_buf); 00196 } 00197 00198 00199 if( word_class != PMT::FEM_HEADER) { 00200 00201 Message::send(MSG::ERROR,__FUNCTION__, 00202 Form("Encountered unexpected word while an event header search: %x (word type=%d)", 00203 word,word_class) ); 00204 status = false; 00205 00206 }else if(get_word_class(word>>16)!=PMT::FEM_HEADER) { 00207 00208 // Event header should come as a 32-bit word which is a pair of two 16-bit header words. 00209 // The first 16-bit is already checked by this point. Check the second part. 00210 00211 Message::send(MSG::ERROR,__FUNCTION__,Form("Found an odd event header word: %x",word)); 00212 00213 status = false; 00214 00215 } 00216 00217 if(status) { 00218 00219 // 00220 // Check the last word type 00221 // 00222 switch(get_word_class(last_word)){ 00223 case PMT::EVENT_HEADER: 00224 case PMT::FEM_HEADER: 00225 case PMT::FEM_LAST_WORD: 00226 // Expected. Nothing to do 00227 break; 00228 case PMT::FEM_FIRST_WORD: 00229 case PMT::CHANNEL_HEADER: 00230 case PMT::CHANNEL_WORD: 00231 case PMT::UNDEFINED_WORD: 00232 case PMT::EVENT_LAST_WORD: 00233 // ERROR 00234 Message::send(MSG::ERROR,__FUNCTION__, 00235 Form("Unexpected word while FEM_HEADER processing: %x (previous word=%x)",word,last_word)); 00236 status = false; 00237 break; 00238 case PMT::CHANNEL_LAST_WORD: 00239 // Store data 00240 status = store_event(); 00241 if(_debug_mode) { 00242 // We have to handle this case separately from a uniifed handling @ process_word 00243 // Because "this" header word is still good. Make a warning to a user. 00244 00245 Message::send(MSG::WARNING,__FUNCTION__,"DEBUG MODE => Continue to the next event...\n"); 00246 00247 clear_event(); 00248 00249 status = true; 00250 } 00251 break; 00252 } 00253 00254 if(status){ 00255 00256 // Process the subject word as an event header 00257 if (_event_header_count<FEM_HEADER_COUNT) { 00258 00259 // Store header words 00260 _event_header_words[_event_header_count]=word; 00261 _event_header_count++; 00262 00263 // If stored number of header words reached to the expected number, decode. 00264 if(_event_header_count==FEM_HEADER_COUNT) { 00265 00266 // Decode header words 00267 status = decode_fem_header(_event_header_words); 00268 00269 } 00270 }else{ 00271 00272 // Raise error if a header word count > set constant (should not happen) 00273 Message::send(MSG::ERROR,__FUNCTION__, 00274 Form("Logic error: event header word counter not working! (%zu/%zu)", 00275 _event_header_count,FEM_HEADER_COUNT)); 00276 status=false; 00277 } 00278 } 00279 } 00280 00281 if(!status){ 00282 00283 Message::send(MSG::ERROR,__FUNCTION__, 00284 Form("Failed processing the word %x (last word %x) as an event header!",word,last_word)); 00285 00286 } 00287 00288 last_word = word; 00289 return status; 00290 00291 }
| virtual bool algo_fem_decoder_base::process_fem_last_word | ( | const PMT::word_t | word, | |
| PMT::word_t & | last_word | |||
| ) | [protected, pure virtual] |
TO BE IMPLEMENTED! A method to process 32-bit end-of-fem word.
Implemented in algo_pmt_xmit, algo_tpc_huffman, and algo_tpc_xmit.
Referenced by process_word().
| bool algo_fem_decoder_base::process_word | ( | const PMT::word_t | word | ) | [virtual] |
Implementation of algo_base::process_word.
Implements algo_base.
Reimplemented in algo_tpc_huffman.
Definition at line 36 of file algo_fem_decoder_base.cc.
References algo_base::_bt_mode, algo_base::_bt_nwords, algo_base::_bt_nwords_filled, algo_base::_bt_words, algo_base::_debug_mode, _header_info, _last_word, _search_for_next_event, decoder_base::_verbosity, algo_base::backtrace(), PMT::CHANNEL_HEADER, PMT::CHANNEL_LAST_WORD, PMT::CHANNEL_WORD, clear_event(), MSG::ERROR, PMT::EVENT_HEADER, algo_fem_decoder_base::InfoFEM_t::event_id, PMT::EVENT_LAST_WORD, PMT::FEM_FIRST_WORD, PMT::FEM_HEADER, PMT::FEM_LAST_WORD, get_word_class(), MSG::INFO, PMT::INVALID_WORD, process_ch_word(), process_event_header(), process_event_last_word(), process_fem_header(), process_fem_last_word(), Message::send(), PMT::UNDEFINED_WORD, and MSG::WARNING.
00038 { 00039 //std::cout<<Form("%x",word)<<std::endl; 00040 // 00041 // A simple function to call other members depending on the status. 00042 // Let other members to deal with expected/unexpected case 00043 // 00044 00045 // If in back_trace mode, add this word in record 00046 if(_bt_mode){ 00047 00048 // Check if buffer is filled 00049 if(!_bt_nwords_filled) 00050 _bt_nwords_filled = (_bt_nwords == _bt_words.size()); 00051 00052 // If filled, remove the oldest element 00053 if(_bt_nwords_filled) 00054 _bt_words.pop_front(); 00055 00056 // Add new word 00057 _bt_words.push_back(word); 00058 00059 } 00060 00061 bool status=true; 00062 PMT::word_t word_class=get_word_class(word); 00063 PMT::word_t last_word_class=get_word_class(_last_word); 00064 // 00065 // Skip this word if a boolean is set to skip to the next event header 00066 // 00067 if( _search_for_next_event && 00068 word_class == PMT::FEM_HEADER && 00069 last_word_class != PMT::FEM_HEADER ) 00070 00071 _search_for_next_event = false; 00072 00073 00074 if( _search_for_next_event ) { 00075 00076 if(_verbosity[MSG::INFO]) 00077 00078 Message::send(MSG::INFO,__FUNCTION__, 00079 Form("Skipping a word (%x, previous=%x) to the next event..",word,_last_word)); 00080 00081 _last_word = PMT::INVALID_WORD; 00082 00083 return true; 00084 } 00085 00086 switch(word_class){ 00087 00088 case PMT::EVENT_HEADER: 00089 00090 // (1) Call process_event_header() 00091 status = process_event_header(word,_last_word); 00092 break; 00093 00094 case PMT::FEM_HEADER: 00095 00096 // (1) Check if the last word was EVENT_HEADER, FEM_HEADER, or EVENT_LAST_WORD 00097 // - If EVENT_HEADER, continue to (2) 00098 // - If FEM_HEADER, continue to (2) 00099 // - If EVENT_LAST_WORD, attempt to store & continue to (2) 00100 // (2) Call process_fem_header() 00101 status = process_fem_header(word,_last_word); 00102 break; 00103 00104 case PMT::FEM_FIRST_WORD: 00105 case PMT::CHANNEL_HEADER: 00106 case PMT::CHANNEL_WORD: 00107 case PMT::CHANNEL_LAST_WORD: 00108 case PMT::FEM_LAST_WORD: 00109 { 00110 // (1) Call process_ch_word() 00111 // - Children class should implement what should be checked in correlation to the last word. 00112 00113 // Split two 16 bit words 00114 PMT::word_t first_word = (word & 0xffff); 00115 PMT::word_t second_word = (word >> 16); 00116 00117 if(status) status = process_ch_word(first_word,_last_word); 00118 00119 // Check if the left 16-bit word is also the relevant type or not 00120 if(status){ 00121 00122 switch(get_word_class(second_word)){ 00123 case PMT::FEM_FIRST_WORD: 00124 case PMT::CHANNEL_HEADER: 00125 case PMT::CHANNEL_WORD: 00126 case PMT::CHANNEL_LAST_WORD: 00127 status = process_ch_word(second_word,_last_word); 00128 break; 00129 case PMT::FEM_LAST_WORD: 00130 status = process_fem_last_word(second_word,_last_word); 00131 break; 00132 default: 00133 status = false; 00134 Message::send(MSG::ERROR,__FUNCTION__, 00135 Form("Unexpected word (%x) while processing channel data (previous=%x)",second_word,first_word)); 00136 } 00137 00138 } 00139 break; 00140 } 00141 case PMT::EVENT_LAST_WORD: 00142 // (1) Call process_event_last_word() 00143 status = process_event_last_word(word,_last_word); 00144 break; 00145 00146 case PMT::UNDEFINED_WORD: 00147 00148 00149 if(word != 0x0 || (last_word_class != PMT::EVENT_LAST_WORD && last_word_class != PMT::FEM_LAST_WORD) ) { 00150 00151 Message::send(MSG::ERROR,__FUNCTION__, 00152 Form("Undefined word: %x (previous = %x)",word,_last_word)); 00153 00154 status = false; 00155 }else if(_verbosity[MSG::INFO]){ 00156 00157 // This happens sometimes according to Chi 10/01/13 00158 Message::send(MSG::INFO,__FUNCTION__, 00159 Form("Padding of undefined word (tolerated): %x (previous=%x)",word,_last_word)); 00160 } 00161 break; 00162 } 00163 00164 if(!status){ 00165 00166 backtrace(); 00167 00168 if(_debug_mode) { 00169 00170 if(_header_info.event_id>0) 00171 00172 Message::send(MSG::WARNING,__FUNCTION__,Form("Failed decoding event %d ...",_header_info.event_id)); 00173 00174 Message::send(MSG::WARNING,__FUNCTION__,"DEBUG MODE => Continue to the next event...\n"); 00175 00176 _search_for_next_event = true; 00177 clear_event(); 00178 } 00179 } 00180 00181 return status; 00182 }
| void algo_fem_decoder_base::reset | ( | ) | [virtual] |
Override function to reset the instance.
Reimplemented from algo_base.
Reimplemented in algo_pmt_xmit, algo_tpc_huffman, and algo_tpc_xmit.
Definition at line 17 of file algo_fem_decoder_base.cc.
References _event_header_count, _event_header_words, _last_word, _search_for_next_event, FEM_HEADER_COUNT, PMT::INVALID_WORD, and algo_base::reset().
Referenced by algo_fem_decoder_base(), algo_tpc_xmit::reset(), and algo_pmt_xmit::reset().
00017 { 00018 //################################################# 00019 00020 algo_base::reset(); 00021 00022 _last_word = PMT::INVALID_WORD; 00023 00024 _event_header_count = 0; 00025 00026 _search_for_next_event = false; 00027 00028 for(size_t i=0; i< FEM_HEADER_COUNT; i++) 00029 00030 _event_header_words[i] = 0; 00031 00032 }
| PMT::word_t algo_fem_decoder_base::round_diff | ( | PMT::word_t | ref_id, | |
| PMT::word_t | subject_id, | |||
| PMT::word_t | diff | |||
| ) | const |
A simple round-diff algorithm for binary words.
Definition at line 368 of file algo_fem_decoder_base.cc.
Referenced by algo_pmt_xmit::decode_ch_word(), and decode_fem_header().
00372 { 00373 // Used to recover pmt/trigger frame id from roll over effect. 00374 // One can test this by simply calling this function. 00375 // For instance, to test the behavior for a roll-over of 0x7 ... 00376 // 00377 // > root 00378 // root[0] gSystem->Load("libDecoder") 00379 // root[1] algo_slow_readout_decoder k 00380 // root [6] k.get_pmt_frame(583,584,0x7) 00381 // (const unsigned int)584 00382 // root [7] k.get_pmt_frame(584,583,0x7) 00383 // (const unsigned int)583 00384 // 00385 // I think this implementation works. ... Aug. 12 2013 00386 if( (subject_id > ref_id) && ((subject_id-ref_id) >= diff) ) 00387 return subject_id - (diff+1); 00388 else if( (ref_id > subject_id) && ((ref_id-subject_id) >= diff) ) 00389 return subject_id + (diff+1); 00390 else 00391 return subject_id; 00392 00393 }
| virtual void algo_base::set_backtrace_mode | ( | size_t | nwords = 0 |
) | [inline, virtual, inherited] |
Run utility: set back-trace mode. One should provide number of words to be stored.
Definition at line 65 of file algo_base.hh.
References algo_base::_bt_mode, and algo_base::_bt_nwords.
Referenced by main().
00065 { 00066 _bt_nwords=nwords; 00067 _bt_mode=(bool)(nwords); 00068 };
| void algo_base::set_debug_mode | ( | bool | doit | ) | [inline, inherited] |
Run utility: set debug mode. Children class defines what-to-do in debug mode.
Definition at line 59 of file algo_base.hh.
References algo_base::_debug_mode.
Referenced by decoder_manager::initialize().
00059 {_debug_mode=doit;};
| void algo_base::set_storage_ptr | ( | storage_manager * | storage | ) | [inline, inherited] |
Expects a storage pointer to be provided from a parent class.
Definition at line 62 of file algo_base.hh.
References algo_base::_storage.
Referenced by decoder_manager::initialize().
00062 {_storage=storage;};
| 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 }
| virtual bool algo_fem_decoder_base::store_event | ( | ) | [protected, pure virtual] |
A method to store event-wise data.
Implemented in algo_pmt_xmit, and algo_tpc_xmit.
Referenced by process_fem_header().
bool algo_base::_bt_mode [protected, inherited] |
Back-trace mode boolean holder.
Definition at line 109 of file algo_base.hh.
Referenced by algo_base::algo_base(), algo_trig_decoder::process_word(), algo_tpc_huffman::process_word(), algo_slow_readout_decoder::process_word(), process_word(), and algo_base::set_backtrace_mode().
size_t algo_base::_bt_nwords [protected, inherited] |
user defined # of words to be temporarily stored in the buffer
Definition at line 133 of file algo_base.hh.
Referenced by algo_base::algo_base(), algo_base::backtrace_mode(), algo_trig_decoder::process_word(), algo_tpc_huffman::process_word(), algo_slow_readout_decoder::process_word(), process_word(), and algo_base::set_backtrace_mode().
bool algo_base::_bt_nwords_filled [protected, inherited] |
run utility boolean to keep a recored of filled buffer
Definition at line 134 of file algo_base.hh.
Referenced by algo_base::algo_base(), algo_trig_decoder::process_word(), algo_tpc_huffman::process_word(), algo_slow_readout_decoder::process_word(), and process_word().
std::deque<PMT::word_t> algo_base::_bt_words [protected, inherited] |
processed words to be stored event-wise for back-trace purpose
Definition at line 132 of file algo_base.hh.
Referenced by algo_base::backtrace(), algo_trig_decoder::process_word(), algo_tpc_huffman::process_word(), algo_slow_readout_decoder::process_word(), and process_word().
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(), ana_processor::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(), 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().
PMT::word_t algo_base::_checksum [protected, inherited] |
data checksum
Definition at line 126 of file algo_base.hh.
Referenced by algo_tpc_xmit::check_event_quality(), algo_slow_readout_decoder::check_event_quality(), algo_pmt_xmit::check_event_quality(), algo_slow_readout_decoder::decode_event_header(), decode_fem_header(), algo_base::init_checker_info(), 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(), and algo_trig_decoder::process_word().
bool algo_base::_debug_mode [protected, inherited] |
Debug mode boolean holder.
Definition at line 108 of file algo_base.hh.
Referenced by algo_base::algo_base(), algo_slow_readout_decoder::process_ch_word(), process_fem_header(), algo_slow_readout_decoder::process_header(), algo_trig_decoder::process_word(), algo_tpc_huffman::process_word(), algo_slow_readout_decoder::process_word(), process_word(), and algo_base::set_debug_mode().
size_t algo_fem_decoder_base::_event_header_count [protected] |
A counter for event header words.
Definition at line 171 of file algo_fem_decoder_base.hh.
Referenced by clear_event(), algo_tpc_huffman::process_fem_header(), process_fem_header(), and reset().
Event header word holder.
Definition at line 165 of file algo_fem_decoder_base.hh.
Referenced by algo_tpc_huffman::process_fem_header(), process_fem_header(), and reset().
InfoFEM_t algo_fem_decoder_base::_header_info [protected] |
Definition at line 174 of file algo_fem_decoder_base.hh.
Referenced by algo_tpc_xmit::check_event_quality(), algo_pmt_xmit::check_event_quality(), clear_event(), decode_fem_header(), is_event_empty(), algo_tpc_huffman::process_ch_word(), algo_tpc_huffman::process_event_last_word(), algo_tpc_huffman::process_word(), process_word(), algo_tpc_xmit::store_event(), and algo_pmt_xmit::store_event().
PMT::word_t algo_fem_decoder_base::_last_word [protected] |
Last word processed.
Definition at line 170 of file algo_fem_decoder_base.hh.
Referenced by algo_tpc_huffman::process_word(), process_word(), and reset().
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_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::storage_manager(), and waveform_sampler::waveform_sampler().
PMT::word_t algo_base::_nwords [protected, inherited] |
number of data word counts processed
Definition at line 127 of file algo_base.hh.
Referenced by algo_tpc_xmit::check_event_quality(), algo_slow_readout_decoder::check_event_quality(), algo_pmt_xmit::check_event_quality(), algo_slow_readout_decoder::decode_event_header(), decode_fem_header(), algo_base::init_checker_info(), 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_pmt_xmit::process_fem_last_word(), algo_trig_decoder::process_word(), and algo_tpc_huffman::process_word().
bool algo_fem_decoder_base::_search_for_next_event [protected] |
A run control boolean: skips any action till it finds the new event header.
Definition at line 173 of file algo_fem_decoder_base.hh.
Referenced by algo_tpc_huffman::process_word(), process_word(), and reset().
storage_manager* algo_base::_storage [protected, inherited] |
Data storage pointer to be provided by a parent process.
Definition at line 121 of file algo_base.hh.
Referenced by algo_base::algo_base(), algo_slow_readout_decoder::process_ch_word(), algo_tpc_xmit::process_event_header(), algo_tpc_huffman::process_event_header(), algo_pmt_xmit::process_event_header(), algo_trig_decoder::process_word(), algo_slow_readout_decoder::process_word(), algo_base::reset(), algo_base::set_storage_ptr(), algo_tpc_xmit::store_event(), and algo_pmt_xmit::store_event().
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(), 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(), 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(), process_fem_header(), algo_pmt_xmit::process_fem_last_word(), algo_xmit_decoder::process_header(), algo_slow_readout_decoder::process_header(), process_word(), bin_io_handler::read_multi_word(), storage_manager::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().
const size_t algo_base::BEAM_NWORDS = 21 [static, protected, inherited] |
Defines # of minimum words to identify beamgate event.
Definition at line 115 of file algo_base.hh.
Referenced by algo_slow_readout_decoder::apply_beamgate_correction(), and algo_slow_readout_decoder::store_ch_data().
const size_t algo_base::BEAM_REF_CHANNEL = 39 [static, protected, inherited] |
Defines a reference channel for beamgate.
Definition at line 114 of file algo_base.hh.
Referenced by algo_slow_readout_decoder::store_ch_data().
const size_t algo_fem_decoder_base::FEM_HEADER_COUNT = 6 [static, protected] |
Number of event header words.
Definition at line 159 of file algo_fem_decoder_base.hh.
Referenced by algo_tpc_huffman::process_fem_header(), process_fem_header(), and reset().
const size_t algo_base::FRAME_WIDTH = 8192 [static, protected, inherited] |
Defines # of ADC samples per readout frame.
Definition at line 116 of file algo_base.hh.
Referenced by algo_slow_readout_decoder::apply_beamgate_correction().
1.4.7