Logo ROOT   6.12/07
Reference Guide
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 #include "TNamed.h"
46 
47 class TChain;
48 class TCollection;
49 class TCut;
50 class TDSet;
51 class TEventList;
52 class TEntryList;
53 class TFileInfo;
54 class THashList;
55 class TIter;
56 class TList;
57 class TProof;
58 class TProofChain;
59 class TSelector;
60 class TTree;
61 
62 // For backward compatibility (handle correctly requests from old clients)
63 #include <set>
64 #include <list>
65 
66 class TDSetElement : public TNamed {
67 public:
68  typedef std::list<std::pair<TDSetElement*, TString> > FriendsList_t;
69  // TDSetElement status bits
70  enum EStatusBits {
72  kWriteV3 = BIT(16),
73  kEmpty = BIT(17),
74  kCorrupted = BIT(18),
75  kNewRun = BIT(19),
77  };
78 
79 private:
80  TString fDirectory; // directory in file where to look for objects
81  Long64_t fFirst; // first entry to process
82  Long64_t fNum; // number of entries to process
83  TString fMsd; // mass storage domain name
84  Long64_t fTDSetOffset;// the global offset in the TDSet of the first
85  // entry in this element
86  TObject *fEntryList; // entry (or event) list to be used in processing
87  Bool_t fValid; // whether or not the input values are valid
88  Long64_t fEntries; // total number of possible entries in file
89  TList *fFriends; // friend elements
90 
91  TString fDataSet; // Name of the dataset of which this element is part
92  TList *fAssocObjList; // List of objects associated to this element
93  // (e.g. TObjString describing associated files)
94  Float_t fMaxProcTime; // Max processing time in secs; -1 no limit
95 
97 
98  TDSetElement& operator=(const TDSetElement &); // Not implemented
99 
100 public:
101  TDSetElement();
102  TDSetElement(const char *file, const char *objname = 0,
103  const char *dir = 0, Long64_t first = 0, Long64_t num = -1,
104  const char *msd = 0, const char *dataset = 0);
105  TDSetElement(const TDSetElement& elem);
106  virtual ~TDSetElement();
107 
108  virtual TList *GetListOfFriends() const { return fFriends; }
109  virtual void AddFriend(TDSetElement *friendElement, const char *alias);
110  virtual void DeleteFriends();
111  const char *GetFileName() const { return GetName(); }
112  Long64_t GetFirst() const { return fFirst; }
113  void SetFirst(Long64_t first) { fFirst = first; }
114  Long64_t GetNum() const { return fNum; }
115  Long64_t GetEntries(Bool_t istree = kTRUE, Bool_t openfile = kTRUE);
116  void SetEntries(Long64_t ent) { fEntries = ent; }
117  const char *GetMsd() const { return fMsd; }
118  void SetNum(Long64_t num) { fNum = num; }
119  Bool_t GetValid() const { return fValid; }
120  const char *GetObjName() const { return GetTitle(); }
121  const char *GetDirectory() const;
122  const char *GetDataSet() const { return fDataSet; }
123  void SetDataSet(const char *dataset) { fDataSet = dataset; }
124  void AddAssocObj(TObject *assocobj);
126  TObject *GetAssocObj(Long64_t i, Bool_t isentry = kFALSE);
127  void Print(Option_t *options="") const;
129  void SetTDSetOffset(Long64_t offset) { fTDSetOffset = offset; }
130  void SetEntryList(TObject *aList, Long64_t first = -1, Long64_t num = -1);
131  TObject *GetEntryList() const { return fEntryList; }
132  void Validate(Bool_t isTree);
133  void Validate(TDSetElement *elem);
134  void Invalidate() { fValid = kFALSE; }
135  void SetValid() { fValid = kTRUE; }
136  Int_t Compare(const TObject *obj) const;
137  Bool_t IsSortable() const { return kTRUE; }
138  Int_t Lookup(Bool_t force = kFALSE);
140  TFileInfo *GetFileInfo(const char *type = "TTree");
141 
142  Float_t GetMaxProcTime() const { return fMaxProcTime; }
143  void SetMaxProcTime(Float_t mpt) { fMaxProcTime = mpt; }
144 
146 
147  ClassDef(TDSetElement,9) // A TDSet element
148 };
149 
150 
151 class TDSet : public TNamed {
152 
153 public:
154  // TDSet status bits
155  enum EStatusBits {
156  kWriteV3 = BIT(16),
157  kEmpty = BIT(17),
158  kValidityChecked = BIT(18), // Set if elements validiy has been checked
159  kSomeInvalid = BIT(19), // Set if at least one element is invalid
160  kMultiDSet = BIT(20), // Set if fElements is a list of datasets
161  kIsLocal = BIT(21) // Set if local, non-PROOF, processing
162  };
163 
164 private:
165  Bool_t fIsTree; // true if type is a TTree (or TTree derived)
166  TObject *fEntryList; //! entry (or event) list for processing
167  TProofChain *fProofChain; //! for browsing purposes
168 
169  void SplitEntryList(); //Split entry list between elements
170 
171  TDSet(const TDSet &); // not implemented
172  void operator=(const TDSet &); // not implemented
173 
174 protected:
175  TString fDir; // name of the directory
176  TString fType; // type of objects (e.g. TTree);
177  TString fObjName; // name of objects to be analyzed (e.g. TTree name)
178  THashList *fElements; //-> list of TDSetElements (or TDSets, if in multi mode)
179  TIter *fIterator; //! iterator on fElements
180  TDSetElement *fCurrent; //! current element
181  TList *fSrvMaps; //! list for mapping server coordinates for files
182  TIter *fSrvMapsIter; //! iterator on fSrvMaps
183 
184 public:
185  TDSet();
186  TDSet(const char *name, const char *objname = "*",
187  const char *dir = "/", const char *type = 0);
188  TDSet(const TChain &chain, Bool_t withfriends = kTRUE);
189  virtual ~TDSet();
190 
191  virtual Bool_t Add(const char *file, const char *objname = 0,
192  const char *dir = 0, Long64_t first = 0,
193  Long64_t num = -1, const char *msd = 0);
194  virtual Bool_t Add(TDSet *set);
195  virtual Bool_t Add(TCollection *fileinfo, const char *meta = 0,
196  Bool_t availableOnly = kFALSE, TCollection *badlist = 0);
197  virtual Bool_t Add(TFileInfo *fileinfo, const char *meta = 0);
198  virtual void AddFriend(TDSet *friendset, const char *alias);
199 
200  virtual Long64_t Process(TSelector *selector, Option_t *option = "",
201  Long64_t nentries = -1,
202  Long64_t firstentry = 0,
203  TObject *enl = 0); // *MENU*
204  virtual Long64_t Process(const char *selector, Option_t *option = "",
205  Long64_t nentries = -1,
206  Long64_t firstentry = 0,
207  TObject *enl = 0); // *MENU*
208  virtual Long64_t Draw(const char *varexp, const char *selection,
209  Option_t *option = "", Long64_t nentries = -1,
210  Long64_t firstentry = 0); // *MENU*
211  virtual Long64_t Draw(const char *varexp, const TCut &selection,
212  Option_t *option = "", Long64_t nentries = -1,
213  Long64_t firstentry = 0); // *MENU*
214  virtual void Draw(Option_t *opt) { Draw(opt, "", "", -1, 0); }
215 
216  Int_t ExportFileList(const char *filepath, Option_t *opt = "");
217 
218  void Print(Option_t *option="") const;
219 
220  void SetObjName(const char *objname);
221  void SetDirectory(const char *dir);
222 
223  Bool_t IsTree() const { return fIsTree; }
224  Bool_t IsValid() const { return !fType.IsNull(); }
225  Bool_t ElementsValid();
226  const char *GetType() const { return fType; }
227  const char *GetObjName() const { return fObjName; }
228  const char *GetDirectory() const { return fDir; }
229  TList *GetListOfElements() const { return (TList *)fElements; }
230  Int_t GetNumOfFiles();
231 
232  Int_t Remove(TDSetElement *elem, Bool_t deleteElem = kTRUE);
233 
234  virtual void Reset();
235  virtual TDSetElement *Next(Long64_t totalEntries = -1);
236  TDSetElement *Current() const { return fCurrent; };
237 
238  static Long64_t GetEntries(Bool_t isTree, const char *filename,
239  const char *path, TString &objname);
240 
241  void AddInput(TObject *obj);
242  void ClearInput();
243  TObject *GetOutput(const char *name);
244  TList *GetOutputList();
245  virtual void StartViewer(); // *MENU*
246 
247  virtual TTree *GetTreeHeader(TProof *proof);
248  virtual void SetEntryList(TObject *aList);
249  TObject *GetEntryList() const { return fEntryList; }
250  void Validate();
251  void Validate(TDSet *dset);
252 
253  void Lookup(Bool_t removeMissing = kFALSE, TList **missingFiles = 0);
254  void SetLookedUp();
255 
256  void SetSrvMaps(TList *srvmaps = 0);
257 
258  void SetWriteV3(Bool_t on = kTRUE);
259 
260  ClassDef(TDSet,9) // Data set for remote processing (PROOF)
261 };
262 
263 #endif
virtual const char * GetName() const
Returns name of object.
Definition: TNamed.h:47
TString fType
Definition: TDSet.h:176
TFileInfo * GetFileInfo(const char *type="TTree")
Return the content of this element in the form of a TFileInfo.
Definition: TDSet.cxx:212
Long64_t GetTDSetOffset() const
Definition: TDSet.h:128
TList * GetListOfAssocObjs() const
Definition: TDSet.h:125
std::list< std::pair< TDSetElement *, TString > > FriendsList_t
Definition: TDSet.h:68
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:178
virtual void Draw(Option_t *opt)
Default Draw method for all objects.
Definition: TDSet.h:214
float Float_t
Definition: RtypesCore.h:53
const char Option_t
Definition: RtypesCore.h:62
void SetTDSetOffset(Long64_t offset)
Definition: TDSet.h:129
This class implements a data set to be used for PROOF processing.
Definition: TDSet.h:151
Bool_t GetValid() const
Definition: TDSet.h:119
#define BIT(n)
Definition: Rtypes.h:78
Bool_t fIsTree
Definition: TDSet.h:165
TString fDirectory
Definition: TDSet.h:80
void AddAssocObj(TObject *assocobj)
Add an associated object to the list.
Definition: TDSet.cxx:615
R__ALWAYS_INLINE Bool_t TestBit(UInt_t f) const
Definition: TObject.h:172
Long64_t GetFirst() const
Definition: TDSet.h:112
Basic string class.
Definition: TString.h:125
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
virtual void Draw(Option_t *option="")
Default Draw method for all objects.
Definition: TObject.cxx:195
virtual TList * GetListOfFriends() const
Definition: TDSet.h:108
TObject * fEntryList
Definition: TDSet.h:86
TList * GetListOfElements() const
Definition: TDSet.h:229
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
Definition: TObject.cxx:694
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:94
Manages an element of a TDSet.
Definition: TDSet.h:66
void SetEntries(Long64_t ent)
Definition: TDSet.h:116
void Validate(Bool_t isTree)
Validate by opening the file.
Definition: TDSet.cxx:256
TObject * GetEntryList() const
Definition: TDSet.h:249
#define ClassDef(name, id)
Definition: Rtypes.h:320
Long64_t GetNum() const
Definition: TDSet.h:114
TIter * fIterator
Definition: TDSet.h:179
THashList implements a hybrid collection class consisting of a hash table and a list to store TObject...
Definition: THashList.h:34
The TNamed class is the base class for all named ROOT classes.
Definition: TNamed.h:29
Float_t GetMaxProcTime() const
Definition: TDSet.h:142
TDSetElement & operator=(const TDSetElement &)
virtual ~TDSetElement()
Clean up the element.
Definition: TDSet.cxx:146
const char * GetDirectory() const
Return directory where to look for object.
Definition: TDSet.cxx:234
TDSetElement * Current() const
Definition: TDSet.h:236
void SetLookedUp()
Definition: TDSet.h:139
void SetDataSet(const char *dataset)
Definition: TDSet.h:123
Long64_t fTDSetOffset
Definition: TDSet.h:84
virtual void DeleteFriends()
Deletes the list of friends and all the friends on the list.
Definition: TDSet.cxx:381
A specialized string object used for TTree selections.
Definition: TCut.h:25
A doubly linked list.
Definition: TList.h:44
const char * GetObjName() const
Definition: TDSet.h:120
void SetMaxProcTime(Float_t mpt)
Definition: TDSet.h:143
TDSetElement * fCurrent
iterator on fElements
Definition: TDSet.h:180
TString fDir
Definition: TDSet.h:175
TString fMsd
Definition: TDSet.h:83
TProofChain * fProofChain
entry (or event) list for processing
Definition: TDSet.h:167
Bool_t IsTree() const
Definition: TDSet.h:223
TList * fSrvMaps
current element
Definition: TDSet.h:181
Int_t Compare(const TObject *obj) const
Compare elements by filename (and the fFirst).
Definition: TDSet.cxx:332
Collection abstract base class.
Definition: TCollection.h:63
void Invalidate()
Definition: TDSet.h:134
A TEventList object is a list of selected events (entries) in a TTree.
Definition: TEventList.h:31
Bool_t HasBeenLookedUp() const
Definition: TDSet.h:96
void Reset(Detail::TBranchProxy *x)
Int_t MergeElement(TDSetElement *elem)
Check if &#39;elem&#39; is overlapping or subsequent and, if the case, return a merged element.
Definition: TDSet.cxx:163
TDSetElement()
Default constructor.
Definition: TDSet.cxx:63
TString fObjName
Definition: TDSet.h:177
void Print(Option_t *options="") const
Print a TDSetElement. When option="a" print full data.
Definition: TDSet.cxx:242
const Bool_t kFALSE
Definition: RtypesCore.h:88
PyObject * fType
void Add(THist< DIMENSIONS, PRECISION_TO, STAT_TO... > &to, const THist< DIMENSIONS, PRECISION_FROM, STAT_FROM... > &from)
Add two histograms.
Definition: THist.hxx:308
TObject * GetEntryList() const
Definition: TDSet.h:131
void SetValid()
Definition: TDSet.h:135
EStatusBits
Definition: TObject.h:57
int type
Definition: TGX11.cxx:120
This class controls a Parallel ROOT Facility, PROOF, cluster.
Definition: TProof.h:316
int nentries
Definition: THbookFile.cxx:89
void SetNum(Long64_t num)
Definition: TDSet.h:118
const char * GetFileName() const
Definition: TDSet.h:111
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
const char * GetType() const
Definition: TDSet.h:226
Bool_t IsNull() const
Definition: TString.h:383
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:37
TObject * GetAssocObj(Long64_t i, Bool_t isentry=kFALSE)
Get i-th associated object.
Definition: TDSet.cxx:633
Long64_t fNum
Definition: TDSet.h:82
const char * GetDataSet() const
Definition: TDSet.h:122
TList * fFriends
Definition: TDSet.h:89
Long64_t fEntries
Definition: TDSet.h:88
Definition: file.py:1
const char * GetMsd() const
Definition: TDSet.h:117
A chain is a collection of files containing TTree objects.
Definition: TChain.h:33
TString fDataSet
Definition: TDSet.h:91
TObject * fEntryList
Definition: TDSet.h:166
A TTree object has a header with a name and a title.
Definition: TTree.h:70
Class describing a generic file including meta information.
Definition: TFileInfo.h:38
Definition: first.py:1
TIter * fSrvMapsIter
list for mapping server coordinates for files
Definition: TDSet.h:182
Bool_t IsSortable() const
Definition: TDSet.h:137
A TSelector object is used by the TTree::Draw, TTree::Scan, TTree::Process to navigate in a TTree and...
Definition: TSelector.h:33
const char * GetObjName() const
Definition: TDSet.h:227
void SetFirst(Long64_t first)
Definition: TDSet.h:113
TList * fAssocObjList
Definition: TDSet.h:92
A List of entry numbers in a TTree or TChain.
Definition: TEntryList.h:25
const Bool_t kTRUE
Definition: RtypesCore.h:87
Bool_t IsValid() const
Definition: TDSet.h:224
char name[80]
Definition: TGX11.cxx:109
Bool_t fValid
Definition: TDSet.h:87
virtual const char * GetTitle() const
Returns title of object.
Definition: TNamed.h:48
const char * GetDirectory() const
Definition: TDSet.h:228
Long64_t fFirst
Definition: TDSet.h:81