DAS  3.0
Das Analysis System
ChainSlice

Description

Wrapper around TChain that restricts available entries to a subset.

This class acts like a TChain, with the additional feature of limiting the available entries to a subset of the original. The first entry that will be used is set with SetBeginEntry, and the last one with SetEndEntry. Once set, a normal iteration through the chain (with SetEntry or similar) will be restricted to entries in [begin, end).

In essence, a ChainSlice behaves like iterating on a normal chain from GetBegin (inclusive) to GetEnd (exclusive).

Note
Adding friends to a ChainSlice is untested. \bugs Calling LoadTree() directly will not work as expected.

#include <FriendUtils.h>

+ Inheritance diagram for ChainSlice:
+ Collaboration diagram for ChainSlice:

Public Member Functions

 ChainSlice (const ChainSlice &)=delete
 
 ChainSlice (Long64_t begin=0, Long64_t end=-1)
 
 ChainSlice (const char *name, Long64_t begin=0, Long64_t end=-1, const char *title="")
 
virtual ~ChainSlice ()
 
Long64_t GetBegin () const
 
Long64_t GetEnd () const
 
void SetBegin (Long64_t begin)
 
void SetEnd (Long64_t end)
 
Long64_t GetEntries () const override
 
Long64_t GetEntriesFast () const override
 
Int_t GetEntry (Long64_t entry, Int_t getall=0) override
 
Long64_t GetReadEntry () const override
 
Long64_t GetReadEvent () const override
 
Long64_t LoadTreeFriend (Long64_t entry, TTree *parent) override
 
 ChainSlice (const ChainSlice &)=delete
 
 ChainSlice (Long64_t begin=0, Long64_t end=-1)
 
 ChainSlice (const char *name, Long64_t begin=0, Long64_t end=-1, const char *title="")
 
virtual ~ChainSlice ()
 
Long64_t GetBegin () const
 
Long64_t GetEnd () const
 
void SetBegin (Long64_t begin)
 
void SetEnd (Long64_t end)
 
Long64_t GetEntries () const override
 
Long64_t GetEntriesFast () const override
 
Int_t GetEntry (Long64_t entry, Int_t getall=0) override
 
Long64_t GetReadEntry () const override
 
Long64_t GetReadEvent () const override
 
Long64_t LoadTreeFriend (Long64_t entry, TTree *parent) override
 

Private Member Functions

auto GetLast () const
 
auto GetLast () const
 

Private Attributes

Long64_t fBegin
 
Long64_t fEnd
 

Constructor & Destructor Documentation

◆ ChainSlice() [1/6]

ChainSlice ( const ChainSlice )
delete

◆ ChainSlice() [2/6]

ChainSlice ( Long64_t  begin = 0,
Long64_t  end = -1 
)
inline

Creates a ChainSlice.

The first and last entries can optionally be provided.

58  : fBegin(begin)
59  , fEnd(end)
60  {
61  // Force creation of the friends list. This controls friend handling in
62  // TChain::LoadTree, *also for the friends of the loaded TTree*. I
63  // consider this a bug in ROOT.
64  fFriends = new TList();
65  }

◆ ChainSlice() [3/6]

ChainSlice ( const char *  name,
Long64_t  begin = 0,
Long64_t  end = -1,
const char *  title = "" 
)
inline

Creates a ChainSlice.

The first and last entries can optionally be provided. See the TChain constructor for other arguments.

77  : TChain(name, title)
78  , fBegin(begin)
79  , fEnd(end)
80  {
81  // Force creation of the friends list. This controls friend handling in
82  // TChain::LoadTree, *also for the friends of the loaded TTree*. I
83  // consider this a bug in ROOT.
84  fFriends = new TList();
85  }

◆ ~ChainSlice() [1/2]

~ChainSlice ( )
virtual

Destructor.

21 {}

◆ ChainSlice() [4/6]

ChainSlice ( const ChainSlice )
delete

