/* * TTextToGraph.h * TTextToGraph - a template class to plot selected columns of a text file using a chosen TGraph variant. * Also uses TTextToVector. * * Created by Hugh Dickinson on 16/01/2008. * Copyright 2008 __MyCompanyName__. All rights reserved. * */ #ifndef __TTEXTTOGRAPH__ #define __TTEXTTOGRAPH__ #include #include #include #include #include #include #include #include #include #include #include // Template helper class with specialisations required to determine the graph type required, since the number of fields is degenerate for // TGraphAsymmErrors and TGraph2DErrors! 0 = TGraph, 1 = TGraphErrors, 2 = TGraphAsymmErrors, 3 = TGraphBentErrors, 4 = TGraph2D, 5 = TGraph2DErrors template struct WhichGraph; template <> struct WhichGraph{ const static int type = 0; }; template <> struct WhichGraph{ const static int type = 1; }; template <> struct WhichGraph{ const static int type = 2; }; template <> struct WhichGraph{ const static int type = 3; }; template <> struct WhichGraph{ const static int type = 4; }; template <> struct WhichGraph{ const static int type = 5; }; // The template class to make the actual graph template class TTextToGraph { public : TTextToGraph(const char * infile, const char * fieldList, Int_t cOr = 0); virtual ~TTextToGraph(); GraphType * GetGraph(); private : int fType; // The integer corresponding to the requested graph type. See definition of WhichGraph above. Int_t fColsOrRows; // Should the file be plotted column- or row-wise? 0 for columns, 1 for rows. Int_t fNumFields; // The number of fields extracted from the file. TString * fFileName; // The name of the input file. TString * fFields; // TString containing comma separated list of fields to be extracted from the file and plotted. std::vector * fFieldArray; // An array of integers containing the fields to be plotted. TTextToVector * fTtov; // Converts the input text file into Double_t arrays. GraphType * fGraph; // the graph object produced. void GetFields(); std::vector * StringToInts(); // generic graph maker using template GraphType * MakeGraph(); // Type specific graph makers. TGraph * MakeTGraph(); TGraphErrors * MakeTGraphErrors(); TGraphAsymmErrors * MakeTGraphAsymmErrors(); TGraphBentErrors * MakeTGraphBentErrors(); TGraph2D * MakeTGraph2D(); TGraph2DErrors * MakeTGraph2DErrors(); ClassDef(TTextToGraph, 0); // A class to produce a specified TGraph variant using arbitrary columns from a columnar text file. }; #endif