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

#include "QFramework/TQNamedTaggable.h"
#include "QFramework/TQNFBase.h"
#include "TFormula.h"

class TQNFCustomCalculator : public TQNFBase {
protected:
  TString fPath;
  TString fPathData;

  double fResult;
  bool fSuccess = false;

  std::vector<TString> vBkgPaths;
  std::vector<TString> fPaths;
  std::vector<TString> fCuts;
  std::vector<TString> fTypes;
  std::vector<bool> fSubtractBkg;
  std::vector<double> fValues;
  TFormula* fFormula = NULL;
  TString fExpression;
  
  double getValue(const TString& path, const TString& cut, TQTaggable& tags, bool subtractBkg = false);
  
  virtual bool initializeSelf() override; 
  virtual bool finalizeSelf() override; 

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

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

  bool readConfiguration(TQFolder* f ) override;

  bool calculate();
  void printResult();
 
  double getResult();

  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(TQNFCustomCalculator,1) // calculator for normalization factors allowing for custom formulae
};

#endif
 TQNFCustomCalculator.h:1
 TQNFCustomCalculator.h:2
 TQNFCustomCalculator.h:3
 TQNFCustomCalculator.h:4
 TQNFCustomCalculator.h:5
 TQNFCustomCalculator.h:6
 TQNFCustomCalculator.h:7
 TQNFCustomCalculator.h:8
 TQNFCustomCalculator.h:9
 TQNFCustomCalculator.h:10
 TQNFCustomCalculator.h:11
 TQNFCustomCalculator.h:12
 TQNFCustomCalculator.h:13
 TQNFCustomCalculator.h:14
 TQNFCustomCalculator.h:15
 TQNFCustomCalculator.h:16
 TQNFCustomCalculator.h:17
 TQNFCustomCalculator.h:18
 TQNFCustomCalculator.h:19
 TQNFCustomCalculator.h:20
 TQNFCustomCalculator.h:21
 TQNFCustomCalculator.h:22
 TQNFCustomCalculator.h:23
 TQNFCustomCalculator.h:24
 TQNFCustomCalculator.h:25
 TQNFCustomCalculator.h:26
 TQNFCustomCalculator.h:27
 TQNFCustomCalculator.h:28
 TQNFCustomCalculator.h:29
 TQNFCustomCalculator.h:30
 TQNFCustomCalculator.h:31
 TQNFCustomCalculator.h:32
 TQNFCustomCalculator.h:33
 TQNFCustomCalculator.h:34
 TQNFCustomCalculator.h:35
 TQNFCustomCalculator.h:36
 TQNFCustomCalculator.h:37
 TQNFCustomCalculator.h:38
 TQNFCustomCalculator.h:39
 TQNFCustomCalculator.h:40
 TQNFCustomCalculator.h:41
 TQNFCustomCalculator.h:42
 TQNFCustomCalculator.h:43
 TQNFCustomCalculator.h:44
 TQNFCustomCalculator.h:45
 TQNFCustomCalculator.h:46
 TQNFCustomCalculator.h:47
 TQNFCustomCalculator.h:48
 TQNFCustomCalculator.h:49
 TQNFCustomCalculator.h:50
 TQNFCustomCalculator.h:51
 TQNFCustomCalculator.h:52
 TQNFCustomCalculator.h:53
 TQNFCustomCalculator.h:54
 TQNFCustomCalculator.h:55
 TQNFCustomCalculator.h:56
 TQNFCustomCalculator.h:57