ROOT  6.07/01
Reference Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
TDSet.h
Go to the documentation of this file.
1 // @(#)root/proof:$Id$
2 // Author: Fons Rademakers 11/01/02
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2001, 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_TDSet
13 #define ROOT_TDSet
14 
15 
16 //////////////////////////////////////////////////////////////////////////
17 // //
18 // TDSet //
19 // //
20 // This class implements a data set to be used for PROOF processing. //
21 // The TDSet defines the class of which objects will be processed, //
22 // the directory in the file where the objects of that type can be //
23 // found and the list of files to be processed. The files can be //
24 // specified as logical file names (LFN's) or as physical file names //
25 // (PFN's). In case of LFN's the resolution to PFN's will be done //
26 // according to the currently active GRID interface. //
27 // Examples: //
28 // TDSet treeset("TTree", "AOD"); //
29 // treeset.Add("lfn:/alien.cern.ch/alice/prod2002/file1"); //
30 // ... //
31 // treeset.AddFriend(friendset); //
32 // //
33 // or //
34 // //
35 // TDSet objset("MyEvent", "*", "/events"); //
36 // objset.Add("root://cms.cern.ch/user/prod2002/hprod_1.root"); //
37 // ... //
38 // objset.Add(set2003); //
39 // //
40 // Validity of file names will only be checked at processing time //
41 // (typically on the PROOF master server), not at creation time. //
42 // //
43 //////////////////////////////////////////////////////////////////////////
44 
45 #ifndef ROOT_TNamed
46 #include "TNamed.h"
47 #endif
48 
49 class TChain;
50 class TCollection;
51 class TCut;
52 class TDSet;
53 class TEventList;
54 class TEntryList;
55 class TFileInfo;
56 class THashList;
57 class TIter;
58 class TList;
59 class TProof;
60 class TProofChain;
61 class TSelector;
62 class TTree;
63 
64 // For backward compatibility (handle correctly requests from old clients)
65 #include <set>
66 #include <list>
67 
68 class TDSetElement : public TNamed {
69 public:
70  typedef std::list<std::pair<TDSetElement*, TString> > FriendsList_t;
71  // TDSetElement status bits
72  enum EStatusBits {
74  kWriteV3 = BIT(16),
75  kEmpty = BIT(17),
76  kCorrupted = BIT(18),
77  kNewRun = BIT(19),
79  };
80 
81 private:
82  TString fDirectory; // directory in file where to look for objects
83  Long64_t fFirst; // first entry to process
84  Long64_t fNum; // number of entries to process
85  TString fMsd; // mass storage domain name
86  Long64_t fTDSetOffset;// the global offset in the TDSet of the first
87  // entry in this element
88  TObject *fEntryList; // entry (or event) list to be used in processing
89  Bool_t fValid; // whether or not the input values are valid
90  Long64_t fEntries; // total number of possible entries in file
91  TList *fFriends; // friend elements
92 
93  TString fDataSet; // Name of the dataset of which this element is part
94  TList *fAssocObjList; // List of objects associated to this element
95  // (e.g. TObjString describing associated files)
96  Float_t fMaxProcTime; // Max processing time in secs; -1 no limit
97 
99 
100  TDSetElement& operator=(const TDSetElement &); // Not implemented
101 
102 public:
103  TDSetElement();
104  TDSetElement(const char *file, const char *objname = 0,
105  const char *dir = 0, Long64_t first = 0, Long64_t num = -1,
106  const char *msd = 0, const char *dataset = 0);
107  TDSetElement(const TDSetElement& elem);
108  virtual ~TDSetElement();
109 
110  virtual TList *GetListOfFriends() const { return fFriends; }
111  virtual void AddFriend(TDSetElement *friendElement, const char *alias);
112  virtual void DeleteFriends();
113  const char *GetFileName() const { return GetName(); }
114  Long64_t GetFirst() const { return fFirst; }
116  Long64_t GetNum() const { return fNum; }
117  Long64_t GetEntries(Bool_t istree = kTRUE, Bool_t openfile = kTRUE);
118  void SetEntries(Long64_t ent) { fEntries = ent; }
119  const char *GetMsd() const { return fMsd; }
120  void SetNum(Long64_t num) { fNum = num; }
121  Bool_t GetValid() const { return fValid; }
122  const char *GetObjName() const { return GetTitle(); }
123  const char *GetDirectory() const;
124  const char *GetDataSet() const { return fDataSet; }
125  void SetDataSet(const char *dataset) { fDataSet = dataset; }
126  void AddAssocObj(TObject *assocobj);
128  TObject *GetAssocObj(Long64_t i, Bool_t isentry = kFALSE);
129  void Print(Option_t *options="") const;
132  void SetEntryList(TObject *aList, Long64_t first = -1, Long64_t num = -1);
133  TObject *GetEntryList() const { return fEntryList; }
134  void Validate(Bool_t isTree);
135  void Validate(TDSetElement *elem);
136  void Invalidate() { fValid = kFALSE; }
137  void SetValid() { fValid = kTRUE; }
138  Int_t Compare(const TObject *obj) const;
139  Bool_t IsSortable() const { return kTRUE; }
140  Int_t Lookup(Bool_t force = kFALSE);
142  TFileInfo *GetFileInfo(const char *type = "TTree");
143 
144  Float_t GetMaxProcTime() const { return fMaxProcTime; }
145  void SetMaxProcTime(Float_t mpt) { fMaxProcTime = mpt; }
146 
148 
149  ClassDef(TDSetElement,9) // A TDSet element
150 };
151 
152 
153 class TDSet : public TNamed {
154 
155 public:
156  // TDSet status bits
157  enum EStatusBits {
158  kWriteV3 = BIT(16),
159  kEmpty = BIT(17),
160  kValidityChecked = BIT(18), // Set if elements validiy has been checked
161  kSomeInvalid = BIT(19), // Set if at least one element is invalid
162  kMultiDSet = BIT(20), // Set if fElements is a list of datasets
163  kIsLocal = BIT(21) // Set if local, non-PROOF, processing
164  };
165 
166 private:
167  Bool_t fIsTree; // true if type is a TTree (or TTree derived)
168  TObject *fEntryList; //! entry (or event) list for processing
169  TProofChain *fProofChain; //! for browsing purposes
170 
171  void SplitEntryList(); //Split entry list between elements
172 
173  TDSet(const TDSet &); // not implemented
174  void operator=(const TDSet &); // not implemented
175 
176 protected:
177  TString fDir; // name of the directory
178  TString fType; // type of objects (e.g. TTree);
179  TString fObjName; // name of objects to be analyzed (e.g. TTree name)
180  THashList *fElements; //-> list of TDSetElements (or TDSets, if in multi mode)
181  TIter *fIterator; //! iterator on fElements
182  TDSetElement *fCurrent; //! current element
183  TList *fSrvMaps; //! list for mapping server coordinates for files
184  TIter *fSrvMapsIter; //! iterator on fSrvMaps
185 
186 public:
187  TDSet();
188  TDSet(const char *name, const char *objname = "*",
189  const char *dir = "/", const char *type = 0);
190  TDSet(const TChain &chain, Bool_t withfriends = kTRUE);
191  virtual ~TDSet();
192 
193  virtual Bool_t Add(const char *file, const char *objname = 0,
194  const char *dir = 0, Long64_t first = 0,
195  Long64_t num = -1, const char *msd = 0);
196  virtual Bool_t Add(TDSet *set);
197  virtual Bool_t Add(TCollection *fileinfo, const char *meta = 0,
198  Bool_t availableOnly = kFALSE, TCollection *badlist = 0);
199  virtual Bool_t Add(TFileInfo *fileinfo, const char *meta = 0);
200  virtual void AddFriend(TDSet *friendset, const char *alias);
201 
202  virtual Long64_t Process(TSelector *selector, Option_t *option = "",
203  Long64_t nentries = -1,
204  Long64_t firstentry = 0,
205  TObject *enl = 0); // *MENU*
206  virtual Long64_t Process(const char *selector, Option_t *option = "",
207  Long64_t nentries = -1,
208  Long64_t firstentry = 0,
209  TObject *enl = 0); // *MENU*
210  virtual Long64_t Draw(const char *varexp, const char *selection,
211  Option_t *option = "", Long64_t nentries = -1,
212  Long64_t firstentry = 0); // *MENU*
213  virtual Long64_t Draw(const char *varexp, const TCut &selection,
214  Option_t *option = "", Long64_t nentries = -1,
215  Long64_t firstentry = 0); // *MENU*
216  virtual void Draw(Option_t *opt) { Draw(opt, "", "", -1, 0); }
217 
218  Int_t ExportFileList(const char *filepath, Option_t *opt = "");
219 
220  void Print(Option_t *option="") const;
221 
222  void SetObjName(const char *objname);
223  void SetDirectory(const char *dir);
224 
225  Bool_t IsTree() const { return fIsTree; }
226  Bool_t IsValid() const { return !fType.IsNull(); }
228  const char *GetType() const { return fType; }
229  const char *GetObjName() const { return fObjName; }
230  const char *GetDirectory() const { return fDir; }
231  TList *GetListOfElements() const { return (TList *)fElements; }
233 
234  Int_t Remove(TDSetElement *elem, Bool_t deleteElem = kTRUE);
235 
236  virtual void Reset();
237  virtual TDSetElement *Next(Long64_t totalEntries = -1);
238  TDSetElement *Current() const { return fCurrent; };
239 
240  static Long64_t GetEntries(Bool_t isTree, const char *filename,
241  const char *path, TString &objname);
242 
243  void AddInput(TObject *obj);
244  void ClearInput();
245  TObject *GetOutput(const char *name);
246  TList *GetOutputList();
247  virtual void StartViewer(); // *MENU*
248 
249  virtual TTree *GetTreeHeader(TProof *proof);
250  virtual void SetEntryList(TObject *aList);
251  TObject *GetEntryList() const { return fEntryList; }
252  void Validate();
253  void Validate(TDSet *dset);
254 
255  void Lookup(Bool_t removeMissing = kFALSE, TList **missingFiles = 0);
256  void SetLookedUp();
257 
258  void SetSrvMaps(TList *srvmaps = 0);
259 
260  void SetWriteV3(Bool_t on = kTRUE);
261 
262  ClassDef(TDSet,9) // Data set for remote processing (PROOF)
263 };
264 
265 #endif
virtual ~TDSet()
Cleanup.
Definition: TDSet.cxx:879
void AddInput(TObject *obj)
Add objects that might be needed during the processing of the selector (see Process()).
Definition: TDSet.cxx:944
virtual const char * GetTitle() const
Returns title of object.
Definition: TNamed.h:52
TString fType
Definition: TDSet.h:178
TFileInfo * GetFileInfo(const char *type="TTree")
Return the content of this element in the form of a TFileInfo.
Definition: TDSet.cxx:212
std::list< std::pair< TDSetElement *, TString > > FriendsList_t
Definition: TDSet.h:70
static Long64_t GetEntries(Bool_t isTree, const char *filename, const char *path, TString &objname)
Returns number of entries in tree or objects in file.
Definition: TDSet.cxx:1360
Long64_t GetEntries(Bool_t istree=kTRUE, Bool_t openfile=kTRUE)
Returns number of entries in tree or objects in file.
Definition: TDSet.cxx:410
long long Long64_t
Definition: RtypesCore.h:69
THashList * fElements
Definition: TDSet.h:180
virtual void Draw(Option_t *opt)
Default Draw method for all objects.
Definition: TDSet.h:216
virtual TDSetElement * Next(Long64_t totalEntries=-1)
Returns next TDSetElement.
Definition: TDSet.cxx:394
TDSet()
iterator on fSrvMaps
Definition: TDSet.cxx:682
void SetLookedUp()
Flag all the elements as looked-up, so to avoid opening the files if the functionality is not support...
Definition: TDSet.cxx:1636
const char Int_t const char TProof Int_t const char const char * msd
Definition: TXSlave.cxx:46
float Float_t
Definition: RtypesCore.h:53
const char Option_t
Definition: RtypesCore.h:62
tuple offset
Definition: tree.py:93
const char * GetObjName() const
Definition: TDSet.h:229
virtual Long64_t Process(TSelector *selector, Option_t *option="", Long64_t nentries=-1, Long64_t firstentry=0, TObject *enl=0)
Process TDSet on currently active PROOF session.
Definition: TDSet.cxx:897
void SetTDSetOffset(Long64_t offset)
Definition: TDSet.h:131
void SetWriteV3(Bool_t on=kTRUE)
Set/Reset the 'OldStreamer' bit in this instance and its elements.
Definition: TDSet.cxx:1853
This class implements a data set to be used for PROOF processing.
Definition: TDSet.h:153
#define BIT(n)
Definition: Rtypes.h:120
Int_t GetNumOfFiles()
Return the number of files in the dataset.
Definition: TDSet.cxx:1986
Bool_t fIsTree
Definition: TDSet.h:167
TString fDirectory
Definition: TDSet.h:82
static const char * filename()
void AddAssocObj(TObject *assocobj)
Add an associated object to the list.
Definition: TDSet.cxx:612
Basic string class.
Definition: TString.h:137
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
const Bool_t kFALSE
Definition: Rtypes.h:92
void Print(Option_t *options="") const
Print a TDSetElement. When option="a" print full data.
Definition: TDSet.cxx:242
Int_t Compare(const TObject *obj) const
Compare elements by filename (and the fFirst).
Definition: TDSet.cxx:332
TObject * fEntryList
Definition: TDSet.h:88
Bool_t GetValid() const
Definition: TDSet.h:121
Int_t ExportFileList(const char *filepath, Option_t *opt="")
Export TDSetElements files as list of TFileInfo objects in file 'fpath'.
Definition: TDSet.cxx:1255
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
Definition: TObject.cxx:732
Int_t Lookup(Bool_t force=kFALSE)
Resolve end-point URL for this element Return 0 on success and -1 otherwise.
Definition: TDSet.cxx:515
Float_t fMaxProcTime
Definition: TDSet.h:96
const char * GetObjName() const
Definition: TDSet.h:122
TList * GetListOfAssocObjs() const
Definition: TDSet.h:127
Long64_t GetNum() const
Definition: TDSet.h:116
TChain chain("h42")
TList * GetOutputList()
Get list with all object created during processing (see Process()).
Definition: TDSet.cxx:976
Manages an element of a TDSet.
Definition: TDSet.h:68
Bool_t HasBeenLookedUp() const
Definition: TDSet.h:98
const char * GetDirectory() const
Definition: TDSet.h:230
Long64_t GetTDSetOffset() const
Definition: TDSet.h:130
Bool_t IsTree() const
Definition: TDSet.h:225
void SetEntries(Long64_t ent)
Definition: TDSet.h:118
void Validate(Bool_t isTree)
Validate by opening the file.
Definition: TDSet.cxx:256
#define ClassDef(name, id)
Definition: Rtypes.h:254
TIter * fIterator
Definition: TDSet.h:181
THashList implements a hybrid collection class consisting of a hash table and a list to store TObject...
Definition: THashList.h:36
const char * GetMsd() const
Definition: TDSet.h:119
The TNamed class is the base class for all named ROOT classes.
Definition: TNamed.h:33
TDSetElement & operator=(const TDSetElement &)
virtual ~TDSetElement()
Clean up the element.
Definition: TDSet.cxx:146
Bool_t IsSortable() const
Definition: TDSet.h:139
TList * GetListOfElements() const
Definition: TDSet.h:231
void SetLookedUp()
Definition: TDSet.h:141
void Validate()
Validate the TDSet by opening files.
Definition: TDSet.cxx:1568
void SetDirectory(const char *dir)
Set/change directory.
Definition: TDSet.cxx:1019
void SetDataSet(const char *dataset)
Definition: TDSet.h:125
Long64_t fTDSetOffset
Definition: TDSet.h:86
void SetSrvMaps(TList *srvmaps=0)
Set (or unset) the list for mapping servers coordinate for files.
Definition: TDSet.cxx:1150
TDSetElement * Current() const
Definition: TDSet.h:238
virtual void DeleteFriends()
Deletes the list of friends and all the friends on the list.
Definition: TDSet.cxx:381
Long64_t GetFirst() const
Definition: TDSet.h:114
A specialized string object used for TTree selections.
Definition: TCut.h:27
A doubly linked list.
Definition: TList.h:47
TObject * GetEntryList() const
Definition: TDSet.h:251
void SetMaxProcTime(Float_t mpt)
Definition: TDSet.h:145
Bool_t ElementsValid()
Check if all elements are valid.
Definition: TDSet.cxx:1534
virtual TList * GetListOfFriends() const
Definition: TDSet.h:110
TDSetElement * fCurrent
iterator on fElements
Definition: TDSet.h:182
TString fDir
Definition: TDSet.h:177
TString fMsd
Definition: TDSet.h:85
TProofChain * fProofChain
entry (or event) list for processing
Definition: TDSet.h:169
const char * GetFileName() const
Definition: TDSet.h:113
TList * fSrvMaps
current element
Definition: TDSet.h:183
Collection abstract base class.
Definition: TCollection.h:48
Bool_t TestBit(UInt_t f) const
Definition: TObject.h:173
TObject * GetEntryList() const
Definition: TDSet.h:133
bool first
Definition: line3Dfit.C:48
void Invalidate()
Definition: TDSet.h:136
A TEventList object is a list of selected events (entries) in a TTree.
Definition: TEventList.h:33
virtual const char * GetName() const
Returns name of object.
Definition: TNamed.h:51
virtual Long64_t Draw(const char *varexp, const char *selection, Option_t *option="", Long64_t nentries=-1, Long64_t firstentry=0)
Draw expression varexp for specified entries.
Definition: TDSet.cxx:1479
Bool_t IsNull() const
Definition: TString.h:387
Int_t MergeElement(TDSetElement *elem)
Check if 'elem' is overlapping or subsequent and, if the case, return a merged element.
Definition: TDSet.cxx:163
TString fObjName
Definition: TDSet.h:179
void Print(Option_t *option="") const
Print TDSet basic or full data. When option="a" print full data.
Definition: TDSet.cxx:986
virtual TTree * GetTreeHeader(TProof *proof)
Returns a tree header containing the branches' structure of the dataset.
Definition: TDSet.cxx:1526
const char * GetDataSet() const
Definition: TDSet.h:124
void ClearInput()
Clear input object list.
Definition: TDSet.cxx:956
tuple file
Definition: fildir.py:20
void SetValid()
Definition: TDSet.h:137
void SetObjName(const char *objname)
Set/change object name.
Definition: TDSet.cxx:1004
virtual void SetEntryList(TObject *aList)
Set entry (or event) list for this data set.
Definition: TDSet.cxx:1872
EStatusBits
Definition: TObject.h:76
int type
Definition: TGX11.cxx:120
void dir(char *path=0)
Definition: rootalias.C:30
This class controls a Parallel ROOT Facility, PROOF, cluster.
Definition: TProof.h:342
int nentries
Definition: THbookFile.cxx:89
TObject * GetOutput(const char *name)
Get specified object that has been produced during the processing (see Process()).
Definition: TDSet.cxx:966
void SetNum(Long64_t num)
Definition: TDSet.h:120
virtual void Reset()
Reset or initialize access to the elements.
Definition: TDSet.cxx:1347
virtual void AddFriend(TDSetElement *friendElement, const char *alias)
Add friend TDSetElement to this set. The friend element will be copied to this object.
Definition: TDSet.cxx:357
#define name(a, b)
Definition: linkTestLib0.cpp:5
void SetEntryList(TObject *aList, Long64_t first=-1, Long64_t num=-1)
Set entry (or event) list for this element.
Definition: TDSet.cxx:580
Mother of all ROOT objects.
Definition: TObject.h:58
void Lookup(Bool_t removeMissing=kFALSE, TList **missingFiles=0)
Resolve the end-point URL for the current elements of this data set If the removeMissing option is se...
Definition: TDSet.cxx:1584
const char Int_t const char TProof * proof
Definition: TXSlave.cxx:46
void SplitEntryList()
for browsing purposes
Definition: TDSet.cxx:1909
TObject * GetAssocObj(Long64_t i, Bool_t isentry=kFALSE)
Get i-th associated object.
Definition: TDSet.cxx:630
virtual Bool_t Add(const char *file, const char *objname=0, const char *dir=0, Long64_t first=0, Long64_t num=-1, const char *msd=0)
Add file to list of files to be analyzed.
Definition: TDSet.cxx:1030
Long64_t fNum
Definition: TDSet.h:84
TList * fFriends
Definition: TDSet.h:91
Long64_t fEntries
Definition: TDSet.h:90
A chain is a collection of files containg TTree objects.
Definition: TChain.h:35
TString fDataSet
Definition: TDSet.h:93
TObject * fEntryList
Definition: TDSet.h:168
const char * GetType() const
Definition: TDSet.h:228
Float_t GetMaxProcTime() const
Definition: TDSet.h:144
A TTree object has a header with a name and a title.
Definition: TTree.h:98
Class describing a generic file including meta information.
Definition: TFileInfo.h:50
TIter * fSrvMapsIter
list for mapping server coordinates for files
Definition: TDSet.h:184
Bool_t IsValid() const
Definition: TDSet.h:226
void operator=(const TDSet &)
A TSelector object is used by the TTree::Draw, TTree::Scan, TTree::Process to navigate in a TTree and...
Definition: TSelector.h:39
const Bool_t kTRUE
Definition: Rtypes.h:91
void SetFirst(Long64_t first)
Definition: TDSet.h:115
virtual void AddFriend(TDSet *friendset, const char *alias)
Add friend dataset to this set.
Definition: TDSet.cxx:1313
TObject * obj
TList * fAssocObjList
Definition: TDSet.h:94
A List of entry numbers in a TTree or TChain.
Definition: TEntryList.h:27
Bool_t fValid
Definition: TDSet.h:89
const char * GetDirectory() const
Return directory where to look for object.
Definition: TDSet.cxx:234
virtual void StartViewer()
Start the TTreeViewer on this TTree.
Definition: TDSet.cxx:1498
Int_t Remove(TDSetElement *elem, Bool_t deleteElem=kTRUE)
Remove TDSetElement 'elem' from the list.
Definition: TDSet.cxx:1555
Long64_t fFirst
Definition: TDSet.h:83