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

#include "QFramework/TQFolder.h"
#include "QFramework/TQTable.h"
#include "QFramework/TQSystematicsManager.h"
#include "QFramework/TQSampleDataReader.h"

class TQSystematicsHandler : public TQSystematicsManager, public TQFolder {
protected:
  TQFolder* _config;
 
  void collectVariation(TQFolder* var);
  void exportObjects(TQFolder* cut, TQFolder* target, bool includeNormalizationInShape, bool symmetrizeOneSided);
  void collectHistograms(TQSampleDataReader* rd, TQFolder* variation);
  void collectCounters(TQSampleDataReader* rd, TQFolder* variation);

  virtual bool writeFolderHook(TDirectory* dir, const TString&, int, bool) override;    
  
public:

  TQSystematicsHandler(const TString& name);  
  TQSystematicsHandler(const TString& name, TQFolder* cfg);
  ~TQSystematicsHandler();

  TQFolder* config();
  
  TQFolder* addCut(const TString& id);
  TQFolder* addSystematic(const TString& id, const TString& tags);
  TQFolder* addSystematic(const TString& id, const TString& upvar, const TString& dnvar);
  TQFolder* addVariation(const TString& id, const TString& tags);
  TQFolder* addSample(const TString& id, const TString& path);
  TQFolder* addHistogram(const TString& id, const TString& path, const TString& options);  

  void printSystematics();

  void collect();
  void compute();  

  TQFolder* exportSystematics(const TString& sample, bool includeNormalizationInShape = true, bool symmetrizeOneSided = false);

  std::vector<TQFolder*> getRanking(const TString& sample, const TString& cutname);
  TQTable* getTable(const TString& sample, const TString& cutname);

  TQSampleFolder* getSampleFolder(const TString& name);
  using TQSystematicsManager::getSampleFolder;

  ClassDefOverride(TQSystematicsHandler,0) // helper class to prepare systematic variations for plotting

};

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