From d08133e66831af99c91301552a9af58645dc6c34 Mon Sep 17 00:00:00 2001 From: cvetan Date: Thu, 5 Apr 2007 13:42:43 +0000 Subject: [PATCH] Moving AliTagAnalysis and AliXMLCollection from ESD to ANALYSIS library (Panos+Cvetan) --- ANALYSIS/ANALYSISLinkDef.h | 2 + ANALYSIS/AliAnalysisGoodies.cxx | 8 +- ANALYSIS/AliTagAnalysis.cxx | 389 ++++++++++++++++++++++++++++++++ ANALYSIS/AliTagAnalysis.h | 71 ++++++ ANALYSIS/AliXMLCollection.cxx | 359 +++++++++++++++++++++++++++++ ANALYSIS/AliXMLCollection.h | 74 ++++++ ANALYSIS/binaliengui.pkg | 3 +- ANALYSIS/libANALYSIS.pkg | 3 +- 8 files changed, 905 insertions(+), 4 deletions(-) create mode 100644 ANALYSIS/AliTagAnalysis.cxx create mode 100644 ANALYSIS/AliTagAnalysis.h create mode 100644 ANALYSIS/AliXMLCollection.cxx create mode 100644 ANALYSIS/AliXMLCollection.h diff --git a/ANALYSIS/ANALYSISLinkDef.h b/ANALYSIS/ANALYSISLinkDef.h index 73dba5d460c..bba319702af 100644 --- a/ANALYSIS/ANALYSISLinkDef.h +++ b/ANALYSIS/ANALYSISLinkDef.h @@ -13,6 +13,8 @@ #ifdef WITHXML #pragma link C++ class AliAnalysisGoodies+; +#pragma link C++ class AliTagAnalysis+; +#pragma link C++ class AliXMLCollection+; #endif #endif diff --git a/ANALYSIS/AliAnalysisGoodies.cxx b/ANALYSIS/AliAnalysisGoodies.cxx index a3437a3fb78..f3eb3874576 100644 --- a/ANALYSIS/AliAnalysisGoodies.cxx +++ b/ANALYSIS/AliAnalysisGoodies.cxx @@ -33,9 +33,9 @@ #ifdef WITHALIEN #include #include +#include #endif #include -#include #include #include #include @@ -98,6 +98,7 @@ Bool_t AliAnalysisGoodies::Alien2Local(const TString collectionNameIn, const TSt // in: a xml esd collection file name // ou: the local directory where to save the esd root files +#ifdef WITHALIEN Bool_t rv = kTRUE ; fTimer.Start() ; @@ -148,7 +149,10 @@ Bool_t AliAnalysisGoodies::Alien2Local(const TString collectionNameIn, const TSt fTimer.Stop(); fTimer.Print(); - return rv ; + return rv ; +#else + return kFALSE; +#endif } //______________________________________________________________________ diff --git a/ANALYSIS/AliTagAnalysis.cxx b/ANALYSIS/AliTagAnalysis.cxx new file mode 100644 index 00000000000..b5fab2f64ec --- /dev/null +++ b/ANALYSIS/AliTagAnalysis.cxx @@ -0,0 +1,389 @@ +/************************************************************************** + * 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 +#include +#include +#include +#include +#include + +//ROOT-AliEn +#include + +#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; +} diff --git a/ANALYSIS/AliTagAnalysis.h b/ANALYSIS/AliTagAnalysis.h new file mode 100644 index 00000000000..64dd30fedeb --- /dev/null +++ b/ANALYSIS/AliTagAnalysis.h @@ -0,0 +1,71 @@ +#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 + +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 + diff --git a/ANALYSIS/AliXMLCollection.cxx b/ANALYSIS/AliXMLCollection.cxx new file mode 100644 index 00000000000..c5dc271bb3d --- /dev/null +++ b/ANALYSIS/AliXMLCollection.cxx @@ -0,0 +1,359 @@ +/************************************************************************** + * 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 +#include +#include +#include +#include +#include +#include +#include + +#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 = "\n"; + fout<<"\n"; + fout<<" "<GetN(); i++) { + listline += list->GetEntry(i); + listline += ","; + } + listline = listline(0,listline.Length()-1); + + TString line0 = ""; + + TString line1 = "\n"; + + return kTRUE; +} + +//___________________________________________________________________________ +Bool_t AliXMLCollection::Export() { + //Closes the stream + fout<<" "<<"\n"; + fout<<"\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 tag in %s",fXmlFile.Data()); + return; + } + + XMLNodePointer_t xcollection = xml.GetChild(xalien); + if (!xcollection) { + Error("ParseXML","cannot find the tag in %s",fXmlFile.Data()); + return; + } + + XMLNodePointer_t xevent = xml.GetChild(xcollection);; + if (!xevent) { + Error("ParseXML","cannot find the 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))); +} + diff --git a/ANALYSIS/AliXMLCollection.h b/ANALYSIS/AliXMLCollection.h new file mode 100644 index 00000000000..d19a7d27829 --- /dev/null +++ b/ANALYSIS/AliXMLCollection.h @@ -0,0 +1,74 @@ +#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 +#include "TGridCollection.h" +#include +#include + +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 diff --git a/ANALYSIS/binaliengui.pkg b/ANALYSIS/binaliengui.pkg index 31cdbcd638c..9d9b6857fd7 100644 --- a/ANALYSIS/binaliengui.pkg +++ b/ANALYSIS/binaliengui.pkg @@ -19,7 +19,8 @@ ELIBS := Aliengui \ FASTSIM microcern \ RAWDatabase RAWDatarec RAWDatasim \ HLTbase AliHLTSrc AliHLTComp AliHLTMisc AliHLTMUON \ - AliHLTHough AliHLTITS + AliHLTHough AliHLTITS \ + ANALYSIS ifeq (macosx,$(ALICE_TARGET)) diff --git a/ANALYSIS/libANALYSIS.pkg b/ANALYSIS/libANALYSIS.pkg index 3e4d697ffd8..fc164b8e6a8 100644 --- a/ANALYSIS/libANALYSIS.pkg +++ b/ANALYSIS/libANALYSIS.pkg @@ -11,7 +11,7 @@ CHECKXML = $(shell root-config --has-xml) ifeq (yes,$(CHECKXML)) PACKCXXFLAGS += $(CXXFLAGS) -DWITHXML CINTFLAGS += -DWITHXML -SRCS += AliAnalysisGoodies.cxx +SRCS += AliAnalysisGoodies.cxx AliTagAnalysis.cxx AliXMLCollection.cxx endif HDRS:= $(SRCS:.cxx=.h) @@ -21,3 +21,4 @@ DHDR= ANALYSISLinkDef.h EXPORT:=$(SRCS:.cxx=.h) + -- 2.31.1