How to get event weight for mc sample

hi, im trying to get the weight of each event for the mc sample that i produced from madgraph and calculate the sum of event weights,

i read through TMVA: How to get event-by-event weights? and TMVA: How do Tree and Event-By-Event Weights Work? but this did not help, im not using TMVA.

i found this formula W = σL/N. where σ is the cross section , L luminosity and N total no of events generated, but this would be the weight i calculated, not the weight of the mc sample generated,

sorry im very confuse can anyone give me a suggestion, thanks

Please read tips for efficient and successful posting and posting code

ROOT Version: Not Provided
Platform: Not Provided
Compiler: Not Provided


@moneta could you please suggest something here? Thank you in advance!

Hi,
This seems to be a MC specific question and not a ROOT question.
If you want to re-weight different MC samples for the same luminosity, the formula above is the correct one to apply an overall weight to your MC sample that you can pass in TMVA in the DataLoader::AddBackgroundTree or AddSignalTree function.

In some case you need to apply a weight for each event. This weight can be produced for example by your MC generator and you provide in TMVA, using the function, DataLoader::SetBackgroundWeightExpression or SetSignalWeightExpression

Lorenzo

but in my case i want to know what is the weight of each events generated,

or is it assume to = 1 as events i generated are unweighted events?

There should be a branch in your TTree with MC-generator weights, one number per event. Don’t assume it’s 1!

thanks!

hi, im sorry i dont understand these values
i generated my samples using madgraph+delphes, so these are the delphes branches

thought im not sure how to interpret these values,

I’m not at all familiar with Delphes, so this might be a question to ask your supervisor instead. What’s in the Weight.Weight leaf?

i have resolved this issue, i am using DELPHES, so for further reference if anyone is having the same problem as mine you do;

ExRootTreeReader *treeReader = new ExRootTreeReader(&chain);
Long64_t numberOfEntries = treeReader->GetEntries();
TClonesArray *branchEvent = treeReader->UseBranch("Event");
for(Int_t entry = 0; entry < numberOfEntries; ++entry)
    {
      // print event number (every 10 event) in the file
      if(entry%10==0) cout << "Reading Event " << entry << endl;
      // Load selected branches with data from specified event
      treeReader->ReadEntry(entry);
      HepMCEvent *event = (HepMCEvent*) branchEvent -> At(0);
    //LHEFEvent *event = (LHEFEvent*) branchEvent -> At(0);
        cout << event->Weight << endl; //prints weight of each event
//...........rest of the selection code.....//
}