AlignmentIORootBase

Macros

Line Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
#ifndef Alignment_CommonAlignmentAlgorithm_AlignmentIORootBase_h
#define Alignment_CommonAlignmentAlgorithm_AlignmentIORootBase_h

#include "TString.h"

class TFile;
class TTree;

/// Base class for ROOT-based I/O of Alignment parameters etc.

class AlignmentIORootBase {
protected:
  /// constructor
  AlignmentIORootBase() : tree(nullptr), myFile(nullptr) {}
  /// destructor
  virtual ~AlignmentIORootBase();

  /// open IO
  int openRoot(const char* filename, int iteration, bool writemode);

  /// close IO
  int closeRoot(void);

  /// create root branches
  virtual void createBranches(void) = 0;

  /// set root branches
  virtual void setBranchAddresses(void) = 0;

  /// test if file is existing and if so, what the highest iteration is
  int testFile(const char* filename, const TString& tname);

  /// compose tree name
  TString treeName(int iter, const TString& tname);

  // data members

  TTree* tree;       // root tree
  TString treename;  // tree identifier name
  TString treetxt;   // tree text
  bool bWrite;       // if true we are writing, else reading

  const static int nParMax = 20;    // maximal number of Parameters
  const static int itermax = 1000;  // max iteration to test for

private:
  TFile* myFile;  // root file
};

#endif