Following is the code that takes input as weighted RooDataSet and tries to create a reduced dataset by picking random events from that dataset.
import ROOT f = ROOT.TFile("inputfile.root") dataset = f.Get("sigMCReader.2016.Fit") sumEntries = int(dataset.sumEntries()) outputBits = ROOT.TBits(int(sumEntries)) for entry in range(100): rnd = ROOT.gRandom.Integer(sumEntries) outputBits.SetBitNumber(rnd) output = dataset.emptyClone("subset") startBit = outputBits.FirstSetBit(0) while startBit < sumEntries: output.Print() output.add(dataset.get(startBit), dataset.weight(), dataset.weightError()) startBit = outputBits.FirstSetBit(startBit + 1) print("Execution successful without any runtime error!")
If I run it, gives the following error. The point to be noted is that error occurs randomly. Please let me know the bug in the code with some explanation.
void RooDataSet::add(const RooArgSet& row, double weight = 1., double weightError = 0) => SegmentationViolation: segfault in C++; program state was reset
Input root file: https://cernbox.cern.ch/index.php/s/KAvFtRS474b226p or