00001 #ifndef LED_PULSE_SELECTOR_CC 00002 #define LED_PULSE_SELECTOR_CC 00003 00004 #include "led_pulse_selector.hh" 00005 00006 led_pulse_selector::led_pulse_selector() : _ref_time() { 00007 _name="led_pulse_selector"; 00008 _pulse_type=DATA_STRUCT::THRES_WIN_PULSE_COLLECTION; 00009 _ref_ch=PMT::INVALID_CH; 00010 _frame_size=PMT::EMPTY_WORD; 00011 _time_cut=PMT::EMPTY_WORD; 00012 clear_event(); 00013 } 00014 00015 void led_pulse_selector::clear_event(){ 00016 _ref_time.clear(); 00017 } 00018 00019 bool led_pulse_selector::initialize() { 00020 00021 bool status = true; 00022 if(_ref_ch==PMT::INVALID_CH) { 00023 00024 Message::send(MSG::ERROR,__PRETTY_FUNCTION__,"Reference channel number is not set! Aborting..."); 00025 00026 status=false; 00027 00028 } 00029 00030 if(_frame_size == PMT::EMPTY_WORD){ 00031 00032 Message::send(MSG::ERROR,__PRETTY_FUNCTION__,"Frame size not set! Aborting..."); 00033 00034 status = false; 00035 00036 } 00037 00038 if(_time_cut == PMT::EMPTY_WORD){ 00039 00040 Message::send(MSG::ERROR,__PRETTY_FUNCTION__,"Timing cut not set! Aborting..."); 00041 00042 status = false; 00043 00044 } 00045 00046 return status; 00047 } 00048 00049 bool led_pulse_selector::analyze(storage_manager* storage) { 00050 00051 pulse_collection *pulses = (pulse_collection*)(storage->get_data(_pulse_type)); 00052 00053 if(pulses->size()==0) { 00054 Message::send(MSG::ERROR,__FUNCTION__,"No Pulse Found!"); 00055 return false; 00056 } 00057 00058 clear_event(); 00059 00060 // Perform analyze() in the base class 00061 bool status = pulse_selector_simple::analyze(storage); 00062 00063 if(status){ 00064 00065 // Look for reference time from the specified channel number 00066 for(pulse_collection::const_iterator iter(pulses->begin()); 00067 iter!=pulses->end(); 00068 ++iter){ 00069 if((*iter).channel_number() != _ref_ch) continue; 00070 00071 _ref_time.insert((*iter).frame_id() * _frame_size + (*iter).timeslice()); 00072 00073 } 00074 00075 } 00076 00077 return status; 00078 } 00079 00080 00081 bool led_pulse_selector::select_pulse(const pulse_info* data){ 00082 00083 // Run base class selection first 00084 bool store = pulse_selector_simple::select_pulse(data); 00085 00086 if(!store) return store; 00087 00088 store= false; 00089 PMT::word_t time_stamp = data->frame_id() * _frame_size + data->timeslice(); 00090 for(auto ts : _ref_time){ 00091 00092 if(ts > time_stamp) { 00093 00094 if( (ts-time_stamp) < _time_cut ) store = true; 00095 00096 break; 00097 00098 }else if( (time_stamp - ts) < _time_cut){ 00099 00100 store = true; 00101 00102 break; 00103 00104 } 00105 } 00106 00107 return store; 00108 } 00109 00110 bool led_pulse_selector::finalize() { 00111 00112 // This function is called at the end of event loop. 00113 // Do all variable finalization you wish to do here. 00114 // If you need, you can store your ROOT class instance in the output 00115 // file. You have an access to the output file through "_fout" pointer. 00116 //amplitude->Write(); 00117 return true; 00118 } 00119 00120 #endif
1.4.7