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