//for wave form analysis
//made by arita 2012.1.4
#ifndef _PSEARCH_H
#define _PSEARCH_H

#include <fstream>
#include <string>
#include <vector>
#include "TFile.h"
#include "TString.h"
#include "TTree.h"
#include "WaveForm.h"


class PeakSearch : public WaveForm{
private:
   int n_peak;

   int n_sample;
   int n_vect;
   std::vector<float> time;
   std::vector<float> adc;

   std::vector<float> peak_id;
   std::vector<float> peak_time;
   std::vector<float> peak_adc;

   int n_accum;
   float accum_time;

   void GetWFfromSuperClass( void );
   float GetInnerPointLinear( float x1 , float x2 , float y1 , float y2 , float v_th );

public:
   PeakSearch();
   ~PeakSearch();

   //Get general value 
   float GetPeakId(int id );
   float GetPeakTime(int id );
   float GetPeakADC(int id );
   float GetTimeMean( void );

   //Leading edge peak search, Return the number of peaks
   int LeadingEdge( float v_th , int edge = -1 ); //edge < 0: falling edge, edge > 0: rising edge

   //peak top search, Return the number of peaks
   int PeakTop( float v_th = 0. , int gradiate_width = 1 ); //vth is threshold as absolute value,gradiate_width is for comparison adc value e

   //Weighted peak top search, Return the number of peaks
   int WPeakTop( float v_th = 0. , int gradiate_width = 1 ); //vth is threshold as absolute value,gradiate_width is for comparison adc value e


};

#endif

