1 #include "TGliteXmlEventlist.h"
3 ///////////////////////////////////////////////////////////////////////////////////////
4 // class to read gLite XML collections
5 // Autor: Dr. A.-J. Peters - CERN 2004/ALICE Mail-to: Andreas.Joachim.Peters@cern.ch
6 ///////////////////////////////////////////////////////////////////////////////////////
9 // ---------------------------------------------------------------------------------
10 // TGliteXmlEventlist* evlist = new TGliteXmlEventlist("/tmp/fileset.rxml");
12 // // loop over all events
13 // while (evlist->Next()) {
14 // printf("URL for file AliESDs.root is: \n", evlist->GetURL("AliESDs.root"));
17 // ---------------------------------------------------------------------------------
19 #include <TCollection.h>
21 #include <TObjString.h>
22 #include <TXMLEngine.h>
26 ClassImp(TGliteXmlEventlist)
29 TGliteXmlEventlist::TGliteXmlEventlist(const char* localfilename) {
30 //Andi - please put a comment
31 fXmlFile = localfilename;
32 fEventList = new TList();
33 fEventList->SetOwner(kTRUE);
34 fEventListIter = new TIter(fEventList);
39 TGliteXmlEventlist::~TGliteXmlEventlist() {
40 //Andi - please put a comment
42 delete fEventListIter;
46 TGliteXmlEventlist::Reset() {
47 //Andi - please put a comment
48 fEventListIter->Reset();
52 TMap* TGliteXmlEventlist::Next() {
53 //Andi - please put a comment
54 fCurrent = (TMap*)fEventListIter->Next();
58 void TGliteXmlEventlist::ReadXML() {
59 //Andi - please put a comment
60 TXMLEngine* xml = new TXMLEngine();
61 #if ROOT_VERSION_CODE < 328704
62 xmlDocPointer xdoc = xml->ParseFile(fXmlFile);
63 xmlNodePointer xglite = xml->DocGetRootElement(xdoc);
64 xmlNodePointer xdtext = xml->GetChild(xglite);
65 xmlNodePointer xcollection = xml->GetNext(xdtext);
67 xmlNodePointer xtext = 0;
68 xmlNodePointer xevent = 0;
69 xmlNodePointer xtextnext = 0;
70 xmlNodePointer xeventnext = 0;
72 XMLDocPointer_t xdoc = xml->ParseFile(fXmlFile);
73 XMLNodePointer_t xglite = xml->DocGetRootElement(xdoc);
74 XMLNodePointer_t xdtext = xml->GetChild(xglite);
75 XMLNodePointer_t xcollection = xml->GetNext(xdtext);
77 XMLNodePointer_t xtext = 0;
78 XMLNodePointer_t xevent = 0;
79 XMLNodePointer_t xtextnext = 0;
80 XMLNodePointer_t xeventnext = 0;
82 Bool_t first_event=kTRUE;
85 xtextnext = xml->GetChild(xcollection);
88 xtextnext = xml->GetNext(xevent);
92 xeventnext = xml->GetNext(xtextnext);
100 if (xml->GetAttr(xevent,"name")) {
101 TMap* files = new TMap();
104 // printf("Found xevent: %s\n",xml->GetAttr(xevent,"name"));
106 Bool_t first_file = kTRUE;
108 #if ROOT_VERSION_CODE < 328704
109 xmlNodePointer xfile = 0;
110 xmlNodePointer xfiletext = 0;
112 xmlNodePointer xfilenext = 0;
113 xmlNodePointer xfiletextnext = 0;
115 XMLNodePointer_t xfile = 0;
116 XMLNodePointer_t xfiletext = 0;
118 XMLNodePointer_t xfilenext = 0;
119 XMLNodePointer_t xfiletextnext = 0;
123 xfiletextnext = xml->GetChild(xevent);
126 xfiletextnext = xml->GetNext(xfile);
130 xfilenext = xml->GetNext(xfiletextnext);
131 xfiletext = xfilenext;
138 // here we have an event file
139 // printf("Found file: %s\n",xml->GetAttr(xfile,"name"));
141 // get the attributes;
142 // xml->GetAttr(xfile,"comment");
143 // xml->GetAttr(xfile,"date");
144 // xml->GetAttr(xfile,"group");
145 // xml->GetAttr(xfile,"guid");
146 // xml->GetAttr(xfile,"path");
147 // xml->GetAttr(xfile,"permissions");
148 // xml->GetAttr(xfile,"pfn");
149 // xml->GetAttr(xfile,"se");
150 // xml->GetAttr(xfile,"size");
151 // xml->GetAttr(xfile,"user");
153 Bool_t first_mirror = kTRUE;
155 #if ROOT_VERSION_CODE < 328704
156 xmlNodePointer xmirror = 0;
157 xmlNodePointer xmirrortext = 0;
159 xmlNodePointer xmirrornext = 0;
160 xmlNodePointer xmirrortextnext = 0;
162 XMLNodePointer_t xmirror = 0;
163 XMLNodePointer_t xmirrortext = 0;
165 XMLNodePointer_t xmirrornext = 0;
166 XMLNodePointer_t xmirrortextnext = 0;
171 xmirrortextnext = xml->GetChild(xfile);
172 first_mirror = kFALSE;
174 xmirrortextnext = xml->GetNext(xmirror);
177 if (xmirrortextnext) {
178 xmirrornext = xml->GetNext(xmirrortextnext);
179 xmirrortext = xmirrornext;
180 xmirror = xmirrornext;
186 // here we have a file mirror
187 xml->GetAttr(xmirror,"name");
188 xml->GetAttr(xmirror,"domain");
189 xml->GetAttr(xmirror,"latitude");
190 xml->GetAttr(xmirror,"longitude");
191 xml->GetAttr(xmirror,"location");
192 xml->GetAttr(xmirror,"master");
193 xml->GetAttr(xmirror,"site");
194 xml->GetAttr(xmirror,"rootd");
195 const char* master = 0;
196 if ( (master = xml->GetAttr(xmirror,"master"))) {
197 if (atoi(master) == 1) {
198 files->Add(new TObjString(xml->GetAttr(xfile,"name")) , new TObjString(xml->GetAttr(xmirror,"rootd")));
201 // printf("Found File Mirror: %s\n",xml->GetAttr(xmirror,"name"));
206 // printf("Adding files\n");
207 fEventList->Add(files);
214 const char* TGliteXmlEventlist::GetURL(const char* filename) const {
215 //Andi - please put a comment
217 TObjString* obj = (TObjString*)fCurrent->GetValue(filename);
219 if (strlen(obj->GetName()))
220 return (obj->GetName());
232 void TGliteXmlEventlist::Print(Option_t */*opt*/) const {
233 //Andi - please put a comment
234 printf("Dumping %d elements\n",fEventList->GetSize());
235 TIter next(fEventList);
238 while ( (filemap = (TMap*)next()) ) {
240 printf("Printing Element %d\n",count);