AliEn Classes necessary for analysis
authorskowron <skowron@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 30 Nov 2004 11:15:58 +0000 (11:15 +0000)
committerskowron <skowron@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 30 Nov 2004 11:15:58 +0000 (11:15 +0000)
ANALYSIS/ANALYSISLinkDef.h
ANALYSIS/TGliteXmlEventlist.cxx [new file with mode: 0644]
ANALYSIS/TGliteXmlEventlist.h [new file with mode: 0644]
ANALYSIS/libANALYSIS.pkg

index 3883d0aa610abd4e5ee4b1873ea2395b1ffef65b..32844bf21305b9aff61afc269485a43f9aac9ac9 100644 (file)
@@ -4,6 +4,8 @@
 #pragma link off all classes;
 #pragma link off all functions;
 
 #pragma link off all classes;
 #pragma link off all functions;
 
+#pragma link C++ class TGliteXmlEventlist+;
+
 #pragma link C++ class AliD0toKpi+;
 #pragma link C++ class AliD0toKpiAnalysis+;
 #pragma link C++ class AliRunAnalysis+;
 #pragma link C++ class AliD0toKpi+;
 #pragma link C++ class AliD0toKpiAnalysis+;
 #pragma link C++ class AliRunAnalysis+;
diff --git a/ANALYSIS/TGliteXmlEventlist.cxx b/ANALYSIS/TGliteXmlEventlist.cxx
new file mode 100644 (file)
index 0000000..57765b6
--- /dev/null
@@ -0,0 +1,218 @@
+#include "TGliteXmlEventlist.h"
+
+///////////////////////////////////////////////////////////////////////////////////////
+// class to read gLite XML collections
+// Autor: Dr. A.-J. Peters - CERN 2004/ALICE   Mail-to: Andreas.Joachim.Peters@cern.ch
+///////////////////////////////////////////////////////////////////////////////////////
+
+// example: 
+//   ---------------------------------------------------------------------------------
+//   TGliteXmlEventlist* evlist = new TGliteXmlEventlist("/tmp/fileset.rxml");
+//   evlist->Reset()
+//   // loop over all events
+//   while (evlist->Next()) {
+//     printf("URL for file AliESDs.root is: \n", evlist->GetURL("AliESDs.root"));
+//   }
+//   delete evlist;
+//   ---------------------------------------------------------------------------------
+
+#include <TCollection.h>
+#include <TMap.h>
+#include <TObjString.h>
+#include <TXMLEngine.h>
+#include <TList.h>
+
+
+ClassImp(TGliteXmlEventlist)
+
+
+TGliteXmlEventlist::TGliteXmlEventlist(const char* localfilename) {
+//Andi - please put a comment
+  fXmlFile = localfilename;
+  fEventList = new TList();
+  fEventList->SetOwner(kTRUE);
+  fEventListIter = new TIter(fEventList);
+  fCurrent = 0;
+  ReadXML();
+}
+
+TGliteXmlEventlist::~TGliteXmlEventlist() {
+//Andi - please put a comment
+  delete fEventList;
+  delete fEventListIter;
+}
+
+void
+TGliteXmlEventlist::Reset() {
+//Andi - please put a comment
+  fEventListIter->Reset();
+  fCurrent = 0;
+}
+
+TMap* TGliteXmlEventlist::Next() {
+//Andi - please put a comment
+  fCurrent = (TMap*)fEventListIter->Next();
+  return fCurrent;
+}
+
+void TGliteXmlEventlist::ReadXML() {
+//Andi - please put a comment
+  TXMLEngine* xml = new TXMLEngine();
+  xmlDocPointer xdoc = xml->ParseFile(fXmlFile);
+  xmlNodePointer xglite = xml->DocGetRootElement(xdoc);
+  xmlNodePointer xdtext = xml->GetChild(xglite);
+  xmlNodePointer xcollection = xml->GetNext(xdtext);
+
+  xmlNodePointer xtext = 0;
+  xmlNodePointer xevent = 0;
+  xmlNodePointer xtextnext  = 0;
+  xmlNodePointer xeventnext = 0;
+  Bool_t first_event=kTRUE;
+  do {
+    if (first_event) {
+      xtextnext  = xml->GetChild(xcollection);
+      first_event = kFALSE;
+    } else {
+      xtextnext  = xml->GetNext(xevent);
+    }
+
+    if (xtextnext) {
+      xeventnext = xml->GetNext(xtextnext);
+      xtext = xeventnext;
+      xevent = xeventnext;
+    } else {
+      xtext  = 0;
+    }
+
+    if (xevent) {
+      if (xml->GetAttr(xevent,"name")) {
+       TMap* files = new TMap();
+       
+       // here is our event
+       //      printf("Found xevent: %s\n",xml->GetAttr(xevent,"name"));
+       
+       Bool_t first_file = kTRUE;
+       
+       xmlNodePointer xfile = 0;
+       xmlNodePointer xfiletext = 0;
+       
+       xmlNodePointer xfilenext = 0;
+       xmlNodePointer xfiletextnext = 0;
+       do {
+         if (first_file) {
+           xfiletextnext = xml->GetChild(xevent);
+           first_file = kFALSE;
+         } else {
+           xfiletextnext = xml->GetNext(xfile);
+         }
+         
+         if (xfiletextnext) {
+           xfilenext = xml->GetNext(xfiletextnext);
+           xfiletext = xfilenext;
+           xfile     = xfilenext;
+         } else {
+           xfile     = 0;
+           xfiletext = 0;
+         }
+         if (xfile) {
+           // here we have an event file  
+           //      printf("Found file:   %s\n",xml->GetAttr(xfile,"name"));
+           
+           // get the attributes;
+           //    xml->GetAttr(xfile,"comment");
+           //    xml->GetAttr(xfile,"date");
+           //    xml->GetAttr(xfile,"group");
+           //    xml->GetAttr(xfile,"guid");
+           //    xml->GetAttr(xfile,"path");
+           //    xml->GetAttr(xfile,"permissions");
+           //    xml->GetAttr(xfile,"pfn");
+           //    xml->GetAttr(xfile,"se");
+           //    xml->GetAttr(xfile,"size");
+           //    xml->GetAttr(xfile,"user");
+           
+           Bool_t first_mirror = kTRUE;
+           
+           xmlNodePointer xmirror = 0;
+           xmlNodePointer xmirrortext = 0;
+           
+           xmlNodePointer xmirrornext = 0;
+           xmlNodePointer xmirrortextnext = 0;
+           
+           do {
+             if (first_mirror) {
+               xmirrortextnext = xml->GetChild(xfile);
+               first_mirror = kFALSE;
+             } else {
+               xmirrortextnext = xml->GetNext(xmirror);
+             }
+             
+             if (xmirrortextnext) {
+               xmirrornext = xml->GetNext(xmirrortextnext);
+               xmirrortext = xmirrornext;
+               xmirror     = xmirrornext;
+             } else {
+               xmirror     = 0;
+               xmirrortext = 0;
+             }
+             if (xmirror) {
+               // here we have a file mirror
+               xml->GetAttr(xmirror,"name");
+               xml->GetAttr(xmirror,"domain");
+               xml->GetAttr(xmirror,"latitude");
+               xml->GetAttr(xmirror,"longitude");
+               xml->GetAttr(xmirror,"location");
+               xml->GetAttr(xmirror,"master");
+               xml->GetAttr(xmirror,"site");
+               xml->GetAttr(xmirror,"rootd");
+               const char* master = 0;
+               if ( (master = xml->GetAttr(xmirror,"master"))) {
+                 if (atoi(master) == 1) {
+                   files->Add(new TObjString(xml->GetAttr(xfile,"name")) , new TObjString(xml->GetAttr(xmirror,"rootd")));
+                 }
+               }
+               //              printf("Found File Mirror: %s\n",xml->GetAttr(xmirror,"name"));
+             }
+           } while (xmirror);
+         }
+       } while (xfile);
+       //      printf("Adding files\n");
+       fEventList->Add(files);
+      }
+    }
+  } while ( xtext );
+  delete xml;
+}    
+
+const char* TGliteXmlEventlist::GetURL(const char* filename) const {
+//Andi - please put a comment
+  if (fCurrent) {
+    TObjString* obj = (TObjString*)fCurrent->GetValue(filename);
+    if (obj) {
+      if (strlen(obj->GetName())) 
+       return (obj->GetName());
+      else 
+       return 0;
+    } else {
+      return 0;
+    }
+  } else {
+    return 0;
+  }
+}
+
+
+void TGliteXmlEventlist::Print(Option_t */*opt*/) const {
+//Andi - please put a comment
+  printf("Dumping %d elements\n",fEventList->GetSize());
+  TIter next(fEventList);
+  TMap* filemap;
+  Int_t count=0;
+  while ( (filemap = (TMap*)next()) ) {
+    count++;
+    printf("Printing Element %d\n",count);
+    filemap->Print();
+  }
+}
+
+
+
diff --git a/ANALYSIS/TGliteXmlEventlist.h b/ANALYSIS/TGliteXmlEventlist.h
new file mode 100644 (file)
index 0000000..c49bd97
--- /dev/null
@@ -0,0 +1,46 @@
+#ifndef TGLITEXMLEVENTLIST_H
+#define TGLITEXMLEVENTLIST_H
+
+///////////////////////////////////////////////////////////////////////////////////////
+// class to read gLite XML collections
+// Autor: Dr. A.-J. Peters - CERN 2004/ALICE   Mail-to: Andreas.Joachim.Peters@cern.ch
+///////////////////////////////////////////////////////////////////////////////////////
+
+// example: 
+//   ---------------------------------------------------------------------------------
+//   TGliteXmlEventlist* evlist = new TGliteXmlEventlist("/tmp/fileset.rxml");
+//   evlist->Reset()
+//   // loop over all events
+//   while (evlist->Next()) {
+//     printf("URL for file AliESDs.root is: \n", evlist->GetURL("AliESDs.root"));
+//   }
+//   delete evlist;
+//   ---------------------------------------------------------------------------------
+
+
+#include <TObject.h>
+#include <TString.h>
+class TList;
+class TIter;
+class TMap;
+
+class TGliteXmlEventlist : public TObject {
+public:
+  TGliteXmlEventlist(const char* localfilename);
+  virtual ~TGliteXmlEventlist();
+  void Reset();
+  TMap* Next();
+  const char* GetURL(const char* name) const ;
+  void        Print(Option_t* opt) const;
+private:
+  TString     fXmlFile;//Andi - please put a comment
+  TList*      fEventList;//Andi - please put a comment
+  TIter*      fEventListIter;//Andi - please put a comment
+  TMap*       fCurrent;//Andi - please put a comment
+
+  virtual void ReadXML();
+
+  ClassDef(TGliteXmlEventlist,0);
+};
+
+#endif
index 735e592903d7b92f81331937b65f2ce6524bfc24..d8c20fbd7fbd7ce4654c37d96237eccdd91e51c2 100644 (file)
@@ -1,4 +1,5 @@
-SRCS= AliAOD.cxx AliEventBuffer.cxx \
+SRCS= TGliteXmlEventlist.cxx\
+      AliAOD.cxx AliEventBuffer.cxx \
       AliRunAnalysis.cxx AliAnalysis.cxx \
       AliVAODParticle.cxx AliAODParticle.cxx \
       AliAODPair.cxx   AliAODRun.cxx     \
       AliRunAnalysis.cxx AliAnalysis.cxx \
       AliVAODParticle.cxx AliAODParticle.cxx \
       AliAODPair.cxx   AliAODRun.cxx     \