Hello,
I am sure this is a trivial question, but I can’t find a solution to it elsewhere:
I can’t seem to apply event weights in a RooDataSet. In reality I am reading from a TTree three values - x,y, and weight (and doing some manipulation before adding them to the RooDataSet) - but it seems they all arrive with a weight of 1.
Here’s a much simplified piece of code that replicates the problem:
#include <iostream>
#include "RooRealVar.h"
#include "RooDataSet.h"
void test(){
RooRealVar x("x","x",0,100);
RooRealVar y("y","y",20,80);
RooDataSet s("s","s",RooArgSet(x,y));
x.setVal(87.0);
y.setVal(23.1415927);
s.add(RooArgSet(x,y),0.5); // give the event weight=0.5
s.Print("v");
std::cout<<"s.sumEntries() = "<<s.sumEntries() <<" weighted? "<<(s.isWeighted() ? "yes" : "no" )<<std::endl;
}
and the output from running this
DataStore s (s)
Contains 1 entries
Observables:
1) x = 87 L(0 - 100) "x"
2) y = 23.1416 L(20 - 80) "y"
s.sumEntries() = 1 weighted? no
I was expecting the sumEntries to contain the weight I assignment (0.5), and for it to say “weighted? yes” based on this member function of RooDataSet:
virtual void add(const RooArgSet& row, Double_t weight = 1.0, Double_t weightError = 0)
Thank you