Public Member Functions | Private Attributes | List of all members
truncatedMean_pos Class Reference

#include <SelectionDefinitions.h>

Public Member Functions

 truncatedMean_pos (double limit)
 
std::vector< double > operator() (std::vector< std::vector< double >> &vecs_dEdX)
 

Private Attributes

double fLimit
 

Detailed Description

Definition at line 254 of file SelectionDefinitions.h.

Constructor & Destructor Documentation

truncatedMean_pos::truncatedMean_pos ( double  limit)
inline

Definition at line 258 of file SelectionDefinitions.h.

259  : fLimit(limit) {}

Member Function Documentation

std::vector<double> truncatedMean_pos::operator() ( std::vector< std::vector< double >> &  vecs_dEdX)
inline

Definition at line 261 of file SelectionDefinitions.h.

262  {
263  //size_t size = 0;
264  std::vector<double> trunc_mean;
265  //std::vector<double> help_vec;
266  double truncate_high = 1 - fLimit;
267  int i_low = 0;
268  int i_high = 0;
269 
270  //sort the dEdX vecotrs in matrix
271  for(auto &&vec : vecs_dEdX){
272  //size = vec.size();
273  std::vector<double> help_vec;
274 
275 
276  //check dEdX vector isn't empty!
277  if(vec.empty()){
278  trunc_mean.push_back(-9999.);
279  continue;
280  }
281 
282  else{
283  std::vector<double> temp_vec;
284  for (double d : vec) {
285  if (d < 0.) {
286  continue;
287  }
288  temp_vec.push_back(d);
289  }
290  for (double d : temp_vec) {
291  if (d < 0.) {
292  std::cout << d << std::endl;
293  }
294  }
295  if (temp_vec.empty()) {
296  trunc_mean.push_back(-9999.);
297  continue;
298  }
299  //Sort Vector
300  sort(temp_vec.begin(), temp_vec.end());
301 
302  //Discard upper and lower part of signal
303  //rint rounds to integer
304  i_low = rint ( temp_vec.size()*fLimit);
305  i_high = rint( temp_vec.size()*truncate_high);
306 
307 
308  //if (i_high >= temp_vec.size()) std::cout << "Warning: too high" << std::endl;
309  for(int i = i_low; i </*=*/ i_high; i++){
310  if (temp_vec[i] < 0) {
311  std::cout << "added " << temp_vec[i] << " " << i << std::endl;
312  }
313  help_vec.push_back(temp_vec[i]);
314  };
315 
316  //Mean of help vector
317 
318  trunc_mean.push_back(accumulate(help_vec.begin(), help_vec.end(), 0.0) / help_vec.size());
319  if (trunc_mean.back() < 0 && trunc_mean.back() != -9999. && trunc_mean.back() != -999.) {
320  std::cout << accumulate(help_vec.begin(), help_vec.end(), 0.0) << " " << help_vec.size() << std::endl;
321  std::cout << temp_vec.size() << " " << i_low << " " << i_high << std::endl;
322  for (size_t i = 0; i < help_vec.size(); ++i) {
323  std::cout << "\t" << help_vec[i] << std::endl;
324  }
325  }
326  }
327 
328 
329  }
330  return trunc_mean;
331  }
QTextStream & endl(QTextStream &s)

Member Data Documentation

double truncatedMean_pos::fLimit
private

Definition at line 256 of file SelectionDefinitions.h.


The documentation for this class was generated from the following file: