Logo ROOT  
Reference Guide
TChain.cxx
Go to the documentation of this file.
1 // @(#)root/tree:$Id$
2 // Author: Rene Brun 03/02/97
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2000, 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 /** \class TChain
13 \ingroup tree
14 
15 A chain is a collection of files containing TTree objects.
16 When the chain is created, the first parameter is the default name
17 for the Tree to be processed later on.
18 
19 Enter a new element in the chain via the TChain::Add function.
20 Once a chain is defined, one can use the normal TTree functions
21 to Draw,Scan,etc.
22 
23 Use TChain::SetBranchStatus to activate one or more branches for all
24 the trees in the chain.
25 */
26 
27 #include "TChain.h"
28 
29 #include <iostream>
30 #include <cfloat>
31 
32 #include "TBranch.h"
33 #include "TBrowser.h"
34 #include "TBuffer.h"
35 #include "TChainElement.h"
36 #include "TClass.h"
37 #include "TColor.h"
38 #include "TCut.h"
39 #include "TError.h"
40 #include "TFile.h"
41 #include "TFileInfo.h"
42 #include "TFriendElement.h"
43 #include "TLeaf.h"
44 #include "TList.h"
45 #include "TObjString.h"
46 #include "TPluginManager.h"
47 #include "TROOT.h"
48 #include "TRegexp.h"
49 #include "TSelector.h"
50 #include "TSystem.h"
51 #include "TTree.h"
52 #include "TTreeCache.h"
53 #include "TUrl.h"
54 #include "TVirtualIndex.h"
55 #include "TEventList.h"
56 #include "TEntryList.h"
57 #include "TEntryListFromFile.h"
58 #include "TFileStager.h"
59 #include "TFilePrefetch.h"
60 #include "TVirtualMutex.h"
61 #include "strlcpy.h"
62 #include "snprintf.h"
63 
65 
66 ////////////////////////////////////////////////////////////////////////////////
67 /// Default constructor.
68 
70 : TTree()
71 , fTreeOffsetLen(100)
72 , fNtrees(0)
73 , fTreeNumber(-1)
74 , fTreeOffset(0)
75 , fCanDeleteRefs(kFALSE)
76 , fTree(0)
77 , fFile(0)
78 , fFiles(0)
79 , fStatus(0)
80 , fProofChain(0)
81 {
84  fStatus = new TList();
85  fTreeOffset[0] = 0;
86  if (gDirectory) gDirectory->Remove(this);
87  gROOT->GetListOfSpecials()->Add(this);
88  fFile = 0;
89  fDirectory = 0;
90 
91  // Reset PROOF-related bits
94 
95  // Add to the global list
96  gROOT->GetListOfDataSets()->Add(this);
97 
98  // Make sure we are informed if the TFile is deleted.
100  gROOT->GetListOfCleanups()->Add(this);
101 }
102 
103 ////////////////////////////////////////////////////////////////////////////////
104 /// Create a chain.
105 ///
106 /// A TChain is a collection of TFile objects.
107 /// the first parameter "name" is the name of the TTree object
108 /// in the files added with Add.
109 /// Use TChain::Add to add a new element to this chain.
110 ///
111 /// In case the Tree is in a subdirectory, do, eg:
112 /// ~~~ {.cpp}
113 /// TChain ch("subdir/treename");
114 /// ~~~
115 /// Example:
116 /// Suppose we have 3 files f1.root, f2.root and f3.root. Each file
117 /// contains a TTree object named "T".
118 /// ~~~ {.cpp}
119 /// TChain ch("T"); creates a chain to process a Tree called "T"
120 /// ch.Add("f1.root");
121 /// ch.Add("f2.root");
122 /// ch.Add("f3.root");
123 /// ch.Draw("x");
124 /// ~~~
125 /// The Draw function above will process the variable "x" in Tree "T"
126 /// reading sequentially the 3 files in the chain ch.
127 ///
128 /// The TChain data structure:
129 ///
130 /// Each TChainElement has a name equal to the tree name of this TChain
131 /// and a title equal to the file name. So, to loop over the
132 /// TFiles that have been added to this chain:
133 /// ~~~ {.cpp}
134 /// TObjArray *fileElements=chain->GetListOfFiles();
135 /// TIter next(fileElements);
136 /// TChainElement *chEl=0;
137 /// while (( chEl=(TChainElement*)next() )) {
138 /// TFile f(chEl->GetTitle());
139 /// ... do something with f ...
140 /// }
141 /// ~~~
142 
143 TChain::TChain(const char* name, const char* title)
144 :TTree(name, title, /*splitlevel*/ 99, nullptr)
145 , fTreeOffsetLen(100)
146 , fNtrees(0)
147 , fTreeNumber(-1)
148 , fTreeOffset(0)
149 , fCanDeleteRefs(kFALSE)
150 , fTree(0)
151 , fFile(0)
152 , fFiles(0)
153 , fStatus(0)
154 , fProofChain(0)
155 {
156  //
157  //*-*
158 
161  fStatus = new TList();
162  fTreeOffset[0] = 0;
163  fFile = 0;
164 
165  // Reset PROOF-related bits
168 
170 
171  // Add to the global lists
172  gROOT->GetListOfSpecials()->Add(this);
173  gROOT->GetListOfDataSets()->Add(this);
174 
175  // Make sure we are informed if the TFile is deleted.
176  gROOT->GetListOfCleanups()->Add(this);
177 }
178 
179 ////////////////////////////////////////////////////////////////////////////////
180 /// Destructor.
181 
183 {
184  bool rootAlive = gROOT && !gROOT->TestBit(TObject::kInvalidObject);
185 
186  if (rootAlive) {
188  gROOT->GetListOfCleanups()->Remove(this);
189  }
190 
192  fStatus->Delete();
193  delete fStatus;
194  fStatus = 0;
195  fFiles->Delete();
196  delete fFiles;
197  fFiles = 0;
198 
199  //first delete cache if exists
200  auto tc = fFile && fTree ? fTree->GetReadCache(fFile) : nullptr;
201  if (tc) {
202  delete tc;
203  fFile->SetCacheRead(0, fTree);
204  }
205 
206  delete fFile;
207  fFile = 0;
208  // Note: We do *not* own the tree.
209  fTree = 0;
210  delete[] fTreeOffset;
211  fTreeOffset = 0;
212 
213  // Remove from the global lists
214  if (rootAlive) {
216  gROOT->GetListOfSpecials()->Remove(this);
217  gROOT->GetListOfDataSets()->Remove(this);
218  }
219 
220  // This is the same as fFile, don't delete it a second time.
221  fDirectory = 0;
222 }
223 
224 ////////////////////////////////////////////////////////////////////////////////
225 /// Add all files referenced by the passed chain to this chain.
226 /// The function returns the total number of files connected.
227 
229 {
230  if (!chain) return 0;
231 
232  // Check for enough space in fTreeOffset.
233  if ((fNtrees + chain->GetNtrees()) >= fTreeOffsetLen) {
234  fTreeOffsetLen += 2 * chain->GetNtrees();
235  Long64_t* trees = new Long64_t[fTreeOffsetLen];
236  for (Int_t i = 0; i <= fNtrees; i++) {
237  trees[i] = fTreeOffset[i];
238  }
239  delete[] fTreeOffset;
240  fTreeOffset = trees;
241  }
242  chain->GetEntries(); //to force the computation of nentries
243  TIter next(chain->GetListOfFiles());
244  Int_t nf = 0;
245  TChainElement* element = 0;
246  while ((element = (TChainElement*) next())) {
247  Long64_t nentries = element->GetEntries();
250  } else {
252  }
253  fNtrees++;
254  fEntries += nentries;
255  TChainElement* newelement = new TChainElement(element->GetName(), element->GetTitle());
256  newelement->SetPacketSize(element->GetPacketSize());
257  newelement->SetNumberEntries(nentries);
258  fFiles->Add(newelement);
259  nf++;
260  }
261  if (fProofChain)
262  // This updates the proxy chain when we will really use PROOF
264 
265  return nf;
266 }
267 
268 ////////////////////////////////////////////////////////////////////////////////
269 /// Add a new file to this chain.
270 ///
271 /// Argument name may have either of two set of formats. The first:
272 /// ~~~ {.cpp}
273 /// [//machine]/path/file_name[?query[#tree_name]]
274 /// or [//machine]/path/file_name.root[.oext][/tree_name]
275 /// ~~~
276 /// If tree_name is missing the chain name will be assumed. Tagging the
277 /// tree_name with a slash [/tree_name] is only supported for backward
278 /// compatibility; it requires the file name to contain the string '.root'
279 /// and its use is deprecated.
280 /// Wildcard treatment is triggered by the any of the special characters []*?
281 /// which may be used in the file name, eg. specifying "xxx*.root" adds
282 /// all files starting with xxx in the current file system directory.
283 ///
284 /// Alternatively name may have the format of a url, eg.
285 /// ~~~ {.cpp}
286 /// root://machine/path/file_name[?query[#tree_name]]
287 /// or root://machine/path/file_name
288 /// or root://machine/path/file_name.root[.oext]/tree_name
289 /// or root://machine/path/file_name.root[.oext]/tree_name?query
290 /// ~~~
291 /// where "query" is to be interpreted by the remote server. Wildcards may be
292 /// supported in urls, depending on the protocol plugin and the remote server.
293 /// http or https urls can contain a query identifier without tree_name, but
294 /// generally urls can not be written with them because of ambiguity with the
295 /// wildcard character. (Also see the documentation for TChain::AddFile,
296 /// which does not support wildcards but allows the url name to contain query).
297 /// Again, tagging the tree_name with a slash [/tree_name] is only supported
298 /// for backward compatibility; it requires the file name ot contain the string
299 /// '.root' and its use is deprecated.
300 ///
301 /// NB. To add all the files of a TChain to a chain, use Add(TChain *chain).
302 ///
303 /// A. if nentries <= 0, the file is connected and the tree header read
304 /// in memory to get the number of entries.
305 ///
306 /// B. if (nentries > 0, the file is not connected, nentries is assumed to be
307 /// the number of entries in the file. In this case, no check is made that
308 /// the file exists and the Tree existing in the file. This second mode
309 /// is interesting in case the number of entries in the file is already stored
310 /// in a run data base for example.
311 ///
312 /// C. if (nentries == TTree::kMaxEntries) (default), the file is not connected.
313 /// the number of entries in each file will be read only when the file
314 /// will need to be connected to read an entry.
315 /// This option is the default and very efficient if one process
316 /// the chain sequentially. Note that in case TChain::GetEntry(entry)
317 /// is called and entry refers to an entry in the 3rd file, for example,
318 /// this forces the Tree headers in the first and second file
319 /// to be read to find the number of entries in these files.
320 /// Note that if one calls TChain::GetEntriesFast() after having created
321 /// a chain with this default, GetEntriesFast will return TTree::kMaxEntries!
322 /// TChain::GetEntries will force of the Tree headers in the chain to be
323 /// read to read the number of entries in each Tree.
324 ///
325 /// D. The TChain data structure
326 /// Each TChainElement has a name equal to the tree name of this TChain
327 /// and a title equal to the file name. So, to loop over the
328 /// TFiles that have been added to this chain:
329 /// ~~~ {.cpp}
330 /// TObjArray *fileElements=chain->GetListOfFiles();
331 /// TIter next(fileElements);
332 /// TChainElement *chEl=0;
333 /// while (( chEl=(TChainElement*)next() )) {
334 /// TFile f(chEl->GetTitle());
335 /// ... do something with f ...
336 /// }
337 /// ~~~
338 /// Return value:
339 ///
340 /// - If nentries>0 (including the default of TTree::kMaxEntries) and no
341 /// wildcarding is used, ALWAYS returns 1 without regard to whether
342 /// the file exists or contains the correct tree.
343 ///
344 /// - If wildcarding is used, regardless of the value of nentries,
345 /// returns the number of files matching the name without regard to
346 /// whether they contain the correct tree.
347 ///
348 /// - If nentries<=0 and wildcarding is not used, return 1 if the file
349 /// exists and contains the correct tree and 0 otherwise.
350 
351 Int_t TChain::Add(const char* name, Long64_t nentries /* = TTree::kMaxEntries */)
352 {
353  TString basename, treename, query, suffix;
354  ParseTreeFilename(name, basename, treename, query, suffix, kTRUE);
355 
356  // case with one single file
357  if (!basename.MaybeWildcard()) {
358  return AddFile(name, nentries);
359  }
360 
361  // wildcarding used in name
362  Int_t nf = 0;
363 
364  Int_t slashpos = basename.Last('/');
365  TString directory;
366  if (slashpos>=0) {
367  directory = basename(0,slashpos); // Copy the directory name
368  basename.Remove(0,slashpos+1); // and remove it from basename
369  } else {
370  directory = gSystem->UnixPathName(gSystem->WorkingDirectory());
371  }
372 
373  const char *file;
374  const char *epath = gSystem->ExpandPathName(directory.Data());
375  void *dir = gSystem->OpenDirectory(epath);
376  delete [] epath;
377  if (dir) {
378  //create a TList to store the file names (not yet sorted)
379  TList l;
380  TRegexp re(basename,kTRUE);
381  while ((file = gSystem->GetDirEntry(dir))) {
382  if (!strcmp(file,".") || !strcmp(file,"..")) continue;
383  TString s = file;
384  if ( (basename!=file) && s.Index(re) == kNPOS) continue;
385  l.Add(new TObjString(file));
386  }
387  gSystem->FreeDirectory(dir);
388  //sort the files in alphanumeric order
389  l.Sort();
390  TIter next(&l);
391  TObjString *obj;
392  while ((obj = (TObjString*)next())) {
393  file = obj->GetName();
394  nf += AddFile(TString::Format("%s/%s%s",directory.Data(),file,suffix.Data()),nentries);
395  }
396  l.Delete();
397  }
398  if (fProofChain)
399  // This updates the proxy chain when we will really use PROOF
401 
402  return nf;
403 }
404 
405 ////////////////////////////////////////////////////////////////////////////////
406 /// Add a new file to this chain.
407 ///
408 /// Filename formats are similar to TChain::Add. Wildcards are not
409 /// applied. urls may also contain query and fragment identifiers
410 /// where the tree name can be specified in the url fragment.
411 ///
412 /// eg.
413 /// ~~~ {.cpp}
414 /// root://machine/path/file_name[?query[#tree_name]]
415 /// root://machine/path/file_name.root[.oext]/tree_name[?query]
416 /// ~~~
417 /// If tree_name is given as a part of the file name it is used to
418 /// as the name of the tree to load from the file. Otherwise if tname
419 /// argument is specified the chain will load the tree named tname from
420 /// the file, otherwise the original treename specified in the TChain
421 /// constructor will be used.
422 /// Tagging the tree_name with a slash [/tree_name] is only supported for
423 /// backward compatibility; it requires the file name ot contain the string
424 /// '.root' and its use is deprecated.
425 ///
426 /// A. If nentries <= 0, the file is opened and the tree header read
427 /// into memory to get the number of entries.
428 ///
429 /// B. If nentries > 0, the file is not opened, and nentries is assumed
430 /// to be the number of entries in the file. In this case, no check
431 /// is made that the file exists nor that the tree exists in the file.
432 /// This second mode is interesting in case the number of entries in
433 /// the file is already stored in a run database for example.
434 ///
435 /// C. If nentries == TTree::kMaxEntries (default), the file is not opened.
436 /// The number of entries in each file will be read only when the file
437 /// is opened to read an entry. This option is the default and very
438 /// efficient if one processes the chain sequentially. Note that in
439 /// case GetEntry(entry) is called and entry refers to an entry in the
440 /// third file, for example, this forces the tree headers in the first
441 /// and second file to be read to find the number of entries in those
442 /// files. Note that if one calls GetEntriesFast() after having created
443 /// a chain with this default, GetEntriesFast() will return TTree::kMaxEntries!
444 /// Using the GetEntries() function instead will force all of the tree
445 /// headers in the chain to be read to read the number of entries in
446 /// each tree.
447 ///
448 /// D. The TChain data structure
449 /// Each TChainElement has a name equal to the tree name of this TChain
450 /// and a title equal to the file name. So, to loop over the
451 /// TFiles that have been added to this chain:
452 /// ~~~ {.cpp}
453 /// TObjArray *fileElements=chain->GetListOfFiles();
454 /// TIter next(fileElements);
455 /// TChainElement *chEl=0;
456 /// while (( chEl=(TChainElement*)next() )) {
457 /// TFile f(chEl->GetTitle());
458 /// ... do something with f ...
459 /// }
460 /// ~~~
461 /// The function returns 1 if the file is successfully connected, 0 otherwise.
462 
463 Int_t TChain::AddFile(const char* name, Long64_t nentries /* = TTree::kMaxEntries */, const char* tname /* = "" */)
464 {
465  if(name==0 || name[0]=='\0') {
466  Error("AddFile", "No file name; no files connected");
467  return 0;
468  }
469 
470  const char *treename = GetName();
471  if (tname && strlen(tname) > 0) treename = tname;
472 
473  TString basename, tn, query, suffix;
474  ParseTreeFilename(name, basename, tn, query, suffix, kFALSE);
475 
476  if (!tn.IsNull()) {
477  treename = tn.Data();
478  }
479 
480  Int_t nch = basename.Length() + query.Length();
481  char *filename = new char[nch+1];
482  strlcpy(filename,basename.Data(),nch+1);
483  strlcat(filename,query.Data(),nch+1);
484 
485  //Check enough space in fTreeOffset
486  if (fNtrees+1 >= fTreeOffsetLen) {
487  fTreeOffsetLen *= 2;
488  Long64_t *trees = new Long64_t[fTreeOffsetLen];
489  for (Int_t i=0;i<=fNtrees;i++) trees[i] = fTreeOffset[i];
490  delete [] fTreeOffset;
491  fTreeOffset = trees;
492  }
493 
494  // Open the file to get the number of entries.
495  Int_t pksize = 0;
496  if (nentries <= 0) {
497  TFile* file;
498  {
500  file = TFile::Open(filename);
501  }
502  if (!file || file->IsZombie()) {
503  delete file;
504  file = 0;
505  delete[] filename;
506  filename = 0;
507  return 0;
508  }
509 
510  // Check that tree with the right name exists in the file.
511  // Note: We are not the owner of obj, the file is!
512  TObject* obj = file->Get(treename);
513  if (!obj || !obj->InheritsFrom(TTree::Class())) {
514  Error("AddFile", "cannot find tree with name %s in file %s", treename, filename);
515  delete file;
516  file = 0;
517  delete[] filename;
518  filename = 0;
519  return 0;
520  }
521  TTree* tree = (TTree*) obj;
522  nentries = tree->GetEntries();
523  pksize = tree->GetPacketSize();
524  // Note: This deletes the tree we fetched.
525  delete file;
526  file = 0;
527  }
528 
529  if (nentries > 0) {
530  if (nentries != TTree::kMaxEntries) {
532  fEntries += nentries;
533  } else {
536  }
537  fNtrees++;
538 
539  TChainElement* element = new TChainElement(treename, filename);
540  element->SetPacketSize(pksize);
541  element->SetNumberEntries(nentries);
542  fFiles->Add(element);
543  } else {
544  Warning("AddFile", "Adding tree with no entries from file: %s", filename);
545  }
546 
547  delete [] filename;
548  if (fProofChain)
549  // This updates the proxy chain when we will really use PROOF
551 
552  return 1;
553 }
554 
555 ////////////////////////////////////////////////////////////////////////////////
556 /// Add all files referenced in the list to the chain. The object type in the
557 /// list must be either TFileInfo or TObjString or TUrl .
558 /// The function return 1 if successful, 0 otherwise.
559 
560 Int_t TChain::AddFileInfoList(TCollection* filelist, Long64_t nfiles /* = TTree::kMaxEntries */)
561 {
562  if (!filelist)
563  return 0;
564  TIter next(filelist);
565 
566  TObject *o = 0;
567  Long64_t cnt=0;
568  while ((o = next())) {
569  // Get the url
570  TString cn = o->ClassName();
571  const char *url = 0;
572  if (cn == "TFileInfo") {
573  TFileInfo *fi = (TFileInfo *)o;
574  url = (fi->GetCurrentUrl()) ? fi->GetCurrentUrl()->GetUrl() : 0;
575  if (!url) {
576  Warning("AddFileInfoList", "found TFileInfo with empty Url - ignoring");
577  continue;
578  }
579  } else if (cn == "TUrl") {
580  url = ((TUrl*)o)->GetUrl();
581  } else if (cn == "TObjString") {
582  url = ((TObjString*)o)->GetName();
583  }
584  if (!url) {
585  Warning("AddFileInfoList", "object is of type %s : expecting TFileInfo, TUrl"
586  " or TObjString - ignoring", o->ClassName());
587  continue;
588  }
589  // Good entry
590  cnt++;
591  AddFile(url);
592  if (cnt >= nfiles)
593  break;
594  }
595  if (fProofChain) {
596  // This updates the proxy chain when we will really use PROOF
598  }
599 
600  return 1;
601 }
602 
603 ////////////////////////////////////////////////////////////////////////////////
604 /// Add a TFriendElement to the list of friends of this chain.
605 ///
606 /// A TChain has a list of friends similar to a tree (see TTree::AddFriend).
607 /// You can add a friend to a chain with the TChain::AddFriend method, and you
608 /// can retrieve the list of friends with TChain::GetListOfFriends.
609 /// This example has four chains each has 20 ROOT trees from 20 ROOT files.
610 /// ~~~ {.cpp}
611 /// TChain ch("t"); // a chain with 20 trees from 20 files
612 /// TChain ch1("t1");
613 /// TChain ch2("t2");
614 /// TChain ch3("t3");
615 /// ~~~
616 /// Now we can add the friends to the first chain.
617 /// ~~~ {.cpp}
618 /// ch.AddFriend("t1")
619 /// ch.AddFriend("t2")
620 /// ch.AddFriend("t3")
621 /// ~~~
622 /// \image html tchain_friend.png
623 ///
624 ///
625 /// The parameter is the name of friend chain (the name of a chain is always
626 /// the name of the tree from which it was created).
627 /// The original chain has access to all variable in its friends.
628 /// We can use the TChain::Draw method as if the values in the friends were
629 /// in the original chain.
630 /// To specify the chain to use in the Draw method, use the syntax:
631 /// ~~~ {.cpp}
632 /// <chainname>.<branchname>.<varname>
633 /// ~~~
634 /// If the variable name is enough to uniquely identify the variable, you can
635 /// leave out the chain and/or branch name.
636 /// For example, this generates a 3-d scatter plot of variable "var" in the
637 /// TChain ch versus variable v1 in TChain t1 versus variable v2 in TChain t2.
638 /// ~~~ {.cpp}
639 /// ch.Draw("var:t1.v1:t2.v2");
640 /// ~~~
641 /// When a TChain::Draw is executed, an automatic call to TTree::AddFriend
642 /// connects the trees in the chain. When a chain is deleted, its friend
643 /// elements are also deleted.
644 ///
645 /// The number of entries in the friend must be equal or greater to the number
646 /// of entries of the original chain. If the friend has fewer entries a warning
647 /// is given and the resulting histogram will have missing entries.
648 /// For additional information see TTree::AddFriend.
649 
650 TFriendElement* TChain::AddFriend(const char* chain, const char* dummy /* = "" */)
651 {
652  if (!fFriends) {
653  fFriends = new TList();
654  }
655  TFriendElement* fe = new TFriendElement(this, chain, dummy);
656 
657  R__ASSERT(fe); // There used to be a "if (fe)" test ... Keep this assert until we are sure that fe is never null
658 
659  fFriends->Add(fe);
660 
661  if (fProofChain)
662  // This updates the proxy chain when we will really use PROOF
664 
665  // We need to invalidate the loading of the current tree because its list
666  // of real friends is now obsolete. It is repairable only from LoadTree.
668 
669  TTree* tree = fe->GetTree();
670  if (!tree) {
671  Warning("AddFriend", "Unknown TChain %s", chain);
672  }
673  return fe;
674 }
675 
676 ////////////////////////////////////////////////////////////////////////////////
677 /// Add the whole chain or tree as a friend of this chain.
678 
680 {
681  if (!fFriends) fFriends = new TList();
682  TFriendElement *fe = new TFriendElement(this,chain,dummy);
683 
684  R__ASSERT(fe); // There used to be a "if (fe)" test ... Keep this assert until we are sure that fe is never null
685 
686  fFriends->Add(fe);
687 
688  if (fProofChain)
689  // This updates the proxy chain when we will really use PROOF
691 
692  // We need to invalidate the loading of the current tree because its list
693  // of real friend is now obsolete. It is repairable only from LoadTree
695 
696  TTree *t = fe->GetTree();
697  if (!t) {
698  Warning("AddFriend","Unknown TChain %s",chain);
699  }
700  return fe;
701 }
702 
703 ////////////////////////////////////////////////////////////////////////////////
704 /// Add the whole chain or tree as a friend of this chain.
705 
706 TFriendElement* TChain::AddFriend(TTree* chain, const char* alias, Bool_t /* warn = kFALSE */)
707 {
708  if (!chain) return nullptr;
709  if (!fFriends) fFriends = new TList();
710  TFriendElement *fe = new TFriendElement(this,chain,alias);
711  R__ASSERT(fe);
712 
713  fFriends->Add(fe);
714 
715  if (fProofChain)
716  // This updates the proxy chain when we will really use PROOF
718 
719  // We need to invalidate the loading of the current tree because its list
720  // of real friend is now obsolete. It is repairable only from LoadTree
722 
723  TTree *t = fe->GetTree();
724  if (!t) {
725  Warning("AddFriend","Unknown TChain %s",chain->GetName());
726  }
727  chain->RegisterExternalFriend(fe);
728  return fe;
729 }
730 
731 ////////////////////////////////////////////////////////////////////////////////
732 /// Browse the contents of the chain.
733 
735 {
736  TTree::Browse(b);
737 }
738 
739 ////////////////////////////////////////////////////////////////////////////////
740 /// When closing a file during the chain processing, the file
741 /// may be closed with option "R" if flag is set to kTRUE.
742 /// by default flag is kTRUE.
743 /// When closing a file with option "R", all TProcessIDs referenced by this
744 /// file are deleted.
745 /// Calling TFile::Close("R") might be necessary in case one reads a long list
746 /// of files having TRef, writing some of the referenced objects or TRef
747 /// to a new file. If the TRef or referenced objects of the file being closed
748 /// will not be referenced again, it is possible to minimize the size
749 /// of the TProcessID data structures in memory by forcing a delete of
750 /// the unused TProcessID.
751 
752 void TChain::CanDeleteRefs(Bool_t flag /* = kTRUE */)
753 {
754  fCanDeleteRefs = flag;
755 }
756 
757 ////////////////////////////////////////////////////////////////////////////////
758 /// Initialize the packet descriptor string.
759 
761 {
762  TIter next(fFiles);
763  TChainElement* element = 0;
764  while ((element = (TChainElement*) next())) {
765  element->CreatePackets();
766  }
767 }
768 
769 ////////////////////////////////////////////////////////////////////////////////
770 /// Override the TTree::DirectoryAutoAdd behavior:
771 /// we never auto add.
772 
774 {
775 }
776 
777 ////////////////////////////////////////////////////////////////////////////////
778 /// Draw expression varexp for selected entries.
779 /// Returns -1 in case of error or number of selected events in case of success.
780 ///
781 /// This function accepts TCut objects as arguments.
782 /// Useful to use the string operator +, example:
783 /// ~~~{.cpp}
784 /// ntuple.Draw("x",cut1+cut2+cut3);
785 /// ~~~
786 ///
787 
788 Long64_t TChain::Draw(const char* varexp, const TCut& selection,
789  Option_t* option, Long64_t nentries, Long64_t firstentry)
790 {
791  if (fProofChain) {
792  // Make sure the element list is uptodate
793  if (!TestBit(kProofUptodate))
794  SetProof(kTRUE, kTRUE);
797  return fProofChain->Draw(varexp, selection, option, nentries, firstentry);
798  }
799 
800  return TChain::Draw(varexp, selection.GetTitle(), option, nentries, firstentry);
801 }
802 
803 ////////////////////////////////////////////////////////////////////////////////
804 /// Process all entries in this chain and draw histogram corresponding to
805 /// expression varexp.
806 /// Returns -1 in case of error or number of selected events in case of success.
807 
808 Long64_t TChain::Draw(const char* varexp, const char* selection,
809  Option_t* option,Long64_t nentries, Long64_t firstentry)
810 {
811  if (fProofChain) {
812  // Make sure the element list is uptodate
813  if (!TestBit(kProofUptodate))
814  SetProof(kTRUE, kTRUE);
817  return fProofChain->Draw(varexp, selection, option, nentries, firstentry);
818  }
819  GetPlayer();
820  if (LoadTree(firstentry) < 0) return 0;
821  return TTree::Draw(varexp,selection,option,nentries,firstentry);
822 }
823 
824 ////////////////////////////////////////////////////////////////////////////////
825 /// See TTree::GetReadEntry().
826 
827 TBranch* TChain::FindBranch(const char* branchname)
828 {
830  // Make sure the element list is uptodate
831  if (!TestBit(kProofUptodate))
832  SetProof(kTRUE, kTRUE);
833  return fProofChain->FindBranch(branchname);
834  }
835  if (fTree) {
836  return fTree->FindBranch(branchname);
837  }
838  LoadTree(0);
839  if (fTree) {
840  return fTree->FindBranch(branchname);
841  }
842  return 0;
843 }
844 
845 ////////////////////////////////////////////////////////////////////////////////
846 /// See TTree::GetReadEntry().
847 
848 TLeaf* TChain::FindLeaf(const char* searchname)
849 {
851  // Make sure the element list is uptodate
852  if (!TestBit(kProofUptodate))
853  SetProof(kTRUE, kTRUE);
854  return fProofChain->FindLeaf(searchname);
855  }
856  if (fTree) {
857  return fTree->FindLeaf(searchname);
858  }
859  LoadTree(0);
860  if (fTree) {
861  return fTree->FindLeaf(searchname);
862  }
863  return 0;
864 }
865 
866 ////////////////////////////////////////////////////////////////////////////////
867 /// Returns the expanded value of the alias. Search in the friends if any.
868 
869 const char* TChain::GetAlias(const char* aliasName) const
870 {
871  const char* alias = TTree::GetAlias(aliasName);
872  if (alias) {
873  return alias;
874  }
875  if (fTree) {
876  return fTree->GetAlias(aliasName);
877  }
878  const_cast<TChain*>(this)->LoadTree(0);
879  if (fTree) {
880  return fTree->GetAlias(aliasName);
881  }
882  return 0;
883 }
884 
885 ////////////////////////////////////////////////////////////////////////////////
886 /// Return pointer to the branch name in the current tree.
887 
889 {
891  // Make sure the element list is uptodate
892  if (!TestBit(kProofUptodate))
893  SetProof(kTRUE, kTRUE);
894  return fProofChain->GetBranch(name);
895  }
896  if (fTree) {
897  return fTree->GetBranch(name);
898  }
899  LoadTree(0);
900  if (fTree) {
901  return fTree->GetBranch(name);
902  }
903  return 0;
904 }
905 
906 ////////////////////////////////////////////////////////////////////////////////
907 /// See TTree::GetReadEntry().
908 
909 Bool_t TChain::GetBranchStatus(const char* branchname) const
910 {
912  // Make sure the element list is uptodate
913  if (!TestBit(kProofUptodate))
914  Warning("GetBranchStatus", "PROOF proxy not up-to-date:"
915  " run TChain::SetProof(kTRUE, kTRUE) first");
916  return fProofChain->GetBranchStatus(branchname);
917  }
918  return TTree::GetBranchStatus(branchname);
919 }
920 
921 ////////////////////////////////////////////////////////////////////////////////
922 /// Return an iterator over the cluster of baskets starting at firstentry.
923 ///
924 /// This iterator is not yet supported for TChain object.
925 
927 {
928  Fatal("GetClusterIterator","Not support for TChain object");
929  return TTree::GetClusterIterator(-1);
930 }
931 
932 ////////////////////////////////////////////////////////////////////////////////
933 /// Return absolute entry number in the chain.
934 /// The input parameter entry is the entry number in
935 /// the current tree of this chain.
936 
938 {
939  return entry + fTreeOffset[fTreeNumber];
940 }
941 
942 ////////////////////////////////////////////////////////////////////////////////
943 /// Return the total number of entries in the chain.
944 /// In case the number of entries in each tree is not yet known,
945 /// the offset table is computed.
946 
948 {
950  // Make sure the element list is uptodate
951  if (!TestBit(kProofUptodate))
952  Warning("GetEntries", "PROOF proxy not up-to-date:"
953  " run TChain::SetProof(kTRUE, kTRUE) first");
954  return fProofChain->GetEntries();
955  }
956  if (fEntries == TTree::kMaxEntries) {
957  const_cast<TChain*>(this)->LoadTree(TTree::kMaxEntries-1);
958  }
959  return fEntries;
960 }
961 
962 ////////////////////////////////////////////////////////////////////////////////
963 /// Get entry from the file to memory.
964 ///
965 /// - getall = 0 : get only active branches
966 /// - getall = 1 : get all branches
967 ///
968 /// Return the total number of bytes read,
969 /// 0 bytes read indicates a failure.
970 
972 {
973  Long64_t treeReadEntry = LoadTree(entry);
974  if (treeReadEntry < 0) {
975  return 0;
976  }
977  if (!fTree) {
978  return 0;
979  }
980  return fTree->GetEntry(treeReadEntry, getall);
981 }
982 
983 ////////////////////////////////////////////////////////////////////////////////
984 /// Return entry number corresponding to entry.
985 ///
986 /// if no TEntryList set returns entry
987 /// else returns entry \#entry from this entry list and
988 /// also computes the global entry number (loads all tree headers)
989 
991 {
992 
993  if (fEntryList){
994  Int_t treenum = 0;
995  Long64_t localentry = fEntryList->GetEntryAndTree(entry, treenum);
996  //find the global entry number
997  //same const_cast as in the GetEntries() function
998  if (localentry<0) return -1;
999  if (treenum != fTreeNumber){
1000  if (fTreeOffset[treenum]==TTree::kMaxEntries){
1001  for (Int_t i=0; i<=treenum; i++){
1003  (const_cast<TChain*>(this))->LoadTree(fTreeOffset[i-1]);
1004  }
1005  }
1006  //(const_cast<TChain*>(this))->LoadTree(fTreeOffset[treenum]);
1007  }
1008  Long64_t globalentry = fTreeOffset[treenum] + localentry;
1009  return globalentry;
1010  }
1011  return entry;
1012 }
1013 
1014 ////////////////////////////////////////////////////////////////////////////////
1015 /// Return entry corresponding to major and minor number.
1016 ///
1017 /// The function returns the total number of bytes read.
1018 /// If the Tree has friend trees, the corresponding entry with
1019 /// the index values (major,minor) is read. Note that the master Tree
1020 /// and its friend may have different entry serial numbers corresponding
1021 /// to (major,minor).
1022 
1024 {
1025  Long64_t serial = GetEntryNumberWithIndex(major, minor);
1026  if (serial < 0) return -1;
1027  return GetEntry(serial);
1028 }
1029 
1030 ////////////////////////////////////////////////////////////////////////////////
1031 /// Return a pointer to the current file.
1032 /// If no file is connected, the first file is automatically loaded.
1033 
1035 {
1036  if (fFile) {
1037  return fFile;
1038  }
1039  // Force opening the first file in the chain.
1040  const_cast<TChain*>(this)->LoadTree(0);
1041  return fFile;
1042 }
1043 
1044 ////////////////////////////////////////////////////////////////////////////////
1045 /// Return a pointer to the leaf name in the current tree.
1046 
1047 TLeaf* TChain::GetLeaf(const char* branchname, const char *leafname)
1048 {
1049  if (fProofChain && !(fProofChain->TestBit(kProofLite))) {
1050  // Make sure the element list is uptodate
1051  if (!TestBit(kProofUptodate))
1052  SetProof(kTRUE, kTRUE);
1053  return fProofChain->GetLeaf(branchname, leafname);
1054  }
1055  if (fTree) {
1056  return fTree->GetLeaf(branchname, leafname);
1057  }
1058  LoadTree(0);
1059  if (fTree) {
1060  return fTree->GetLeaf(branchname, leafname);
1061  }
1062  return 0;
1063 }
1064 
1065 ////////////////////////////////////////////////////////////////////////////////
1066 /// Return a pointer to the leaf name in the current tree.
1067 
1069 {
1070  if (fProofChain && !(fProofChain->TestBit(kProofLite))) {
1071  // Make sure the element list is uptodate
1072  if (!TestBit(kProofUptodate))
1073  SetProof(kTRUE, kTRUE);
1074  return fProofChain->GetLeaf(name);
1075  }
1076  if (fTree) {
1077  return fTree->GetLeaf(name);
1078  }
1079  LoadTree(0);
1080  if (fTree) {
1081  return fTree->GetLeaf(name);
1082  }
1083  return 0;
1084 }
1085 
1086 ////////////////////////////////////////////////////////////////////////////////
1087 /// Return a pointer to the list of branches of the current tree.
1088 ///
1089 /// Warning: If there is no current TTree yet, this routine will open the
1090 /// first in the chain.
1091 ///
1092 /// Returns 0 on failure.
1093 
1095 {
1096  if (fProofChain && !(fProofChain->TestBit(kProofLite))) {
1097  // Make sure the element list is uptodate
1098  if (!TestBit(kProofUptodate))
1099  SetProof(kTRUE, kTRUE);
1100  return fProofChain->GetListOfBranches();
1101  }
1102  if (fTree) {
1103  return fTree->GetListOfBranches();
1104  }
1105  LoadTree(0);
1106  if (fTree) {
1107  return fTree->GetListOfBranches();
1108  }
1109  return 0;
1110 }
1111 
1112 ////////////////////////////////////////////////////////////////////////////////
1113 /// Return a pointer to the list of leaves of the current tree.
1114 ///
1115 /// Warning: May set the current tree!
1116 
1118 {
1119  if (fProofChain && !(fProofChain->TestBit(kProofLite))) {
1120  // Make sure the element list is uptodate
1121  if (!TestBit(kProofUptodate))
1122  SetProof(kTRUE, kTRUE);
1123  return fProofChain->GetListOfLeaves();
1124  }
1125  if (fTree) {
1126  return fTree->GetListOfLeaves();
1127  }
1128  LoadTree(0);
1129  if (fTree) {
1130  return fTree->GetListOfLeaves();
1131  }
1132  return 0;
1133 }
1134 
1135 ////////////////////////////////////////////////////////////////////////////////
1136 /// Return maximum of column with name columname.
1137 
1138 Double_t TChain::GetMaximum(const char* columname)
1139 {
1140  Double_t theMax = -DBL_MAX;
1141  for (Int_t file = 0; file < fNtrees; file++) {
1143  LoadTree(first);
1144  Double_t curmax = fTree->GetMaximum(columname);
1145  if (curmax > theMax) {
1146  theMax = curmax;
1147  }
1148  }
1149  return theMax;
1150 }
1151 
1152 ////////////////////////////////////////////////////////////////////////////////
1153 /// Return minimum of column with name columname.
1154 
1155 Double_t TChain::GetMinimum(const char* columname)
1156 {
1157  Double_t theMin = DBL_MAX;
1158  for (Int_t file = 0; file < fNtrees; file++) {
1160  LoadTree(first);
1161  Double_t curmin = fTree->GetMinimum(columname);
1162  if (curmin < theMin) {
1163  theMin = curmin;
1164  }
1165  }
1166  return theMin;
1167 }
1168 
1169 ////////////////////////////////////////////////////////////////////////////////
1170 /// Return the number of branches of the current tree.
1171 ///
1172 /// Warning: May set the current tree!
1173 
1175 {
1176  if (fTree) {
1177  return fTree->GetNbranches();
1178  }
1179  LoadTree(0);
1180  if (fTree) {
1181  return fTree->GetNbranches();
1182  }
1183  return 0;
1184 }
1185 
1186 ////////////////////////////////////////////////////////////////////////////////
1187 /// See TTree::GetReadEntry().
1188 
1190 {
1191  if (fProofChain && !(fProofChain->TestBit(kProofLite))) {
1192  // Make sure the element list is uptodate
1193  if (!TestBit(kProofUptodate))
1194  Warning("GetBranchStatus", "PROOF proxy not up-to-date:"
1195  " run TChain::SetProof(kTRUE, kTRUE) first");
1196  return fProofChain->GetReadEntry();
1197  }
1198  return TTree::GetReadEntry();
1199 }
1200 
1201 ////////////////////////////////////////////////////////////////////////////////
1202 /// Return the chain weight.
1203 ///
1204 /// By default the weight is the weight of the current tree.
1205 /// However, if the weight has been set in TChain::SetWeight()
1206 /// with the option "global", then that weight will be returned.
1207 ///
1208 /// Warning: May set the current tree!
1209 
1211 {
1212  if (TestBit(kGlobalWeight)) {
1213  return fWeight;
1214  } else {
1215  if (fTree) {
1216  return fTree->GetWeight();
1217  }
1218  const_cast<TChain*>(this)->LoadTree(0);
1219  if (fTree) {
1220  return fTree->GetWeight();
1221  }
1222  return 0;
1223  }
1224 }
1225 
1226 ////////////////////////////////////////////////////////////////////////////////
1227 /// Set the TTree to be reloaded as soon as possible. In particular this
1228 /// is needed when adding a Friend.
1229 ///
1230 /// If the tree has clones, copy them into the chain
1231 /// clone list so we can change their branch addresses
1232 /// when necessary.
1233 ///
1234 /// This is to support the syntax:
1235 /// ~~~ {.cpp}
1236 /// TTree* clone = chain->GetTree()->CloneTree(0);
1237 /// ~~~
1238 
1240 {
1241  if (fTree && fTree->GetListOfClones()) {
1242  for (TObjLink* lnk = fTree->GetListOfClones()->FirstLink(); lnk; lnk = lnk->Next()) {
1243  TTree* clone = (TTree*) lnk->GetObject();
1244  AddClone(clone);
1245  }
1246  }
1247  fTreeNumber = -1;
1248  fTree = 0;
1249 }
1250 
1251 ////////////////////////////////////////////////////////////////////////////////
1252 /// Dummy function.
1253 /// It could be implemented and load all baskets of all trees in the chain.
1254 /// For the time being use TChain::Merge and TTree::LoadBasket
1255 /// on the resulting tree.
1256 
1258 {
1259  Error("LoadBaskets", "Function not yet implemented for TChain.");
1260  return 0;
1261 }
1262 
1263 ////////////////////////////////////////////////////////////////////////////////
1264 /// Find the tree which contains entry, and set it as the current tree.
1265 ///
1266 /// Returns the entry number in that tree.
1267 ///
1268 /// The input argument entry is the entry serial number in the whole chain.
1269 ///
1270 /// In case of error, LoadTree returns a negative number:
1271 /// * -1: The chain is empty.
1272 /// * -2: The requested entry number is less than zero or too large for the chain.
1273 /// or too large for the large TTree.
1274 /// * -3: The file corresponding to the entry could not be correctly open
1275 /// * -4: The TChainElement corresponding to the entry is missing or
1276 /// the TTree is missing from the file.
1277 /// * -5: Internal error, please report the circumstance when this happen
1278 /// as a ROOT issue.
1279 /// * -6: An error occurred within the notify callback.
1280 ///
1281 /// Note: This is the only routine which sets the value of fTree to
1282 /// a non-zero pointer.
1283 
1285 {
1286  // We already have been visited while recursively looking
1287  // through the friends tree, let's return.
1288  if (kLoadTree & fFriendLockStatus) {
1289  return 0;
1290  }
1291 
1292  if (!fNtrees) {
1293  // -- The chain is empty.
1294  return -1;
1295  }
1296 
1297  if ((entry < 0) || ((entry > 0) && (entry >= fEntries && entry!=(TTree::kMaxEntries-1) ))) {
1298  // -- Invalid entry number.
1299  if (fTree) fTree->LoadTree(-1);
1300  fReadEntry = -1;
1301  return -2;
1302  }
1303 
1304  // Find out which tree in the chain contains the passed entry.
1305  Int_t treenum = fTreeNumber;
1306  if ((fTreeNumber == -1) || (entry < fTreeOffset[fTreeNumber]) || (entry >= fTreeOffset[fTreeNumber+1]) || (entry==TTree::kMaxEntries-1)) {
1307  // -- Entry is *not* in the chain's current tree.
1308  // Do a linear search of the tree offset array.
1309  // FIXME: We could be smarter by starting at the
1310  // current tree number and going forwards,
1311  // then wrapping around at the end.
1312  for (treenum = 0; treenum < fNtrees; treenum++) {
1313  if (entry < fTreeOffset[treenum+1]) {
1314  break;
1315  }
1316  }
1317  }
1318 
1319  // Calculate the entry number relative to the found tree.
1320  Long64_t treeReadEntry = entry - fTreeOffset[treenum];
1321  fReadEntry = entry;
1322 
1323  // If entry belongs to the current tree return entry.
1324  if (fTree && treenum == fTreeNumber) {
1325  // First set the entry the tree on its owns friends
1326  // (the friends of the chain will be updated in the
1327  // next loop).
1328  fTree->LoadTree(treeReadEntry);
1329  if (fFriends) {
1330  // The current tree has not changed but some of its friends might.
1331  //
1332  TIter next(fFriends);
1333  TFriendLock lock(this, kLoadTree);
1334  TFriendElement* fe = 0;
1335  while ((fe = (TFriendElement*) next())) {
1336  TTree* at = fe->GetTree();
1337  // If the tree is a
1338  // direct friend of the chain, it should be scanned
1339  // used the chain entry number and NOT the tree entry
1340  // number (treeReadEntry) hence we do:
1341  at->LoadTreeFriend(entry, this);
1342  }
1343  Bool_t needUpdate = kFALSE;
1344  if (fTree->GetListOfFriends()) {
1346  if (fetree->IsUpdated()) {
1347  needUpdate = kTRUE;
1348  fetree->ResetUpdated();
1349  }
1350  }
1351  }
1352  if (needUpdate) {
1353  // Update the branch/leaf addresses and
1354  // thelist of leaves in all TTreeFormula of the TTreePlayer (if any).
1355 
1356  // Set the branch statuses for the newly opened file.
1357  TChainElement *frelement;
1358  TIter fnext(fStatus);
1359  while ((frelement = (TChainElement*) fnext())) {
1360  Int_t status = frelement->GetStatus();
1361  fTree->SetBranchStatus(frelement->GetName(), status);
1362  }
1363 
1364  // Set the branch addresses for the newly opened file.
1365  fnext.Reset();
1366  while ((frelement = (TChainElement*) fnext())) {
1367  void* addr = frelement->GetBaddress();
1368  if (addr) {
1369  TBranch* br = fTree->GetBranch(frelement->GetName());
1370  TBranch** pp = frelement->GetBranchPtr();
1371  if (pp) {
1372  // FIXME: What if br is zero here?
1373  *pp = br;
1374  }
1375  if (br) {
1376  if (!frelement->GetCheckedType()) {
1378  (EDataType) frelement->GetBaddressType(), frelement->GetBaddressIsPtr());
1379  if ((res & kNeedEnableDecomposedObj) && !br->GetMakeClass()) {
1380  br->SetMakeClass(kTRUE);
1381  }
1382  frelement->SetDecomposedObj(br->GetMakeClass());
1383  frelement->SetCheckedType(kTRUE);
1384  }
1385  // FIXME: We may have to tell the branch it should
1386  // not be an owner of the object pointed at.
1387  br->SetAddress(addr);
1388  if (TestBit(kAutoDelete)) {
1389  br->SetAutoDelete(kTRUE);
1390  }
1391  }
1392  }
1393  }
1394  if (fPlayer) {
1396  }
1397  // Notify user if requested.
1398  if (fNotify) {
1399  if(!fNotify->Notify()) return -6;
1400  }
1401  }
1402  }
1403  return treeReadEntry;
1404  }
1405 
1406  if (fExternalFriends) {
1408  external_fe->MarkUpdated();
1409  }
1410  }
1411 
1412  // Delete the current tree and open the new tree.
1413  TTreeCache* tpf = 0;
1414  // Delete file unless the file owns this chain!
1415  // FIXME: The "unless" case here causes us to leak memory.
1416  if (fFile) {
1417  if (!fDirectory->GetList()->FindObject(this)) {
1418  if (fTree) {
1419  // (fFile != 0 && fTree == 0) can happen when
1420  // InvalidateCurrentTree is called (for example from
1421  // AddFriend). Having fTree === 0 is necessary in that
1422  // case because in some cases GetTree is used as a check
1423  // to see if a TTree is already loaded.
1424  // However, this prevent using the following to reuse
1425  // the TTreeCache object.
1426  tpf = fTree->GetReadCache(fFile);
1427  if (tpf) {
1428  tpf->ResetCache();
1429  }
1430 
1431  fFile->SetCacheRead(0, fTree);
1432  // If the tree has clones, copy them into the chain
1433  // clone list so we can change their branch addresses
1434  // when necessary.
1435  //
1436  // This is to support the syntax:
1437  //
1438  // TTree* clone = chain->GetTree()->CloneTree(0);
1439  //
1440  // We need to call the invalidate exactly here, since
1441  // we no longer need the value of fTree and it is
1442  // about to be deleted.
1444  }
1445 
1446  if (fCanDeleteRefs) {
1447  fFile->Close("R");
1448  }
1449  delete fFile;
1450  fFile = 0;
1451  } else {
1452  // If the tree has clones, copy them into the chain
1453  // clone list so we can change their branch addresses
1454  // when necessary.
1455  //
1456  // This is to support the syntax:
1457  //
1458  // TTree* clone = chain->GetTree()->CloneTree(0);
1459  //
1461  }
1462  }
1463 
1464  TChainElement* element = (TChainElement*) fFiles->At(treenum);
1465  if (!element) {
1466  if (treeReadEntry) {
1467  return -4;
1468  }
1469  // Last attempt, just in case all trees in the chain have 0 entries.
1470  element = (TChainElement*) fFiles->At(0);
1471  if (!element) {
1472  return -4;
1473  }
1474  }
1475 
1476  // FIXME: We leak memory here, we've just lost the open file
1477  // if we did not delete it above.
1478  {
1479  TDirectory::TContext ctxt;
1480  fFile = TFile::Open(element->GetTitle());
1481  if (fFile) fFile->SetBit(kMustCleanup);
1482  }
1483 
1484  // ----- Begin of modifications by MvL
1485  Int_t returnCode = 0;
1486  if (!fFile || fFile->IsZombie()) {
1487  if (fFile) {
1488  delete fFile;
1489  fFile = 0;
1490  }
1491  // Note: We do *not* own fTree.
1492  fTree = 0;
1493  returnCode = -3;
1494  } else {
1495  // Note: We do *not* own fTree after this, the file does!
1496  fTree = dynamic_cast<TTree*>(fFile->Get(element->GetName()));
1497  if (!fTree) {
1498  // Now that we do not check during the addition, we need to check here!
1499  Error("LoadTree", "Cannot find tree with name %s in file %s", element->GetName(), element->GetTitle());
1500  delete fFile;
1501  fFile = 0;
1502  // We do not return yet so that 'fEntries' can be updated with the
1503  // sum of the entries of all the other trees.
1504  returnCode = -4;
1505  }
1506  }
1507 
1508  fTreeNumber = treenum;
1509  // FIXME: We own fFile, we must be careful giving away a pointer to it!
1510  // FIXME: We may set fDirectory to zero here!
1511  fDirectory = fFile;
1512 
1513  // Reuse cache from previous file (if any).
1514  if (tpf) {
1515  if (fFile) {
1516  // FIXME: fTree may be zero here.
1517  tpf->UpdateBranches(fTree);
1518  tpf->ResetCache();
1519  fFile->SetCacheRead(tpf, fTree);
1520  } else {
1521  // FIXME: One of the file in the chain is missing
1522  // we have no place to hold the pointer to the
1523  // TTreeCache.
1524  delete tpf;
1525  tpf = 0;
1526  }
1527  } else {
1528  if (fCacheUserSet) {
1529  this->SetCacheSize(fCacheSize);
1530  }
1531  }
1532 
1533  // Check if fTreeOffset has really been set.
1534  Long64_t nentries = 0;
1535  if (fTree) {
1536  nentries = fTree->GetEntries();
1537  }
1538 
1542  element->SetNumberEntries(nentries);
1543  // Below we must test >= in case the tree has no entries.
1544  if (entry >= fTreeOffset[fTreeNumber+1]) {
1545  if ((fTreeNumber < (fNtrees - 1)) && (entry < fTreeOffset[fTreeNumber+2])) {
1546  // The request entry is not in the tree 'fTreeNumber' we will need
1547  // to look further.
1548 
1549  // Before moving on, let's record the result.
1550  element->SetLoadResult(returnCode);
1551 
1552  // Before trying to read the file file/tree, notify the user
1553  // that we have switched trees if requested; the user might need
1554  // to properly account for the number of files/trees even if they
1555  // have no entries.
1556  if (fNotify) {
1557  if(!fNotify->Notify()) return -6;
1558  }
1559 
1560  // Load the next TTree.
1561  return LoadTree(entry);
1562  } else {
1563  treeReadEntry = fReadEntry = -2;
1564  }
1565  }
1566  }
1567 
1568 
1569  if (!fTree) {
1570  // The Error message already issued. However if we reach here
1571  // we need to make sure that we do not use fTree.
1572  //
1573  // Force a reload of the tree next time.
1574  fTreeNumber = -1;
1575 
1576  element->SetLoadResult(returnCode);
1577  return returnCode;
1578  }
1579  // ----- End of modifications by MvL
1580 
1581  // Copy the chain's clone list into the new tree's
1582  // clone list so that branch addresses stay synchronized.
1583  if (fClones) {
1584  for (TObjLink* lnk = fClones->FirstLink(); lnk; lnk = lnk->Next()) {
1585  TTree* clone = (TTree*) lnk->GetObject();
1586  ((TChain*) fTree)->TTree::AddClone(clone);
1587  }
1588  }
1589 
1590  // Since some of the friends of this chain might simple trees
1591  // (i.e., not really chains at all), we need to execute this
1592  // before calling LoadTree(entry) on the friends (so that
1593  // they use the correct read entry number).
1594 
1595  // Change the new current tree to the new entry.
1596  Long64_t loadResult = fTree->LoadTree(treeReadEntry);
1597  if (loadResult == treeReadEntry) {
1598  element->SetLoadResult(0);
1599  } else {
1600  // This is likely to be an internal error, if treeReadEntry was not in range
1601  // (or intentionally -2 for TChain::GetEntries) then something happened
1602  // that is very odd/surprising.
1603  element->SetLoadResult(-5);
1604  }
1605 
1606 
1607  // Change the chain friends to the new entry.
1608  if (fFriends) {
1609  // An alternative would move this code to each of the function
1610  // calling LoadTree (and to overload a few more).
1611  TIter next(fFriends);
1612  TFriendLock lock(this, kLoadTree);
1613  TFriendElement* fe = 0;
1614  while ((fe = (TFriendElement*) next())) {
1615  TTree* t = fe->GetTree();
1616  if (!t) continue;
1617  if (t->GetTreeIndex()) {
1619  }
1620  if (t->GetTree() && t->GetTree()->GetTreeIndex()) {
1622  }
1623  t->LoadTreeFriend(entry, this);
1624  TTree* friend_t = t->GetTree();
1625  if (friend_t) {
1626  auto localfe = fTree->AddFriend(t, fe->GetName());
1628  }
1629  }
1630  }
1631 
1634 
1636 
1637  // Set the branch statuses for the newly opened file.
1638  TIter next(fStatus);
1639  while ((element = (TChainElement*) next())) {
1640  Int_t status = element->GetStatus();
1641  fTree->SetBranchStatus(element->GetName(), status);
1642  }
1643 
1644  // Set the branch addresses for the newly opened file.
1645  next.Reset();
1646  while ((element = (TChainElement*) next())) {
1647  void* addr = element->GetBaddress();
1648  if (addr) {
1649  TBranch* br = fTree->GetBranch(element->GetName());
1650  TBranch** pp = element->GetBranchPtr();
1651  if (pp) {
1652  // FIXME: What if br is zero here?
1653  *pp = br;
1654  }
1655  if (br) {
1656  if (!element->GetCheckedType()) {
1658  (EDataType) element->GetBaddressType(), element->GetBaddressIsPtr());
1659  if ((res & kNeedEnableDecomposedObj) && !br->GetMakeClass()) {
1660  br->SetMakeClass(kTRUE);
1661  }
1662  element->SetDecomposedObj(br->GetMakeClass());
1663  element->SetCheckedType(kTRUE);
1664  }
1665  // FIXME: We may have to tell the branch it should
1666  // not be an owner of the object pointed at.
1667  br->SetAddress(addr);
1668  if (TestBit(kAutoDelete)) {
1669  br->SetAutoDelete(kTRUE);
1670  }
1671  }
1672  }
1673  }
1674 
1675  // Update the addresses of the chain's cloned trees, if any.
1676  if (fClones) {
1677  for (TObjLink* lnk = fClones->FirstLink(); lnk; lnk = lnk->Next()) {
1678  TTree* clone = (TTree*) lnk->GetObject();
1679  CopyAddresses(clone);
1680  }
1681  }
1682 
1683  // Update list of leaves in all TTreeFormula's of the TTreePlayer (if any).
1684  if (fPlayer) {
1686  }
1687 
1688  // Notify user we have switched trees if requested.
1689  if (fNotify) {
1690  if(!fNotify->Notify()) return -6;
1691  }
1692 
1693  // Return the new local entry number.
1694  return treeReadEntry;
1695 }
1696 
1697 ////////////////////////////////////////////////////////////////////////////////
1698 /// Check / locate the files in the chain.
1699 /// By default only the files not yet looked up are checked.
1700 /// Use force = kTRUE to check / re-check every file.
1701 
1703 {
1704  TIter next(fFiles);
1705  TChainElement* element = 0;
1706  Int_t nelements = fFiles->GetEntries();
1707  printf("\n");
1708  printf("TChain::Lookup - Looking up %d files .... \n", nelements);
1709  Int_t nlook = 0;
1710  TFileStager *stg = 0;
1711  while ((element = (TChainElement*) next())) {
1712  // Do not do it more than needed
1713  if (element->HasBeenLookedUp() && !force) continue;
1714  // Count
1715  nlook++;
1716  // Get the Url
1717  TUrl elemurl(element->GetTitle(), kTRUE);
1718  // Save current options and anchor
1719  TString anchor = elemurl.GetAnchor();
1720  TString options = elemurl.GetOptions();
1721  // Reset options and anchor
1722  elemurl.SetOptions("");
1723  elemurl.SetAnchor("");
1724  // Locate the file
1725  TString eurl(elemurl.GetUrl());
1726  if (!stg || !stg->Matches(eurl)) {
1727  SafeDelete(stg);
1728  {
1729  TDirectory::TContext ctxt;
1730  stg = TFileStager::Open(eurl);
1731  }
1732  if (!stg) {
1733  Error("Lookup", "TFileStager instance cannot be instantiated");
1734  break;
1735  }
1736  }
1737  Int_t n1 = (nelements > 100) ? (Int_t) nelements / 100 : 1;
1738  if (stg->Locate(eurl.Data(), eurl) == 0) {
1739  if (nlook > 0 && !(nlook % n1)) {
1740  printf("Lookup | %3d %% finished\r", 100 * nlook / nelements);
1741  fflush(stdout);
1742  }
1743  // Get the effective end-point Url
1744  elemurl.SetUrl(eurl);
1745  // Restore original options and anchor, if any
1746  elemurl.SetOptions(options);
1747  elemurl.SetAnchor(anchor);
1748  // Save it into the element
1749  element->SetTitle(elemurl.GetUrl());
1750  // Remember
1751  element->SetLookedUp();
1752  } else {
1753  // Failure: remove
1754  fFiles->Remove(element);
1755  if (gSystem->AccessPathName(eurl))
1756  Error("Lookup", "file %s does not exist\n", eurl.Data());
1757  else
1758  Error("Lookup", "file %s cannot be read\n", eurl.Data());
1759  }
1760  }
1761  if (nelements > 0)
1762  printf("Lookup | %3d %% finished\n", 100 * nlook / nelements);
1763  else
1764  printf("\n");
1765  fflush(stdout);
1766  SafeDelete(stg);
1767 }
1768 
1769 ////////////////////////////////////////////////////////////////////////////////
1770 /// Loop on nentries of this chain starting at firstentry. (NOT IMPLEMENTED)
1771 
1772 void TChain::Loop(Option_t* option, Long64_t nentries, Long64_t firstentry)
1773 {
1774  Error("Loop", "Function not yet implemented");
1775 
1776  if (option || nentries || firstentry) { } // keep warnings away
1777 
1778 #if 0
1779  if (LoadTree(firstentry) < 0) return;
1780 
1781  if (firstentry < 0) firstentry = 0;
1782  Long64_t lastentry = firstentry + nentries -1;
1783  if (lastentry > fEntries-1) {
1784  lastentry = fEntries -1;
1785  }
1786 
1787  GetPlayer();
1788  GetSelector();
1789  fSelector->Start(option);
1790 
1791  Long64_t entry = firstentry;
1792  Int_t tree,e0,en;
1793  for (tree=0;tree<fNtrees;tree++) {
1794  e0 = fTreeOffset[tree];
1795  en = fTreeOffset[tree+1] - 1;
1796  if (en > lastentry) en = lastentry;
1797  if (entry > en) continue;
1798 
1799  LoadTree(entry);
1800  fSelector->BeginFile();
1801 
1802  while (entry <= en) {
1803  fSelector->Execute(fTree, entry - e0);
1804  entry++;
1805  }
1806  fSelector->EndFile();
1807  }
1808 
1809  fSelector->Finish(option);
1810 #endif
1811 }
1812 
1813 ////////////////////////////////////////////////////////////////////////////////
1814 /// List the chain.
1815 
1816 void TChain::ls(Option_t* option) const
1817 {
1818  TObject::ls(option);
1819  TIter next(fFiles);
1820  TChainElement* file = 0;
1822  while ((file = (TChainElement*)next())) {
1823  file->ls(option);
1824  }
1826 }
1827 
1828 ////////////////////////////////////////////////////////////////////////////////
1829 /// Merge all the entries in the chain into a new tree in a new file.
1830 ///
1831 /// See important note in the following function Merge().
1832 ///
1833 /// If the chain is expecting the input tree inside a directory,
1834 /// this directory is NOT created by this routine.
1835 ///
1836 /// So in a case where we have:
1837 /// ~~~ {.cpp}
1838 /// TChain ch("mydir/mytree");
1839 /// ch.Merge("newfile.root");
1840 /// ~~~
1841 /// The resulting file will have not subdirectory. To recreate
1842 /// the directory structure do:
1843 /// ~~~ {.cpp}
1844 /// TFile* file = TFile::Open("newfile.root", "RECREATE");
1845 /// file->mkdir("mydir")->cd();
1846 /// ch.Merge(file);
1847 /// ~~~
1848 
1849 Long64_t TChain::Merge(const char* name, Option_t* option)
1850 {
1851  TFile *file = TFile::Open(name, "recreate", "chain files", 1);
1852  return Merge(file, 0, option);
1853 }
1854 
1855 ////////////////////////////////////////////////////////////////////////////////
1856 /// Merge all chains in the collection. (NOT IMPLEMENTED)
1857 
1858 Long64_t TChain::Merge(TCollection* /* list */, Option_t* /* option */ )
1859 {
1860  Error("Merge", "not implemented");
1861  return -1;
1862 }
1863 
1864 ////////////////////////////////////////////////////////////////////////////////
1865 /// Merge all chains in the collection. (NOT IMPLEMENTED)
1866 
1868 {
1869  Error("Merge", "not implemented");
1870  return -1;
1871 }
1872 
1873 ////////////////////////////////////////////////////////////////////////////////
1874 /// Merge all the entries in the chain into a new tree in the current file.
1875 ///
1876 /// Note: The "file" parameter is *not* the file where the new
1877 /// tree will be inserted. The new tree is inserted into
1878 /// gDirectory, which is usually the most recently opened
1879 /// file, or the directory most recently cd()'d to.
1880 ///
1881 /// If option = "C" is given, the compression level for all branches
1882 /// in the new Tree is set to the file compression level. By default,
1883 /// the compression level of all branches is the original compression
1884 /// level in the old trees.
1885 ///
1886 /// If basketsize > 1000, the basket size for all branches of the
1887 /// new tree will be set to basketsize.
1888 ///
1889 /// Example using the file generated in $ROOTSYS/test/Event
1890 /// merge two copies of Event.root
1891 /// ~~~ {.cpp}
1892 /// gSystem.Load("libEvent");
1893 /// TChain ch("T");
1894 /// ch.Add("Event1.root");
1895 /// ch.Add("Event2.root");
1896 /// ch.Merge("all.root");
1897 /// ~~~
1898 /// If the chain is expecting the input tree inside a directory,
1899 /// this directory is NOT created by this routine.
1900 ///
1901 /// So if you do:
1902 /// ~~~ {.cpp}
1903 /// TChain ch("mydir/mytree");
1904 /// ch.Merge("newfile.root");
1905 /// ~~~
1906 /// The resulting file will not have subdirectories. In order to
1907 /// preserve the directory structure do the following instead:
1908 /// ~~~ {.cpp}
1909 /// TFile* file = TFile::Open("newfile.root", "RECREATE");
1910 /// file->mkdir("mydir")->cd();
1911 /// ch.Merge(file);
1912 /// ~~~
1913 /// If 'option' contains the word 'fast' the merge will be done without
1914 /// unzipping or unstreaming the baskets (i.e., a direct copy of the raw
1915 /// bytes on disk).
1916 ///
1917 /// When 'fast' is specified, 'option' can also contains a
1918 /// sorting order for the baskets in the output file.
1919 ///
1920 /// There is currently 3 supported sorting order:
1921 /// ~~~ {.cpp}
1922 /// SortBasketsByOffset (the default)
1923 /// SortBasketsByBranch
1924 /// SortBasketsByEntry
1925 /// ~~~
1926 /// When using SortBasketsByOffset the baskets are written in
1927 /// the output file in the same order as in the original file
1928 /// (i.e. the basket are sorted on their offset in the original
1929 /// file; Usually this also means that the baskets are sorted
1930 /// on the index/number of the _last_ entry they contain)
1931 ///
1932 /// When using SortBasketsByBranch all the baskets of each
1933 /// individual branches are stored contiguously. This tends to
1934 /// optimize reading speed when reading a small number (1->5) of
1935 /// branches, since all their baskets will be clustered together
1936 /// instead of being spread across the file. However it might
1937 /// decrease the performance when reading more branches (or the full
1938 /// entry).
1939 ///
1940 /// When using SortBasketsByEntry the baskets with the lowest
1941 /// starting entry are written first. (i.e. the baskets are
1942 /// sorted on the index/number of the first entry they contain).
1943 /// This means that on the file the baskets will be in the order
1944 /// in which they will be needed when reading the whole tree
1945 /// sequentially.
1946 ///
1947 /// ## IMPORTANT Note 1: AUTOMATIC FILE OVERFLOW
1948 ///
1949 /// When merging many files, it may happen that the resulting file
1950 /// reaches a size > TTree::fgMaxTreeSize (default = 100 GBytes).
1951 /// In this case the current file is automatically closed and a new
1952 /// file started. If the name of the merged file was "merged.root",
1953 /// the subsequent files will be named "merged_1.root", "merged_2.root",
1954 /// etc. fgMaxTreeSize may be modified via the static function
1955 /// TTree::SetMaxTreeSize.
1956 /// When in fast mode, the check and switch is only done in between each
1957 /// input file.
1958 ///
1959 /// ## IMPORTANT Note 2: The output file is automatically closed and deleted.
1960 ///
1961 /// This is required because in general the automatic file overflow described
1962 /// above may happen during the merge.
1963 /// If only the current file is produced (the file passed as first argument),
1964 /// one can instruct Merge to not close and delete the file by specifying
1965 /// the option "keep".
1966 ///
1967 /// The function returns the total number of files produced.
1968 /// To check that all files have been merged use something like:
1969 /// ~~~ {.cpp}
1970 /// if (newchain->GetEntries()!=oldchain->GetEntries()) {
1971 /// ... not all the file have been copied ...
1972 /// }
1973 /// ~~~
1974 
1976 {
1977  // We must have been passed a file, we will use it
1978  // later to reset the compression level of the branches.
1979  if (!file) {
1980  // FIXME: We need an error message here.
1981  return 0;
1982  }
1983 
1984  // Options
1985  Bool_t fastClone = kFALSE;
1986  TString opt = option;
1987  opt.ToLower();
1988  if (opt.Contains("fast")) {
1989  fastClone = kTRUE;
1990  }
1991 
1992  // The chain tree must have a list of branches
1993  // because we may try to change their basket
1994  // size later.
1995  TObjArray* lbranches = GetListOfBranches();
1996  if (!lbranches) {
1997  // FIXME: We need an error message here.
1998  return 0;
1999  }
2000 
2001  // The chain must have a current tree because
2002  // that is the one we will clone.
2003  if (!fTree) {
2004  // -- LoadTree() has not yet been called, no current tree.
2005  // FIXME: We need an error message here.
2006  return 0;
2007  }
2008 
2009  // Copy the chain's current tree without
2010  // copying any entries, we will do that later.
2011  TTree* newTree = CloneTree(0);
2012  if (!newTree) {
2013  // FIXME: We need an error message here.
2014  return 0;
2015  }
2016 
2017  // Strip out the (potential) directory name.
2018  // FIXME: The merged chain may or may not have the
2019  // same name as the original chain. This is
2020  // bad because the chain name determines the
2021  // names of the trees in the chain by default.
2022  newTree->SetName(gSystem->BaseName(GetName()));
2023 
2024  // FIXME: Why do we do this?
2025  newTree->SetAutoSave(2000000000);
2026 
2027  // Circularity is incompatible with merging, it may
2028  // force us to throw away entries, which is not what
2029  // we are supposed to do.
2030  newTree->SetCircular(0);
2031 
2032  // Reset the compression level of the branches.
2033  if (opt.Contains("c")) {
2034  TBranch* branch = 0;
2035  TIter nextb(newTree->GetListOfBranches());
2036  while ((branch = (TBranch*) nextb())) {
2037  branch->SetCompressionSettings(file->GetCompressionSettings());
2038  }
2039  }
2040 
2041  // Reset the basket size of the branches.
2042  if (basketsize > 1000) {
2043  TBranch* branch = 0;
2044  TIter nextb(newTree->GetListOfBranches());
2045  while ((branch = (TBranch*) nextb())) {
2046  branch->SetBasketSize(basketsize);
2047  }
2048  }
2049 
2050  // Copy the entries.
2051  if (fastClone) {
2052  if ( newTree->CopyEntries( this, -1, option ) < 0 ) {
2053  // There was a problem!
2054  Error("Merge", "TTree has not been cloned\n");
2055  }
2056  } else {
2057  newTree->CopyEntries( this, -1, option );
2058  }
2059 
2060  // Write the new tree header.
2061  newTree->Write();
2062 
2063  // Get our return value.
2064  Int_t nfiles = newTree->GetFileNumber() + 1;
2065 
2066  // Close and delete the current file of the new tree.
2067  if (!opt.Contains("keep")) {
2068  // Delete the currentFile and the TTree object.
2069  delete newTree->GetCurrentFile();
2070  }
2071  return nfiles;
2072 }
2073 
2074 ////////////////////////////////////////////////////////////////////////////////
2075 /// Get the tree url or filename and other information from the name
2076 ///
2077 /// A treename and a url's query section is split off from name. The
2078 /// splitting depends on whether the resulting filename is to be
2079 /// subsequently treated for wildcards or not, since the question mark is
2080 /// both the url query identifier and a wildcard. Wildcard matching is not
2081 /// done in this method itself.
2082 /// ~~~ {.cpp}
2083 /// [xxx://host]/a/path/file_name[?query[#treename]]
2084 /// ~~~
2085 ///
2086 /// The following way to specify the treename is still supported with the
2087 /// constrain that the file name contains the sub-string '.root'.
2088 /// This is now deprecated and will be removed in future versions.
2089 /// ~~~ {.cpp}
2090 /// [xxx://host]/a/path/file.root[.oext][/treename]
2091 /// [xxx://host]/a/path/file.root[.oext][/treename][?query]
2092 /// ~~~
2093 ///
2094 /// Note that in a case like this
2095 /// ~~~ {.cpp}
2096 /// [xxx://host]/a/path/file#treename
2097 /// ~~~
2098 /// i.e. anchor but no options (query), the filename will be the full path, as
2099 /// the anchor may be the internal file name of an archive. Use '?#treename' to
2100 /// pass the treename if the query field is empty.
2101 ///
2102 /// \param[in] name is the original name
2103 /// \param[in] wildcards indicates if the resulting filename will be treated for
2104 /// wildcards. For backwards compatibility, with most protocols
2105 /// this flag suppresses the search for the url fragment
2106 /// identifier and limits the query identifier search to cases
2107 /// where the tree name is given as a trailing slash-separated
2108 /// string at the end of the file name.
2109 /// \param[out] filename the url or filename to be opened or matched
2110 /// \param[out] treename the treename, which may be found in a url fragment section
2111 /// as a trailing part of the name (deprecated).
2112 /// If not found this will be empty.
2113 /// \param[out] query is the url query section, including the leading question
2114 /// mark. If not found or the query section is only followed by
2115 /// a fragment this will be empty.
2116 /// \param[out] suffix the portion of name which was removed to from filename.
2117 
2118 void TChain::ParseTreeFilename(const char *name, TString &filename, TString &treename, TString &query, TString &suffix,
2119  Bool_t) const
2120 {
2121  Ssiz_t pIdx = kNPOS;
2122  filename.Clear();
2123  treename.Clear();
2124  query.Clear();
2125  suffix.Clear();
2126 
2127  // General case
2128  TUrl url(name, kTRUE);
2129  filename = (strcmp(url.GetProtocol(), "file")) ? url.GetUrl() : url.GetFileAndOptions();
2130 
2131  TString fn = url.GetFile();
2132  // Extract query, if any
2133  if (url.GetOptions() && (strlen(url.GetOptions()) > 0))
2134  query.Form("?%s", url.GetOptions());
2135  // The treename can be passed as anchor
2136  if (url.GetAnchor() && (strlen(url.GetAnchor()) > 0)) {
2137  // Support "?#tree_name" and "?query#tree_name"
2138  // "#tree_name" (no '?' is for tar archives)
2139  if (!query.IsNull() || strstr(name, "?#")) {
2140  treename = url.GetAnchor();
2141  } else {
2142  // The anchor is part of the file name
2143  fn = url.GetFileAndOptions();
2144  }
2145  }
2146  // Suffix
2147  suffix = url.GetFileAndOptions();
2148  // Get options from suffix by removing the file name
2149  suffix.Replace(suffix.Index(fn), fn.Length(), "");
2150  // Remove the options suffix from the original file name
2151  filename.Replace(filename.Index(suffix), suffix.Length(), "");
2152 
2153  // Special case: [...]file.root/treename
2154  static const char *dotr = ".root";
2155  static Ssiz_t dotrl = strlen(dotr);
2156  // Find the last one
2157  Ssiz_t js = filename.Index(dotr);
2158  while (js != kNPOS) {
2159  pIdx = js;
2160  js = filename.Index(dotr, js + 1);
2161  }
2162  if (pIdx != kNPOS) {
2163  static const char *slash = "/";
2164  static Ssiz_t slashl = strlen(slash);
2165  // Find the last one
2166  Ssiz_t ppIdx = filename.Index(slash, pIdx + dotrl);
2167  if (ppIdx != kNPOS) {
2168  // Good treename with the old receipe
2169  treename = filename(ppIdx + slashl, filename.Length());
2170  filename.Remove(ppIdx + slashl - 1);
2171  suffix.Insert(0, TString::Format("/%s", treename.Data()));
2172  }
2173  }
2174 }
2175 
2176 ////////////////////////////////////////////////////////////////////////////////
2177 /// Print the header information of each tree in the chain.
2178 /// See TTree::Print for a list of options.
2179 
2180 void TChain::Print(Option_t *option) const
2181 {
2182  TIter next(fFiles);
2183  TChainElement *element;
2184  while ((element = (TChainElement*)next())) {
2185  Printf("******************************************************************************");
2186  Printf("*Chain :%-10s: %-54s *", GetName(), element->GetTitle());
2187  Printf("******************************************************************************");
2188  TFile *file = TFile::Open(element->GetTitle());
2189  if (file && !file->IsZombie()) {
2190  TTree *tree = (TTree*)file->Get(element->GetName());
2191  if (tree) tree->Print(option);
2192  }
2193  delete file;
2194  }
2195 }
2196 
2197 ////////////////////////////////////////////////////////////////////////////////
2198 /// Process all entries in this chain, calling functions in filename.
2199 /// The return value is -1 in case of error and TSelector::GetStatus() in
2200 /// in case of success.
2201 /// See TTree::Process.
2202 
2203 Long64_t TChain::Process(const char *filename, Option_t *option, Long64_t nentries, Long64_t firstentry)
2204 {
2205  if (fProofChain) {
2206  // Make sure the element list is uptodate
2207  if (!TestBit(kProofUptodate))
2208  SetProof(kTRUE, kTRUE);
2211  return fProofChain->Process(filename, option, nentries, firstentry);
2212  }
2213 
2214  if (LoadTree(firstentry) < 0) {
2215  return 0;
2216  }
2217  return TTree::Process(filename, option, nentries, firstentry);
2218 }
2219 
2220 ////////////////////////////////////////////////////////////////////////////////
2221 /// Process this chain executing the code in selector.
2222 /// The return value is -1 in case of error and TSelector::GetStatus() in
2223 /// in case of success.
2224 
2226 {
2227  if (fProofChain) {
2228  // Make sure the element list is uptodate
2229  if (!TestBit(kProofUptodate))
2230  SetProof(kTRUE, kTRUE);
2233  return fProofChain->Process(selector, option, nentries, firstentry);
2234  }
2235 
2236  return TTree::Process(selector, option, nentries, firstentry);
2237 }
2238 
2239 ////////////////////////////////////////////////////////////////////////////////
2240 /// Make sure that obj (which is being deleted or will soon be) is no
2241 /// longer referenced by this TTree.
2242 
2244 {
2245  if (fFile == obj) {
2246  fFile = 0;
2247  fDirectory = 0;
2248  fTree = 0;
2249  }
2250  if (fDirectory == obj) {
2251  fDirectory = 0;
2252  fTree = 0;
2253  }
2254  if (fTree == obj) {
2255  fTree = 0;
2256  }
2257 }
2258 
2259 ////////////////////////////////////////////////////////////////////////////////
2260 /// Remove a friend from the list of friends.
2261 
2262 void TChain::RemoveFriend(TTree* oldFriend)
2263 {
2264  // We already have been visited while recursively looking
2265  // through the friends tree, let return
2266 
2267  if (!fFriends) {
2268  return;
2269  }
2270 
2271  TTree::RemoveFriend(oldFriend);
2272 
2273  if (fProofChain)
2274  // This updates the proxy chain when we will really use PROOF
2276 
2277  // We need to invalidate the loading of the current tree because its list
2278  // of real friends is now obsolete. It is repairable only from LoadTree.
2280 }
2281 
2282 ////////////////////////////////////////////////////////////////////////////////
2283 /// Resets the state of this chain.
2284 
2286 {
2287  delete fFile;
2288  fFile = 0;
2289  fNtrees = 0;
2290  fTreeNumber = -1;
2291  fTree = 0;
2292  fFile = 0;
2293  fFiles->Delete();
2294  fStatus->Delete();
2295  fTreeOffset[0] = 0;
2296  TChainElement* element = new TChainElement("*", "");
2297  fStatus->Add(element);
2298  fDirectory = 0;
2299 
2300  TTree::Reset();
2301 }
2302 
2303 ////////////////////////////////////////////////////////////////////////////////
2304 /// Resets the state of this chain after a merge (keep the customization but
2305 /// forget the data).
2306 
2308 {
2309  fNtrees = 0;
2310  fTreeNumber = -1;
2311  fTree = 0;
2312  fFile = 0;
2313  fFiles->Delete();
2314  fTreeOffset[0] = 0;
2315 
2316  TTree::ResetAfterMerge(info);
2317 }
2318 
2319 ////////////////////////////////////////////////////////////////////////////////
2320 /// Save TChain as a C++ statements on output stream out.
2321 /// With the option "friend" save the description of all the
2322 /// TChain's friend trees or chains as well.
2323 
2324 void TChain::SavePrimitive(std::ostream &out, Option_t *option)
2325 {
2326  static Int_t chCounter = 0;
2327 
2328  TString chName = gInterpreter->MapCppName(GetName());
2329  if (chName.IsNull())
2330  chName = "_chain";
2331  ++chCounter;
2332  chName += chCounter;
2333 
2334  TString opt = option;
2335  opt.ToLower();
2336 
2337  out << " TChain *" << chName.Data() << " = new TChain(\"" << GetName() << "\");" << std::endl;
2338 
2339  if (opt.Contains("friend")) {
2340  opt.ReplaceAll("friend", "");
2341  for (TObject *frel : *fFriends) {
2342  TTree *frtree = ((TFriendElement *)frel)->GetTree();
2343  if (dynamic_cast<TChain *>(frtree)) {
2344  if (strcmp(frtree->GetName(), GetName()) != 0)
2345  --chCounter; // make friends get the same chain counter
2346  frtree->SavePrimitive(out, opt.Data());
2347  out << " " << chName.Data() << "->AddFriend(\"" << frtree->GetName() << "\");" << std::endl;
2348  } else { // ordinary friend TTree
2349  TDirectory *file = frtree->GetDirectory();
2350  if (file && dynamic_cast<TFile *>(file))
2351  out << " " << chName.Data() << "->AddFriend(\"" << frtree->GetName() << "\", \"" << file->GetName()
2352  << "\");" << std::endl;
2353  }
2354  }
2355  }
2356  out << std::endl;
2357 
2358  for (TObject *el : *fFiles) {
2359  TChainElement *chel = (TChainElement *)el;
2360  // Save tree file if it is really loaded to the chain
2361  if (chel->GetLoadResult() == 0 && chel->GetEntries() != 0) {
2362  if (chel->GetEntries() == TTree::kMaxEntries) // tree number of entries is not yet known
2363  out << " " << chName.Data() << "->AddFile(\"" << chel->GetTitle() << "\");" << std::endl;
2364  else
2365  out << " " << chName.Data() << "->AddFile(\"" << chel->GetTitle() << "\"," << chel->GetEntries() << ");"
2366  << std::endl;
2367  }
2368  }
2369  out << std::endl;
2370 
2371  if (GetMarkerColor() != 1) {
2372  if (GetMarkerColor() > 228) {
2374  out << " " << chName.Data() << "->SetMarkerColor(ci);" << std::endl;
2375  } else
2376  out << " " << chName.Data() << "->SetMarkerColor(" << GetMarkerColor() << ");" << std::endl;
2377  }
2378  if (GetMarkerStyle() != 1) {
2379  out << " " << chName.Data() << "->SetMarkerStyle(" << GetMarkerStyle() << ");" << std::endl;
2380  }
2381  if (GetMarkerSize() != 1) {
2382  out << " " << chName.Data() << "->SetMarkerSize(" << GetMarkerSize() << ");" << std::endl;
2383  }
2384 }
2385 
2386 ////////////////////////////////////////////////////////////////////////////////
2387 /// Loop on tree and print entries passing selection.
2388 /// - If varexp is 0 (or "") then print only first 8 columns.
2389 /// - If varexp = "*" print all columns.
2390 /// - Otherwise a columns selection can be made using "var1:var2:var3".
2391 /// See TTreePlayer::Scan for more information.
2392 
2393 Long64_t TChain::Scan(const char* varexp, const char* selection, Option_t* option, Long64_t nentries, Long64_t firstentry)
2394 {
2395  if (LoadTree(firstentry) < 0) {
2396  return 0;
2397  }
2398  return TTree::Scan(varexp, selection, option, nentries, firstentry);
2399 }
2400 
2401 ////////////////////////////////////////////////////////////////////////////////
2402 /// Set the global branch kAutoDelete bit.
2403 ///
2404 /// When LoadTree loads a new Tree, the branches for which
2405 /// the address is set will have the option AutoDelete set
2406 /// For more details on AutoDelete, see TBranch::SetAutoDelete.
2407 
2409 {
2410  if (autodelete) {
2411  SetBit(kAutoDelete, 1);
2412  } else {
2413  SetBit(kAutoDelete, 0);
2414  }
2415 }
2416 
2418 {
2419  // Set the cache size of the underlying TTree,
2420  // See TTree::SetCacheSize.
2421  // Returns 0 cache state ok (exists or not, as appropriate)
2422  // -1 on error
2423 
2424  Int_t res = 0;
2425 
2426  // remember user has requested this cache setting
2427  fCacheUserSet = kTRUE;
2428 
2429  if (fTree) {
2430  res = fTree->SetCacheSize(cacheSize);
2431  } else {
2432  // If we don't have a TTree yet only record the cache size wanted
2433  res = 0;
2434  }
2435  fCacheSize = cacheSize; // Record requested size.
2436  return res;
2437 }
2438 
2439 ////////////////////////////////////////////////////////////////////////////////
2440 /// Reset the addresses of the branch.
2441 
2443 {
2444  TChainElement* element = (TChainElement*) fStatus->FindObject(branch->GetName());
2445  if (element) {
2446  element->SetBaddress(0);
2447  }
2448  if (fTree) {
2449  fTree->ResetBranchAddress(branch);
2450  }
2451 }
2452 
2453 ////////////////////////////////////////////////////////////////////////////////
2454 /// Reset the addresses of the branches.
2455 
2457 {
2458  TIter next(fStatus);
2459  TChainElement* element = 0;
2460  while ((element = (TChainElement*) next())) {
2461  element->SetBaddress(0);
2462  }
2463  if (fTree) {
2465  }
2466 }
2467 
2468 ////////////////////////////////////////////////////////////////////////////////
2469 /// Set branch address.
2470 ///
2471 /// \param[in] bname is the name of a branch.
2472 /// \param[in] add is the address of the branch.
2473 /// \param[in] ptr
2474 ///
2475 /// Note: See the comments in TBranchElement::SetAddress() for a more
2476 /// detailed discussion of the meaning of the add parameter.
2477 ///
2478 /// IMPORTANT REMARK:
2479 ///
2480 /// In case TChain::SetBranchStatus is called, it must be called
2481 /// BEFORE calling this function.
2482 ///
2483 /// See TTree::CheckBranchAddressType for the semantic of the return value.
2484 
2485 Int_t TChain::SetBranchAddress(const char *bname, void* add, TBranch** ptr)
2486 {
2487  Int_t res = kNoCheck;
2488 
2489  // Check if bname is already in the status list.
2490  // If not, create a TChainElement object and set its address.
2491  TChainElement* element = (TChainElement*) fStatus->FindObject(bname);
2492  if (!element) {
2493  element = new TChainElement(bname, "");
2494  fStatus->Add(element);
2495  }
2496  element->SetBaddress(add);
2497  element->SetBranchPtr(ptr);
2498  // Also set address in current tree.
2499  // FIXME: What about the chain clones?
2500  if (fTreeNumber >= 0) {
2501  TBranch* branch = fTree->GetBranch(bname);
2502  if (ptr) {
2503  *ptr = branch;
2504  }
2505  if (branch) {
2506  res = CheckBranchAddressType(branch, TClass::GetClass(element->GetBaddressClassName()), (EDataType) element->GetBaddressType(), element->GetBaddressIsPtr());
2507  if ((res & kNeedEnableDecomposedObj) && !branch->GetMakeClass()) {
2508  branch->SetMakeClass(kTRUE);
2509  }
2510  element->SetDecomposedObj(branch->GetMakeClass());
2511  element->SetCheckedType(kTRUE);
2512  if (fClones) {
2513  void* oldAdd = branch->GetAddress();
2514  for (TObjLink* lnk = fClones->FirstLink(); lnk; lnk = lnk->Next()) {
2515  TTree* clone = (TTree*) lnk->GetObject();
2516  TBranch* cloneBr = clone->GetBranch(bname);
2517  if (cloneBr && (cloneBr->GetAddress() == oldAdd)) {
2518  // the clone's branch is still pointing to us
2519  cloneBr->SetAddress(add);
2520  if ((res & kNeedEnableDecomposedObj) && !cloneBr->GetMakeClass()) {
2521  cloneBr->SetMakeClass(kTRUE);
2522  }
2523  }
2524  }
2525  }
2526 
2527  branch->SetAddress(add);
2528  } else {
2529  Error("SetBranchAddress", "unknown branch -> %s", bname);
2530  return kMissingBranch;
2531  }
2532  } else {
2533  if (ptr) {
2534  *ptr = 0;
2535  }
2536  }
2537  return res;
2538 }
2539 
2540 ////////////////////////////////////////////////////////////////////////////////
2541 /// Check if bname is already in the status list, and if not, create a TChainElement object and set its address.
2542 /// See TTree::CheckBranchAddressType for the semantic of the return value.
2543 ///
2544 /// Note: See the comments in TBranchElement::SetAddress() for a more
2545 /// detailed discussion of the meaning of the add parameter.
2546 
2547 Int_t TChain::SetBranchAddress(const char* bname, void* add, TClass* realClass, EDataType datatype, Bool_t isptr)
2548 {
2549  return SetBranchAddress(bname, add, 0, realClass, datatype, isptr);
2550 }
2551 
2552 ////////////////////////////////////////////////////////////////////////////////
2553 /// Check if bname is already in the status list, and if not, create a TChainElement object and set its address.
2554 /// See TTree::CheckBranchAddressType for the semantic of the return value.
2555 ///
2556 /// Note: See the comments in TBranchElement::SetAddress() for a more
2557 /// detailed discussion of the meaning of the add parameter.
2558 
2559 Int_t TChain::SetBranchAddress(const char* bname, void* add, TBranch** ptr, TClass* realClass, EDataType datatype, Bool_t isptr)
2560 {
2561  TChainElement* element = (TChainElement*) fStatus->FindObject(bname);
2562  if (!element) {
2563  element = new TChainElement(bname, "");
2564  fStatus->Add(element);
2565  }
2566  if (realClass) {
2567  element->SetBaddressClassName(realClass->GetName());
2568  }
2569  element->SetBaddressType((UInt_t) datatype);
2570  element->SetBaddressIsPtr(isptr);
2571  element->SetBranchPtr(ptr);
2572  return SetBranchAddress(bname, add, ptr);
2573 }
2574 
2575 ////////////////////////////////////////////////////////////////////////////////
2576 /// Set branch status to Process or DoNotProcess
2577 ///
2578 /// \param[in] bname is the name of a branch. if bname="*", apply to all branches.
2579 /// \param[in] status = 1 branch will be processed,
2580 /// = 0 branch will not be processed
2581 /// \param[out] found
2582 ///
2583 /// See IMPORTANT REMARKS in TTree::SetBranchStatus and TChain::SetBranchAddress
2584 ///
2585 /// If found is not 0, the number of branch(es) found matching the regular
2586 /// expression is returned in *found AND the error message 'unknown branch'
2587 /// is suppressed.
2588 
2589 void TChain::SetBranchStatus(const char* bname, Bool_t status, UInt_t* found)
2590 {
2591  // FIXME: We never explicitly set found to zero!
2592 
2593  // Check if bname is already in the status list,
2594  // if not create a TChainElement object and set its status.
2595  TChainElement* element = (TChainElement*) fStatus->FindObject(bname);
2596  if (element) {
2597  fStatus->Remove(element);
2598  } else {
2599  element = new TChainElement(bname, "");
2600  }
2601  fStatus->Add(element);
2602  element->SetStatus(status);
2603  // Also set status in current tree.
2604  if (fTreeNumber >= 0) {
2605  fTree->SetBranchStatus(bname, status, found);
2606  } else if (found) {
2607  *found = 1;
2608  }
2609 }
2610 
2611 ////////////////////////////////////////////////////////////////////////////////
2612 /// Remove reference to this chain from current directory and add
2613 /// reference to new directory dir. dir can be 0 in which case the chain
2614 /// does not belong to any directory.
2615 
2617 {
2618  if (fDirectory == dir) return;
2619  if (fDirectory) fDirectory->Remove(this);
2620  fDirectory = dir;
2621  if (fDirectory) {
2622  fDirectory->Append(this);
2623  fFile = fDirectory->GetFile();
2624  } else {
2625  fFile = 0;
2626  }
2627 }
2628 
2629 ////////////////////////////////////////////////////////////////////////////////
2630 /// Set the input entry list (processing the entries of the chain will then be
2631 /// limited to the entries in the list).
2632 /// This function finds correspondence between the sub-lists of the TEntryList
2633 /// and the trees of the TChain.
2634 /// By default (opt=""), both the file names of the chain elements and
2635 /// the file names of the TEntryList sublists are expanded to full path name.
2636 /// If opt = "ne", the file names are taken as they are and not expanded
2637 
2639 {
2640  if (fEntryList){
2641  //check, if the chain is the owner of the previous entry list
2642  //(it happens, if the previous entry list was created from a user-defined
2643  //TEventList in SetEventList() function)
2644  if (fEntryList->TestBit(kCanDelete)) {
2645  TEntryList *tmp = fEntryList;
2646  fEntryList = 0; // Avoid problem with RecursiveRemove.
2647  delete tmp;
2648  } else {
2649  fEntryList = 0;
2650  }
2651  }
2652  if (!elist){
2653  fEntryList = 0;
2654  fEventList = 0;
2655  return;
2656  }
2657  if (!elist->TestBit(kCanDelete)){
2658  //this is a direct call to SetEntryList, not via SetEventList
2659  fEventList = 0;
2660  }
2661  if (elist->GetN() == 0){
2662  fEntryList = elist;
2663  return;
2664  }
2665  if (fProofChain){
2666  //for processing on proof, event list and entry list can't be
2667  //set at the same time.
2668  fEventList = 0;
2669  fEntryList = elist;
2670  return;
2671  }
2672 
2673  Int_t ne = fFiles->GetEntries();
2674  Int_t listfound=0;
2675  TString treename, filename;
2676 
2677  TEntryList *templist = 0;
2678  for (Int_t ie = 0; ie<ne; ie++){
2679  auto chainElement = (TChainElement*)fFiles->UncheckedAt(ie);
2680  treename = chainElement->GetName();
2681  filename = chainElement->GetTitle();
2682  templist = elist->GetEntryList(treename, filename, opt);
2683  if (templist) {
2684  listfound++;
2685  templist->SetTreeNumber(ie);
2686  }
2687  }
2688 
2689  if (listfound == 0){
2690  Error("SetEntryList", "No list found for the trees in this chain");
2691  fEntryList = 0;
2692  return;
2693  }
2694  fEntryList = elist;
2695  TList *elists = elist->GetLists();
2696  Bool_t shift = kFALSE;
2697  TIter next(elists);
2698 
2699  //check, if there are sub-lists in the entry list, that don't
2700  //correspond to any trees in the chain
2701  while((templist = (TEntryList*)next())){
2702  if (templist->GetTreeNumber() < 0){
2703  shift = kTRUE;
2704  break;
2705  }
2706  }
2707  fEntryList->SetShift(shift);
2708 
2709 }
2710 
2711 ////////////////////////////////////////////////////////////////////////////////
2712 /// Set the input entry list (processing the entries of the chain will then be
2713 /// limited to the entries in the list). This function creates a special kind
2714 /// of entry list (TEntryListFromFile object) that loads lists, corresponding
2715 /// to the chain elements, one by one, so that only one list is in memory at a time.
2716 ///
2717 /// If there is an error opening one of the files, this file is skipped and the
2718 /// next file is loaded
2719 ///
2720 /// File naming convention:
2721 ///
2722 /// - by default, filename_elist.root is used, where filename is the
2723 /// name of the chain element
2724 /// - xxx$xxx.root - $ sign is replaced by the name of the chain element
2725 ///
2726 /// If the list name is not specified (by passing filename_elist.root/listname to
2727 /// the TChain::SetEntryList() function, the first object of class TEntryList
2728 /// in the file is taken.
2729 ///
2730 /// It is assumed, that there are as many list files, as there are elements in
2731 /// the chain and they are in the same order
2732 
2733 void TChain::SetEntryListFile(const char *filename, Option_t * /*opt*/)
2734 {
2735 
2736  if (fEntryList){
2737  //check, if the chain is the owner of the previous entry list
2738  //(it happens, if the previous entry list was created from a user-defined
2739  //TEventList in SetEventList() function)
2740  if (fEntryList->TestBit(kCanDelete)) {
2741  TEntryList *tmp = fEntryList;
2742  fEntryList = 0; // Avoid problem with RecursiveRemove.
2743  delete tmp;
2744  } else {
2745  fEntryList = 0;
2746  }
2747  }
2748 
2749  fEventList = 0;
2750 
2751  TString basename(filename);
2752 
2753  Int_t dotslashpos = basename.Index(".root/");
2754  TString behind_dot_root = "";
2755  if (dotslashpos>=0) {
2756  // Copy the list name specification
2757  behind_dot_root = basename(dotslashpos+6,basename.Length()-dotslashpos+6);
2758  // and remove it from basename
2759  basename.Remove(dotslashpos+5);
2760  }
2761  fEntryList = new TEntryListFromFile(basename.Data(), behind_dot_root.Data(), fNtrees);
2764  ((TEntryListFromFile*)fEntryList)->SetFileNames(fFiles);
2765 }
2766 
2767 ////////////////////////////////////////////////////////////////////////////////
2768 /// This function transfroms the given TEventList into a TEntryList
2769 ///
2770 /// NOTE, that this function loads all tree headers, because the entry numbers
2771 /// in the TEventList are global and have to be recomputed, taking into account
2772 /// the number of entries in each tree.
2773 ///
2774 /// The new TEntryList is owned by the TChain and gets deleted when the chain
2775 /// is deleted. This TEntryList is returned by GetEntryList() function, and after
2776 /// GetEntryList() function is called, the TEntryList is not owned by the chain
2777 /// any more and will not be deleted with it.
2778 
2780 {
2781  fEventList = evlist;
2782  if (fEntryList) {
2783  if (fEntryList->TestBit(kCanDelete)) {
2784  TEntryList *tmp = fEntryList;
2785  fEntryList = 0; // Avoid problem with RecursiveRemove.
2786  delete tmp;
2787  } else {
2788  fEntryList = 0;
2789  }
2790  }
2791 
2792  if (!evlist) {
2793  fEntryList = 0;
2794  fEventList = 0;
2795  return;
2796  }
2797 
2798  if(fProofChain) {
2799  //on proof, fEventList and fEntryList shouldn't be set at the same time
2800  if (fEntryList){
2801  //check, if the chain is the owner of the previous entry list
2802  //(it happens, if the previous entry list was created from a user-defined
2803  //TEventList in SetEventList() function)
2804  if (fEntryList->TestBit(kCanDelete)){
2805  TEntryList *tmp = fEntryList;
2806  fEntryList = 0; // Avoid problem with RecursiveRemove.
2807  delete tmp;
2808  } else {
2809  fEntryList = 0;
2810  }
2811  }
2812  return;
2813  }
2814 
2815  char enlistname[100];
2816  snprintf(enlistname,100, "%s_%s", evlist->GetName(), "entrylist");
2817  TEntryList *enlist = new TEntryList(enlistname, evlist->GetTitle());
2818  enlist->SetDirectory(0);
2819 
2820  Int_t nsel = evlist->GetN();
2821  Long64_t globalentry, localentry;
2822  const char *treename;
2823  const char *filename;
2825  //Load all the tree headers if the tree offsets are not known
2826  //It is assumed here, that loading the last tree will load all
2827  //previous ones
2828  printf("loading trees\n");
2829  (const_cast<TChain*>(this))->LoadTree(evlist->GetEntry(evlist->GetN()-1));
2830  }
2831  for (Int_t i=0; i<nsel; i++){
2832  globalentry = evlist->GetEntry(i);
2833  //add some protection from globalentry<0 here
2834  Int_t treenum = 0;
2835  while (globalentry>=fTreeOffset[treenum])
2836  treenum++;
2837  treenum--;
2838  localentry = globalentry - fTreeOffset[treenum];
2839  // printf("globalentry=%lld, treeoffset=%lld, localentry=%lld\n", globalentry, fTreeOffset[treenum], localentry);
2840  treename = ((TNamed*)fFiles->At(treenum))->GetName();
2841  filename = ((TNamed*)fFiles->At(treenum))->GetTitle();
2842  //printf("entering for tree %s %s\n", treename, filename);
2843  enlist->SetTree(treename, filename);
2844  enlist->Enter(localentry);
2845  }
2846  enlist->SetBit(kCanDelete, kTRUE);
2847  enlist->SetReapplyCut(evlist->GetReapplyCut());
2848  SetEntryList(enlist);
2849 }
2850 
2851 ////////////////////////////////////////////////////////////////////////////////
2852 /// Change the name of this TChain.
2853 
2854 void TChain::SetName(const char* name)
2855 {
2856  {
2857  // Should this be extended to include the call to TTree::SetName?
2858  R__WRITE_LOCKGUARD(ROOT::gCoreMutex); // Take the lock once rather than 3 times.
2859  gROOT->GetListOfCleanups()->Remove(this);
2860  gROOT->GetListOfSpecials()->Remove(this);
2861  gROOT->GetListOfDataSets()->Remove(this);
2862  }
2864  {
2865  // Should this be extended to include the call to TTree::SetName?
2866  R__WRITE_LOCKGUARD(ROOT::gCoreMutex); // Take the lock once rather than 3 times.
2867  gROOT->GetListOfCleanups()->Add(this);
2868  gROOT->GetListOfSpecials()->Add(this);
2869  gROOT->GetListOfDataSets()->Add(this);
2870  }
2871 
2872 }
2873 
2874 ////////////////////////////////////////////////////////////////////////////////
2875 /// Set number of entries per packet for parallel root.
2876 
2878 {
2879  fPacketSize = size;
2880  TIter next(fFiles);
2881  TChainElement *element;
2882  while ((element = (TChainElement*)next())) {
2883  element->SetPacketSize(size);
2884  }
2885 }
2886 
2887 ////////////////////////////////////////////////////////////////////////////////
2888 /// Enable/Disable PROOF processing on the current default Proof (gProof).
2889 ///
2890 /// "Draw" and "Processed" commands will be handled by PROOF.
2891 /// The refresh and gettreeheader are meaningful only if on == kTRUE.
2892 /// If refresh is kTRUE the underlying fProofChain (chain proxy) is always
2893 /// rebuilt (even if already existing).
2894 /// If gettreeheader is kTRUE the header of the tree will be read from the
2895 /// PROOF cluster: this is only needed for browsing and should be used with
2896 /// care because it may take a long time to execute.
2897 
2898 void TChain::SetProof(Bool_t on, Bool_t refresh, Bool_t gettreeheader)
2899 {
2900  if (!on) {
2901  // Disable
2903  // Reset related bit
2905  } else {
2906  if (fProofChain && !refresh &&
2907  (!gettreeheader || (gettreeheader && fProofChain->GetTree()))) {
2908  return;
2909  }
2912 
2913  // Make instance of TChainProof via the plugin manager
2914  TPluginHandler *h;
2915  if ((h = gROOT->GetPluginManager()->FindHandler("TChain", "proof"))) {
2916  if (h->LoadPlugin() == -1)
2917  return;
2918  if (!(fProofChain = reinterpret_cast<TChain *>(h->ExecPlugin(2, this, gettreeheader))))
2919  Error("SetProof", "creation of TProofChain failed");
2920  // Set related bits
2922  }
2923  }
2924 }
2925 
2926 ////////////////////////////////////////////////////////////////////////////////
2927 /// Set chain weight.
2928 ///
2929 /// The weight is used by TTree::Draw to automatically weight each
2930 /// selected entry in the resulting histogram.
2931 /// For example the equivalent of
2932 /// ~~~ {.cpp}
2933 /// chain.Draw("x","w")
2934 /// ~~~
2935 /// is
2936 /// ~~~ {.cpp}
2937 /// chain.SetWeight(w,"global");
2938 /// chain.Draw("x");
2939 /// ~~~
2940 /// By default the weight used will be the weight
2941 /// of each Tree in the TChain. However, one can force the individual
2942 /// weights to be ignored by specifying the option "global".
2943 /// In this case, the TChain global weight will be used for all Trees.
2944 
2946 {
2947  fWeight = w;
2948  TString opt = option;
2949  opt.ToLower();
2951  if (opt.Contains("global")) {
2953  }
2954 }
2955 
2956 ////////////////////////////////////////////////////////////////////////////////
2957 /// Stream a class object.
2958 
2959 void TChain::Streamer(TBuffer& b)
2960 {
2961  if (b.IsReading()) {
2962  // Remove using the 'old' name.
2963  {
2965  gROOT->GetListOfCleanups()->Remove(this);
2966  }
2967 
2968  UInt_t R__s, R__c;
2969  Version_t R__v = b.ReadVersion(&R__s, &R__c);
2970  if (R__v > 2) {
2971  b.ReadClassBuffer(TChain::Class(), this, R__v, R__s, R__c);
2972  } else {
2973  //====process old versions before automatic schema evolution
2974  TTree::Streamer(b);
2975  b >> fTreeOffsetLen;
2976  b >> fNtrees;
2977  fFiles->Streamer(b);
2978  if (R__v > 1) {
2979  fStatus->Streamer(b);
2981  b.ReadFastArray(fTreeOffset,fTreeOffsetLen);
2982  }
2983  b.CheckByteCount(R__s, R__c, TChain::IsA());
2984  //====end of old versions
2985  }
2986  // Re-add using the new name.
2987  {
2989  gROOT->GetListOfCleanups()->Add(this);
2990  }
2991 
2992  } else {
2993  b.WriteClassBuffer(TChain::Class(),this);
2994  }
2995 }
2996 
2997 ////////////////////////////////////////////////////////////////////////////////
2998 /// Dummy function kept for back compatibility.
2999 /// The cache is now activated automatically when processing TTrees/TChain.
3000 
3001 void TChain::UseCache(Int_t /* maxCacheSize */, Int_t /* pageSize */)
3002 {
3003 }
TObject::kMustCleanup
@ kMustCleanup
if object destructor must call RecursiveRemove()
Definition: TObject.h:60
TTree::kLoadTree
@ kLoadTree
Definition: TTree.h:217
l
auto * l
Definition: textangle.C:4
TVirtualTreePlayer::UpdateFormulaLeaves
virtual void UpdateFormulaLeaves()=0
TEntryListFromFile
Manages entry lists from different files, when they are not loaded in memory at the same time.
Definition: TEntryListFromFile.h:41
TChain::fFiles
TObjArray * fFiles
-> List of file names containing the trees (TChainElement, owned)
Definition: TChain.h:43
TChainElement::SetBaddressType
virtual void SetBaddressType(UInt_t type)
Definition: TChainElement.h:72
TFileMergeInfo
Definition: TFileMergeInfo.h:42
TEventList::GetN
virtual Int_t GetN() const
Definition: TEventList.h:56
TTree::Reset
virtual void Reset(Option_t *option="")
Reset baskets, buffers and entries count in all branches and leaves.
Definition: TTree.cxx:7870
first
Definition: first.py:1
TChain::fFile
TFile * fFile
! Pointer to current file (We own the file).
Definition: TChain.h:42
TCut
A specialized string object used for TTree selections.
Definition: TCut.h:25
TFileInfo
Class describing a generic file including meta information.
Definition: TFileInfo.h:39
TObject::SavePrimitive
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save a primitive as a C++ statement(s) on output stream "out".
Definition: TObject.cxx:666
TChainElement::SetLoadResult
void SetLoadResult(Int_t result)
Definition: TChainElement.h:76
TChain::Scan
virtual Long64_t Scan(const char *varexp="", const char *selection="", Option_t *option="", Long64_t nentries=kMaxEntries, Long64_t firstentry=0)
Loop on tree and print entries passing selection.
Definition: TChain.cxx:2393
TDirectory::Remove
virtual TObject * Remove(TObject *)
Remove an object from the in-memory list.
Definition: TDirectory.cxx:1155
TBrowser
Using a TBrowser one can browse all ROOT objects.
Definition: TBrowser.h:37
kTRUE
const Bool_t kTRUE
Definition: RtypesCore.h:91
TChain::Loop
virtual void Loop(Option_t *option="", Long64_t nentries=kMaxEntries, Long64_t firstentry=0)
Loop on nentries of this chain starting at firstentry. (NOT IMPLEMENTED)
Definition: TChain.cxx:1772
TTree::FindBranch
virtual TBranch * FindBranch(const char *name)
Return the branch that correspond to the path 'branchname', which can include the name of the tree or...
Definition: TTree.cxx:4763
TChain::ResetAfterMerge
virtual void ResetAfterMerge(TFileMergeInfo *)
Resets the state of this chain after a merge (keep the customization but forget the data).
Definition: TChain.cxx:2307
TDirectory::GetList
virtual TList * GetList() const
Definition: TDirectory.h:167
TObjArray::Delete
virtual void Delete(Option_t *option="")
Remove all objects from the array AND delete all heap based objects.
Definition: TObjArray.cxx:356
TObject::TestBit
R__ALWAYS_INLINE Bool_t TestBit(UInt_t f) const
Definition: TObject.h:172
Version_t
short Version_t
Definition: RtypesCore.h:65
TTree::Browse
virtual void Browse(TBrowser *)
Browse content of the TTree.
Definition: TTree.cxx:2584
TEventList
A TEventList object is a list of selected events (entries) in a TTree.
Definition: TEventList.h:31
snprintf
#define snprintf
Definition: civetweb.c:1540
TChain::SetBranchAddress
virtual Int_t SetBranchAddress(const char *bname, void *add, TBranch **ptr=0)
Set branch address.
Definition: TChain.cxx:2485
TObjArray
An array of TObjects.
Definition: TObjArray.h:37
TFileInfo::GetCurrentUrl
TUrl * GetCurrentUrl() const
Return the current url.
Definition: TFileInfo.cxx:249
TSelector
A TSelector object is used by the TTree::Draw, TTree::Scan, TTree::Process to navigate in a TTree and...
Definition: TSelector.h:31
TROOT::DecreaseDirLevel
static Int_t DecreaseDirLevel()
Decrease the indentation level for ls().
Definition: TROOT.cxx:2702
Option_t
const char Option_t
Definition: RtypesCore.h:66
TChain::fProofChain
TChain * fProofChain
! chain proxy when going to be processed by PROOF
Definition: TChain.h:45
TChainElement::GetCheckedType
Bool_t GetCheckedType() const
Definition: TChainElement.h:62
TTree::GetLeaf
virtual TLeaf * GetLeaf(const char *branchname, const char *leafname)
Return pointer to the 1st Leaf named name in any Branch of this Tree or any branch in the list of fri...
Definition: TTree.cxx:6093
kNPOS
const Ssiz_t kNPOS
Definition: RtypesCore.h:115
TTree::GetPlayer
TVirtualTreePlayer * GetPlayer()
Load the TTreePlayer (if not already done).
Definition: TTree.cxx:6203
TTree::GetListOfFriends
virtual TList * GetListOfFriends() const
Definition: TTree.h:485
TChain::GetAlias
virtual const char * GetAlias(const char *aliasName) const
Returns the expanded value of the alias. Search in the friends if any.
Definition: TChain.cxx:869
TSystem::BaseName
virtual const char * BaseName(const char *pathname)
Base name of a file name. Base name of /user/root is root.
Definition: TSystem.cxx:933
TChain::Merge
virtual Long64_t Merge(const char *name, Option_t *option="")
Merge all the entries in the chain into a new tree in a new file.
Definition: TChain.cxx:1849
TEventList::GetReapplyCut
virtual Bool_t GetReapplyCut() const
Definition: TEventList.h:57
TChain::FindLeaf
virtual TLeaf * FindLeaf(const char *name)
See TTree::GetReadEntry().
Definition: TChain.cxx:848
TBranch::SetMakeClass
virtual Bool_t SetMakeClass(Bool_t decomposeObj=kTRUE)
Set the branch in a mode where the object are decomposed (Also known as MakeClass mode).
Definition: TBranch.cxx:2767
TList::FindObject
virtual TObject * FindObject(const char *name) const
Find an object in this list using its name.
Definition: TList.cxx:577
TList::Delete
virtual void Delete(Option_t *option="")
Remove all objects from the list AND delete all heap based objects.
Definition: TList.cxx:469
TChain::Draw
virtual Long64_t Draw(const char *varexp, const TCut &selection, Option_t *option="", Long64_t nentries=kMaxEntries, Long64_t firstentry=0)
Draw expression varexp for selected entries.
Definition: TChain.cxx:788
TTree::fMakeClass
Int_t fMakeClass
! not zero when processing code generated by MakeClass
Definition: TTree.h:115
TString::Data
const char * Data() const
Definition: TString.h:369
TSystem::FreeDirectory
virtual void FreeDirectory(void *dirp)
Free a directory.
Definition: TSystem.cxx:844
TString::MaybeWildcard
Bool_t MaybeWildcard() const
Returns true if string contains one of the wildcard characters "[]*?".
Definition: TString.cxx:925
tree
Definition: tree.py:1
ClassImp
#define ClassImp(name)
Definition: Rtypes.h:364
TObjArray::Remove
virtual TObject * Remove(TObject *obj)
Remove object from array.
Definition: TObjArray.cxx:719
TNamed::GetTitle
virtual const char * GetTitle() const
Returns title of object.
Definition: TNamed.h:48
TObjString.h
TChainElement::HasBeenLookedUp
virtual Bool_t HasBeenLookedUp()
Definition: TChainElement.h:67
TAttMarker::GetMarkerSize
virtual Size_t GetMarkerSize() const
Return the marker size.
Definition: TAttMarker.h:33
TChain::GetChainEntryNumber
virtual Long64_t GetChainEntryNumber(Long64_t entry) const
Return absolute entry number in the chain.
Definition: TChain.cxx:937
TString::Replace
TString & Replace(Ssiz_t pos, Ssiz_t n, const char *s)
Definition: TString.h:682
TTree::GetReadCache
TTreeCache * GetReadCache(TFile *file) const
Find and return the TTreeCache registered with the file and which may contain branches for us.
Definition: TTree.cxx:6216
TBranch.h
TChain::Add
virtual Int_t Add(TChain *chain)
Add all files referenced by the passed chain to this chain.
Definition: TChain.cxx:228
Long64_t
long long Long64_t
Definition: RtypesCore.h:73
TObject::Error
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition: TObject.cxx:890
TTree::GetListOfClones
virtual TList * GetListOfClones()
Definition: TTree.h:482
TChainElement::GetBaddressClassName
virtual const char * GetBaddressClassName() const
Definition: TChainElement.h:56
TBranch::GetMakeClass
virtual Bool_t GetMakeClass() const
Return whether this branch is in a mode where the object are decomposed or not (Also known as MakeCla...
Definition: TBranch.cxx:1972
TTree::CloneTree
virtual TTree * CloneTree(Long64_t nentries=-1, Option_t *option="")
Create a clone of this tree and copy nentries.
Definition: TTree.cxx:3089
TTree
A TTree represents a columnar dataset.
Definition: TTree.h:79
TChain::SetEntryListFile
virtual void SetEntryListFile(const char *filename="", Option_t *opt="")
Set the input entry list (processing the entries of the chain will then be limited to the entries in ...
Definition: TChain.cxx:2733
TEntryList::SetShift
virtual void SetShift(Bool_t shift)
Definition: TEntryList.h:99
gInterpreter
#define gInterpreter
Definition: TInterpreter.h:560
TTree::SetMaxVirtualSize
virtual void SetMaxVirtualSize(Long64_t size=0)
Definition: TTree.h:619
TChain::SetEntryList
virtual void SetEntryList(TEntryList *elist, Option_t *opt="")
Set the input entry list (processing the entries of the chain will then be limited to the entries in ...
Definition: TChain.cxx:2638
TGeant4Unit::s
static constexpr double s
Definition: TGeant4SystemOfUnits.h:162
TFile::Open
static TFile * Open(const char *name, Option_t *option="", const char *ftitle="", Int_t compress=ROOT::RCompressionSetting::EDefaults::kUseCompiledDefault, Int_t netopt=0)
Create / open a file.
Definition: TFile.cxx:3995
TObject::Fatal
virtual void Fatal(const char *method, const char *msgfmt,...) const
Issue fatal error message.
Definition: TObject.cxx:918
TUrl::SetAnchor
void SetAnchor(const char *anchor)
Definition: TUrl.h:86
TChainElement::GetStatus
virtual Int_t GetStatus() const
Definition: TChainElement.h:66
TTree::GetClusterIterator
virtual TClusterIterator GetClusterIterator(Long64_t firstentry)
Return an iterator over the cluster of baskets starting at firstentry.
Definition: TTree.cxx:5366
TBrowser.h
TChain::fTreeOffset
Long64_t * fTreeOffset
[fTreeOffsetLen] Array of variables
Definition: TChain.h:39
TChain::GetListOfLeaves
virtual TObjArray * GetListOfLeaves()
Return a pointer to the list of leaves of the current tree.
Definition: TChain.cxx:1117
TString::Contains
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
Definition: TString.h:624
SafeDelete
#define SafeDelete(p)
Definition: RConfig.hxx:543
TChain::fTreeOffsetLen
Int_t fTreeOffsetLen
Current size of fTreeOffset array.
Definition: TChain.h:36
TObjArray::GetEntries
Int_t GetEntries() const
Return the number of objects in array (i.e.
Definition: TObjArray.cxx:523
TString::Length
Ssiz_t Length() const
Definition: TString.h:410
TDirectory::TContext
Small helper to keep current directory context.
Definition: TDirectory.h:47
TClass.h
TAttMarker::GetMarkerStyle
virtual Style_t GetMarkerStyle() const
Return the marker style.
Definition: TAttMarker.h:32
TChain::GetEntryNumber
virtual Long64_t GetEntryNumber(Long64_t entry) const
Return entry number corresponding to entry.
Definition: TChain.cxx:990
TList.h
TChain::ls
virtual void ls(Option_t *option="") const
List the chain.
Definition: TChain.cxx:1816
nentries
int nentries
Definition: THbookFile.cxx:91
TColor.h
TFriendElement
A TFriendElement TF describes a TTree object TF in a file.
Definition: TFriendElement.h:33
TTreeCache::UpdateBranches
virtual void UpdateBranches(TTree *tree)
Update pointer to current Tree and recompute pointers to the branches in the cache.
Definition: TTreeCache.cxx:2191
TChain::GetBranchStatus
virtual Bool_t GetBranchStatus(const char *branchname) const
See TTree::GetReadEntry().
Definition: TChain.cxx:909
TIter::Reset
void Reset()
Definition: TCollection.h:252
ROOT::gCoreMutex
R__EXTERN TVirtualRWMutex * gCoreMutex
Definition: TVirtualRWMutex.h:32
TTree::RemoveFriend
virtual void RemoveFriend(TTree *)
Remove a friend from the list of friends.
Definition: TTree.cxx:7844
TBuffer
Buffer base class used for serializing objects.
Definition: TBuffer.h:43
TUrl::SetOptions
void SetOptions(const char *opt)
Definition: TUrl.h:87
TObjArray::UncheckedAt
TObject * UncheckedAt(Int_t i) const
Definition: TObjArray.h:90
TChain::ResetBranchAddress
virtual void ResetBranchAddress(TBranch *)
Reset the addresses of the branch.
Definition: TChain.cxx:2442
TObjArray::At
TObject * At(Int_t idx) const
Definition: TObjArray.h:166
TString::Format
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString.
Definition: TString.cxx:2311
TFriendElement.h
TEntryList::SetTree
virtual void SetTree(const TTree *tree)
If a list for a tree with such name and filename exists, sets it as the current sublist If not,...
Definition: TEntryList.cxx:1194
TTree.h
TColor::SaveColor
static void SaveColor(std::ostream &out, Int_t ci)
Save a color with index > 228 as a C++ statement(s) on output stream out.
Definition: TColor.cxx:2118
TChainElement::GetBaddressType
virtual UInt_t GetBaddressType() const
Definition: TChainElement.h:58
TString
Basic string class.
Definition: TString.h:136
TChain::SetDirectory
virtual void SetDirectory(TDirectory *dir)
Remove reference to this chain from current directory and add reference to new directory dir.
Definition: TChain.cxx:2616
TSystem::AccessPathName
virtual Bool_t AccessPathName(const char *path, EAccessMode mode=kFileExists)
Returns FALSE if one can access a file using the specified access mode.
Definition: TSystem.cxx:1294
TTree::fDirectory
TDirectory * fDirectory
! Pointer to directory holding this tree
Definition: TTree.h:118
TChain::RemoveFriend
virtual void RemoveFriend(TTree *)
Remove a friend from the list of friends.
Definition: TChain.cxx:2262
TChainElement::SetNumberEntries
virtual void SetNumberEntries(Long64_t n)
Definition: TChainElement.h:78
TObject::InheritsFrom
virtual Bool_t InheritsFrom(const char *classname) const
Returns kTRUE if object inherits from class "classname".
Definition: TObject.cxx:445
TTree::SetAutoSave
virtual void SetAutoSave(Long64_t autos=-300000000)
This function may be called at the start of a program to change the default value for fAutoSave (and ...
Definition: TTree.cxx:8167
TString::Clear
void Clear()
Clear string without changing its capacity.
Definition: TString.cxx:1176
TTree::GetMinimum
virtual Double_t GetMinimum(const char *columname)
Return minimum of column with name columname.
Definition: TTree.cxx:6173
TChain::kAutoDelete
@ kAutoDelete
Definition: TChain.h:60
b
#define b(i)
Definition: RSha256.hxx:100
TTree::GetEntry
virtual Int_t GetEntry(Long64_t entry=0, Int_t getall=0)
Read all branches of entry and return total number of bytes read.
Definition: TTree.cxx:5537
TFile.h
TObjString::GetName
const char * GetName() const
Returns name of object.
Definition: TObjString.h:38
bool
TSystem::WorkingDirectory
virtual const char * WorkingDirectory()
Return working directory.
Definition: TSystem.cxx:870
TTree::Write
virtual Int_t Write(const char *name=0, Int_t option=0, Int_t bufsize=0)
Write this object to the current directory.
Definition: TTree.cxx:9568
TString::ReplaceAll
TString & ReplaceAll(const TString &s1, const TString &s2)
Definition: TString.h:692
TObjArray::Add
void Add(TObject *obj)
Definition: TObjArray.h:74
TChainElement::GetBaddress
virtual void * GetBaddress() const
Definition: TChainElement.h:55
TTree::GetMaximum
virtual Double_t GetMaximum(const char *columname)
Return maximum of column with name columname.
Definition: TTree.cxx:6133
TTree::GetListOfBranches
virtual TObjArray * GetListOfBranches()
Definition: TTree.h:483
TTree::fPlayer
TVirtualTreePlayer * fPlayer
! Pointer to current Tree player
Definition: TTree.h:131
TChainElement::SetStatus
virtual void SetStatus(Int_t status)
Definition: TChainElement.h:80
TChainElement
A TChainElement describes a component of a TChain.
Definition: TChainElement.h:28
TString::Last
Ssiz_t Last(char c) const
Find last occurrence of a character c.
Definition: TString.cxx:892
TChain::GetMaximum
virtual Double_t GetMaximum(const char *columname)
Return maximum of column with name columname.
Definition: TChain.cxx:1138
TROOT.h
TObject::ls
virtual void ls(Option_t *option="") const
The ls function lists the contents of a class on stdout.
Definition: TObject.cxx:494
TObjString
Collectable string class.
Definition: TObjString.h:28
TChainElement::SetDecomposedObj
void SetDecomposedObj(Bool_t m)
Definition: TChainElement.h:75
TTree::GetTree
virtual TTree * GetTree() const
Definition: TTree.h:512
TTree::GetAlias
virtual const char * GetAlias(const char *aliasName) const
Returns the expanded value of the alias. Search in the friends if any.
Definition: TTree.cxx:5142
TChain::RecursiveRemove
virtual void RecursiveRemove(TObject *obj)
Make sure that obj (which is being deleted or will soon be) is no longer referenced by this TTree.
Definition: TChain.cxx:2243
TTree::fCacheUserSet
Bool_t fCacheUserSet
! true if the cache setting was explicitly given by user
Definition: TTree.h:138
TBranch
A TTree is a list of TBranches.
Definition: TBranch.h:89
TChainElement::SetBaddressIsPtr
virtual void SetBaddressIsPtr(Bool_t isptr)
Definition: TChainElement.h:71
TTree::GetBranch
virtual TBranch * GetBranch(const char *name)
Return pointer to the branch with the given name in this tree or its friends.
Definition: TTree.cxx:5210
TPluginHandler
Definition: TPluginManager.h:101
TChain::fTree
TTree * fTree
! Pointer to current tree (Note: We do not own this tree.)
Definition: TChain.h:41
TChain::SetProof
virtual void SetProof(Bool_t on=kTRUE, Bool_t refresh=kFALSE, Bool_t gettreeheader=kFALSE)
Enable/Disable PROOF processing on the current default Proof (gProof).
Definition: TChain.cxx:2898
TTree::GetNbranches
virtual Int_t GetNbranches()
Definition: TTree.h:497
TRegexp.h
TTree::GetCurrentFile
TFile * GetCurrentFile() const
Return pointer to the current file.
Definition: TTree.cxx:5378
TString::Form
void Form(const char *fmt,...)
Formats a string using a printf style format descriptor.
Definition: TString.cxx:2289
TTree::GetFileNumber
virtual Int_t GetFileNumber() const
Definition: TTree.h:471
TChain::AddFile
virtual Int_t AddFile(const char *name, Long64_t nentries=TTree::kMaxEntries, const char *tname="")
Add a new file to this chain.
Definition: TChain.cxx:463
TTree::fFriendLockStatus
UInt_t fFriendLockStatus
! Record which method is locking the friend recursion
Definition: TTree.h:134
TTree::fEntryList
TEntryList * fEntryList
! Pointer to event selection list (if one)
Definition: TTree.h:123
TDirectoryFile::Get
TObject * Get(const char *namecycle) override
Return pointer to object identified by namecycle.
Definition: TDirectoryFile.cxx:909
TDirectory::Append
virtual void Append(TObject *obj, Bool_t replace=kFALSE)
Append object to this directory.
Definition: TDirectory.cxx:191
TTree::AddFriend
virtual TFriendElement * AddFriend(const char *treename, const char *filename="")
Add a TFriendElement to the list of friends.
Definition: TTree.cxx:1310
TTreeCache.h
TChain.h
TTree::GetWeight
virtual Double_t GetWeight() const
Definition: TTree.h:539
TBuffer.h
TList::FirstLink
virtual TObjLink * FirstLink() const
Definition: TList.h:108
TChain::DirectoryAutoAdd
virtual void DirectoryAutoAdd(TDirectory *)
Override the TTree::DirectoryAutoAdd behavior: we never auto add.
Definition: TChain.cxx:773
TLeaf.h
TTree::fEventList
TEventList * fEventList
! Pointer to event selection list (if one)
Definition: TTree.h:122
TChain::GetListOfFiles
TObjArray * GetListOfFiles() const
Definition: TChain.h:107
TObject::ResetBit
void ResetBit(UInt_t f)
Definition: TObject.h:171
slash
TCanvas * slash()
Definition: slash.C:1
TSystem.h
TObject::Notify
virtual Bool_t Notify()
This method must be overridden to handle object notification.
Definition: TObject.cxx:508
TFileInfo.h
TEntryList::GetLists
virtual TList * GetLists() const
Definition: TEntryList.h:73
TTree::CopyEntries
virtual Long64_t CopyEntries(TTree *tree, Long64_t nentries=-1, Option_t *option="")
Copy nentries from given tree to this tree.
Definition: TTree.cxx:3477
gROOTMutex
R__EXTERN TVirtualMutex * gROOTMutex
Definition: TROOT.h:61
TTree::RegisterExternalFriend
virtual void RegisterExternalFriend(TFriendElement *)
Record a TFriendElement that we need to warn when the chain switches to a new file (typically this is...
Definition: TTree.cxx:7824
h
#define h(i)
Definition: RSha256.hxx:106
TEntryList::Enter
virtual Bool_t Enter(Long64_t entry, TTree *tree=0)
Add entry #entry to the list.
Definition: TEntryList.cxx:560
TFileStager
Definition: TFileStager.h:36
TLeaf
A TLeaf describes individual elements of a TBranch See TBranch structure in TTree.
Definition: TLeaf.h:57
TChain::GetEntryWithIndex
virtual Int_t GetEntryWithIndex(Int_t major, Int_t minor=0)
Return entry corresponding to major and minor number.
Definition: TChain.cxx:1023
TObject::SetBit
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
Definition: TObject.cxx:696
TChain::GetMinimum
virtual Double_t GetMinimum(const char *columname)
Return minimum of column with name columname.
Definition: TChain.cxx:1155
TChain::FindBranch
virtual TBranch * FindBranch(const char *name)
See TTree::GetReadEntry().
Definition: TChain.cxx:827
TTree::Process
virtual Long64_t Process(const char *filename, Option_t *option="", Long64_t nentries=kMaxEntries, Long64_t firstentry=0)
Process this tree executing the TSelector code in the specified filename.
Definition: TTree.cxx:7326
TChain::CanDeleteRefs
virtual void CanDeleteRefs(Bool_t flag=kTRUE)
When closing a file during the chain processing, the file may be closed with option "R" if flag is se...
Definition: TChain.cxx:752
TTree::GetReadEntry
virtual Long64_t GetReadEntry() const
Definition: TTree.h:504
TChain::GetClusterIterator
virtual TClusterIterator GetClusterIterator(Long64_t firstentry)
Return an iterator over the cluster of baskets starting at firstentry.
Definition: TChain.cxx:926
TChain::AddFileInfoList
virtual Int_t AddFileInfoList(TCollection *list, Long64_t nfiles=TTree::kMaxEntries)
Add all files referenced in the list to the chain.
Definition: TChain.cxx:560
TTree::LoadTree
virtual Long64_t LoadTree(Long64_t entry)
Set current entry.
Definition: TTree.cxx:6371
TFriendElement::GetTree
virtual TTree * GetTree()
Return pointer to friend TTree.
Definition: TFriendElement.cxx:209
ROOT::Detail::TRangeStaticCast
TRangeStaticCast is an adaptater class that allows the typed iteration through a TCollection.
Definition: TCollection.h:382
TString::Remove
TString & Remove(Ssiz_t pos)
Definition: TString.h:673
TChain::GetEntry
virtual Int_t GetEntry(Long64_t entry=0, Int_t getall=0)
Get entry from the file to memory.
Definition: TChain.cxx:971
TNamed
The TNamed class is the base class for all named ROOT classes.
Definition: TNamed.h:29
TChain::kProofLite
@ kProofLite
Definition: TChain.h:62
kFALSE
const Bool_t kFALSE
Definition: RtypesCore.h:92
TTree::LoadTreeFriend
virtual Long64_t LoadTreeFriend(Long64_t entry, TTree *T)
Load entry on behalf of our master tree, we may use an index.
Definition: TTree.cxx:6455
TChain::GetWeight
virtual Double_t GetWeight() const
Return the chain weight.
Definition: TChain.cxx:1210
TFriendElement::kFromChain
@ kFromChain
Definition: TFriendElement.h:49
TVirtualIndex.h
TBranch::SetAutoDelete
virtual void SetAutoDelete(Bool_t autodel=kTRUE)
Set the automatic delete bit.
Definition: TBranch.cxx:2556
TTree::Scan
virtual Long64_t Scan(const char *varexp="", const char *selection="", Option_t *option="", Long64_t nentries=kMaxEntries, Long64_t firstentry=0)
Loop over tree entries and print entries passing selection.
Definition: TTree.cxx:7961
gDirectory
#define gDirectory
Definition: TDirectory.h:236
TChain::GetNtrees
Int_t GetNtrees() const
Definition: TChain.h:95
TChain::LoadTree
virtual Long64_t LoadTree(Long64_t entry)
Find the tree which contains entry, and set it as the current tree.
Definition: TChain.cxx:1284
TTree::Draw
virtual void Draw(Option_t *opt)
Default Draw method for all objects.
Definition: TTree.h:427
TChain::GetEntries
virtual Long64_t GetEntries() const
Return the total number of entries in the chain.
Definition: TChain.cxx:947
TCut.h
R__LOCKGUARD
#define R__LOCKGUARD(mutex)
Definition: TVirtualMutex.h:104
TChain::InvalidateCurrentTree
void InvalidateCurrentTree()
Set the TTree to be reloaded as soon as possible.
Definition: TChain.cxx:1239
TString::Insert
TString & Insert(Ssiz_t pos, const char *s)
Definition: TString.h:649
UInt_t
unsigned int UInt_t
Definition: RtypesCore.h:46
TClass::GetClass
static TClass * GetClass(const char *name, Bool_t load=kTRUE, Bool_t silent=kFALSE)
Static method returning pointer to TClass of the specified class name.
Definition: TClass.cxx:2925
TTree::fReadEntry
Long64_t fReadEntry
! Number of the entry being processed
Definition: TTree.h:107
TChain::GetBranch
virtual TBranch * GetBranch(const char *name)
Return pointer to the branch name in the current tree.
Definition: TChain.cxx:888
TTree::kNoCheck
@ kNoCheck
Definition: TTree.h:239
TUrl::SetUrl
void SetUrl(const char *url, Bool_t defaultIsFile=kFALSE)
Parse url character string and split in its different subcomponents.
Definition: TUrl.cxx:108
TSystem::ExpandPathName
virtual Bool_t ExpandPathName(TString &path)
Expand a pathname getting rid of special shell characters like ~.
Definition: TSystem.cxx:1272
TChain::TChain
TChain()
Default constructor.
Definition: TChain.cxx:69
TBranch::SetAddress
virtual void SetAddress(void *add)
Set address of this branch.
Definition: TBranch.cxx:2522
TEventList::GetEntry
virtual Long64_t GetEntry(Int_t index) const
Return value of entry at index in the list.
Definition: TEventList.cxx:225
TTree::TFriendLock
Helper class to prevent infinite recursion in the usage of TTree Friends.
Definition: TTree.h:184
TChain::fTreeNumber
Int_t fTreeNumber
! Current Tree number in fTreeOffset table
Definition: TChain.h:38
TNamed::SetTitle
virtual void SetTitle(const char *title="")
Set the title of the TNamed.
Definition: TNamed.cxx:164
TAttMarker::GetMarkerColor
virtual Color_t GetMarkerColor() const
Return the marker color.
Definition: TAttMarker.h:31
TVirtualMutex.h
TObject::Warning
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
Definition: TObject.cxx:876
TUrl::GetUrl
const char * GetUrl(Bool_t withDeflt=kFALSE) const
Return full URL.
Definition: TUrl.cxx:387
TChainElement::GetLoadResult
Int_t GetLoadResult() const
Definition: TChainElement.h:61
TUrl
This class represents a WWW compatible URL.
Definition: TUrl.h:33
TChainElement::SetPacketSize
virtual void SetPacketSize(Int_t size=100)
Set number of entries per packet for parallel root.
Definition: TChainElement.cxx:92
TROOT::IncreaseDirLevel
static Int_t IncreaseDirLevel()
Increase the indentation level for ls().
Definition: TROOT.cxx:2798
TTree::FindLeaf
virtual TLeaf * FindLeaf(const char *name)
Find leaf..
Definition: TTree.cxx:4835
TObject::kCanDelete
@ kCanDelete
if object in a list can be deleted
Definition: TObject.h:58
TFile
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format.
Definition: TFile.h:54
TObject::kInvalidObject
@ kInvalidObject
if object ctor succeeded but object should not be used
Definition: TObject.h:68
TTreeCache::ResetCache
virtual void ResetCache()
This will simply clear the cache.
Definition: TTreeCache.cxx:2021
TChainElement::SetBaddressClassName
virtual void SetBaddressClassName(const char *clname)
Definition: TChainElement.h:70
unsigned int
TRegexp
Regular expression class.
Definition: TRegexp.h:31
TTree::GetDirectory
TDirectory * GetDirectory() const
Definition: TTree.h:457
TChain::SetName
virtual void SetName(const char *name)
Change the name of this TChain.
Definition: TChain.cxx:2854
TEntryList
A List of entry numbers in a TTree or TChain.
Definition: TEntryList.h:26
TUrl::GetFile
const char * GetFile() const
Definition: TUrl.h:69
TString::Index
Ssiz_t Index(const char *pat, Ssiz_t i=0, ECaseCompare cmp=kExact) const
Definition: TString.h:639
Printf
void Printf(const char *fmt,...)
TUrl::GetProtocol
const char * GetProtocol() const
Definition: TUrl.h:64
TObject::IsZombie
R__ALWAYS_INLINE Bool_t IsZombie() const
Definition: TObject.h:134
gSystem
R__EXTERN TSystem * gSystem
Definition: TSystem.h:559
TTree::TClusterIterator
Helper class to iterate over cluster of baskets.
Definition: TTree.h:266
TTree::GetBranchStatus
virtual Bool_t GetBranchStatus(const char *branchname) const
Return status of branch with name branchname.
Definition: TTree.cxx:5289
TChain::GetNbranches
virtual Int_t GetNbranches()
Return the number of branches of the current tree.
Definition: TChain.cxx:1174
TChain::SetPacketSize
virtual void SetPacketSize(Int_t size=100)
Set number of entries per packet for parallel root.
Definition: TChain.cxx:2877
TTree::GetEntryNumberWithIndex
virtual Long64_t GetEntryNumberWithIndex(Long64_t major, Long64_t minor=0) const
Return entry number corresponding to major and minor number.
Definition: TTree.cxx:5810
TTree::SetCacheSize
virtual Int_t SetCacheSize(Long64_t cachesize=-1)
Set maximum size of the file cache .
Definition: TTree.cxx:8506
TEntryList::SetReapplyCut
virtual void SetReapplyCut(Bool_t apply=kFALSE)
Definition: TEntryList.h:105
TTree::SetCircular
virtual void SetCircular(Long64_t maxEntries)
Enable/Disable circularity for this tree.
Definition: TTree.cxx:8712
TChain::CreatePackets
virtual void CreatePackets()
Initialize the packet descriptor string.
Definition: TChain.cxx:760
TTree::GetTreeIndex
virtual TVirtualIndex * GetTreeIndex() const
Definition: TTree.h:513
TChain::GetReadEntry
virtual Long64_t GetReadEntry() const
See TTree::GetReadEntry().
Definition: TChain.cxx:1189
TTreeCache
A cache to speed-up the reading of ROOT datasets.
Definition: TTreeCache.h:32
TString::IsNull
Bool_t IsNull() const
Definition: TString.h:407
TTree::fNotify
TObject * fNotify
! Object to be notified when loading a Tree
Definition: TTree.h:117
TChain::~TChain
virtual ~TChain()
Destructor.
Definition: TChain.cxx:182
Double_t
double Double_t
Definition: RtypesCore.h:59
TChain::GetListOfBranches
virtual TObjArray * GetListOfBranches()
Return a pointer to the list of branches of the current tree.
Definition: TChain.cxx:1094
TTree::fExternalFriends
TList * fExternalFriends
! List of TFriendsElement pointing to us and need to be notified of LoadTree. Content not owned.
Definition: TTree.h:128
TSystem::OpenDirectory
virtual void * OpenDirectory(const char *name)
Open a directory. Returns 0 if directory does not exist.
Definition: TSystem.cxx:835
TEntryList::GetEntryAndTree
virtual Long64_t GetEntryAndTree(Int_t index, Int_t &treenum)
Return the index of "index"-th non-zero entry in the TTree or TChain and the # of the corresponding t...
Definition: TEntryList.cxx:733
TVirtualIndex::UpdateFormulaLeaves
virtual void UpdateFormulaLeaves(const TTree *parent)=0
TPluginManager.h
R__ASSERT
#define R__ASSERT(e)
Definition: TError.h:120
TChain::SavePrimitive
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save TChain as a C++ statements on output stream out.
Definition: TChain.cxx:2324
TChainElement::CreatePackets
virtual void CreatePackets()
Initialize the packet descriptor string.
Definition: TChainElement.cxx:65
TChain::ParseTreeFilename
void ParseTreeFilename(const char *name, TString &filename, TString &treename, TString &query, TString &suffix, Bool_t wildcards) const
Get the tree url or filename and other information from the name.
Definition: TChain.cxx:2118
TSystem::UnixPathName
virtual const char * UnixPathName(const char *unixpathname)
Convert from a local pathname to a Unix pathname.
Definition: TSystem.cxx:1061
TTree::fEntries
Long64_t fEntries
Number of entries.
Definition: TTree.h:84
TList::Remove
virtual TObject * Remove(TObject *obj)
Remove object from the list.
Definition: TList.cxx:821
dummy
static RooMathCoreReg dummy
Definition: RooMathCoreReg.cxx:27
TClass
TClass instances represent classes, structs and namespaces in the ROOT type system.
Definition: TClass.h:80
TEntryList::GetTreeNumber
virtual Int_t GetTreeNumber() const
Definition: TEntryList.h:78
TChainElement::SetCheckedType
void SetCheckedType(Bool_t m)
Definition: TChainElement.h:74
file
Definition: file.py:1
EDataType
EDataType
Definition: TDataType.h:28
TUrl::GetAnchor
const char * GetAnchor() const
Definition: TUrl.h:70
TTree::ResetBranchAddress
virtual void ResetBranchAddress(TBranch *)
Tell all of our branches to set their addresses to zero.
Definition: TTree.cxx:7932
TList::Add
virtual void Add(TObject *obj)
Definition: TList.h:87
TSystem::GetDirEntry
virtual const char * GetDirEntry(void *dirp)
Get a directory entry. Returns 0 if no more entries.
Definition: TSystem.cxx:852
TObject
Mother of all ROOT objects.
Definition: TObject.h:37
TFile::Close
void Close(Option_t *option="") override
Close a file.
Definition: TFile.cxx:876
TChainElement::SetBranchPtr
virtual void SetBranchPtr(TBranch **ptr)
Definition: TChainElement.h:73
TChain::LoadBaskets
virtual Int_t LoadBaskets(Long64_t maxmemory)
Dummy function.
Definition: TChain.cxx:1257
TChain::SetAutoDelete
virtual void SetAutoDelete(Bool_t autodel=kTRUE)
Set the global branch kAutoDelete bit.
Definition: TChain.cxx:2408
TTree::AddClone
void AddClone(TTree *)
Add a cloned tree to our list of trees to be notified whenever we change our branch addresses or when...
Definition: TTree.cxx:1198
TFileStager::Open
static TFileStager * Open(const char *stager)
Open a stager, after having loaded the relevant plug-in.
Definition: TFileStager.cxx:101
TEntryList.h
TDirectory::GetFile
virtual TFile * GetFile() const
Definition: TDirectory.h:165
TChain::SetEventList
virtual void SetEventList(TEventList *evlist)
This function transfroms the given TEventList into a TEntryList.
Definition: TChain.cxx:2779
name
char name[80]
Definition: TGX11.cxx:110
TBranch::GetAddress
virtual char * GetAddress() const
Definition: TBranch.h:208
TChain::fStatus
TList * fStatus
-> List of active/inactive branches (TChainElement, owned)
Definition: TChain.h:44
TTree::CheckBranchAddressType
virtual Int_t CheckBranchAddressType(TBranch *branch, TClass *ptrClass, EDataType datatype, Bool_t ptr)
Check whether or not the address described by the last 3 parameters matches the content of the branch...
Definition: TTree.cxx:2820
TTree::SetName
virtual void SetName(const char *name)
Change the name of this tree.
Definition: TTree.cxx:9025
TUrl::GetFileAndOptions
const char * GetFileAndOptions() const
Return the file and its options (the string specified behind the ?).
Definition: TUrl.cxx:501
TChain::kProofUptodate
@ kProofUptodate
Definition: TChain.h:61
TFileStager::Matches
virtual Bool_t Matches(const char *s)
Definition: TFileStager.h:46
TDirectory
Describe directory structure in memory.
Definition: TDirectory.h:40
TTree::CopyAddresses
virtual void CopyAddresses(TTree *, Bool_t undo=kFALSE)
Set branch addresses of passed tree equal to ours.
Definition: TTree.cxx:3249
TEntryListFromFile.h
TTree::fCacheSize
Long64_t fCacheSize
! Maximum size of file buffers
Definition: TTree.h:105
TTree::SetMakeClass
virtual void SetMakeClass(Int_t make)
Set all the branches in this TTree to be in decomposed object mode (also known as MakeClass mode).
Definition: TTree.cxx:8997
TIter
Definition: TCollection.h:233
TTree::fMaxVirtualSize
Long64_t fMaxVirtualSize
Maximum total size of buffers kept in memory.
Definition: TTree.h:99
TFileStager.h
TTree::fWeight
Double_t fWeight
Tree weight (see TTree::SetWeight)
Definition: TTree.h:90
TFileStager::Locate
virtual Int_t Locate(const char *u, TString &f)
Just check if the file exists locally.
Definition: TFileStager.cxx:146
TUrl::GetOptions
const char * GetOptions() const
Definition: TUrl.h:71
TTree::fClones
TList * fClones
! List of cloned trees which share our addresses
Definition: TTree.h:132
TChain::AddFriend
virtual TFriendElement * AddFriend(const char *chainname, const char *dummy="")
Add a TFriendElement to the list of friends of this chain.
Definition: TChain.cxx:650
TChain
A chain is a collection of files containing TTree objects.
Definition: TChain.h:33
TCollection
Collection abstract base class.
Definition: TCollection.h:63
xmlio::cnt
const char * cnt
Definition: TXMLSetup.cxx:75
TChain::GetLeaf
virtual TLeaf * GetLeaf(const char *branchname, const char *leafname)
Return a pointer to the leaf name in the current tree.
Definition: TChain.cxx:1047
TNamed::GetName
virtual const char * GetName() const
Returns name of object.
Definition: TNamed.h:47
TTree::kNeedEnableDecomposedObj
@ kNeedEnableDecomposedObj
Definition: TTree.h:240
TChainElement::GetBranchPtr
virtual TBranch ** GetBranchPtr() const
Definition: TChainElement.h:59
TChain::Lookup
void Lookup(Bool_t force=kFALSE)
Check / locate the files in the chain.
Definition: TChain.cxx:1702
TFilePrefetch.h
R__WRITE_LOCKGUARD
#define R__WRITE_LOCKGUARD(mutex)
Definition: TVirtualRWMutex.h:163
TChain::Browse
virtual void Browse(TBrowser *)
Browse the contents of the chain.
Definition: TChain.cxx:734
TTree::fPacketSize
Int_t fPacketSize
! Number of entries in one packet for parallel root
Definition: TTree.h:109
TTree::ResetBranchAddresses
virtual void ResetBranchAddresses()
Tell all of our branches to drop their current objects and allocate new ones.
Definition: TTree.cxx:7942
TChainElement::SetLookedUp
virtual void SetLookedUp(Bool_t y=kTRUE)
Set/Reset the looked-up bit.
Definition: TChainElement.cxx:100
TChain::GetFile
TFile * GetFile() const
Return a pointer to the current file.
Definition: TChain.cxx:1034
Class
void Class()
Definition: Class.C:29
TString::ToLower
void ToLower()
Change string to lower-case.
Definition: TString.cxx:1125
TChain::kGlobalWeight
@ kGlobalWeight
Definition: TChain.h:59
TChain::SetBranchStatus
virtual void SetBranchStatus(const char *bname, Bool_t status=1, UInt_t *found=0)
Set branch status to Process or DoNotProcess.
Definition: TChain.cxx:2589
TTree::kMaxEntries
static constexpr Long64_t kMaxEntries
Definition: TTree.h:225
TChainElement::GetPacketSize
virtual Int_t GetPacketSize() const
Definition: TChainElement.h:65
TChain::fCanDeleteRefs
Bool_t fCanDeleteRefs
! If true, TProcessIDs are deleted when closing a file
Definition: TChain.h:40
TChainElement::GetBaddressIsPtr
virtual Bool_t GetBaddressIsPtr() const
Definition: TChainElement.h:57
TChain::Print
virtual void Print(Option_t *option="") const
Print the header information of each tree in the chain.
Definition: TChain.cxx:2180
TChainElement::SetBaddress
virtual void SetBaddress(void *add)
Definition: TChainElement.h:69
TObject::ClassName
virtual const char * ClassName() const
Returns name of class to which the object belongs.
Definition: TObject.cxx:130
TChain::Reset
virtual void Reset(Option_t *option="")
Resets the state of this chain.
Definition: TChain.cxx:2285
TTree::GetListOfLeaves
virtual TObjArray * GetListOfLeaves()
Definition: TTree.h:484
TTree::SetBranchStatus
virtual void SetBranchStatus(const char *bname, Bool_t status=1, UInt_t *found=0)
Set branch status to Process or DoNotProcess.
Definition: TTree.cxx:8359
TTree::GetEntries
virtual Long64_t GetEntries() const
Definition: TTree.h:458
TChain::SetCacheSize
virtual Int_t SetCacheSize(Long64_t cacheSize=-1)
Set maximum size of the file cache .
Definition: TChain.cxx:2417
TTree::SetChainOffset
virtual void SetChainOffset(Long64_t offset=0)
Definition: TTree.h:603
TEntryList::GetN
virtual Long64_t GetN() const
Definition: TEntryList.h:75
TTree::ResetAfterMerge
virtual void ResetAfterMerge(TFileMergeInfo *)
Resets the state of this TTree after a merge (keep the customization but forget the data).
Definition: TTree.cxx:7901
TUrl.h
TChainElement.h
TChain::SetWeight
virtual void SetWeight(Double_t w=1, Option_t *option="")
Set chain weight.
Definition: TChain.cxx:2945
TSelector.h
TTree::kMissingBranch
@ kMissingBranch
Definition: TTree.h:229
TChain::UseCache
virtual void UseCache(Int_t maxCacheSize=10, Int_t pageSize=0)
Dummy function kept for back compatibility.
Definition: TChain.cxx:3001
TEntryList::SetDirectory
virtual void SetDirectory(TDirectory *dir)
Add reference to directory dir. dir can be 0.
Definition: TEntryList.cxx:1068
TChain::fNtrees
Int_t fNtrees
Number of trees.
Definition: TChain.h:37
TChainElement::GetEntries
virtual Long64_t GetEntries() const
Definition: TChainElement.h:60
TChain::GetTree
virtual TTree * GetTree() const
Definition: TChain.h:115
TBranch::SetBasketSize
virtual void SetBasketSize(Int_t buffsize)
Set the basket size The function makes sure that the basket size is greater than fEntryOffsetlen.
Definition: TBranch.cxx:2569
TList
A doubly linked list.
Definition: TList.h:44
TChain::Process
virtual Long64_t Process(const char *filename, Option_t *option="", Long64_t nentries=kMaxEntries, Long64_t firstentry=0)
Process all entries in this chain, calling functions in filename.
Definition: TChain.cxx:2203
TFile::SetCacheRead
virtual void SetCacheRead(TFileCacheRead *cache, TObject *tree=0, ECacheAction action=kDisconnect)
Set a pointer to the read cache.
Definition: TFile.cxx:2278
TEntryList::GetEntryList
virtual TEntryList * GetEntryList(const char *treename, const char *filename, Option_t *opt="")
Return the entry list, corresponding to treename and filename By default, the filename is first tried...
Definition: TEntryList.cxx:787
TChain::ResetBranchAddresses
virtual void ResetBranchAddresses()
Reset the addresses of the branches.
Definition: TChain.cxx:2456
TEntryList::SetTreeNumber
virtual void SetTreeNumber(Int_t index)
Definition: TEntryList.h:104
gROOT
#define gROOT
Definition: TROOT.h:406
TTree::fFriends
TList * fFriends
pointer to list of friend elements
Definition: TTree.h:127
int
TError.h
TBranch::SetCompressionSettings
void SetCompressionSettings(Int_t settings=ROOT::RCompressionSetting::EDefaults::kUseCompiledDefault)
Set compression settings.
Definition: TBranch.cxx:2645
TEventList.h