VMC Version 2.0
Loading...
Searching...
No Matches
TGeoMCBranchArrayContainer.h
Go to the documentation of this file.
1// -----------------------------------------------------------------------
2// Copyright (C) 2019 CERN and copyright holders of VMC Project.
3// This software is distributed under the terms of the GNU General Public
4// License v3 (GPL Version 3), copied verbatim in the file "LICENSE".
5//
6// See https://github.com/vmc-project/vmc for full licensing information.
7// -----------------------------------------------------------------------
8
9// Authors: Benedikt Volkel 07/03/2019
10
11/*************************************************************************
12 * Copyright (C) 2019, Rene Brun and Fons Rademakers. *
13 * Copyright (C) 2019, ALICE Experiment at CERN. *
14 * All rights reserved. *
15 * *
16 * For the licensing terms see $ROOTSYS/LICENSE. *
17 * For the list of contributors see $ROOTSYS/README/CREDITS. *
18 *************************************************************************/
19
20// Class TGeoMCBranchArrayContainer
21// ---------------------
22// cache for storing TGeoBranchArray objects
23//
24
25#ifndef ROOT_TGeoMCBranchArrayContainer
26#define ROOT_TGeoMCBranchArrayContainer
27
28#include <vector>
29#include <memory>
30
31#include "TGeoBranchArray.h"
32
33class TGeoManager;
34
36public:
41
44 void Initialize(UInt_t maxlevels = 100, UInt_t size = 8);
46 void InitializeFromGeoManager(TGeoManager *man, UInt_t size = 8);
48 void ResetCache();
49
51 TGeoBranchArray *GetNewGeoState(UInt_t &userIndex);
53 const TGeoBranchArray *GetGeoState(UInt_t userIndex);
55 void FreeGeoState(UInt_t userIndex);
57 void FreeGeoState(const TGeoBranchArray *geoState);
59 void FreeGeoStates();
60
61private:
67 void ExtendCache(UInt_t targetSize = 1);
68
69private:
71 std::vector<std::unique_ptr<TGeoBranchArray>> fCache;
73 UInt_t fMaxLevels = 100;
76 std::vector<UInt_t> fFreeIndices;
78 Bool_t fIsInitialized = kFALSE;
79
80 ClassDefNV(TGeoMCBranchArrayContainer, 1)
81};
82
83#endif /* ROOT_TGeoMCBranchArrayContainer */
Storing and re-using geometry states of the TGeoManager in use by storing them as TGeoBranchArrays.
void ExtendCache(UInt_t targetSize=1)
Resize the cache.
~TGeoMCBranchArrayContainer()=default
Destructor.
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.
TGeoMCBranchArrayContainer(const TGeoMCBranchArrayContainer &)
Copying kept private.
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.
TGeoMCBranchArrayContainer()=default
Default constructor.
TGeoMCBranchArrayContainer & operator=(const TGeoMCBranchArrayContainer &)
Assignement kept private.
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.