Dear all,
I am trying to use RooFit to fit a weighted data-set, trough a RooDataSet.
I am loading the data from a TTree: since my variables are not in “flat” branches, I am doing that manually, looping over the TTree (see code).
However, it seems to me all the weights in the RooDataSet are fixed to 1.
My root version: 5.32
The code I am using:
RooRealVar vx("omega_mass","omega_mass",0.78,0.78-0.15,0.78+0.15);
RooRealVar qq("qq_value","qq_value",0,1);
RooArgSet arg(vx,qq);
RooDataSet data("data","data",arg,WeightVar("qq_value"));
data.Print("v");
t->SetBranchAddress("event",&m_event);
for (int jj=0;jj<t->GetEntries();jj++){
t->GetEntry(jj);
vx.setVal(m_event.omega_mass);
qq.setVal(m_event.q_value);
data.add(arg);
cout<<qq.getValV()<<endl;
cout<<data.weight()<<endl;
cin.get();
}
Where “t” is a TTree containing a Branch “event”, where “event” is a C-structure:
struct{
unsigned int run_number,event_number,tree_number;
float q_value,eq_value;
float mc_weight;
float W;
float e_gamma;
float t;
float cos_cm;
float theta_adair,phi_adair;
float s_omega,t_omega,u_omega;
float omega_mass;
float m2_ep;
float lambda; //the lambda method.
}m_event;
When I execute the code, I see:
DataStore data (data)
Contains 0 entries
Observables:
1) omega_mass = 0.7557 L(0.63 - 0.93) "omega_mass"
Dataset variable "qq_value" is interpreted as the event weight
That is, the RooDataSet “recognizes” that qq is the weight var. However, at each loop execution, I see that the “qq.getValV()” returns the correct value (between 0 and 1), while the “data.weight()” always returns 1.
(Later on in the code I am also plotting the RooDataSet, and I confirm that the values are ploted with constant weight = 1)
Am I making any mistake?
Thanks!
Andrea