Following is the code that takes input as weighted RooDataSet and tries to create a reduced dataset by picking random events from that dataset.
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)
output = dataset.emptyClone("subset")
startBit = outputBits.FirstSetBit(0)
while startBit < sumEntries:
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
I can reproduce the segfault, getting this stack trace
#6 0x00007fc074c8c4af in RooAbsCollection::tryFastFind(TNamed const*) const () from /install-debug/lib/libRooFitCore.so
#7 0x00007fc074c8c678 in RooAbsCollection::find(RooAbsArg const&) const () from /install-debug/lib/libRooFitCore.so
#8 0x00007fc074c8c97f in RooAbsCollection::operator=(RooAbsCollection const&) () from /install-debug/lib/libRooFitCore.so
#9 0x00007fc074d5a7f9 in RooDataSet::add(RooArgSet const&, double, double) () from /install-debug/lib/libRooFitCore.so
@moneta can you help?
@StephanH Please have a look.
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
StephanH moved on, and that leaved its traces. Maybe @jonas could have a look? @pkalbhor did you find a work-around?
Hi @pkalbhor, sorry for the very late reply!
Your problem is that you are are trying to get rows from the dataset with an index that is out of bounds. At the origin of this is that you retreive the number of entries in the dataset in the wrong way. You use RooDataSet::sumEntries(), but this returns the effective number of entries in dataset, i.e., sum all weights. In your case, it’s larger than the number of rows, hence the out of bounds error. Please use numEntries() instead.
I hope this helps. Don’t hesitate to ask further questions!
This topic was automatically closed after 13 days. New replies are no longer allowed.