◆ ChainSlice() [5/6]

ChainSlice ( Long64_t  begin = 0,
Long64_t  end = -1 
)
inline

Creates a ChainSlice.

The first and last entries can optionally be provided.

58  : fBegin(begin)
59  , fEnd(end)
60  {
61  // Force creation of the friends list. This controls friend handling in
62  // TChain::LoadTree, *also for the friends of the loaded TTree*. I
63  // consider this a bug in ROOT.
64  fFriends = new TList();
65  }

◆ ChainSlice() [6/6]

ChainSlice ( const char *  name,
Long64_t  begin = 0,
Long64_t  end = -1,
const char *  title = "" 
)
inline

Creates a ChainSlice.

The first and last entries can optionally be provided. See the TChain constructor for other arguments.

77  : TChain(name, title)
78  , fBegin(begin)
79  , fEnd(end)
80  {
81  // Force creation of the friends list. This controls friend handling in
82  // TChain::LoadTree, *also for the friends of the loaded TTree*. I
83  // consider this a bug in ROOT.
84  fFriends = new TList();
85  }

◆ ~ChainSlice() [2/2]

virtual ~ChainSlice ( )
virtual

Member Function Documentation

◆ GetBegin() [1/2]

Long64_t GetBegin ( ) const
inline

Returns the index of the first entry that will be used.

93 { return fBegin; }

◆ GetBegin() [2/2]

Long64_t GetBegin ( ) const
inline

Returns the index of the first entry that will be used.

93 { return fBegin; }

◆ GetEnd() [1/2]

Long64_t GetEnd ( ) const
inline

Returns the index past the last entry that will be used.

98 { return fEnd; }

◆ GetEnd() [2/2]

Long64_t GetEnd ( ) const
inline

Returns the index past the last entry that will be used.

98 { return fEnd; }

◆ GetEntries() [1/2]

Long64_t GetEntries ( ) const
inlineoverride

Return the total number of entries in the chain, taking the restrictions set by GetBegin and GetEnd into account.

118 { return GetLast() - GetBegin(); }

◆ GetEntries() [2/2]

Long64_t GetEntries ( ) const
inlineoverride

Return the total number of entries in the chain, taking the restrictions set by GetBegin and GetEnd into account.

118 { return GetLast() - GetBegin(); }

◆ GetEntriesFast() [1/2]

Long64_t GetEntriesFast ( ) const
inlineoverride

Return the total number of entries in the chain, taking the restrictions set by begin and end into account.

Synomym for GetEntries.

126 { return GetEntries(); }

◆ GetEntriesFast() [2/2]

Long64_t GetEntriesFast ( ) const
inlineoverride

Return the total number of entries in the chain, taking the restrictions set by begin and end into account.

Synomym for GetEntries.

126 { return GetEntries(); }

◆ GetEntry() [1/2]

Int_t GetEntry ( Long64_t  entry,
Int_t  getall = 0 
)
inlineoverride

Get entry from the chain to memory.

Todo:
description

See TChain::GetEntry for details.

136  { return TChain::GetEntry(entry + GetBegin(), getall); }

◆ GetEntry() [2/2]

Int_t GetEntry ( Long64_t  entry,
Int_t  getall = 0 
)
inlineoverride

Get entry from the chain to memory.

Todo:
description

See TChain::GetEntry for details.

136  { return TChain::GetEntry(entry + GetBegin(), getall); }

◆ GetLast() [1/2]

auto GetLast ( ) const
inlineprivate

Returns the last entry to load, taking negative fEnd into account.

43  {
44  return fEnd >= 0 ? std::min(fEnd, TChain::GetEntries())
45  : TChain::GetEntries();
46  }

◆ GetLast() [2/2]

auto GetLast ( ) const
inlineprivate

Returns the last entry to load, taking negative fEnd into account.

43  {
44  return fEnd >= 0 ? std::min(fEnd, TChain::GetEntries())
45  : TChain::GetEntries();
46  }

