Logo ROOT   6.12/07
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 #include "TGridCollection.h"
28 #include "TString.h"
29 #include "TList.h"
30 #include "TFileStager.h"
31 
32 
33 class TFileCollection;
34 
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);
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 
106 
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 
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
Long64_t GetSize(const char *name="")
Get a file's LFN. Returns 0 in case of error.
TMap * fCurrent
event file list iterator
virtual void ParseXML(UInt_t maxentries)
Parse event file collection XML file.
long long Long64_t
Definition: RtypesCore.h:69
void AddFast(TGridCollection *addcollection)
adds <addcollection> to this collection - NO check for identical elements
const char * GetExportUrl()
const char Option_t
Definition: RtypesCore.h:62
Bool_t Prepare(Bool_t bulk=kFALSE)
Bool_t IsOnline(const char *name="")
Get a file&#39;s online tag. Returns false if not online or CheckIfOnline was never executed, true if online.
void Print(Option_t *opt) const
Print event file collection.
const char * GetLFN(const char *name="")
Get a file&#39;s LFN. Returns 0 in case of error.
This class implements a data set to be used for PROOF processing.
Definition: TDSet.h:151
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format...
Definition: TFile.h:46
Bool_t IsSelected(const char *name="")
Get a file&#39;s online tag. Returns false if not online or CheckIfOnline was never executed, true if online.
Bool_t InvertSelection()
Invert the selection.
virtual ~TAlienCollection()
Clean up event file collection.
Basic string class.
Definition: TString.h:125
Bool_t DeselectFile(const char *name, Int_t=-1, Int_t=-1)
Deselects the file <filename> from the loaded collection All files can be deselected using "*" as <fi...
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&#39;s a key value pair in a tagmap. If it is existing, the existing tag is overwritten. If not, it is created.
TFileStager * fFileStager
Bool_t CheckIfOnline(Bool_t bulk=kFALSE)
Run an online check if files are currently accessible (staged) or offline (to be staged).
Bool_t SetExportUrl(const char *exporturl=0)
Set the &#39;default&#39; export URL for an XML collection. A collection can be restored to the export URL us...
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:320
void Add(TGridCollection *addcollection)
adds <addcollection> 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 <filename> in the collection All files can be selected using "*" as filen...
UInt_t fNofGroups
current event file map
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 &#39;stage&#39; method for all files in this collection (trigger staging).
TIter * fFileGroupListIter
A doubly linked list.
Definition: TList.h:44
TEntryList * GetEntryList(const char *name)
Get a file&#39;s event list. Returns 0 in case of error.
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...
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...
const char * GetCollectionName() const
const char * GetInfoComment() const
void Status()
Prints statistics, selection and status about the loaded collection.
unsigned int UInt_t
Definition: RtypesCore.h:42
Ssiz_t Length() const
Definition: TString.h:386
TList * GetFileGroupList() const
const char * GetSURL(const char *name="")
Get a file&#39;s storage URL (SURL). Returns 0 in case of error.
const char * GetTURL(const char *name="")
Get a file&#39;s transport URL (TURL). Returns 0 in case of error.
const Bool_t kFALSE
Definition: RtypesCore.h:88
void SetTagFilterList(TList *filterlist)
Bool_t LookupSUrls(Bool_t verbose=kTRUE)
retrieves all the SURLS for the LFNS
UInt_t GetNofGroups() const
TMap implements an associative array of (key,value) pairs using a THashTable for efficient retrieval ...
Definition: TMap.h:40
int type
Definition: TGX11.cxx:120
Bool_t DownscaleSelection(UInt_t scaler=2)
downscales the selection with scaler
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.
TList * GetTagFilterList() const
TMap * Next()
Return next event file map.
Class that contains a list of TFileInfo&#39;s and accumulated meta data information about its entries...
Definition: file.py:1
void Reset()
Reset file iterator.
TString fExportUrl
pointer to the file stager object
Bool_t Remove(TMap *map)
Return next event file map.
UInt_t GetNofGroupfiles() const
TFile * OpenFile(const char *filename)
Open the file specified by <filename> 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.
A List of entry numbers in a TTree or TChain.
Definition: TEntryList.h:25
const Bool_t kTRUE
Definition: RtypesCore.h:87
char name[80]
Definition: TGX11.cxx:109
const char * Data() const
Definition: TString.h:345