FairRoot/PandaRoot
PndEmcPSAFPGASampleAnalyser.cxx
Go to the documentation of this file.
2 #include "PndEmcWaveform.h"
3 
8 
9 #include <iostream>
10 #include <fstream>
11 #include <string>
12 #include <set>
13 #include <sstream>
14 /*
15 #include <boost/config.hpp>
16 #include <boost/program_options/detail/config_file.hpp>
17 #include <boost/program_options/parsers.hpp>
18 
19 namespace pod = boost::program_options::detail;
20 */
28  baseline_value = 7000.;
29 }
30 
38  baseline_value = 7000.;
39  initFromFile(fname);
40 }
41 
43 }
44 
62 
67 
68  return;
69 }
70 
71 void PndEmcPSAFPGASampleAnalyser::initFromFile(const std::string &) {// fname //[R.K.03/2017] unused variable(s)
72  SampleAnalyserParams newParams;
73  newParams.hit_threshold = 200;
74  newParams.ma_trig_M = 30;
75  newParams.cf_delay = 5;
76  newParams.cf_ratio = 0.15;
77  newParams.cf_fitter_length = 5;
78  newParams.cf_fit_offset = 2;
79  newParams.mwd_length = 90;
80  newParams.mwd_tau = 2500;
81  newParams.clock_unit = 10;//ns
82  newParams.iafactor= 1.;//ns
83 
84 /* std::ifstream ifile(fname.c_str());
85  if(!ifile) {
86  std::cerr << "Can not open input file: " << fname << "\n";
87  exit(1);
88  }
89 
90  std::set<std::string> options;
91  options.insert("MWD_Tau");
92  options.insert("MWD_Length");
93  options.insert("TR_Thresh");
94  options.insert("CFD_Ratio");
95  options.insert("CFD_Delay");
96  options.insert("Fit_ofset");
97  options.insert("Fitter_L");
98  options.insert("MA_trig");
99 
100  //parser
101  for (pod::config_file_iterator i(ifile, options), e ; i != e; ++i) {
102  if (i->string_key == "MWD_Tau") {
103  newParams.mwd_tau = atof((i->value[0]).c_str());
104  }
105  if (i->string_key == "MWD_Length") {
106  newParams.mwd_length = atoi((i->value[0]).c_str());
107  }
108  if (i->string_key == "TR_Thresh") {
109  newParams.hit_threshold = atof((i->value[0]).c_str());
110  }
111  if (i->string_key == "CFD_Ratio") {
112  newParams.cf_ratio = atof((i->value[0]).c_str());
113  }
114  if (i->string_key == "CFD_Delay") {
115  newParams.cf_delay = atoi((i->value[0]).c_str());
116  }
117  if (i->string_key == "Fit_ofset") {
118  newParams.cf_fit_offset = atoi((i->value[0]).c_str());
119  }
120  if (i->string_key == "Fitter_L") {
121  newParams.cf_fitter_length = atoi((i->value[0]).c_str());
122  }
123  if (i->string_key == "MA_trig") {
124  newParams.ma_trig_M = atoi((i->value[0]).c_str());
125  }
126  }
127 
128  ifile.close();*/
129  init(newParams);
130  return;
131 }
132 void PndEmcPSAFPGASampleAnalyser::Init(const std::vector<Double_t> &params){
133  SampleAnalyserParams newParams;
134  newParams.ma_trig_M = (int) params.at(0);
135  newParams.hit_threshold = params.at(1);
136  newParams.cf_delay = (int) params.at(2);
137  newParams.cf_ratio = params.at(3);
138  newParams.cf_fitter_length = (int) params.at(4);
139  newParams.cf_fit_offset = (int) params.at(5);
140  newParams.mwd_length = (int) params.at(6);
141  newParams.mwd_tau = params.at(7);
142  newParams.clock_unit = params.at(8);
143  newParams.iafactor = params.at(9);
144  /*
145  std::cout << newParams.ma_trig_M << std::endl;
146  std::cout << newParams.hit_threshold << std::endl;
147  std::cout << newParams.cf_delay << std::endl;
148  std::cout << newParams.cf_ratio << std::endl;
149  std::cout << newParams.cf_fitter_length << std::endl;
150  std::cout << newParams.cf_fit_offset << std::endl;
151  std::cout << newParams.mwd_length << std::endl;
152  std::cout << newParams.mwd_tau << std::endl;
153 */
154  init(newParams);
155  return;
156 }
157 
158 
160  if (index < nHits() && index >= 0)
161  return time[index];
162  return 0.0;
163 }
164 
166  if(index < nHits() && index >= 0)
167  return amplitude[index];
168  return 0.0;
169 }
170 
172  if (index < nHits() && index >= 0)
173  return integral[index];
174  return 0.0;
175 }
176 
178  //std::cout<<"PndEmcPSAFPGASampleAnalyser::Process#"<<waveform->GetTimeStamp()
179  // <<", "<<waveform->GetActiveTime()<<std::endl;
180  reset();
181  std::vector<double> signal = waveform->GetSignal();
182  std::vector<double>::iterator it;
183  for(it = signal.begin(); it < signal.end();it++){
184  this->put(*it);
185  }
186  return this->nHits();
187 }
188 
190  //energy = this->sampleIntegral(i);
191  energy = this->sampleAmplitude(i);
192  t = this->sampleTime(i);
193 }
194 
float integral[MAX_NUMBER_OF_HITS]
virtual std::vector< double > GetSignal() const
Int_t i
Definition: run_full.C:25
void set(unsigned int newBufferSize)
virtual void put(float valueToStore)=0
void set(unsigned int newBufferSize, float newRatio)
PndEmcPSAFPGAFilterDelay * MA_delay
ClassImp(PndEmcPSAFPGASampleAnalyser)
virtual void GetHit(Int_t i, Double_t &energy, Double_t &time)
Get energy and time of hit.
float amplitude[MAX_NUMBER_OF_HITS]
Double_t
virtual void initFromFile(const std::string &fname)
virtual void Init(const std::vector< Double_t > &params)
virtual Int_t Process(const PndEmcWaveform *waveform)
Find Hits in Waveform.
represents a simulated waveform in an emc crystal
PndEmcPSAFPGAFilterDelay * Signal_delay
void set(unsigned int newBufferSize)
TTree * t
Definition: bump_analys.C:13
PndEmcPSAFPGAFilterDelay * CF_delay
int status[10]
Definition: f_Init.h:28
Double_t energy
Definition: plot_dirc.C:15
virtual void init(SampleAnalyserParams &params)