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):
31 fXmlFile(localfilename),
32 fEventList(new TList()),
33 fEventListIter(new TIter(fEventList)),
36 //Andi - please put a comment
37 fEventList->SetOwner(kTRUE);
41 TGliteXmlEventlist::~TGliteXmlEventlist() {
42 //Andi - please put a comment
44 delete fEventListIter;
48 TGliteXmlEventlist::Reset() {
49 //Andi - please put a comment
50 fEventListIter->Reset();
54 TMap* TGliteXmlEventlist::Next() {
55 //Andi - please put a comment
56 fCurrent = (TMap*)fEventListIter->Next();
60 void TGliteXmlEventlist::ReadXML() {
61 //Andi - please put a comment
62 TXMLEngine* xml = new TXMLEngine();
63 #if ROOT_VERSION_CODE < 328704
64 xmlDocPointer xdoc = xml->ParseFile(fXmlFile);
65 xmlNodePointer xglite = xml->DocGetRootElement(xdoc);
66 xmlNodePointer xdtext = xml->GetChild(xglite);
67 xmlNodePointer xcollection = xml->GetNext(xdtext);
69 xmlNodePointer xtext = 0;
70 xmlNodePointer xevent = 0;
71 xmlNodePointer xtextnext = 0;
72 xmlNodePointer xeventnext = 0;
74 XMLDocPointer_t xdoc = xml->ParseFile(fXmlFile);
75 XMLNodePointer_t xglite = xml->DocGetRootElement(xdoc);
76 XMLNodePointer_t xdtext = xml->GetChild(xglite);
77 XMLNodePointer_t xcollection = xml->GetNext(xdtext);
79 XMLNodePointer_t xtext = 0;
80 XMLNodePointer_t xevent = 0;
81 XMLNodePointer_t xtextnext = 0;
82 XMLNodePointer_t xeventnext = 0;
84 Bool_t first_event=kTRUE;
87 xtextnext = xml->GetChild(xcollection);
90 xtextnext = xml->GetNext(xevent);
94 xeventnext = xml->GetNext(xtextnext);
102 if (xml->GetAttr(xevent,"name")) {
103 TMap* files = new TMap();
106 // printf("Found xevent: %s\n",xml->GetAttr(xevent,"name"));
108 Bool_t first_file = kTRUE;
110 #if ROOT_VERSION_CODE < 328704
111 xmlNodePointer xfile = 0;
112 xmlNodePointer xfiletext = 0;
114 xmlNodePointer xfilenext = 0;
115 xmlNodePointer xfiletextnext = 0;
117 XMLNodePointer_t xfile = 0;
118 XMLNodePointer_t xfiletext = 0;
120 XMLNodePointer_t xfilenext = 0;
121 XMLNodePointer_t xfiletextnext = 0;
125 xfiletextnext = xml->GetChild(xevent);
128 xfiletextnext = xml->GetNext(xfile);
132 xfilenext = xml->GetNext(xfiletextnext);
133 xfiletext = xfilenext;
140 // here we have an event file
141 // printf("Found file: %s\n",xml->GetAttr(xfile,"name"));
143 // get the attributes;
144 // xml->GetAttr(xfile,"comment");
145 // xml->GetAttr(xfile,"date");
146 // xml->GetAttr(xfile,"group");
147 // xml->GetAttr(xfile,"guid");
148 // xml->GetAttr(xfile,"path");
149 // xml->GetAttr(xfile,"permissions");
150 // xml->GetAttr(xfile,"pfn");
151 // xml->GetAttr(xfile,"se");
152 // xml->GetAttr(xfile,"size");
153 // xml->GetAttr(xfile,"user");
155 Bool_t first_mirror = kTRUE;
157 #if ROOT_VERSION_CODE < 328704
158 xmlNodePointer xmirror = 0;
159 xmlNodePointer xmirrortext = 0;
161 xmlNodePointer xmirrornext = 0;
162 xmlNodePointer xmirrortextnext = 0;
164 XMLNodePointer_t xmirror = 0;
165 XMLNodePointer_t xmirrortext = 0;
167 XMLNodePointer_t xmirrornext = 0;
168 XMLNodePointer_t xmirrortextnext = 0;
173 xmirrortextnext = xml->GetChild(xfile);
174 first_mirror = kFALSE;
176 xmirrortextnext = xml->GetNext(xmirror);
179 if (xmirrortextnext) {
180 xmirrornext = xml->GetNext(xmirrortextnext);
181 xmirrortext = xmirrornext;
182 xmirror = xmirrornext;
188 // here we have a file mirror
189 xml->GetAttr(xmirror,"name");
190 xml->GetAttr(xmirror,"domain");
191 xml->GetAttr(xmirror,"latitude");
192 xml->GetAttr(xmirror,"longitude");
193 xml->GetAttr(xmirror,"location");
194 xml->GetAttr(xmirror,"master");
195 xml->GetAttr(xmirror,"site");
196 xml->GetAttr(xmirror,"rootd");
197 const char* master = 0;
198 if ( (master = xml->GetAttr(xmirror,"master"))) {
199 if (atoi(master) == 1) {
200 files->Add(new TObjString(xml->GetAttr(xfile,"name")) , new TObjString(xml->GetAttr(xmirror,"rootd")));
203 // printf("Found File Mirror: %s\n",xml->GetAttr(xmirror,"name"));
208 // printf("Adding files\n");
209 fEventList->Add(files);
216 const char* TGliteXmlEventlist::GetURL(const char* filename) const {
217 //Andi - please put a comment
219 TObjString* obj = (TObjString*)fCurrent->GetValue(filename);
221 if (strlen(obj->GetName()))
222 return (obj->GetName());
234 void TGliteXmlEventlist::Print(Option_t */*opt*/) const {
235 //Andi - please put a comment
236 printf("Dumping %d elements\n",fEventList->GetSize());
237 TIter next(fEventList);
240 while ( (filemap = (TMap*)next()) ) {
242 printf("Printing Element %d\n",count);