◆ GetReadEntry() [1/2]

Long64_t GetReadEntry ( ) const
inlineoverride

Number of the currently-loaded entry.

This override takes GetBegin into account.

143 { return TChain::GetReadEntry() - GetBegin(); }

◆ GetReadEntry() [2/2]

Long64_t GetReadEntry ( ) const
inlineoverride

Number of the currently-loaded entry.

This override takes GetBegin into account.

143 { return TChain::GetReadEntry() - GetBegin(); }

◆ GetReadEvent() [1/2]

Long64_t GetReadEvent ( ) const
inlineoverride

Number of the currently-loaded entry.

This override takes GetBegin into account.

150 { return GetReadEntry(); }

◆ GetReadEvent() [2/2]

Long64_t GetReadEvent ( ) const
inlineoverride

Number of the currently-loaded entry.

This override takes GetBegin into account.

150 { return GetReadEntry(); }

◆ LoadTreeFriend() [1/2]

Long64_t LoadTreeFriend ( Long64_t  entry,
TTree *  parent 
)
inlineoverride

Loads the requested entry, called from a friend tree.

This override takes GetBegin into account.

158  { return TChain::LoadTreeFriend(entry + GetBegin(), parent); }

◆ LoadTreeFriend() [2/2]

Long64_t LoadTreeFriend ( Long64_t  entry,
TTree *  parent 
)
inlineoverride

Loads the requested entry, called from a friend tree.

This override takes GetBegin into account.

158  { return TChain::LoadTreeFriend(entry + GetBegin(), parent); }

◆ SetBegin() [1/2]

void SetBegin ( Long64_t  begin)
inline

Changes the first entry to be loaded.

The currently loaded entry is not modified.

105 { fBegin = begin; }

◆ SetBegin() [2/2]

void SetBegin ( Long64_t  begin)
inline

Changes the first entry to be loaded.

The currently loaded entry is not modified.

105 { fBegin = begin; }

◆ SetEnd() [1/2]

void SetEnd ( Long64_t  end)
inline

Changes the last entry to be loaded.

The currently loaded entry is not modified.

112 { fEnd = end; }

◆ SetEnd() [2/2]

void SetEnd ( Long64_t  end)
inline

Changes the last entry to be loaded.

The currently loaded entry is not modified.

112 { fEnd = end; }

Member Data Documentation

◆ fBegin

Long64_t fBegin
private

The first entry to use.

◆ fEnd

Long64_t fEnd
private

Past the last entry to use, or -1 to go till the end.


The documentation for this class was generated from the following files:
DYToLL_M-50_13TeV_pythia8_cff_GEN_SIM_RECOBEFMIX_DIGI_L1_DIGI2RAW_L1Reco_RECO.name
name
Definition: DYToLL_M-50_13TeV_pythia8_cff_GEN_SIM_RECOBEFMIX_DIGI_L1_DIGI2RAW_L1Reco_RECO.py:48
Darwin::Tools::ChainSlice::GetEntries
Long64_t GetEntries() const override
Return the total number of entries in the chain, taking the restrictions set by GetBegin and GetEnd i...
Definition: FriendUtils.h:118
Darwin::Tools::ChainSlice::GetLast
auto GetLast() const
Definition: FriendUtils.h:42
Darwin::Tools::ChainSlice::GetBegin
Long64_t GetBegin() const
Returns the index of the first entry that will be used.
Definition: FriendUtils.h:93
Darwin::Tools::ChainSlice::fBegin
Long64_t fBegin
The first entry to use.
Definition: FriendUtils.h:36
Darwin::Tools::ChainSlice::fEnd
Long64_t fEnd
Past the last entry to use, or -1 to go till the end.
Definition: FriendUtils.h:37
Darwin::Tools::ChainSlice::GetReadEntry
Long64_t GetReadEntry() const override
Number of the currently-loaded entry.
Definition: FriendUtils.h:143