Warning, file /include/root/TBranchCacheInfo.h was not indexed
or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012 #ifndef ROOT_TBranchCacheInfo
0013 #define ROOT_TBranchCacheInfo
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024 #include "Rtypes.h"
0025 #include "TBits.h"
0026 #include "TString.h" // for Printf
0027
0028 #include <vector>
0029
0030 class TBranch;
0031
0032 namespace ROOT {
0033 namespace Internal {
0034
0035 class TBranchCacheInfo {
0036
0037 enum EStates {
0038 kLoaded = 0,
0039 kUsed = 1,
0040 kVetoed = 2,
0041 kSize = 3
0042 };
0043
0044 Int_t fBasketPedestal{-1};
0045 TBits fInfo;
0046
0047
0048 void UpdatePedestal(Int_t basketNumber)
0049 {
0050 if (fBasketPedestal == -1) {
0051 fBasketPedestal = basketNumber;
0052 } else if (basketNumber < fBasketPedestal) {
0053 auto delta = fBasketPedestal - basketNumber;
0054 fBasketPedestal = basketNumber;
0055 fInfo <<= (delta * kSize);
0056 }
0057 }
0058
0059
0060 bool TestState(Int_t basketNumber, EStates what) const
0061 {
0062 if (basketNumber < fBasketPedestal)
0063 return false;
0064 return fInfo.TestBitNumber(kSize * (basketNumber - fBasketPedestal) + what);
0065 }
0066
0067
0068 void SetState(Int_t basketNumber, EStates what)
0069 {
0070 if (fBasketPedestal <= basketNumber)
0071 fInfo.SetBitNumber(kSize * (basketNumber - fBasketPedestal) + what, true);
0072 }
0073
0074 public:
0075
0076 bool HasBeenUsed(Int_t basketNumber) const { return TestState(basketNumber, kUsed); }
0077
0078
0079 void SetUsed(Int_t basketNumber)
0080 {
0081 UpdatePedestal(basketNumber);
0082 SetState(basketNumber, kUsed);
0083 }
0084
0085
0086 bool IsInCache(Int_t basketNumber) const { return TestState(basketNumber, kLoaded); }
0087
0088
0089 void SetIsInCache(Int_t basketNumber)
0090 {
0091 UpdatePedestal(basketNumber);
0092 SetState(basketNumber, kLoaded);
0093 }
0094
0095
0096
0097
0098 void Veto(Int_t basketNumber)
0099 {
0100 UpdatePedestal(basketNumber);
0101 SetState(basketNumber, kVetoed);
0102 }
0103
0104
0105 bool IsVetoed(Int_t basketNumber) const { return TestState(basketNumber, kVetoed); }
0106
0107
0108
0109 bool AllUsed() const
0110 {
0111 auto len = fInfo.GetNbits() / kSize + 1;
0112 for (UInt_t b = 0; b < len; ++b) {
0113 if (fInfo[kSize * b + kLoaded] && !fInfo[kSize * b + kUsed]) {
0114
0115 return false;
0116 }
0117 }
0118 return true;
0119 }
0120
0121
0122 void GetUnused(std::vector<Int_t> &unused)
0123 {
0124 unused.clear();
0125 auto len = fInfo.GetNbits() / kSize + 1;
0126 for (UInt_t b = 0; b < len; ++b) {
0127 if (fInfo[kSize * b + kLoaded] && !fInfo[kSize * b + kUsed]) {
0128 unused.push_back(fBasketPedestal + b);
0129 }
0130 }
0131 }
0132
0133
0134 void Reset()
0135 {
0136 fBasketPedestal = -1;
0137 fInfo.ResetAllBits();
0138 }
0139
0140
0141 void Print(const char *owner, Long64_t *entries) const
0142 {
0143 if (!owner || !entries)
0144 return;
0145 auto len = fInfo.GetNbits() / kSize + 1;
0146 if (fBasketPedestal >= 0)
0147 for (UInt_t b = 0; b < len; ++b) {
0148 Printf("Branch %s : basket %d loaded=%d used=%d start entry=%lld", owner, b + fBasketPedestal,
0149 (bool)fInfo[kSize * b + kLoaded], (bool)fInfo[kSize * b + kUsed], entries[fBasketPedestal + b]);
0150 }
0151 }
0152 };
0153
0154 }
0155 }
0156
0157 #endif