#ifndef TDumpMidasFile_hxx_seen #define TDumpMidasFile_hxx_seen // $Id: IDumpMidasFile.hxx,v 1.6 2009/09/25 06:02:21 nickwest Exp $ #include #include #include #include "TFile.h" #include "TTree.h" #include "IHandle.hxx" #include "IMidasBank.hxx" #include "IMidasFile.hxx" #include "ICOMETInput.hxx" #include "ICOMETOutput.hxx" #include "ICOMETRawEvent.hxx" #include "IVInputFile.hxx" /// This is a simple utility to dump MIDAS data files. /// For usage just run without command args. // This file consists of headers for the following:- // // class IBankStats - Accumulate and print bank statistics // class IRawDataFile - Wrapper for a MIDAS file (.mid/.mid.gz) or its ROOT (.mid.root) equivalent // class IDumpMidasFile - Read and dump MIDAS file or its ROOT equivalent class IBankStats { public: IBankStats() {} ~IBankStats() {} void Update(const COMET::IHandle bank); void PrintStats() const; private: struct stats_row_t { stats_row_t() : total_size(0),total(0),good_checksum(0),bad_checksum(0),no_checksum(0), good_trailer_wd(0),bad_trailer_wd(0),no_trailer_wd(0) {} ~ stats_row_t() {} public: Int_t total_size,total,good_checksum,bad_checksum,no_checksum,good_trailer_wd,bad_trailer_wd,no_trailer_wd; }; std::map fBankStats; // bank name -> bank statistics }; class IRawDataFile { public: IRawDataFile(std::string file_path); ~IRawDataFile(); std::string GetFilePath() const { return fFilePath; } bool IsRootFile() const { return fIsRootFile; } COMET::ICOMETEvent* ReadEvent(); // NULL = EOF. Retains ownership private: std::string fFilePath; // File name path bool fIsRootFile; // true if a ROOT (ICOMETInput) file. COMET::IVInputFile* fFile; // Either IMidasFile or ICOMETInput Int_t fRootEventNum; // Event number within ROOT file or =0 }; class IDumpMidasFile { public: IDumpMidasFile(int argc, char **argv); ~IDumpMidasFile() {} bool HasValidCommand() const { return fValidCommand; } void Run() ; void Usage() const; private: void ParseCommand(int argc, char **argv); /// List of file names std::list fFileNames; /// True if command is valid bool fValidCommand; /// Record to start at int fStartRec; /// Number of records to process int fProcessRec; /// Print level. std::string fPrintLevel; /// Print bank statistics bool fBankStats; /// No promotion i.e. print as raw IMidasBank bool fNoPromote; /// ROOT output dta directory std::string fRootDir; }; #endif