33#include "TGeoManager.h"
67 userIndex = internalIndex + 1;
68 fCache[internalIndex]->SetUniqueID(userIndex);
69 return fCache[internalIndex].get();
77 if (userIndex >
fCache.size()) {
78 ::Fatal(
"TGeoMCBranchArrayContainer::GetGeoState",
79 "ID %u is not an index referring to TGeoBranchArray "
80 "managed by this TGeoMCBranchArrayContainer",
83 if (
fCache[userIndex - 1]->GetUniqueID() == 0) {
84 ::Fatal(
"TGeoMCBranchArrayContainer::GetGeoState",
"Passed index %u refers to an empty/unused geo state",
87 return fCache[userIndex - 1].get();
92 if (userIndex >
fCache.size() || userIndex == 0) {
96 if (
fCache[userIndex - 1]->GetUniqueID() > 0) {
98 fCache[userIndex - 1]->SetUniqueID(0);
113 for (UInt_t i = 0; i <
fCache.size(); i++) {
120 if (targetSize <=
fCache.size()) {
121 targetSize = 2 *
fCache.size();
124 fCache.reserve(targetSize);
125 for (UInt_t i =
fCache.size(); i < targetSize; i++) {
127 fCache.back()->SetUniqueID(0);
void ExtendCache(UInt_t targetSize=1)
Resize the cache.
UInt_t fMaxLevels
Maximum level of node array inside a chached state.
void Initialize(UInt_t maxlevels=100, UInt_t size=8)
Initialize manually specifying initial number of internal TGeoBranchArray objects.
TGeoBranchArray * GetNewGeoState(UInt_t &userIndex)
Get a TGeoBranchArray to set to current geo state.
const TGeoBranchArray * GetGeoState(UInt_t userIndex)
Get a TGeoBranchArray to read the current state from.
std::vector< UInt_t > fFreeIndices
Provide indices in fCachedStates which are already popped and can be re-populated again.
void InitializeFromGeoManager(TGeoManager *man, UInt_t size=8)
Initialize from TGeoManager to extract maxlevels.
Bool_t fIsInitialized
Flag if initialized.
void ResetCache()
Clear the internal cache.
void FreeGeoStates()
Free all geo states at once but keep the container size.
void FreeGeoState(UInt_t userIndex)
Free the index of this geo state such that it can be re-used.
std::vector< std::unique_ptr< TGeoBranchArray > > fCache
Cache states via TGeoBranchArray.