Project

General

Profile

Getting the run, subrun, and event number from an art-formatted file

Usually the run and event number are available after an event has been read in using the ROOTINPUT source
and is available to analysis modules. But sometimes, as when writing input sources or when just inspecting a file
to get the run and event number of say the first event in it, one would like to unpack the data structure as is.
Here's a short ROOT macro from Kyle Knoepfel which does this:

#include "art/Persistency/Provenance/EventAuxiliary.h”
art::EventAuxiliary evAux;
auto pEvAux = &evAux;
TBranch* auxBranch = yourTree->GetBranch(“EventAuxiliary”);
auxBranch->SetAddress(&pEvAux);
auxBranch->GetEntry( your_favorite_entry_here );
auto evtNo = evAux.event();
auto srNo = evAux.subRun();
auto runNo = evAux.run();
etc.