Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
TAlienCollection.h
Go to the documentation of this file.
1 // @(#)root/alien:$Id$
2 // Author: Andreas-Joachim Peters 9/5/2005
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2005, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 #ifndef ROOT_TAlienCollection
13 #define ROOT_TAlienCollection
14 
15 //////////////////////////////////////////////////////////////////////////
16 // //
17 // TAlienCollection //
18 // //
19 // Class which manages collection of files on AliEn middleware. //
20 // The file collection is in the form of an XML file. //
21 // //
22 // The internal list is managed as follows: //
23 // TList* ===> TMap*(file) ===> TMap*(attributes) //
24 // //
25 //////////////////////////////////////////////////////////////////////////
26 
27 #include "TGridCollection.h"
28 #include "TString.h"
29 #include "TList.h"
30 #include "TFileStager.h"
31 
32 
33 class TFileCollection;
34 
35 class TAlienCollection : public TGridCollection {
36 
37 private:
38  TString fXmlFile; // collection XML file
39  TList *fFileGroupList; //-> list with event file maps
40  TIter *fFileGroupListIter; //! event file list iterator
41  TMap *fCurrent; //! current event file map
42  UInt_t fNofGroups; // number of file groups
43  UInt_t fNofGroupfiles; // number of files per group
44  Bool_t fHasSUrls; // defines if SURLs are present in the collection
45  Bool_t fHasSelection; // defines if the user made some selection on the files
46  // to be exported for processing
47  Bool_t fHasOnline; // defines if the collection was checked for the online status
48  TString fLastOutFileName; // keeps the latest outputfilename produced with GetOutputFileName
49  TFileStager *fFileStager; //! pointer to the file stager object
50  TString fExportUrl; // defines the url where to store back this collection
51  TString fInfoComment; // comment in the info section of the XML file
52  TString fCollectionName; // name of the collection in the collection section of the XML file
53  TList *fTagFilterList; //-> list of TObjStrings with tags to filter out in export operations
54 
55  virtual void ParseXML(UInt_t maxentries);
56  Bool_t ExportXML(TFile * file, Bool_t selected, Bool_t online,
57  const char *name, const char *comment);
58 
59 public:
60  TAlienCollection() : fFileGroupList(0), fFileGroupListIter(0), fCurrent(0),
61  fNofGroups(0), fNofGroupfiles(0), fHasSUrls(0), fHasSelection(0),
62  fHasOnline(0), fFileStager(0), fExportUrl(""), fInfoComment(""),
63  fCollectionName("unnamed"), fTagFilterList(0)
64  { }
65  TAlienCollection(TList *eventlist, UInt_t ngroups = 0,
66  UInt_t ngroupfiles = 0);
67  TAlienCollection(const char *localCollectionFile, UInt_t maxentries);
68 
69  virtual ~TAlienCollection();
70 
71  TFileCollection* GetFileCollection(const char* name = "", const char* title = "") const;
72 
73  void Reset();
74  TMap *Next();
75  Bool_t Remove(TMap * map);
76  const char *GetTURL(const char *name = "") ;
77  const char *GetSURL(const char *name = "") ;
78  const char *GetLFN(const char *name = "") ;
79  Long64_t GetSize(const char *name = "") ;
80  Bool_t IsOnline(const char *name = "") ;
81  Bool_t IsSelected(const char *name = "") ;
82  void Status();
83  void SetTag(const char *tag, const char *value, TMap * tagmap);
84  Bool_t SelectFile(const char *name, Int_t /*start*/ = -1, Int_t /*stop*/ = -1);
85  Bool_t DeselectFile(const char *name, Int_t /*start*/ = -1, Int_t /*stop*/ = -1);
86  Bool_t InvertSelection();
87  Bool_t DownscaleSelection(UInt_t scaler = 2);
88  Bool_t ExportXML(const char *exporturl, Bool_t selected, Bool_t online,
89  const char *name, const char *comment);
90  const char *GetExportUrl() {
91  if (fExportUrl.Length()) return fExportUrl; else return 0;
92  } // return's (if defined) the export url protected:
93 
94  Bool_t SetExportUrl(const char *exporturl = 0);
95 
96  void Print(Option_t * opt) const;
97  TFile *OpenFile(const char *filename) ;
98 
99  TEntryList *GetEntryList(const char *name) ;
100 
101  TList *GetFileGroupList() const { return fFileGroupList; }
102 
103  UInt_t GetNofGroups() const { return fNofGroups; }
104 
105  UInt_t GetNofGroupfiles() const { return fNofGroupfiles; }
106 
107  Bool_t OverlapCollection(TGridCollection *comparator);
108  void Add(TGridCollection *addcollection);
109  void AddFast(TGridCollection *addcollection);
110  Bool_t Stage(Bool_t bulk = kFALSE, Option_t* option = "");
111  Bool_t Prepare(Bool_t bulk = kFALSE) { return Stage(bulk,"option=0"); }
112 
113  Bool_t CheckIfOnline(Bool_t bulk = kFALSE);
114  TDSet *GetDataset(const char *type, const char *objname = "*", const char *dir = "/");
115 
116  TGridResult *GetGridResult(const char *filename = "",
117  Bool_t onlyonline = kTRUE,
118  Bool_t publicaccess = kFALSE);
119 
120  Bool_t LookupSUrls(Bool_t verbose = kTRUE);
121 
122  TList *GetTagFilterList() const { return fTagFilterList; }
123 
124  void SetTagFilterList(TList * filterlist) { if (fTagFilterList)
125  delete fTagFilterList; fTagFilterList = filterlist;
126  }
127 
128  const char* GetCollectionName() const { return fCollectionName.Data(); }
129  const char* GetInfoComment() const { return fInfoComment.Data(); }
130 
131  static TGridCollection *Open(const char *collectionurl,
132  UInt_t maxentries = 1000000);
133  static TGridCollection *OpenQuery(TGridResult * queryresult,
134  Bool_t nogrouping = kFALSE);
135  static TAlienCollection *OpenAlienCollection(TGridResult * queryresult,
136  Option_t* option = "");
137 
138  const char *GetOutputFileName(const char *infile, Bool_t rename = kTRUE, const char *suffix="root");
139 
140  ClassDef(TAlienCollection, 1) // Manages collection of files on AliEn
141 };
142 
143 #endif