+++ /dev/null
-/**************************************************************************
- * Author: Panos Christakoglou. *
- * Contributors are mentioned in the code where appropriate. *
- * *
- * Permission to use, copy, modify and distribute this software and its *
- * documentation strictly for non-commercial purposes is hereby granted *
- * without fee, provided that the above copyright notice appears in all *
- * copies and that both the copyright notice and this permission notice *
- * appear in the supporting documentation. The authors make no claims *
- * about the suitability of this software for any purpose. It is *
- * provided "as is" without express or implied warranty. *
- **************************************************************************/
-
-/* $Id$ */
-
-//-----------------------------------------------------------------
-// AliTagAnalysis class
-// This is the class to deal with the tag analysis
-// Origin: Panos Christakoglou, UOA-CERN, Panos.Christakoglou@cern.ch
-//-----------------------------------------------------------------
-
-//ROOT
-#include <TSystem.h>
-#include <TChain.h>
-#include <TFile.h>
-#include <TEventList.h>
-#include <TEntryList.h>
-#include <TTreeFormula.h>
-
-//ROOT-AliEn
-#include <TGridResult.h>
-
-#include "AliLog.h"
-
-#include "AliRunTag.h"
-#include "AliEventTag.h"
-#include "AliTagAnalysis.h"
-#include "AliEventTagCuts.h"
-#include "AliRunTagCuts.h"
-#include "AliXMLCollection.h"
-
-class TTree;
-
-ClassImp(AliTagAnalysis)
-
-//___________________________________________________________________________
-AliTagAnalysis::AliTagAnalysis():
- TObject(),
- ftagresult(0x0),
- fTagDirName(),
- fChain(0x0)
-{
- //Default constructor for a AliTagAnalysis
-}
-
-//___________________________________________________________________________
-AliTagAnalysis::~AliTagAnalysis() {
-//Default destructor for a AliTagAnalysis
-}
-
-//___________________________________________________________________________
-Bool_t AliTagAnalysis::AddTagsFile(const char *alienUrl) {
-
- // Add a single tags file to the chain
-
- Bool_t rv = kTRUE ;
-
- if (! fChain) fChain = new TChain("T");
-
- TFile *f = TFile::Open(alienUrl,"READ");
- fChain->Add(alienUrl);
- AliInfo(Form("Chained tag files: %d ",fChain->GetEntries()));
- delete f;
-
- if (fChain->GetEntries() == 0 )
- rv = kFALSE ;
-
- return rv ;
-}
-
-//___________________________________________________________________________
-void AliTagAnalysis::ChainLocalTags(const char *dirname) {
- //Searches the entries of the provided direcory
- //Chains the tags that are stored locally
- fTagDirName = dirname;
- TString fTagFilename;
-
- if (! fChain) fChain = new TChain("T");
-
- const char * tagPattern = "tag.root";
- // Open the working directory
- void * dirp = gSystem->OpenDirectory(fTagDirName);
- const char * name = 0x0;
- // Add all files matching *pattern* to the chain
- while((name = gSystem->GetDirEntry(dirp))) {
- if (strstr(name,tagPattern)) {
- fTagFilename = fTagDirName;
- fTagFilename += "/";
- fTagFilename += name;
-
- fChain->Add(fTagFilename);
- }//pattern check
- }//directory loop
- AliInfo(Form("Chained tag files: %d ",fChain->GetEntries()));
-}
-
-
-//___________________________________________________________________________
-void AliTagAnalysis::ChainGridTags(TGridResult *res) {
- //Loops overs the entries of the TGridResult
- //Chains the tags that are stored in the GRID
- ftagresult = res;
- Int_t nEntries = ftagresult->GetEntries();
-
- if (! fChain) fChain = new TChain("T");
-
- TString gridname = "alien://";
- TString alienUrl;
-
- for(Int_t i = 0; i < nEntries; i++) {
- alienUrl = ftagresult->GetKey(i,"turl");
- fChain->Add(alienUrl);
- }//grid result loop
-}
-
-
-//___________________________________________________________________________
-TChain *AliTagAnalysis::QueryTags(AliRunTagCuts *RunTagCuts, AliEventTagCuts *EvTagCuts) {
- //Queries the tag chain using the defined
- //event tag cuts from the AliEventTagCuts object
- //and returns a TChain along with the associated TEventList
- AliInfo(Form("Querying the tags........"));
-
- //ESD file chain
- TChain *fESDchain = new TChain("esdTree");
- //Event list
- TEventList *fEventList = new TEventList();
-
- //Defining tag objects
- AliRunTag *tag = new AliRunTag;
- AliEventTag *evTag = new AliEventTag;
- fChain->SetBranchAddress("AliTAG",&tag);
-
- TString guid = 0;
- TString turl = 0;
- TString path = 0;
-
- Int_t iAccepted = 0;
- for(Int_t iTagFiles = 0; iTagFiles < fChain->GetEntries(); iTagFiles++) {
- fChain->GetEntry(iTagFiles);
- if(RunTagCuts->IsAccepted(tag)) {
- Int_t iEvents = tag->GetNEvents();
- const TClonesArray *tagList = tag->GetEventTags();
- for(Int_t i = 0; i < iEvents; i++) {
- evTag = (AliEventTag *) tagList->At(i);
- guid = evTag->GetGUID();
- turl = evTag->GetTURL();
- path = evTag->GetPath();
- if(EvTagCuts->IsAccepted(evTag)) fEventList->Enter(iAccepted+i);
- }//event loop
- iAccepted += iEvents;
-
- if(path != "") fESDchain->AddFile(path);
- else if(turl != "") fESDchain->AddFile(turl);
- }//run tags cut
- }//tag file loop
- AliInfo(Form("Accepted events: %d",fEventList->GetN()));
- fESDchain->SetEventList(fEventList);
-
- return fESDchain;
-}
-
-//___________________________________________________________________________
-TChain *AliTagAnalysis::QueryTags(const char *fRunCut, const char *fEventCut) {
- //Queries the tag chain using the defined
- //event tag cuts from the AliEventTagCuts object
- //and returns a TChain along with the associated TEventList
- AliInfo(Form("Querying the tags........"));
-
- //ESD file chain
- TChain *fESDchain = new TChain("esdTree");
- //Event list
- TEventList *fEventList = new TEventList();
-
- //Defining tag objects
- AliRunTag *tag = new AliRunTag;
- AliEventTag *evTag = new AliEventTag;
- fChain->SetBranchAddress("AliTAG",&tag);
-
- TString guid = 0;
- TString turl = 0;
- TString path = 0;
-
- TTreeFormula *fRunFormula = new TTreeFormula("fRun",fRunCut,fChain);
- TTreeFormula *fEventFormula = new TTreeFormula("fEvent",fEventCut,fChain);
-
- Int_t current = -1;
- Int_t iAccepted = 0;
- for(Int_t iTagFiles = 0; iTagFiles < fChain->GetEntries(); iTagFiles++) {
- fChain->GetEntry(iTagFiles);
- if (current != fChain->GetTreeNumber()) {
- fRunFormula->UpdateFormulaLeaves();
- fEventFormula->UpdateFormulaLeaves();
- current = fChain->GetTreeNumber();
- }
- if(fRunFormula->EvalInstance(iTagFiles) == 1) {
- Int_t iEvents = fEventFormula->GetNdata();
- const TClonesArray *tagList = tag->GetEventTags();
- for(Int_t i = 0; i < iEvents; i++) {
- evTag = (AliEventTag *) tagList->At(i);
- guid = evTag->GetGUID();
- turl = evTag->GetTURL();
- path = evTag->GetPath();
- if(fEventFormula->EvalInstance(i) == 1) fEventList->Enter(iAccepted+i);
- }//event loop
- iAccepted += iEvents;
-
- if(path != "") fESDchain->AddFile(path);
- else if(turl != "") fESDchain->AddFile(turl);
- }//run tag cut
- }//tag file loop
- AliInfo(Form("Accepted events: %d",fEventList->GetN()));
- fESDchain->SetEventList(fEventList);
-
- return fESDchain;
-}
-
-//___________________________________________________________________________
-Bool_t AliTagAnalysis::CreateXMLCollection(const char* name, AliRunTagCuts *RunTagCuts, AliEventTagCuts *EvTagCuts) {
- //Queries the tag chain using the defined
- //event tag cuts from the AliEventTagCuts object
- //and returns a XML collection
- AliInfo(Form("Creating the collection........"));
-
- AliXMLCollection *collection = new AliXMLCollection();
- collection->SetCollectionName(name);
- collection->WriteHeader();
-
- //Event list
- //TEntryList *fEventList = new TEntryList();
- TString guid = 0x0;
- TString turl = 0x0;
- TString lfn = 0x0;
-
- //Defining tag objects
- AliRunTag *tag = new AliRunTag;
- AliEventTag *evTag = new AliEventTag;
- fChain->SetBranchAddress("AliTAG",&tag);
-
- for(Int_t iTagFiles = 0; iTagFiles < fChain->GetEntries(); iTagFiles++) {
- //Event list
- TEntryList *fList = new TEntryList();
- fChain->GetEntry(iTagFiles);
- if(RunTagCuts->IsAccepted(tag)) {
- Int_t iEvents = tag->GetNEvents();
- const TClonesArray *tagList = tag->GetEventTags();
- for(Int_t i = 0; i < iEvents; i++) {
- evTag = (AliEventTag *) tagList->At(i);
- guid = evTag->GetGUID();
- turl = evTag->GetTURL();
- lfn = turl(8,turl.Length());
- if(EvTagCuts->IsAccepted(evTag)) fList->Enter(i);
- }//event loop
- collection->WriteBody(iTagFiles+1,guid,lfn,turl,fList);
- }//run tag cuts
- }//tag file loop
- collection->Export();
-
- return kTRUE;
-}
-
-//___________________________________________________________________________
-Bool_t AliTagAnalysis::CreateXMLCollection(const char* name, const char *fRunCut, const char *fEventCut) {
- //Queries the tag chain using the defined
- //event tag cuts from the AliEventTagCuts object
- //and returns a XML collection
- AliInfo(Form("Creating the collection........"));
-
- AliXMLCollection *collection = new AliXMLCollection();
- collection->SetCollectionName(name);
- collection->WriteHeader();
-
- TString guid = 0x0;
- TString turl = 0x0;
- TString lfn = 0x0;
-
- //Defining tag objects
- AliRunTag *tag = new AliRunTag;
- AliEventTag *evTag = new AliEventTag;
- fChain->SetBranchAddress("AliTAG",&tag);
-
- TTreeFormula *fRunFormula = new TTreeFormula("fRun",fRunCut,fChain);
- TTreeFormula *fEventFormula = new TTreeFormula("fEvent",fEventCut,fChain);
-
- Int_t current = -1;
- for(Int_t iTagFiles = 0; iTagFiles < fChain->GetEntries(); iTagFiles++) {
- //Event list
- TEntryList *fList = new TEntryList();
- fChain->GetEntry(iTagFiles);
- if (current != fChain->GetTreeNumber()) {
- fRunFormula->UpdateFormulaLeaves();
- fEventFormula->UpdateFormulaLeaves();
- current = fChain->GetTreeNumber();
- }
- if(fRunFormula->EvalInstance(iTagFiles) == 1) {
- Int_t iEvents = fEventFormula->GetNdata();
- const TClonesArray *tagList = tag->GetEventTags();
- for(Int_t i = 0; i < iEvents; i++) {
- evTag = (AliEventTag *) tagList->At(i);
- guid = evTag->GetGUID();
- turl = evTag->GetTURL();
- lfn = turl(8,turl.Length());
- if(fEventFormula->EvalInstance(i) == 1) fList->Enter(i);
- }//event loop
- collection->WriteBody(iTagFiles+1,guid,lfn,turl,fList);
- }//run tag cuts
- }//tag file loop
- collection->Export();
-
- return kTRUE;
-}
-
-//___________________________________________________________________________
-TChain *AliTagAnalysis::GetInputChain(const char* system, const char *wn) {
- //returns the chain+event list - used in batch sessions
- // this function will be removed once the new root
- // improvements are committed
- TString fsystem = system;
- Int_t iAccepted = 0;
- //ESD file chain
- TChain *fESDchain = new TChain("esdTree");
- //Event list
- TEventList *fEventList = new TEventList();
- AliXMLCollection *collection = AliXMLCollection::Open(wn);
-
- collection->Reset();
- while (collection->Next()) {
- AliInfo(Form("Adding: %s",collection->GetTURL("")));
- fESDchain->Add(collection->GetTURL(""));
- TEntryList *list = (TEntryList *)collection->GetEventList("");
- for(Int_t i = 0; i < list->GetN(); i++) fEventList->Enter(iAccepted+list->GetEntry(i));
-
- if(fsystem == "pp") iAccepted += 100;
- else if(fsystem == "PbPb") iAccepted += 1;
- }
-
- fESDchain->SetEventList(fEventList);
-
- AliInfo(Form("Number of selected events: %d",fEventList->GetN()));
-
- return fESDchain;
-}
-
-//___________________________________________________________________________
-TChain *AliTagAnalysis::GetChainFromCollection(const char* collectionname, const char* treename) {
- //returns the TChain+TEntryList object- used in batch sessions
- TString fAliceFile = treename;
- Int_t iAccepted = 0;
- TChain *fAnalysisChain = new TChain();
- if(fAliceFile == "esdTree") {
- //ESD file chain
- fAnalysisChain->SetName("esdTree");
- } else if(fAliceFile == "aodTree") {
- //AOD file chain
- fAnalysisChain->SetName("aodTree");
- AliFatal("AOD case not yet implemented!!!");
- }
- else AliFatal("Inconsistent tree name - use esdTree or aodTree!");
- //Event list
- TEntryList *fGlobalList = new TEntryList();
- AliXMLCollection *collection = AliXMLCollection::Open(collectionname);
-
- collection->Reset();
- while (collection->Next()) {
- AliInfo(Form("Adding: %s",collection->GetTURL("")));
- fAnalysisChain->Add(collection->GetTURL(""));
- TEntryList *list = (TEntryList *)collection->GetEventList("");
- list->SetTreeName(fAliceFile.Data());
- list->SetFileName(collection->GetTURL(""));
- fGlobalList->Add(list);
- iAccepted += list->GetN();
- }
-
- fAnalysisChain->SetEntryList(fGlobalList,"ne");
-
- AliInfo(Form("Number of selected events: %d",iAccepted));
-
- return fAnalysisChain;
-}
+++ /dev/null
-#ifndef ALITAGANALYSIS_H
-#define ALITAGANALYSIS_H
-/* See cxx source for full Copyright notice */
-
-
-/* $Id$ */
-
-//-------------------------------------------------------------------------
-// Class AliTagAnalysis
-// This is the AliTagAnalysis class for the tag analysis
-//
-// Origin: Panos Christakoglou, UOA-CERN, Panos.Christakoglou@cern.ch
-//-------------------------------------------------------------------------
-
-
-
-//////////////////////////////////////////////////////////////////////////
-// //
-// AliTagAnalysis //
-// //
-// Implementation of the tag analysis mechanism. //
-// //
-//////////////////////////////////////////////////////////////////////////
-
-
-//ROOT
-#include <TObject.h>
-
-class AliEventTag;
-class TChain;
-class AliEventTagCuts;
-class AliRunTagCuts;
-class TGridResult;
-class TTreeFormula;
-
-//____________________________________________________//
-class AliTagAnalysis : public TObject {
- public:
- AliTagAnalysis();
- ~AliTagAnalysis();
-
- Bool_t AddTagsFile(const char *alienUrl);
- void ChainLocalTags(const char *dirname);
- void ChainGridTags(TGridResult *result);
-
- TChain *QueryTags(AliRunTagCuts *RunTagCuts, AliEventTagCuts *EvTagCuts);
- TChain *QueryTags(const char *fRunCut, const char *fEventCut);
-
- Bool_t CreateXMLCollection(const char* name, AliRunTagCuts *RunTagCuts, AliEventTagCuts *EvTagCuts);
- Bool_t CreateXMLCollection(const char* name, const char *fRunCut, const char *fEventCut);
-
- TChain *GetInputChain(const char* system, const char *wn);
- TChain *GetChainFromCollection(const char* collectionname, const char* treename);
-
- //____________________________________________________//
- protected:
- TGridResult *ftagresult; //the results from the tag grid query
- TString fTagDirName; //the location of the locally stored tags
-
- TChain *fChain; //tag chain
-
- //____________________________________________________//
- private:
- AliTagAnalysis(const AliTagAnalysis & source);
- AliTagAnalysis & operator=(const AliTagAnalysis & source);
-
- ClassDef(AliTagAnalysis,0)
-};
-
-#endif
-
+++ /dev/null
-/**************************************************************************
- * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
- * *
- * Author: The ALICE Off-line Project. *
- * Contributors are mentioned in the code where appropriate. *
- * *
- * Permission to use, copy, modify and distribute this software and its *
- * documentation strictly for non-commercial purposes is hereby granted *
- * without fee, provided that the above copyright notice appears in all *
- * copies and that both the copyright notice and this permission notice *
- * appear in the supporting documentation. The authors make no claims *
- * about the suitability of this software for any purpose. It is *
- * provided "as is" without express or implied warranty. *
- **************************************************************************/
-
-/* $Id$ */
-
-//-----------------------------------------------------------------
-// Implementation of the AliXMLCollection class
-// This is the class that creates XML collections after querying the tags
-// Origin: Panos Christakoglou, UOA-CERN, Panos.Christakoglou@cern.ch
-//-----------------------------------------------------------------
-
-//ROOT
-#include <Riostream.h>
-#include <TEntryList.h>
-#include <TList.h>
-#include <TMap.h>
-#include <TObjArray.h>
-#include <TObjString.h>
-#include <TString.h>
-#include <TXMLEngine.h>
-
-#include "AliXMLCollection.h"
-
-ClassImp(AliXMLCollection)
-
-//___________________________________________________________________________
- AliXMLCollection::AliXMLCollection() :
- TGridCollection(),
- fXmlFile(),
- fEventList(0),
- fEventListIter(0),
- fCurrent(0),
- fCollectionName(),
- fout() {
- //Default constructor
-}
-
-//___________________________________________________________________________
-AliXMLCollection::AliXMLCollection(const char *localcollectionfile) {
- // Create Alien event collection, by reading collection for the specified
- // file.
-
- fXmlFile = localcollectionfile;
- fEventList = new TList();
- fEventList->SetOwner(kTRUE);
- fEventListIter = new TIter(fEventList);
- fCurrent = 0;
- if (localcollectionfile!=0) {
- ParseXML();
- }
-}
-
-//___________________________________________________________________________
-AliXMLCollection::AliXMLCollection(const AliXMLCollection& collection):
- TGridCollection(collection),
- fXmlFile(collection.fXmlFile),
- fCollectionName(collection.fCollectionName) {
- //copy constructor
-
- if (collection.fEventList) fEventList = new TList();
- if (collection.fEventListIter) fEventListIter = new TIter(fEventList);
- if (collection.fCurrent) fCurrent = 0;
-}
-
-//___________________________________________________________________________
-AliXMLCollection::~AliXMLCollection() {
- //Destructor
- if(fEventList) delete fEventList;
- if(fEventListIter) delete fEventListIter;
-}
-
-//___________________________________________________________________________
-Bool_t AliXMLCollection::WriteHeader() {
- //Creates the xml output file
-
- TString xmlName = fCollectionName;
- xmlName += ".xml";
-
- TString collectionHeader = "<collection name=";
- collectionHeader += "\"";
- collectionHeader += fCollectionName;
- collectionHeader += "\"";
- collectionHeader += ">";
-
- // Open the output stream
- fout.open(xmlName);
- fout<<"<?xml version=\"1.0\"?>\n";
- fout<<"<alien>\n";
- fout<<" "<<collectionHeader<<"\n";
-
- return kTRUE;
-}
-
-//___________________________________________________________________________
-Bool_t AliXMLCollection::WriteBody(Int_t counter, const char* guid, const char* lfn, const char* turl, TEntryList *list) {
- //Writes the body of the xml collection
- TString listline;
- for(Int_t i = 0; i < list->GetN(); i++) {
- listline += list->GetEntry(i);
- listline += ",";
- }
- listline = listline(0,listline.Length()-1);
-
- TString line0 = "<event name=\"";
- line0 += counter;
- line0 += "\">";
-
- TString line1 = "<file name=\"AliESDs.root\" ";
- line1 += "guid=\"";
- line1 += guid;
- line1 += "\" ";
- line1 += "lfn=\"";
- line1 += lfn;
- line1 += "\" ";
- line1 += "turl=\"";
- line1 += turl;
- line1 += "\" ";
- line1 += "evlist=\"";
- line1 += listline;
- line1 += "\"";
- line1 += " />";
-
- fout<<" "<<line0<<"\n";
- fout<<" "<<line1<<"\n";
- fout<<" </event>\n";
-
- return kTRUE;
-}
-
-//___________________________________________________________________________
-Bool_t AliXMLCollection::Export() {
- //Closes the stream
- fout<<" "<<"</collection>\n";
- fout<<"</alien>\n";
-
- fout.close();
-
- return kTRUE;
-}
-
-//___________________________________________________________________________
-void AliXMLCollection::Reset() {
- // Reset file iterator.
-
- fEventListIter->Reset();
- fCurrent = 0;
-}
-
-//___________________________________________________________________________
-TMap *AliXMLCollection::Next() {
- // Return next event file map.
-
- fCurrent = (TMap*)fEventListIter->Next();
- return fCurrent;
-}
-
-//___________________________________________________________________________
-const char *AliXMLCollection::GetTURL(const char* filename) const {
- // Get a file's transport URL (TURL). Returns 0 in case of error.
-
- if (fCurrent) {
- TMap *obj = (TMap*)fCurrent->GetValue(filename);
- if (obj) {
- if (obj->GetValue("turl")) {
- return ( ((TObjString*)obj->GetValue("turl"))->GetName());
- }
- }
- }
- Error("GetTURL","cannot get TURL of file %s",filename);
- return 0;
-}
-
-//___________________________________________________________________________
-const char *AliXMLCollection::GetGUID(const char* filename) const {
- // Get a file's transport UID. Returns 0 in case of error.
-
- if (fCurrent) {
- TMap *obj = (TMap*)fCurrent->GetValue(filename);
- if (obj) {
- if (obj->GetValue("guid")) {
- return ( ((TObjString*)obj->GetValue("guid"))->GetName());
- }
- }
- }
- Error("GetGUID","cannot get GUID of file %s",filename);
- return 0;
-}
-
-//___________________________________________________________________________
-TEntryList *AliXMLCollection::GetEventList(const char *filename) const {
- // Get a file's event list. Returns 0 in case of error.
-
- if (fCurrent) {
- TMap *obj = (TMap *) fCurrent->GetValue(filename);
- if (obj) {
- if (obj->GetValue("evlist")) {
- return ((TEntryList *) obj->GetValue("evlist"));
- }
- }
- }
- Error("GetEvList", "cannot get evelist of file %s", filename);
- return 0;
-}
-
-//___________________________________________________________________________
-Bool_t AliXMLCollection::Remove(TMap * map) {
- // Return next event file map.
- if (fEventList->Remove(map)) {
- return kTRUE;
- } else {
- return kFALSE;
- }
-}
-
-//___________________________________________________________________________
-const char *AliXMLCollection::GetLFN(const char* ) const {
- // Get a file's LFN. Returns 0 in case of error.
-
- if (fCurrent) {
- TMap *obj = (TMap *) fCurrent->GetValue("");
- if (obj) {
- if (obj->GetValue("lfn")) {
- return (((TObjString *) obj->GetValue("lfn"))->GetName());
- }
- }
- }
- Error("GetLFN", "cannot get LFN");
- return 0;
-}
-
-//__________________________________________________________________________
-Bool_t AliXMLCollection::OverlapCollection(AliXMLCollection * comparator) {
- // return kTRUE if comparator overlaps with this
- if ((!comparator)) return kFALSE;
-
- loopagain:
- // loop over col1 and try to find it in col2
- this->Reset();
- // loop over all elements in reference (=this)
- TMap *overlapmap;
- while ((overlapmap = this->Next())) {
- comparator->Reset();
- Bool_t found = kFALSE;
- // try to find in the comparator collection
- while ((comparator->Next())) {
- TString s1 = this->GetLFN("");
- TString s2 = comparator->GetLFN("");
- if (s1 == s2) {
- found = kTRUE;
- break;
- }
- }
- if (!found) {
- this->Remove(overlapmap);
- goto loopagain;
- }
- }
- return kTRUE;
-}
-
-//___________________________________________________________________________
-AliXMLCollection *AliXMLCollection::Open(const char *localcollectionfile) {
- // Static method used to create an Alien event collection, by reading
- // collection for the specified file.
-
- AliXMLCollection *collection = new AliXMLCollection(localcollectionfile);
- return collection;
-}
-
-//___________________________________________________________________________
-void AliXMLCollection::ParseXML() {
- // Parse event file collection XML file.
-
- TXMLEngine xml;
-
- XMLDocPointer_t xdoc = xml.ParseFile(fXmlFile);
- if (!xdoc) {
- Error("ParseXML","cannot parse the xml file %s",fXmlFile.Data());
- return;
- }
-
- XMLNodePointer_t xalien = xml.DocGetRootElement(xdoc);
- if (!xalien) {
- Error("ParseXML","cannot find the <alien> tag in %s",fXmlFile.Data());
- return;
- }
-
- XMLNodePointer_t xcollection = xml.GetChild(xalien);
- if (!xcollection) {
- Error("ParseXML","cannot find the <collection> tag in %s",fXmlFile.Data());
- return;
- }
-
- XMLNodePointer_t xevent = xml.GetChild(xcollection);;
- if (!xevent) {
- Error("ParseXML","cannot find the <event> tag in %s",fXmlFile.Data());
- return;
- }
- if (!xevent) return;
-
- do {
- if (xml.GetAttr(xevent, "name")) {
- TMap *files = new TMap();
-
- // files
- XMLNodePointer_t xfile = xml.GetChild(xevent);
- if (!xfile) continue;
-
- Bool_t firstfile=kTRUE;
- do {
- // here we have an event file
- // get the attributes;
- xml.GetAttr(xfile, "lfn");
- xml.GetAttr(xfile, "turl");
-
- TMap *attributes = new TMap();
- TObjString *oname = new TObjString(xml.GetAttr(xfile,"name"));
- TObjString *oturl = new TObjString(xml.GetAttr(xfile,"turl"));
- TObjString *olfn = new TObjString(xml.GetAttr(xfile,"lfn"));
- TObjString *oguid = new TObjString(xml.GetAttr(xfile,"guid"));
- TObjString *oevlist = new TObjString(xml.GetAttr(xfile, "evlist"));
- printf("Collection: %s - The Eventlist is %s\n",fXmlFile.Data(),oevlist->GetName());
- if (oevlist->GetName() != "") {
- TEntryList *xmlevlist = new TEntryList(oturl->GetName(), oguid->GetName());
- TString stringevlist = oevlist->GetName();
- TObjArray *evlist = stringevlist.Tokenize(",");
- for (Int_t n = 0; n < evlist->GetEntries(); n++) xmlevlist->Enter(atol(((TObjString *) evlist->At(n))->GetName()));
- attributes->Add(new TObjString("evlist"), xmlevlist);
- }
-
- attributes->Add(new TObjString("name"),oname);
- attributes->Add(new TObjString("turl"),oturl);
- attributes->Add(new TObjString("lfn"),olfn);
- attributes->Add(new TObjString("guid"),oguid);
- files->Add(new TObjString(xml.GetAttr(xfile,"name")) , attributes);
-
- // we add the first file always as a file without name to the map
- if (firstfile) {
- files->Add(new TObjString(""),attributes);
- firstfile=kFALSE;
- }
- } while ((xfile = xml.GetNext(xfile)));
- fEventList->Add(files);
- }
- } while ((xevent = xml.GetNext(xevent)));
-}
-
+++ /dev/null
-#ifndef ALIXMLCOLLECTION_H
-#define ALIXMLCOLLECTION_H
-/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
- * See cxx source for full Copyright notice */
-
-
-/* $Id$ */
-
-//-------------------------------------------------------------------------
-// Class AliXMLCollection
-// This is the class that creates XML collections after querying the tags
-//
-// Origin: Panos Christakoglou, UOA-CERN, Panos.Christakoglou@cern.ch
-//-------------------------------------------------------------------------
-
-#include <TObject.h>
-#include "TGridCollection.h"
-#include <Riostream.h>
-#include <TString.h>
-
-class TMap;
-class TIter;
-class TEntryList;
-
-//___________________________________________________________________________
-class AliXMLCollection : public TGridCollection {
-
- public:
- AliXMLCollection();
- AliXMLCollection(const char *localCollectionFile);
- AliXMLCollection(const AliXMLCollection& collection);
-
- virtual ~AliXMLCollection();
-
- //____________________________________________________//
- Bool_t WriteHeader();
- Bool_t WriteBody(Int_t counter, const char* guid, const char *lfn, const char *turl, TEntryList *fEntryList);
- Bool_t Export();
-
- void SetCollectionName(const char* name) {fCollectionName = name;}
-
- //____________________________________________________//
- const char* GetCollectionName() {return fCollectionName.Data();}
-
- //____________________________________________________//
- void Reset();
- TMap *Next();
- Bool_t Remove(TMap *map);
- const char *GetTURL(const char *name) const;
- const char *GetLFN(const char *name) const;
- const char *GetGUID(const char *name) const;
- TEntryList *GetEventList(const char *filename) const;
- Bool_t OverlapCollection(AliXMLCollection * comparator);
-
- static AliXMLCollection *Open(const char *localcollectionfile);
-
- //____________________________________________________//
- protected:
- virtual void ParseXML();
-
- TString fXmlFile; // collection XML file
- TList *fEventList; // list with event file maps
- TIter *fEventListIter; // event file list iterator
- TMap *fCurrent; // current event file map
- TString fCollectionName; //the name of the xml file
- ofstream fout; // The output stream
-
- AliXMLCollection & operator=(const AliXMLCollection & ) {return *this;}
-
- ClassDef(AliXMLCollection,0) //(ClassName, ClassVersion)
-};
-//___________________________________________________________________________
-
-#endif
#pragma link C++ class AliRawDataErrorLog+;
-#ifdef WITHXML
-#pragma link C++ class AliTagAnalysis+;
-#pragma link C++ class AliXMLCollection+;
-#endif
-
#endif
AliSelector.cxx \
AliRawDataErrorLog.cxx
-CHECKXML = $(shell root-config --has-xml)
-ifeq (yes,$(CHECKXML))
-PACKCXXFLAGS := $(CXXFLAGS) -DWITHXML
-CINTFLAGS += -DWITHXML
-SRCS += AliTagAnalysis.cxx AliXMLCollection.cxx
-endif
-
-
HDRS:= $(SRCS:.cxx=.h)
EINCLUDE:= RAW