/* * TTextToVector.h * TTextToVector * * Created by Hugh Dickinson on 14/01/2008. * Copyright 2008 Hugh Dickinson. All rights reserved. * */ #ifndef __TTextToVector__ #define __TTextToVector__ #include #include #include #include #include #include #include #include class TTextToVector{ public : TTextToVector(const char * inFile); virtual ~TTextToVector(); Double_t * GetCol(Int_t col); Double_t * GetRow(Int_t row); Double_t GetValue(Int_t col, Int_t row); Int_t GetNumRows(); Int_t GetNumCols(); void PrintRows(); void PrintCols(); private : TString * fFilename; // The name of the file to be processed into vectors. std::vector * fVectorOfRows; // The vector of rows in the text file. std::vector * fVectorOfCols; // The vector of columns in the text file. Int_t fNumRows; // the number of rows in the file. Int_t fNumCols; // the number of columns in the file. // function opens a text file. std::ifstream * OpenFile(TString * filename); // function checks if a file is open bool CheckFile(std::ifstream * fileStream); // function returns TObjArray of TObjStrings containing the lines of the file. TObjArray * ReadFile(std::ifstream * fileStream); // function converts each line of the file into a TArrayD of Double_ts - returns std::vector. std::vector * MakeRowVectors(TObjArray * rowStrings); // function to transpose row vectors into columns - returns std::vector; std::vector * MakeColumnVectors(std::vector * rowVectors); // function to convert a string into a TArrayD; TArrayD * StringToDoubles(TString * string); ClassDef(TTextToVector, 0); // A class to extract rows and columns of double precision values from a columnar text file. }; #endif