Event-by-event weighting and saving as a branch at TTree

Hi,

thanks a lot for reply.

To illustrate this, I attached four histograms.
D_ETA - original TH1
weight - original weight for all events
D_ETA_weighted_TH1 - D_ETA weighted via h->Fill(“D_ETA”, “weight”)
D_ETA_weighted_multiplication - result of D_ETA after multiplication values and weights event-by-event.
As can be see, the result is absolutely different.

Code used for creating of a new branch, with the values after multiplication, is just a basic tutorial script, also attached.
Min_work_sample.c (526 Bytes)

I presume, the catch is in the multiplication of values and weights (done according to the linked post), for me such a method doesn’t give much sense.

double D_ETA;
double D_ETA_w;
double weight;

TBranch *newb = tree1->Branch("D_ETA_w",&D_ETA_w,"D_ETA_w/D"); 

tree1->SetBranchAddress("weight", &weight);
tree1->SetBranchAddress("D_ETA", &D_ETA);
Long64_t nentries = tree1->GetEntries();
 for(Long64_t i=0; i< nentries; i++){
	 tree1->GetEntry(i);
	 D_ETA_w = D_ETA * weight;
	 newb->Fill();
	 
	}



!