00001 #ifndef ALGO_THRESHOLD_CC 00002 #define ALGO_THRESHOLD_CC 00003 00004 #include "algo_threshold.hh" 00005 00006 //*************************************************************** 00007 algo_threshold::algo_threshold() : preco_algo_base() { 00008 //*************************************************************** 00009 00010 _name = "algo_threshold"; 00011 00012 _adc_thres = 3; 00013 00014 _nsigma = 5; 00015 00016 reset(); 00017 00018 } 00019 00020 void algo_threshold::reset(){ 00021 00022 preco_algo_base::reset(); 00023 00024 } 00025 00026 //*************************************************************** 00027 bool algo_threshold::reco(const std::vector<UShort_t> *wf) { 00028 //*************************************************************** 00029 00030 bool fire = false; 00031 00032 double counter=0; 00033 00034 double threshold = ( _adc_thres > (_nsigma * _ped_rms) ? _adc_thres : (_nsigma * _ped_rms) ); 00035 00036 threshold += _ped_mean; 00037 00038 reset(); 00039 00040 for(auto value : *wf){ 00041 00042 if( !fire && ((double)value) > threshold ){ 00043 00044 // Found a new pulse 00045 00046 fire = true; 00047 00048 _pulse.t_start = counter; 00049 00050 } 00051 00052 if( fire && ((double)value) < threshold ){ 00053 00054 // Found the end of a pulse 00055 00056 fire = false; 00057 00058 _pulse.t_end = counter - 1; 00059 00060 _pulse_v.push_back(_pulse); 00061 00062 _pulse.reset_param(); 00063 00064 } 00065 00066 if(fire){ 00067 00068 // Add this adc count to the integral 00069 00070 _pulse.area += ((double)value - (double)_ped_mean); 00071 00072 if(_pulse.peak < ((double)value - (double)_ped_mean)) { 00073 00074 // Found a new maximum 00075 00076 _pulse.peak = ((double)value - (double)_ped_mean); 00077 00078 _pulse.t_max = counter; 00079 00080 } 00081 00082 } 00083 00084 counter++; 00085 } 00086 00087 if(fire){ 00088 00089 // Take care of a pulse that did not finish within the readout window. 00090 00091 fire = false; 00092 00093 _pulse.t_end = counter - 1; 00094 00095 _pulse_v.push_back(_pulse); 00096 00097 _pulse.reset_param(); 00098 00099 } 00100 00101 return true; 00102 00103 } 00104 00105 #endif
1.4.7