start implementing TDirectoryFile instead of TFolder, since TFolder is depricated. First I added the necessary parts on the validator. The read/write are still missing.
This commit is contained in:
parent
e5ff0fa743
commit
764cdf4e51
@ -39,7 +39,9 @@
|
||||
#include "TString.h"
|
||||
#include "TFile.h"
|
||||
#include "TFolder.h"
|
||||
#include "TDirectoryFile.h"
|
||||
#include "TKey.h"
|
||||
#include "TList.h"
|
||||
#include "TObjArray.h"
|
||||
#include "TObjString.h"
|
||||
#include "TSystemFile.h"
|
||||
@ -73,7 +75,7 @@ class PMusrRoot2Xml
|
||||
virtual UInt_t GetNoOfDetectors() { return fNoOfDetectors; }
|
||||
|
||||
private:
|
||||
enum EFolderTag {eUnkown, eDecayAnaModule, eSlowControlAnaModule};
|
||||
enum fNodeTag {eUnkown, eDecayAnaModule, eSlowControlAnaModule};
|
||||
|
||||
std::vector<std::string> fXmlData; ///< keeps the XML structure dump of the ROOT file
|
||||
|
||||
@ -82,14 +84,15 @@ class PMusrRoot2Xml
|
||||
Bool_t fValid; ///< true if the conversion was fine
|
||||
TString fFileName; ///< file name of the ROOT file
|
||||
TString fXmlDumpFileName; ///< file name of the XML dump file
|
||||
EFolderTag fFolderTag; ///< switch indicating which kind of TFolder object is found
|
||||
fNodeTag fNodeTag; ///< switch indicating which kind of TFolder or TDirectoryFile object is found
|
||||
|
||||
UInt_t fNoOfDecayHistos; ///< number of decay histos in the DecayAnaModule
|
||||
UInt_t fNoOfHistos; ///< number of histos from run header
|
||||
UInt_t fNoOfRedGreenOffsets; ///< number of RedGreen offsets
|
||||
UInt_t fNoOfDetectors; ///< number of detector entries in the header
|
||||
UInt_t fNoOfDecayHistos{0}; ///< number of decay histos in the DecayAnaModule
|
||||
UInt_t fNoOfHistos{0}; ///< number of histos from run header
|
||||
UInt_t fNoOfRedGreenOffsets{0}; ///< number of RedGreen offsets
|
||||
UInt_t fNoOfDetectors{0}; ///< number of detector entries in the header
|
||||
|
||||
virtual void SortHistoFolders();
|
||||
virtual void DumpDirectory(TDirectoryFile *dir, UInt_t offset);
|
||||
virtual void DumpFolder(TFolder *folder, UInt_t offset);
|
||||
virtual void DumpObjArray(TObjArray *obj, UInt_t offset);
|
||||
virtual void DumpEntry(TObject *obj, UInt_t offset);
|
||||
@ -105,13 +108,9 @@ class PMusrRoot2Xml
|
||||
PMusrRoot2Xml::PMusrRoot2Xml(const char *fileName, bool quiet, bool keep) : fQuiet(quiet), fKeep(keep), fFileName(fileName)
|
||||
{
|
||||
fXmlDumpFileName = "__MusrRootXmlDump.xml";
|
||||
fFolderTag = eUnkown;
|
||||
fNodeTag = eUnkown;
|
||||
fValid = false;
|
||||
fXmlData.clear();
|
||||
fNoOfDecayHistos = 0;
|
||||
fNoOfHistos = 0;
|
||||
fNoOfRedGreenOffsets = 0;
|
||||
fNoOfDetectors = 0;
|
||||
|
||||
// read assumed MusrRoot file
|
||||
TFile f(fFileName.Data());
|
||||
@ -127,7 +126,8 @@ PMusrRoot2Xml::PMusrRoot2Xml(const char *fileName, bool quiet, bool keep) : fQui
|
||||
TIter next = f.GetListOfKeys();
|
||||
TKey *key;
|
||||
TFolder *folder;
|
||||
TString str, tag;
|
||||
TDirectoryFile *dir;
|
||||
TString str;
|
||||
|
||||
UInt_t offset = 2;
|
||||
|
||||
@ -137,6 +137,9 @@ PMusrRoot2Xml::PMusrRoot2Xml(const char *fileName, bool quiet, bool keep) : fQui
|
||||
if (str == "TFolder") {
|
||||
folder = dynamic_cast<TFolder*>(key->ReadObj());
|
||||
CheckClass(folder, str, offset);
|
||||
} else if (str == "TDirectoryFile") {
|
||||
dir = dynamic_cast<TDirectoryFile*>(key->ReadObj());
|
||||
CheckClass(dir, str, offset);
|
||||
}
|
||||
}
|
||||
if (!fQuiet) std::cout << std::endl;
|
||||
@ -226,6 +229,30 @@ void PMusrRoot2Xml::SortHistoFolders()
|
||||
temp_xml_data.clear();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
/**
|
||||
* <p>Dump TDirectoryFile structure.
|
||||
*
|
||||
* \param dir TDirectoryFile object found in the ROOT file
|
||||
* \param offset needed to indent dump info
|
||||
*/
|
||||
void PMusrRoot2Xml::DumpDirectory(TDirectoryFile *dir, UInt_t offset)
|
||||
{
|
||||
TString offsetStr="";
|
||||
for (UInt_t i=0; i<offset; i++)
|
||||
offsetStr += " ";
|
||||
|
||||
TList *ll = dir->GetListOfKeys();
|
||||
TString str;
|
||||
TObject *oo;
|
||||
for (TObject *obj: *ll) {
|
||||
oo = static_cast<TKey*>(obj)->ReadObj();
|
||||
if (!fQuiet) std::cout << std::endl << offsetStr << "name: " << oo->GetName() << ", class name: " << oo->ClassName();
|
||||
str = oo->ClassName();
|
||||
CheckClass(oo, str, offset);
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
/**
|
||||
* <p>Dump folder structure.
|
||||
@ -343,7 +370,7 @@ void PMusrRoot2Xml::DumpEntry(TObject *obj, UInt_t offset)
|
||||
offsetStr += " ";
|
||||
|
||||
TString nameTag(""), typeTag("");
|
||||
switch (fFolderTag) {
|
||||
switch (fNodeTag) {
|
||||
case eDecayAnaModule:
|
||||
nameTag = "HistoName";
|
||||
typeTag = "HistoType";
|
||||
@ -359,7 +386,7 @@ void PMusrRoot2Xml::DumpEntry(TObject *obj, UInt_t offset)
|
||||
break;
|
||||
}
|
||||
|
||||
if (fFolderTag == eDecayAnaModule)
|
||||
if (fNodeTag == eDecayAnaModule)
|
||||
fNoOfDecayHistos++;
|
||||
|
||||
TString str;
|
||||
@ -389,34 +416,37 @@ void PMusrRoot2Xml::CheckClass(TObject *obj, TString str, UInt_t offset)
|
||||
for (UInt_t i=0; i<offset; i++)
|
||||
offsetStr += " ";
|
||||
|
||||
if (str == "TFolder") {
|
||||
if ((str == "TFolder") || (str == "TDirectoryFile")) {
|
||||
TString xmlTagName(TString(obj->GetName()));
|
||||
|
||||
// set folder tag
|
||||
if (!xmlTagName.CompareTo("DecayAnaModule"))
|
||||
fFolderTag = eDecayAnaModule;
|
||||
fNodeTag = eDecayAnaModule;
|
||||
else if (!xmlTagName.CompareTo("SCAnaModule"))
|
||||
fFolderTag = eSlowControlAnaModule;
|
||||
fNodeTag = eSlowControlAnaModule;
|
||||
else if (!xmlTagName.CompareTo("SCAnaModule"))
|
||||
fFolderTag = eSlowControlAnaModule;
|
||||
fNodeTag = eSlowControlAnaModule;
|
||||
else
|
||||
fFolderTag = eUnkown;
|
||||
fNodeTag = eUnkown;
|
||||
|
||||
offset += 2;
|
||||
str = offsetStr + "<" + xmlTagName + ">";
|
||||
fXmlData.push_back(str.Data());
|
||||
TString sstr = offsetStr + "<" + xmlTagName + ">";
|
||||
fXmlData.push_back(sstr.Data());
|
||||
|
||||
DumpFolder(dynamic_cast<TFolder*>(obj), offset);
|
||||
if (str == "TFolder")
|
||||
DumpFolder(dynamic_cast<TFolder*>(obj), offset);
|
||||
else
|
||||
DumpDirectory(dynamic_cast<TDirectoryFile*>(obj), offset);
|
||||
|
||||
str = offsetStr + "</" + xmlTagName + ">";
|
||||
fXmlData.push_back(str.Data());
|
||||
sstr = offsetStr + "</" + xmlTagName + ">";
|
||||
fXmlData.push_back(sstr.Data());
|
||||
} else if (str == "TObjArray") {
|
||||
offset += 2;
|
||||
DumpObjArray(dynamic_cast<TObjArray*>(obj), offset);
|
||||
} else {
|
||||
// filter out the proper entry tag
|
||||
TString entryTag("");
|
||||
switch (fFolderTag) {
|
||||
switch (fNodeTag) {
|
||||
case eDecayAnaModule:
|
||||
entryTag = TString("DecayHistoEntry");
|
||||
break;
|
||||
|
Loading…
x
Reference in New Issue
Block a user