#ifndef PtStatistic_h
#define PtStatistic_h

class Event;

class PtStatistic {

 public:

  PtStatistic( int id ); // id = 0 or 1 for hadrons or muons respectively
  ~PtStatistic();

  void add( const Event& ev );                // get data from a new event

  int particleType() const { return select; } // return 0 or 1 for
                                              // hadrons or muons respectively
  int nParticles()   const { return nPart; }  // return
                                              // number of accepted particles
  float ptMean()     const;                   // return mean pt
  float ptRMS()      const;                   // return rms  pt

 private:

  // dummy copy constructor and assignment to prevent unadvertent copy
  PtStatistic           ( const PtStatistic& x );
  PtStatistic& operator=( const PtStatistic& x );

  int select;             // 0 or 1 for hadrons or muons respectively
  int nPart;              // number of particles selected to compute mean pt

  float sum;              // sum of pt
  float sqr;              // sum of pt square
  mutable float mean;     // mean pt
  mutable float rms;      // rms  pt
  mutable bool updated;   // flag to recompute mean and rms

  void compute() const;   // compute mean and rms

};

#endif

