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

class TQCounter;

#include "QFramework/TQNFBase.h"

class TQNFTop0jetEstimator : public TQNFBase {
protected:
  TString fPath;
  TString fPathData;
  TString fCutCR;
  TString fCutJetEffNumerator;
  TString fCutJetEffDenominator;

  double fResult;
  double fResultXSec;
  double fResultExtrapolation;
  double fResultAlphaMC;
  double fResultAlphaData;
  
  bool fSuccess = false;

  TQCounter* cnt_mc_cr = NULL;
  TQCounter* cnt_data_cr = NULL;
  TQCounter* cnt_mc_numerator = NULL;
  TQCounter* cnt_data_numerator = NULL;
  TQCounter* cnt_mc_denominator = NULL;
  TQCounter* cnt_data_denominator = NULL;
  
  std::vector<TString> vBkgPaths;
  std::vector<TQCounter*> vBkgCountersCR;
  std::vector<TQCounter*> vBkgCountersNumerator;
  std::vector<TQCounter*> vBkgCountersDenominator;
  
  int deployResultInternal(const std::vector<TString>& startCutNames, const std::vector<TString>& stopAtCut, int overwrite, bool applyToStopCut, int mode);
  
  TString getPostfix(int mode = 0);
  
  virtual bool initializeSelf() override; 
  virtual bool finalizeSelf() override; 

public:
  TQNFTop0jetEstimator();
  TQNFTop0jetEstimator(TQSampleDataReader* rd);
  TQNFTop0jetEstimator(TQSampleFolder* sf);
  virtual ~TQNFTop0jetEstimator();

  TString getPathMC();
  TString getPathData();
  void setPathMC(const TString& path);
  void setPathData(const TString& path);

  TString getControlRegion();
  TString getJetEffNumerator();
  TString getJetEffDenominator();
  void setControlRegion(const TString& region);
  void setJetEffNumerator(const TString& region);
  void setJetEffDenominator(const TString& region);
 
  bool readConfiguration(TQFolder* f ) override;

  bool calculate();
  void printResult(int mode = 0);
 
  double getResult(int mode = 0);

  int execute(int itrNumber = -1) override;
  bool success() override;

  int deployResult(const std::vector<TString>& startCutNames, const std::vector<TString>& stopAtCut, int overwrite, bool applyToStopCut) override;
  
  ClassDefOverride(TQNFTop0jetEstimator,1) // implements the HWW top0jet estimate
};

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