//this file looks like plain C, but it's actually -*- c++ -*-
#ifndef __TQCounter__
#define __TQCounter__

#include "TNamed.h"

class TQCounter : public TNamed {

protected:
 
  double fCounter; // counter
  double fErrorSquared; // error
  int fRawCounter; // raw counter

  // TODO: remove
  bool fWarning;


public:

  static TString getComparison(TQCounter * cnt1, TQCounter * cnt2, bool colored = false, double order = 1E-7);

  TQCounter();
  TQCounter(const char * name);
  TQCounter(const char * name, const char* title);
  TQCounter(const TString& name, double cnt, double err = 0.);
  TQCounter(const TString& name, double cnt, double err, int raw);
  TQCounter(const TQCounter * counter);

  double getCounter() const ;
  void setCounter(double counter);
  int getRawCounter() const;
  void setRawCounter(int raw);

  double getError() const;
  double getErrorSquared() const;
  void setErrorSquared(double errorSquared);
  void setError(double error);

  double getStatError() const;
  double getStatErrorSquared() const;

  double getSysError() const;
  double getSysErrorSquared() const;

 
  void reset();

  TString getAsString(const TString& options = "") const;
  void print(const TString& options = "") const;
  void printCounter(const TString& options = "") const;

  void setWarning(bool warning = true);
  bool getWarning() const ;
 
  void add(double weight);
  void add(const TQCounter * counter, double scale = 1., double scaleUncertainty = 0., double correlation = 0., bool includeScaleUncertainty = true);
  void add(const TQCounter * counter, TQCounter * scale, double correlation = 0., bool includeScaleUncertainty = false);
  void subtract(const TQCounter * counter, double scale = 1., double scaleUncertainty = 0., double correlation = 0., bool includeScaleUncertainty = true);
  void subtract(const TQCounter * counter, TQCounter* scale, double correlation = 0., bool includeScaleUncertainty = false);
  void multiply(double factor, double uncertainty = 0., double correlation = 0., bool includeScaleUncertainty = true);
  void multiply(const TQCounter * counter, double correlation = 0., bool includeScaleUncertainty = false);
  void divide(double denominator, double uncertainty = 0., double correlation = 0., bool includeScaleUncertainty = true);
  void divide(const TQCounter * counter, double correlation = 0, bool includeScaleUncertainty = false);
 
  void scale(double factor, double scaleUncertainty = 0., bool includeScaleUncertainty = true);
  void scale(const TQCounter * scale, bool includeScaleUncertainty = true);

  bool isEqualTo(TQCounter * counter, double order = 1E-7);
  bool isRawEqualTo(TQCounter * counter);

  virtual ~TQCounter();

  ClassDefOverride(TQCounter, 1); // event counter
};

#endif

 TQCounter.h:1
 TQCounter.h:2
 TQCounter.h:3
 TQCounter.h:4
 TQCounter.h:5
 TQCounter.h:6
 TQCounter.h:7
 TQCounter.h:8
 TQCounter.h:9
 TQCounter.h:10
 TQCounter.h:11
 TQCounter.h:12
 TQCounter.h:13
 TQCounter.h:14
 TQCounter.h:15
 TQCounter.h:16
 TQCounter.h:17
 TQCounter.h:18
 TQCounter.h:19
 TQCounter.h:20
 TQCounter.h:21
 TQCounter.h:22
 TQCounter.h:23
 TQCounter.h:24
 TQCounter.h:25
 TQCounter.h:26
 TQCounter.h:27
 TQCounter.h:28
 TQCounter.h:29
 TQCounter.h:30
 TQCounter.h:31
 TQCounter.h:32
 TQCounter.h:33
 TQCounter.h:34
 TQCounter.h:35
 TQCounter.h:36
 TQCounter.h:37
 TQCounter.h:38
 TQCounter.h:39
 TQCounter.h:40
 TQCounter.h:41
 TQCounter.h:42
 TQCounter.h:43
 TQCounter.h:44
 TQCounter.h:45
 TQCounter.h:46
 TQCounter.h:47
 TQCounter.h:48
 TQCounter.h:49
 TQCounter.h:50
 TQCounter.h:51
 TQCounter.h:52
 TQCounter.h:53
 TQCounter.h:54
 TQCounter.h:55
 TQCounter.h:56
 TQCounter.h:57
 TQCounter.h:58
 TQCounter.h:59
 TQCounter.h:60
 TQCounter.h:61
 TQCounter.h:62
 TQCounter.h:63
 TQCounter.h:64
 TQCounter.h:65
 TQCounter.h:66
 TQCounter.h:67
 TQCounter.h:68
 TQCounter.h:69
 TQCounter.h:70
 TQCounter.h:71
 TQCounter.h:72
 TQCounter.h:73
 TQCounter.h:74
 TQCounter.h:75
 TQCounter.h:76
 TQCounter.h:77
 TQCounter.h:78