Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
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
47class TChain;
48class TCollection;
49class TCut;
50class TDSet;
51class TEventList;
52class TEntryList;
53class TFileInfo;
54class THashList;
55class TIter;
56class TList;
57class TProof;
58class TProofChain;
59class TSelector;
60class TTree;
61
62// For backward compatibility (handle correctly requests from old clients)
63#include <set>
64#include <list>
65
66class TDSetElement : public TNamed {
67public:
68 typedef std::list<std::pair<TDSetElement*, TString> > FriendsList_t;
69 // TDSetElement status bits
73 kEmpty = BIT(17),
75 kNewRun = BIT(19),
76 kNewPacket = BIT(20)
77 };
78
79private:
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
100public:
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 ~TDSetElement() override;
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);
127 void Print(Option_t *options="") const override;
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);
135 void SetValid() { fValid = kTRUE; }
136 Int_t Compare(const TObject *obj) const override;
137 Bool_t IsSortable() const override { return kTRUE; }
138 Int_t Lookup(Bool_t force = kFALSE);
140 TFileInfo *GetFileInfo(const char *type = "TTree");
141
142 void Reset();
143
146
148
149 ClassDefOverride(TDSetElement,9) // A TDSet element
150};
151
152
153class TDSet : public TNamed {
154
155public:
156 // TDSet status bits
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
166private:
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
176protected:
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
186public:
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 ~TDSet() override;
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 void Draw(Option_t *opt) override { Draw(opt, "", "", -1, 0); }
217
218 Int_t ExportFileList(const char *filepath, Option_t *opt = "");
219
220 void Print(Option_t *option="") const override;
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);
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 ClassDefOverride(TDSet,9) // Data set for remote processing (PROOF)
263};
264
265#endif
bool Bool_t
Definition RtypesCore.h:63
int Int_t
Definition RtypesCore.h:45
float Float_t
Definition RtypesCore.h:57
constexpr Bool_t kFALSE
Definition RtypesCore.h:94
long long Long64_t
Definition RtypesCore.h:69
constexpr Bool_t kTRUE
Definition RtypesCore.h:93
const char Option_t
Definition RtypesCore.h:66
#define BIT(n)
Definition Rtypes.h:90
#define ClassDefOverride(name, id)
Definition Rtypes.h:346
Option_t Option_t option
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char filename
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h offset
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void on
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t type
char name[80]
Definition TGX11.cxx:110
int nentries
A chain is a collection of files containing TTree objects.
Definition TChain.h:33
Collection abstract base class.
Definition TCollection.h:65
A specialized string object used for TTree selections.
Definition TCut.h:25
Manages an element of a TDSet.
Definition TDSet.h:66
TFileInfo * GetFileInfo(const char *type="TTree")
Return the content of this element in the form of a TFileInfo.
Definition TDSet.cxx:231
TString fDirectory
Definition TDSet.h:80
void SetEntries(Long64_t ent)
Definition TDSet.h:116
Long64_t GetEntries(Bool_t istree=kTRUE, Bool_t openfile=kTRUE)
Returns number of entries in tree or objects in file.
Definition TDSet.cxx:429
const char * GetObjName() const
Definition TDSet.h:120
void Print(Option_t *options="") const override
Print a TDSetElement. When option="a" print full data.
Definition TDSet.cxx:261
Long64_t GetNum() const
Definition TDSet.h:114
@ kCorrupted
Definition TDSet.h:74
@ kNewPacket
Definition TDSet.h:76
@ kHasBeenLookedUp
Definition TDSet.h:71
TDSetElement & operator=(const TDSetElement &)
void Validate(Bool_t isTree)
Validate by opening the file.
Definition TDSet.cxx:275
TString fDataSet
Definition TDSet.h:91
Bool_t HasBeenLookedUp() const
Definition TDSet.h:96
std::list< std::pair< TDSetElement *, TString > > FriendsList_t
Definition TDSet.h:68
void SetMaxProcTime(Float_t mpt)
Definition TDSet.h:145
Bool_t fValid
Definition TDSet.h:87
Float_t GetMaxProcTime() const
Definition TDSet.h:144
TObject * GetEntryList() const
Definition TDSet.h:131
TString fMsd
Definition TDSet.h:83
virtual TList * GetListOfFriends() const
Definition TDSet.h:108
void SetFirst(Long64_t first)
Definition TDSet.h:113
void SetLookedUp()
Definition TDSet.h:139
Int_t Compare(const TObject *obj) const override
Compare elements by filename (and the fFirst).
Definition TDSet.cxx:351
TList * fFriends
Definition TDSet.h:89
void Invalidate()
Definition TDSet.h:134
TList * fAssocObjList
Definition TDSet.h:92
const char * GetDataSet() const
Definition TDSet.h:122
void Reset()
Reset TDSet element.
Definition TDSet.cxx:158
void SetTDSetOffset(Long64_t offset)
Definition TDSet.h:129
void SetNum(Long64_t num)
Definition TDSet.h:118
const char * GetDirectory() const
Return directory where to look for object.
Definition TDSet.cxx:253
void SetValid()
Definition TDSet.h:135
virtual void DeleteFriends()
Deletes the list of friends and all the friends on the list.
Definition TDSet.cxx:400
TList * GetListOfAssocObjs() const
Definition TDSet.h:125
void SetEntryList(TObject *aList, Long64_t first=-1, Long64_t num=-1)
Set entry (or event) list for this element.
Definition TDSet.cxx:599
void AddAssocObj(TObject *assocobj)
Add an associated object to the list.
Definition TDSet.cxx:634
Long64_t GetTDSetOffset() const
Definition TDSet.h:128
Bool_t GetValid() const
Definition TDSet.h:119
TObject * fEntryList
Definition TDSet.h:86
Float_t fMaxProcTime
Definition TDSet.h:94
void SetDataSet(const char *dataset)
Definition TDSet.h:123
Long64_t fTDSetOffset
Definition TDSet.h:84
Int_t Lookup(Bool_t force=kFALSE)
Resolve end-point URL for this element Return 0 on success and -1 otherwise.
Definition TDSet.cxx:534
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:376
const char * GetMsd() const
Definition TDSet.h:117
Long64_t fFirst
Definition TDSet.h:81
const char * GetFileName() const
Definition TDSet.h:111
TDSetElement()
Default constructor.
Definition TDSet.cxx:63
Long64_t fNum
Definition TDSet.h:82
Long64_t fEntries
Definition TDSet.h:88
TObject * GetAssocObj(Long64_t i, Bool_t isentry=kFALSE)
Get i-th associated object.
Definition TDSet.cxx:652
Bool_t IsSortable() const override
Definition TDSet.h:137
Long64_t GetFirst() const
Definition TDSet.h:112
~TDSetElement() override
Clean up the element.
Definition TDSet.cxx:146
Int_t MergeElement(TDSetElement *elem)
Check if 'elem' is overlapping or subsequent and, if the case, return a merged element.
Definition TDSet.cxx:182
This class implements a data set to be used for PROOF processing.
Definition TDSet.h:153
void SplitEntryList()
for browsing purposes
Definition TDSet.cxx:1941
TIter * fSrvMapsIter
list for mapping server coordinates for files
Definition TDSet.h:184
virtual TDSetElement * Next(Long64_t totalEntries=-1)
Returns next TDSetElement.
Definition TDSet.cxx:413
virtual void StartViewer()
Start the TTreeViewer on this TTree.
Definition TDSet.cxx:1520
virtual void SetEntryList(TObject *aList)
Set entry (or event) list for this data set.
Definition TDSet.cxx:1893
Int_t Remove(TDSetElement *elem, Bool_t deleteElem=kTRUE)
Remove TDSetElement 'elem' from the list.
Definition TDSet.cxx:1576
TString fDir
Definition TDSet.h:177
void AddInput(TObject *obj)
Add objects that might be needed during the processing of the selector (see Process()).
Definition TDSet.cxx:966
TProofChain * fProofChain
entry (or event) list for processing
Definition TDSet.h:169
void operator=(const TDSet &)
TString fType
Definition TDSet.h:178
void Print(Option_t *option="") const override
Print TDSet basic or full data. When option="a" print full data.
Definition TDSet.cxx:1008
void SetLookedUp()
Flag all the elements as looked-up, so to avoid opening the files if the functionality is not support...
Definition TDSet.cxx:1657
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:1052
virtual void Reset()
Reset or initialize access to the elements.
Definition TDSet.cxx:1369
Bool_t ElementsValid()
Check if all elements are valid.
Definition TDSet.cxx:1555
Bool_t IsTree() const
Definition TDSet.h:225
TList * fSrvMaps
current element
Definition TDSet.h:183
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:1382
Int_t GetNumOfFiles()
Return the number of files in the dataset.
Definition TDSet.cxx:2018
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:1605
TIter * fIterator
Definition TDSet.h:181
Int_t ExportFileList(const char *filepath, Option_t *opt="")
Export TDSetElements files as list of TFileInfo objects in file 'fpath'.
Definition TDSet.cxx:1277
virtual TTree * GetTreeHeader(TProof *proof)
Returns a tree header containing the branches' structure of the dataset.
Definition TDSet.cxx:1547
virtual void AddFriend(TDSet *friendset, const char *alias)
Add friend dataset to this set.
Definition TDSet.cxx:1335
TDSetElement * Current() const
Definition TDSet.h:238
void SetSrvMaps(TList *srvmaps=0)
Set (or unset) the list for mapping servers coordinate for files.
Definition TDSet.cxx:1172
TObject * GetOutput(const char *name)
Get specified object that has been produced during the processing (see Process()).
Definition TDSet.cxx:988
TDSetElement * fCurrent
iterator on fElements
Definition TDSet.h:182
TObject * GetEntryList() const
Definition TDSet.h:251
void Validate()
Validate the TDSet by opening files.
Definition TDSet.cxx:1589
const char * GetType() const
Definition TDSet.h:228
TList * GetOutputList()
Get list with all object created during processing (see Process()).
Definition TDSet.cxx:998
Bool_t IsValid() const
Definition TDSet.h:226
~TDSet() override
Cleanup.
Definition TDSet.cxx:901
TDSet(const TDSet &)
void Draw(Option_t *opt) override
Default Draw method for all objects.
Definition TDSet.h:216
THashList * fElements
Definition TDSet.h:180
void SetWriteV3(Bool_t on=kTRUE)
Set/Reset the 'OldStreamer' bit in this instance and its elements.
Definition TDSet.cxx:1874
TString fObjName
Definition TDSet.h:179
TList * GetListOfElements() const
Definition TDSet.h:231
Bool_t fIsTree
Definition TDSet.h:167
void SetDirectory(const char *dir)
Set/change directory.
Definition TDSet.cxx:1041
void SetObjName(const char *objname)
Set/change object name.
Definition TDSet.cxx:1026
const char * GetDirectory() const
Definition TDSet.h:230
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:919
TDSet()
iterator on fSrvMaps
Definition TDSet.cxx:704
const char * GetObjName() const
Definition TDSet.h:229
void ClearInput()
Clear input object list.
Definition TDSet.cxx:978
TObject * fEntryList
Definition TDSet.h:168
EStatusBits
Definition TDSet.h:157
@ kSomeInvalid
Definition TDSet.h:161
@ kEmpty
Definition TDSet.h:159
@ kIsLocal
Definition TDSet.h:163
@ kWriteV3
Definition TDSet.h:158
@ kValidityChecked
Definition TDSet.h:160
@ kMultiDSet
Definition TDSet.h:162
A List of entry numbers in a TTree or TChain.
Definition TEntryList.h:26
<div class="legacybox"><h2>Legacy Code</h2> TEventList is a legacy interface: there will be no bug fi...
Definition TEventList.h:31
Class describing a generic file including meta information.
Definition TFileInfo.h:39
THashList implements a hybrid collection class consisting of a hash table and a list to store TObject...
Definition THashList.h:34
A doubly linked list.
Definition TList.h:38
The TNamed class is the base class for all named ROOT classes.
Definition TNamed.h:29
const char * GetName() const override
Returns name of object.
Definition TNamed.h:47
const char * GetTitle() const override
Returns title of object.
Definition TNamed.h:48
Mother of all ROOT objects.
Definition TObject.h:41
R__ALWAYS_INLINE Bool_t TestBit(UInt_t f) const
Definition TObject.h:199
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
Definition TObject.cxx:786
This class controls a Parallel ROOT Facility, PROOF, cluster.
Definition TProof.h:316
A TSelector object is used by the TTree::Draw, TTree::Scan, TTree::Process to navigate in a TTree and...
Definition TSelector.h:31
Basic string class.
Definition TString.h:139
Bool_t IsNull() const
Definition TString.h:414
A TTree represents a columnar dataset.
Definition TTree.h:79
th1 Draw()