Skip to content

Commit e6bd040

Browse files
author
miranov25
committed
Updated READMEtreeFastCache.md
1 parent e699b8e commit e6bd040

File tree

2 files changed

+44
-20
lines changed

2 files changed

+44
-20
lines changed

UTILS/Parsers/READMEtreeFastCache.md

Lines changed: 43 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
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

73
This 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"});
5753
tree->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

98122
Intended 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`.

UTILS/Parsers/treeFastCacheND.C

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ void setNearestNDAlias(TTree* tree, const std::string& aliasName, const std::str
163163
tree->SetAlias(aliasName.c_str(), expr.c_str());
164164
}
165165

166-
/// Example usage for ND map creation
166+
/// Example usage for ND map creation - for very High voltage queries for distertion calibration
167167
void exampleND() {
168168
TTree* tree = new TTree("tree", "demo");
169169
int mapID = registerMapND("test_map", tree, {"CRU", "iTF"}, "time", "val", "subentry==127");

0 commit comments

Comments
 (0)