From: skowron Date: Tue, 30 Nov 2004 11:15:58 +0000 (+0000) Subject: AliEn Classes necessary for analysis X-Git-Url: http://git.uio.no/git/?p=u%2Fmrichter%2FAliRoot.git;a=commitdiff_plain;h=2589e668ec021c93c5d2365066954ecf69deb618 AliEn Classes necessary for analysis --- diff --git a/ANALYSIS/ANALYSISLinkDef.h b/ANALYSIS/ANALYSISLinkDef.h index 3883d0aa610..32844bf2130 100644 --- a/ANALYSIS/ANALYSISLinkDef.h +++ b/ANALYSIS/ANALYSISLinkDef.h @@ -4,6 +4,8 @@ #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+; diff --git a/ANALYSIS/TGliteXmlEventlist.cxx b/ANALYSIS/TGliteXmlEventlist.cxx new file mode 100644 index 00000000000..57765b66fd3 --- /dev/null +++ b/ANALYSIS/TGliteXmlEventlist.cxx @@ -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 +#include +#include +#include +#include + + +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 index 00000000000..c49bd97df28 --- /dev/null +++ b/ANALYSIS/TGliteXmlEventlist.h @@ -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 +#include +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 diff --git a/ANALYSIS/libANALYSIS.pkg b/ANALYSIS/libANALYSIS.pkg index 735e592903d..d8c20fbd7fb 100644 --- a/ANALYSIS/libANALYSIS.pkg +++ b/ANALYSIS/libANALYSIS.pkg @@ -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 \