Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files 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 #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 {
71  kHasBeenLookedUp = BIT(15),
72  kWriteV3 = BIT(16),
73  kEmpty = BIT(17),
74  kCorrupted = BIT(18),
75  kNewRun = BIT(19),
76  kNewPacket = BIT(20)
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 
96  Bool_t HasBeenLookedUp() const { return TestBit(kHasBeenLookedUp); }
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);
125  TList *GetListOfAssocObjs() const { return fAssocObjList; }
126  TObject *GetAssocObj(Long64_t i, Bool_t isentry = kFALSE);
127  void Print(Option_t *options="") const;
128  Long64_t GetTDSetOffset() const { return fTDSetOffset; }
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);
139  void SetLookedUp() { SetBit(kHasBeenLookedUp); }
140  TFileInfo *GetFileInfo(const char *type = "TTree");
141 
142  void Reset();
143 
144  Float_t GetMaxProcTime() const { return fMaxProcTime; }
145  void SetMaxProcTime(Float_t mpt) { fMaxProcTime = mpt; }
146 
147  Int_t MergeElement(TDSetElement *elem);
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(); }
227  Bool_t ElementsValid();
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; }
232  Int_t GetNumOfFiles();
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