# MarlinMT hist manager
## Comments from Remi:
1. The code should be placed in directories `include/marlin/book` and `src/book`. Example `include/marlin/book/BookStore.h` and `src/book/BookStore.cc`
2. The project is located on [https://github.com/iLCSoft/MarlinMT](https://github.com/iLCSoft/MarlinMT).
3. Julian: for all `book` stuff, make a new PR
4. The `book` component in MarlinMT must be optional, as it relies on ROOT 7 experimental library
## Comments from Julian:
1. added `include/marlin/hist`
### ROOT Confusions
* Coordinate Array is an `std::array<double, Dimensions>` under the hood
* funFact:
> if you destroy the filler before the histogram you get a segfault ...
* root Add don't keep the EntrieCount !
## TODO list
Remi:
- [x] Merge the marlin-mt branch in master (PR)
- [x] Implement a proper CMake find_package call for finding ROOT 7 hist headers
- [ ] Integrate ROOT 7 -> 6 conversion from Hadrian in a PR
- [ ] Fix std hash warning
- [ ] Cleanup MarlinMT test directory
Julian:
- [ ] Define the HistManager interface
- [x] write Down First ideas
- [x] iterate over Deseign
- [x] impliment example Header [link](eba09726811910d330a5d69e507d4cbbfb49dc77)
- [x] add namspace to MemLayer
- [x] move Flags in Flag_t
- [x] add if Malin_Book for tests
- [ ] WriteTest
- [ ] remove explicit construction
- [x] no use of default arguments
- [ ] Model the internal storage of booked elements
- [ ] DataModel modeling
- [ ] define C++ header
- [ ] Define the XML interface (code and XML)
- [ ] Construct XML Interface
- [ ] Define in XML
- [ ] Define in Code
## BookStore
### Implimentation
#### DataModel
1. unorderd_map<path, shared<HistEntry>>, path = /<processor>/<histPath>
+ **pro**
+ easy
+ scalable
+ map has O(1) to worst case O(N)
+ **contra**
+ deadlinks when Hist is deleted
+ wastet memory
### API
#### HistogramBooking
```cpp
enum struct Flags : uint8_t {
MutipleInstance = 1 << 0,
Default = 0b…1,
};
template<class BookT>
HND<trait<BookT>>
book( … );
```
#### HistHandle
* types
```cpp
using Type = HistType;
```
* Filling
```cpp
histHnd->Fill(…);
/// add one value
void
fill(const FillType& x, const Weight_t& w);
/// add mutible values
void
fillN(
const std::span<CoordArray_t const>& xN,
const std::span<Weight_t const>& w);
```
* Reading
```cpp
/// finalize object and return it
const Type& Get();
```
* :::warning
**Only read in serial parts**. Reading is **not** thread save.