00001
00002
00003
00004
00005
00006
00007
00008
00009 #ifndef _TGoodRunsListWriter
00010 #define _TGoodRunsListWriter
00011
00012 #include <vector>
00013
00014 #include "TROOT.h"
00015 #include "TList.h"
00016 #include "TObject.h"
00017 #include "TString.h"
00018
00019 #include "GoodRunsLists/TMsgLogger.h"
00020 #include "GoodRunsLists/TGoodRunsList.h"
00021 #include "GoodRunsLists/TGRLCollection.h"
00022
00023 #include <vector>
00024
00025 typedef unsigned char xmlChar;
00026 typedef struct _xmlTextWriter xmlTextWriter;
00027 typedef xmlTextWriter *xmlTextWriterPtr;
00028
00029 namespace Root {
00030
00031 class TLumiBlockRange;
00032 class TGoodRun;
00033 class TGoodRunsList;
00034
00035 class TGoodRunsListWriter : public TObject {
00036
00037 public:
00038
00039 TGoodRunsListWriter();
00040 TGoodRunsListWriter( const TGoodRunsList& goodrunslist, const TString& dataCardName );
00041 ~TGoodRunsListWriter();
00042
00043 Bool_t WriteXMLFile();
00044 Bool_t WriteXMLFiles();
00045 const TString& GetXMLString();
00046 const std::vector<TString>& GetXMLStrings();
00047
00048
00049 inline const TString& GetFilename() const { return m_dataCardName; }
00050 inline const TGoodRunsList GetMergedGoodRunsList( const Root::BoolOperation& operation = OR ) const
00051 { return m_grlvec.GetMergedGoodRunsList(operation); }
00052 inline const TGRLCollection& GetGRLCollection() const { return m_grlvec; }
00053
00054 inline void SetMergeGoodRunsLists( bool merge=true ) { m_mergegrls=merge; }
00055 inline void SetCheckGRLInfo( bool check=true ) { m_grlvec.SetCheckGRLInfo( check ); }
00056 inline void SetIndividuals( bool indf=true ) { m_individuals=indf; }
00057
00058 void SetGRLCollection( const TGRLCollection& grlvec ) { reset(); m_grlvec=grlvec; }
00059 void SetGoodRunsList( const TGoodRunsList& goodrunslist ) { reset(); m_grlvec.push_back(goodrunslist); }
00060 void SetFilename( const TString& dataCardName ) { m_dataCardName=dataCardName; }
00061 void SetPrefix( const TString& prefix ) { m_prefix=prefix; }
00062 void AddGoodRunsList( const TGoodRunsList& goodrunslist ) { m_grlvec.push_back(goodrunslist); }
00063
00064 private:
00065
00066
00067 void reset();
00068
00069 Bool_t WriteLumiRangeCollection(xmlTextWriterPtr writer);
00070 Bool_t WriteNamedLumiRange(xmlTextWriterPtr writer);
00071 Bool_t WriteMetadata(xmlTextWriterPtr writer);
00072 Bool_t WriteLumiBlockCollection(xmlTextWriterPtr writer, const TGoodRun& goodrun);
00073 Bool_t WriteElement(xmlTextWriterPtr writer, const char* name, const char* value=0,
00074 const char* atr1=0, const char* val1=0, const char* atr2=0, const char* val2=0);
00075
00076 xmlChar* ConvertInput(const char *in, const char *encoding);
00077
00078 TGRLCollection m_grlvec;
00079 TGoodRunsList m_grl;
00080
00081 std::vector<TString> m_xmlstringVec;
00082 TString m_xmlstring;
00083 TString m_dataCardName;
00084 TString m_prefix;
00085
00086 TMsgLogger m_logger;
00087
00088 Bool_t m_mergegrls;
00089 Bool_t m_individuals;
00090
00091 ClassDef(TGoodRunsListWriter,0)
00092 };
00093 }
00094
00095 #endif
00096