15 using Diana::QVectorC;
21 cout<<
"NO READER PASSED TO TRIGGER"<<endl;
24 SetCFGParameters(
reader->
GetString((
"AveragePulse"+
triggerLabel),
""),
reader->
GetString((
"AverageNoisePS"+
triggerLabel),
""),
reader->
GetInt((
"Dataset"+
triggerLabel),1,
true),
reader->
GetDouble((
"ThresholdInRMS"+
triggerLabel).c_str(),5.),
reader->
GetDouble((
"ReceedLevel"+
triggerLabel).c_str(),2.),
reader->
GetString((
"AvgPulseOwner"+
triggerLabel),
"AveragePulses",
false),
reader->
GetString((
"AvgNoiseOwner"+
triggerLabel),
"NoiseAvgPowerSpectrum",
false));
31 cout<<
"FATAL ERROR: Stream not the right size"<<endl;
32 cout<<
"Size should be "<<2*
windowsize<<
" Found instead "<<window_stream.
Size()<<endl;
35 stream_FD[0].Set(0,0);
42 Diana::QGlobalDataManager
dm;
58 cout<<
"Impossible to read average pulse"<<endl;
59 cout<<
err.ToString()<<
"\t"<<
err.GetDescription()<<endl;
73 cout<<
"Impossible to read average noise"<<endl;
74 cout<<
err.ToString()<<
"\t"<<
err.GetDescription()<<endl;
86 while(
transient <= 0){
87 transient = (2*i*
ap.Size())/25;
92 smoothing_ap[i] = TMath::Cos(2*TMath::Pi()*i/
transient+TMath::Pi()) * 0.5 +0.5;
94 smoothing_ap[i] = TMath::Cos(2*TMath::Pi()*i/
transient) * 0.5 +0.5;
106 double M = 1./SNR.
Sum(
ap.Size()-1,1);
118 for(
size_t i = 0; i<
fFilterTD.Size();i++){
124 rms = TMath::Sqrt(M);
131 for(
size_t i = 0; i<
ap.Size();i++){
137 int max_index =
ap_d.GetMaxIndex();
139 int threshold_index = max_index/2;
140 i = (size_t)max_index;
141 while( (
ap_d[i]-threshold)>=0 and (i>=0)){
145 if((threshold -
ap_d[threshold_index])>(
ap_d[threshold_index+1]-threshold)){
148 threshold_index = max_index - threshold_index;
157 cout<<
"Building OF"<<endl;
175 for(
size_t i = 0; i<(size_t)
windowsize and i<stream.size() ;i++){
176 win[i] = stream[i]-stream[0];
186 filtered_win =
Filter(win);
198 win = vector<double> (stream.begin()+i, stream.begin()+i+2*
windowsize);
199 win = win - stream[i];
203 for(
size_t k = 0; k<stream.size()-i;k++){
204 win[k]=stream[i+k]-stream[i];
209 filtered_win =
Filter(win);
223 std::iota(sample_idx.begin(),sample_idx.end(),0);
224 sort( sample_idx.begin(),sample_idx.end(), [&](
int i,
int j){return filteredStream[i]>filteredStream[j];} );
226 std::iota(mapping.begin(),mapping.end(),0);
227 sort(mapping.begin(),mapping.end(), [&](
int i,
int j){return sample_idx[i]<sample_idx[j];});
229 for(
size_t i = 0; i<enabled.size();i++){
230 while(i <enabled.size()){
231 if(enabled[i]==
true)
break;
235 if(i==enabled.size())
break;
248 while(sample_idx[i]-min_deb<0){
251 while(sample_idx[i]+max_deb>=(
int)enabled.size()){
254 for(
int j = -min_deb; j<max_deb;j++){
255 enabled[mapping[sample_idx[i]+j]] =
false;
#define Q_BEGIN_NAMESPACE
ClassImp(Diana::QTriggerOptimumFilter)
global handle for average noise power spectra
global handle for average pulse
const std::string & GetString(const std::string &parname, const std::string &defVal, bool warnCfg=true) const
Get a string parameter from config file ( see GetDouble() )
double GetDouble(const std::string &parname, double defVal, bool warnCfg=true) const
Get a double parameter from config file.
int GetInt(const std::string &parname, int defVal, bool warnCfg=true) const
Get an int parameter from config file ( see GetDouble() )
error class with error type and description
QError Get(const std::string &owner, GlobalHandle< Q > *gh, const std::string &inSource, bool printError=true) const
Get an object using a global handle.
Wrapper for a specific QRealComplexFFT algorithm class.
Diana::QVector smoothed_ap
bool BuildOptimumFilter()
bool optimum_filter_built
void GetParametersFromCFG()
Diana::QRealComplexFFT * fTransformer
Diana::QVector fFilterTD_d
Diana::QVector filt_stream_window
void SetCFGParameters(string apinput="", string aninput="", int ds=1, double trigLevl=5., double receed=2., string APOwner="AveragePulses", string ANOwner="NoiseAvgPowerSpectrum")
Diana::QVectorC fFilterFD_d
Diana::QVector smoothing_ap
void TriggerStream(const vector< double > &stream)
Diana::QRealComplexFFT * fTransformer_d
const Diana::QVector & Filter(const QVector &window_stream)
vector< double > triggerHeights
vector< double > filteredStream
const QBaseModule * reader
Interface for complex vectors in Diana analysis.
Interface for vectors in Diana analysis.
UInt_t Size() const
size of QVector
const QVector & Shift(const int nstep)
Cyclic shift of vector.
void Append(const double val)
append
double Sum(UInt_t nelem, UInt_t first=0) const
sum elements
void Resize(const UInt_t newsize)
resize a QVector
void Initialize(const double val=0)
initialize elements (default to 0)