ROOT  6.06/09
Reference Guide
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 #ifndef ROOT_TGridCollection
28 #include "TGridCollection.h"
29 #endif
30 #ifndef ROOT_TString
31 #include "TString.h"
32 #endif
33 #ifndef ROOT_TList
34 #include "TList.h"
35 #endif
36 #ifndef ROOT_TFileStager
37 #include "TFileStager.h"
38 #endif
39 
40 
41 class TFileCollection;
42 
44 
45 private:
46  TString fXmlFile; // collection XML file
47  TList *fFileGroupList; //-> list with event file maps
48  TIter *fFileGroupListIter; //! event file list iterator
49  TMap *fCurrent; //! current event file map
50  UInt_t fNofGroups; // number of file groups
51  UInt_t fNofGroupfiles; // number of files per group
52  Bool_t fHasSUrls; // defines if SURLs are present in the collection
53  Bool_t fHasSelection; // defines if the user made some selection on the files
54  // to be exported for processing
55  Bool_t fHasOnline; // defines if the collection was checked for the online status
56  TString fLastOutFileName; // keeps the latest outputfilename produced with GetOutputFileName
57  TFileStager *fFileStager; //! pointer to the file stager object
58  TString fExportUrl; // defines the url where to store back this collection
59  TString fInfoComment; // comment in the info section of the XML file
60  TString fCollectionName; // name of the collection in the collection section of the XML file
61  TList *fTagFilterList; //-> list of TObjStrings with tags to filter out in export operations
62 
63  virtual void ParseXML(UInt_t maxentries);
64  Bool_t ExportXML(TFile * file, Bool_t selected, Bool_t online,
65  const char *name, const char *comment);
66 
67 public:
68  TAlienCollection() : fFileGroupList(0), fFileGroupListIter(0), fCurrent(0),
69  fNofGroups(0), fNofGroupfiles(0), fHasSUrls(0), fHasSelection(0),
70  fHasOnline(0), fFileStager(0), fExportUrl(""), fInfoComment(""),
71  fCollectionName("unnamed"), fTagFilterList(0)
72  { }
73  TAlienCollection(TList *eventlist, UInt_t ngroups = 0,
74  UInt_t ngroupfiles = 0);
75  TAlienCollection(const char *localCollectionFile, UInt_t maxentries);
76 
77  virtual ~TAlienCollection();
78 
79  TFileCollection* GetFileCollection(const char* name = "", const char* title = "") const;
80 
81  void Reset();
82  TMap *Next();
83  Bool_t Remove(TMap * map);
84  const char *GetTURL(const char *name = "") ;
85  const char *GetSURL(const char *name = "") ;
86  const char *GetLFN(const char *name = "") ;
87  Long64_t GetSize(const char *name = "") ;
88  Bool_t IsOnline(const char *name = "") ;
89  Bool_t IsSelected(const char *name = "") ;
90  void Status();
91  void SetTag(const char *tag, const char *value, TMap * tagmap);
92  Bool_t SelectFile(const char *name, Int_t /*start*/ = -1, Int_t /*stop*/ = -1);
93  Bool_t DeselectFile(const char *name, Int_t /*start*/ = -1, Int_t /*stop*/ = -1);
95  Bool_t DownscaleSelection(UInt_t scaler = 2);
96  Bool_t ExportXML(const char *exporturl, Bool_t selected, Bool_t online,
97  const char *name, const char *comment);
98  const char *GetExportUrl() {
99  if (fExportUrl.Length()) return fExportUrl; else return 0;
100  } // return's (if defined) the export url protected:
101 
102  Bool_t SetExportUrl(const char *exporturl = 0);
103 
104  void Print(Option_t * opt) const;
105  TFile *OpenFile(const char *filename) ;
106 
107  TEntryList *GetEntryList(const char *name) ;
108 
109  TList *GetFileGroupList() const { return fFileGroupList; }
110 
111  UInt_t GetNofGroups() const { return fNofGroups; }
112 
114 
116  void Add(TGridCollection *addcollection);
117  void AddFast(TGridCollection *addcollection);
118  Bool_t Stage(Bool_t bulk = kFALSE, Option_t* option = "");
119  Bool_t Prepare(Bool_t bulk = kFALSE) { return Stage(bulk,"option=0"); }
120 
122  TDSet *GetDataset(const char *type, const char *objname = "*", const char *dir = "/");
123 
124  TGridResult *GetGridResult(const char *filename = "",
125  Bool_t onlyonline = kTRUE,
126  Bool_t publicaccess = kFALSE);
127 
129 
130  TList *GetTagFilterList() const { return fTagFilterList; }
131 
132  void SetTagFilterList(TList * filterlist) { if (fTagFilterList)
133  delete fTagFilterList; fTagFilterList = filterlist;
134  }
135 
136  const char* GetCollectionName() const { return fCollectionName.Data(); }
137  const char* GetInfoComment() const { return fInfoComment.Data(); }
138 
139  static TGridCollection *Open(const char *collectionurl,
140  UInt_t maxentries = 1000000);
141  static TGridCollection *OpenQuery(TGridResult * queryresult,
142  Bool_t nogrouping = kFALSE);
143  static TAlienCollection *OpenAlienCollection(TGridResult * queryresult,
144  Option_t* option = "");
145 
146  const char *GetOutputFileName(const char *infile, Bool_t rename = kTRUE, const char *suffix="root");
147 
148  ClassDef(TAlienCollection, 1) // Manages collection of files on AliEn
149 };
150 
151 #endif
Long64_t GetSize(const char *name="")
Get a file's LFN. Returns 0 in case of error.
TMap * fCurrent
event file list iterator
TList * GetFileGroupList() const
virtual void ParseXML(UInt_t maxentries)
Parse event file collection XML file.
TList * GetTagFilterList() const
long long Long64_t
Definition: RtypesCore.h:69
void AddFast(TGridCollection *addcollection)
adds to this collection - NO check for identical elements
const char * GetExportUrl()
Ssiz_t Length() const
Definition: TString.h:390
const char Option_t
Definition: RtypesCore.h:62
static const std::string comment("comment")
Bool_t Prepare(Bool_t bulk=kFALSE)
Bool_t IsOnline(const char *name="")
Get a file's online tag. Returns false if not online or CheckIfOnline was never executed, true if online.
const char * GetLFN(const char *name="")
Get a file's LFN. Returns 0 in case of error.
Definition: TDSet.h:153
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format...
Definition: TFile.h:45
Bool_t IsSelected(const char *name="")
Get a file's online tag. Returns false if not online or CheckIfOnline was never executed, true if online.
Bool_t InvertSelection()
Invert the selection.
UInt_t GetNofGroupfiles() const
virtual ~TAlienCollection()
Clean up event file collection.
static const char * filename()
Basic string class.
Definition: TString.h:137
Bool_t DeselectFile(const char *name, Int_t=-1, Int_t=-1)
Deselects the file from the loaded collection All files can be deselected using "*" as
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
void SetTag(const char *tag, const char *value, TMap *tagmap)
Set's a key value pair in a tagmap. If it is existing, the existing tag is overwritten. If not, it is created.
const Bool_t kFALSE
Definition: Rtypes.h:92
TFileStager * fFileStager
Bool_t CheckIfOnline(Bool_t bulk=kFALSE)
Run an online check if files are currently accessible (staged) or offline (to be staged).
const char * Data() const
Definition: TString.h:349
Bool_t SetExportUrl(const char *exporturl=0)
Set the 'default' export URL for an XML collection. A collection can be restored to the export URL us...
void Print(Option_t *opt) const
Print event file collection.
TDSet * GetDataset(const char *type, const char *objname="*", const char *dir="/")
Return a TDSet from a collection.
static TAlienCollection * OpenAlienCollection(TGridResult *queryresult, Option_t *option="")
Static method used to create an Alien event collection, by creating collection from a TGridResult Get...
#define ClassDef(name, id)
Definition: Rtypes.h:254
void Add(TGridCollection *addcollection)
adds to this collection - equal elements are skipped
static TGridCollection * Open(const char *collectionurl, UInt_t maxentries=1000000)
Static method used to create an Alien event collection, by reading an XML collection from the specifi...
Bool_t SelectFile(const char *name, Int_t=-1, Int_t=-1)
Selects all files with name in the collection All files can be selected using "*" as filen...
UInt_t fNofGroups
current event file map
UInt_t GetNofGroups() const
const char * GetOutputFileName(const char *infile, Bool_t rename=kTRUE, const char *suffix="root")
Adds to a file given by infile the collection identification , f.e.
Bool_t Stage(Bool_t bulk=kFALSE, Option_t *option="")
Execute the 'stage' method for all files in this collection (trigger staging).
TIter * fFileGroupListIter
A doubly linked list.
Definition: TList.h:47
TEntryList * GetEntryList(const char *name)
Get a file's event list. Returns 0 in case of error.
Bool_t OverlapCollection(TGridCollection *comparator)
return kTRUE if comparator overlaps with this all objects in this collection, which are not defined i...
static TGridCollection * OpenQuery(TGridResult *queryresult, Bool_t nogrouping=kFALSE)
Static method used to create an Alien event collection, by creating collection from a TGridResult Que...
void Status()
Prints statistics, selection and status about the loaded collection.
unsigned int UInt_t
Definition: RtypesCore.h:42
bool verbose
const char * GetSURL(const char *name="")
Get a file's storage URL (SURL). Returns 0 in case of error.
const char * GetInfoComment() const
const char * GetTURL(const char *name="")
Get a file's transport URL (TURL). Returns 0 in case of error.
void SetTagFilterList(TList *filterlist)
Bool_t LookupSUrls(Bool_t verbose=kTRUE)
retrieves all the SURLS for the LFNS
TMap implements an associative array of (key,value) pairs using a THashTable for efficient retrieval ...
Definition: TMap.h:44
int type
Definition: TGX11.cxx:120
Bool_t DownscaleSelection(UInt_t scaler=2)
downscales the selection with scaler
#define name(a, b)
Definition: linkTestLib0.cpp:5
Bool_t ExportXML(TFile *file, Bool_t selected, Bool_t online, const char *name, const char *comment)
Internal Export function to write a collection as an XML file. See above.
TMap * Next()
Return next event file map.
Class that contains a list of TFileInfo's and accumulated meta data information about its entries...
void Reset()
Reset file iterator.
TString fExportUrl
pointer to the file stager object
Bool_t Remove(TMap *map)
Return next event file map.
const Bool_t kTRUE
Definition: Rtypes.h:91
TFileCollection * GetFileCollection(const char *name="", const char *title="") const
creates a TFileCollection objects and fills it with the information from this collection note that TF...
TFile * OpenFile(const char *filename)
Open the file specified by from the currently active file group in the collection via its ...
TGridResult * GetGridResult(const char *filename="", Bool_t onlyonline=kTRUE, Bool_t publicaccess=kFALSE)
Return a TGridResult.
float value
Definition: math.cpp:443
A List of entry numbers in a TTree or TChain.
Definition: TEntryList.h:27
const char * GetCollectionName() const