(snapshot)= # Exercise 9: Writing the n-tuple **(10 minutes)** If you've made changes to your n-tuple (defining new columns, applying filters) and you want to write the revised n-tuple to a file, use the `Snapshot()` method. **Here's an example** :::{code-block} c++ :name: snapshot-c-example :caption: An example using the `Snapshot` method (C++) // Open a dataframe from an n-tuple within a file. auto dataframe = ROOT::RDataFrame("tree1","experiment.root"); // Make a change to the n-tuple. auto pzcut = dataframe.Filter("pz < 145"); // Write the revised n-tuple with the name "pzcut" to file // "analysis.root". pzcut.Snapshot("pzcut","analysis.root"); ::: **Here's the Exercise** In the past few pages, we've built a collection of new variables ($p_{T}$, $\theta$, $E_{meas}$, $E_{loss}$) and useful analysis cuts ($\chi^{2} < 1.5$, $\theta < 0.15$). Derive an n-tuple with all these new columns and cuts, and write it as n-tuple `analyzed` to file {file}`analysis.root`. :::{tip} If you look up `Snapshot()` on the [RDataFrame web page](https://root.cern/doc/master/classROOT_1_1RDataFrame.html) you'll see that it's classified as an {dfn}`instant action`. This means that the event loop will be executed when the `Snapshot()` is executed. If, for some reason, you want a lazy evaluation of `Snapshot()`, click on the highlighted word `Snapshot()` on that page. It will take you to a different page; search for `fLazy` on that new page. ::: :::{figure-md} effect_size-fig :align: center xkcd effect_size by Randall Munroe :::