1- Here's a combined ` README.md ` that covers both ` treeFastCache1D.C ` and ` treeFastCacheND.C ` . It provides an overview of both systems, explains their purpose and usage, and includes examples for each.
2-
3- ---
4-
51# 📦 ROOT Tree Fast Cache System
62
73This repository contains ROOT macros for fast lookup and interpolation of values from TTrees, using:
@@ -35,17 +31,17 @@ tree->Draw("dcar_value:dcar_smooth", "indexType==1", "colz", 10000);
3531
3632---
3733
38- ## 🔷 `treeFastCacheND.C`
34+ ## 🔸 `treeFastCacheND.C`
3935
4036### ✅ Features
4137
4238- ND caching with:
43- - **Exact match** in N–1 dimensions
44- - **Nearest-neighbor** lookup in 1 dimension (e.g. `time`)
39+ - **Exact match** in N–1 dimensions
40+ - **Nearest-neighbor** lookup in 1 dimension (e.g. `time`)
4541- Uses full `double` precision for all keys
4642- Alias support for `TTree::Draw`
4743- Registration by name with hashed map ID
48- - Easy to integrate, extendable to class-based interface
44+ - Variadic interface for direct use
4945
5046### 🧪 Example: Time Series
5147
@@ -57,9 +53,37 @@ setNearestNDAlias(tree, "dcar_smooth", "dcar_vs_time", "time", {"subentry"});
5753tree->Draw("mTSITSTPC.mDCAr_A_NTracks_median:dcar_smooth", "indexType==1", "colz", 10000);
5854```
5955
56+ ### 🖊️ Parameters for ` registerMapND `
57+ ``` cpp
58+ int registerMapND (
59+ const std::string& name, // Unique name of the map
60+ TTree* tree, // Source TTree
61+ const std::vector< std::string > & exactDims, // Exact-match coordinate names
62+ const std::string& nearestDim, // Nearest-match dimension (e.g. time)
63+ const std::string& valueVar, // Variable to interpolate
64+ const std::string& selection // TTree selection
65+ );
66+ ```
67+
68+ ### 🖊️ Parameters for ` setNearestNDAlias `
69+ ``` cpp
70+ void setNearestNDAlias (
71+ TTree* tree, // Target tree
72+ const std::string& aliasName, // Alias to create
73+ const std::string& mapName, // Name used in registration
74+ const std::string& nearestCoordExpr, // Nearest-match expression
75+ const std::vector< std::string > & exactCoordExprs // Exact match expressions
76+ );
77+ ```
78+
79+ ### ⚡️ Alternative: Direct expression
80+ ``` cpp
81+ tree->Draw ("val: getNearestND (time,mapID,subentry)", ...);
82+ ```
83+
6084---
6185
62- ## 🧱 Internal Storage
86+ ## 📊 Internal Storage
6387
6488### 1D:
6589```cpp
@@ -77,26 +101,26 @@ std::map<std::string, int> ndNameToID;
77101
78102## 📌 Best Practices
79103
80- - Use aliases to simplify and standardize plotting
81- - Pre-register frequently used maps in init scripts
82- - Use full double precision for input axes to ensure match stability
83- - Prefer descriptive names for map registration
104+ - Use aliases to simplify ` TTree::Draw ` expressions
105+ - Use double precision for stability in nearest search
106+ - Store maps by string name to simplify re-registration
107+ - Prefer ` setNearestNDAlias() ` over manual ` getNearestND(...) ` for readability
84108
85109---
86110
87111## 📤 Future Ideas
88112
89- - Optional linear interpolation (vs. nearest )
90- - Fallback behavior when no exact match is found
91- - Statistics and diagnostics on caches
92- - Class-based C++ wrapper with lifecycle management
113+ - Optional interpolation (linear, spline )
114+ - Graceful handling of unmatched keys
115+ - Caching diagnostics and summary statistics
116+ - C++ class wrapper for lifecycle + reusability
93117
94118---
95119
96- ## 📄 License
120+ ## 📜 License
97121
98122Intended for use in internal physics analyses. No warranty implied.
99123
100124---
101125
102- Let me know if you'd like me to create a markdown file or commit it alongside the ` .C ` macros .
126+ For more details, see comments and examples inside ` treeFastCache1D.C ` and ` treeFastCacheND .C` .
0 commit comments