# Schema Evolution: Renaming a \`std::map\` Member Variable

**URL:** <https://root-forum.cern.ch/t/schema-evolution-renaming-a-std-map-member-variable/64310>\
**Category:** ROOT\
**Tags:** tree, io\
**Created:** [October 10, 2025, 8:16pm UTC](https://root-forum.cern.ch/t/schema-evolution-renaming-a-std-map-member-variable/64310 "2025-10-10T20:16:14Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![tomeichlersmith](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/tomeichlersmith/32/39455_2.png) [@tomeichlersmith](https://root-forum.cern.ch/u/tomeichlersmith)\
**Post date:** [October 10, 2025, 8:16pm UTC](https://root-forum.cern.ch/t/schema-evolution-renaming-a-std-map-member-variable/64310/1 "2025-10-10T20:16:14Z")

</div>

* * *

_ROOT Version:_ 6.34.04  
_Platform:_ linuxx8664gcc  
_Compiler:_ GCC 13.3.0

Specifically, I am using the container image [ldmx/pro:v4.4.0 on DockerHub](https://hub.docker.com/layers/ldmx/pro/v4.4.0/images/sha256-3e2c25c7430441b5871d334b13a0ed93bcfa58cfe2fd6d88503040df7a1ae01f). Look there for all the messy details.

* * *

I am working in a project where we recently adopted some naming guidelines for our member variables and have now applied them to classes that are serialized by ROOT into output TTrees. However, unsurprisingly, we still have data files with the old schema (old names for member variables) floating around and so I am interested in having some schema rules that rename the member variables when reading the old format.

The full project [ldmx-sw](https://github.com/LDMX-Software/ldmx-sw) is large and takes quite some time to compile, but I’ve been able to partially replicate the issue with a smaller example.

The source code for this example is:

[rename-std-map-member-variable.tar.gz](https://root-forum.cern.ch/uploads/short-url/1JIIZkyh9vpGgbROssTIXilG3Gt.gz) (2.3 KB)

The script `show` in this example, configures and builds the example and then runs the different reading programs to display the issue. Ignoring the configuration and compiling output, we can see that the naive schema rule does not read in the data from the old schema for the `std::map` member (`my_parameter`) but does appropriately get the re-named `int` member (`run`). I can get the reading to work, but it requires carrying around an extra copy of the `std::map` member using the old name which I don’t want to do.

```bash
Writing Header V1 to file...
Reading file with Header V1:
run: 2
myParameter[example]: 42
Reading file with Header V2:
manual schema evolution rule being applied
run: 2
my_parameter[example]: does not exist
Reading file with Header Both:
manual schema evolution rule being applied
run: 2
my_parameter[example]: 42

```

- “V1” is the “old schema” with members `int runNumber_` and `std::map<std::string, int> myParameters_`
- “V2” is the “new schema” with members `int run_number_` and `std::map<std::string, int> my_parameters_` along with the schema rule that does `{ run_number_ = onfile.runNumber_; my_parameters_ = onfile.myParameters_; }`. In this simplified case, the `std::map` just does not read the on-file data, but in a more complex case (see LDMX-Software/ldmx-sw Issue 1815 on GitHub) it seg faults.
- “Both” is a “intermediate” schema with members `int run_number_`, `std::map<std::string, int> myParameters_`, and `std::map<std::string, int> my_parameters_` along with the schema rule `{run_number_ = onfile.runNumber_; my_parameters_ = myParameters_}`

This is my first attempt writing schema evolution rules within ROOT. Am I missing something obvious or is this a corner case where I need to do something more than the naive approach?

---

<div class="post-metadata">

**Author:** ![Danilo](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/danilo/32/34528_2.png) [@Danilo](https://root-forum.cern.ch/u/Danilo)\
**Post date:** [October 12, 2025, 1:30pm UTC](https://root-forum.cern.ch/t/schema-evolution-renaming-a-std-map-member-variable/64310/2 "2025-10-12T13:30:05Z")

</div>

Hello,

Welcome to the ROOT Community!

We acknowledge your post. We are working on your reproducer.

Cheers,  
Danilo

---

<div class="post-metadata">

**Author:** ![tomeichlersmith](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/tomeichlersmith/32/39455_2.png) [@tomeichlersmith](https://root-forum.cern.ch/u/tomeichlersmith)\
**Post date:** [October 17, 2025, 6:39pm UTC](https://root-forum.cern.ch/t/schema-evolution-renaming-a-std-map-member-variable/64310/3 "2025-10-17T18:39:57Z")

</div>

I have updated my example code to hopefully make it easier to understand. It is now in the `forum-rename-std-map-64310` directory of a repo on GitHub: [ldmx-root-schema-evolution-testbench/forum-rename-std-map-64310 at main · tomeichlersmith/ldmx-root-schema-evolution-testbench · GitHub](https://github.com/tomeichlersmith/ldmx-root-schema-evolution-testbench/tree/main/forum-rename-std-map-64310)

I’ll work off of this repo, so let me know if I should add another/different test in some way or feel free to fork and PR a new test and/or fix.

---

<div class="post-metadata">

**Author:** ![tomeichlersmith](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/tomeichlersmith/32/39455_2.png) [@tomeichlersmith](https://root-forum.cern.ch/u/tomeichlersmith)\
**Post date:** [October 20, 2025, 2:28pm UTC](https://root-forum.cern.ch/t/schema-evolution-renaming-a-std-map-member-variable/64310/4 "2025-10-20T14:28:57Z")

</div>

This same behavior is present when I am using ROOT 6.36.04. Repo linked above updated with container image digest (under `form-rename-std-map-64310/.denv/config`).

---

<div class="post-metadata">

**Author:** ![ferhue](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/ferhue/32/29462_2.png) [@ferhue](https://root-forum.cern.ch/u/ferhue)\
**Post date:** [October 21, 2025, 7:26am UTC](https://root-forum.cern.ch/t/schema-evolution-renaming-a-std-map-member-variable/64310/5 "2025-10-21T07:26:45Z")

</div>

Maybe related [https://its.cern.ch/jira/browse/ROOT-9862](https://its.cern.ch/jira/browse/ROOT-9862)

---

<div class="post-metadata">

**Author:** ![system](https://root-forum.cern.ch/uploads/default/original/3X/e/f/efe4f24398fd8ffeb76bccb6ecc46d9d9c003376.png) [@system](https://root-forum.cern.ch/u/system)\
**Post date:** [November 4, 2025, 7:27am UTC](https://root-forum.cern.ch/t/schema-evolution-renaming-a-std-map-member-variable/64310/6 "2025-11-04T07:27:05Z")

</div>

Closed on November 4, 2025, 7:27am UTC

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
