Dear ROOT experts,
I’m trying to fill a TNtuple with variables from a selection of events. However the problem is that not every event does contain all desired variables (in my case, this means that there are events with only one jet). I tried to solve this as in the code below (simplified version of the actual code), but jet2pt gets filled with zeros, whereas I would like to leave this field empty for events without a second jet. Is there a way to do this with tntuple (or ttree)?
[code]
//preselection: at least one jet and Z in event
tntuple = new TNtuple(“tntuple”, “TNtuple”, “zpt:jet1pt:jet2pt”);
//loop over events
…
std::vector variables = {event.ZpT, event.jet1pT};
//check if there is a second jet
if (event.number_of_jets > 1)
{
variables.push_back(event.jet2pT);
}
m_tree.Fill(&variables[0]);
//save tntuple
…[/code]
Thanks!