root icon indicating copy to clipboard operation
root copied to clipboard

[ntuple] Consider making `REntry::AddValue()` publicly accessible

Open jalopezg-git opened this issue 3 years ago • 4 comments

As per a request from @Nowakus, making REntry::AddValue() publicly accessible would be useful in some specific cases.

@Nowakus could you please comment in this issue why (I cannot recall now). Also, it would be helpful if you also attach your current workaround.

jalopezg-git avatar Nov 08 '22 14:11 jalopezg-git

Lets start with the requirement: What I want is a way to create a default object for one of the fields. Right now I need to do this: obj = entry->GetValue(fieldname).GetField()->GenerateValue().GetRawPtr(); entry->CaptureValueUnsafe( fieldname, obj ); which is very convoluted and in addition it leaves object ownership to me for no good reason. I think AddValue() can do all this and even make the RNTuple manage the created object, is that right? (if not, that is what I would actually prefer)

Cheers, Marcin

Nowakus avatar Nov 09 '22 10:11 Nowakus

What I want is a way to create a default object for one of the fields. Right now I need to do this: obj = entry->GetValue(fieldname).GetField()->GenerateValue().GetRawPtr(); entry->CaptureValueUnsafe( fieldname, obj );

@Nowakus I assume that entry above is a "bare" entry, no?

jalopezg-git avatar Nov 09 '22 15:11 jalopezg-git

Yes, I create the Entry this way: entry = ntupleWriter->GetModel()->CreateBareEntry(); In most cases the objects to be added to the ntuple are already existing, but in some cases one may be missing for a given Event so I create a default objects to fill out the empty Field.

Nowakus avatar Nov 10 '22 09:11 Nowakus

Required flexibility for framework use should be given now by

  • RFieldBase::CreateObject()
  • REntry::EmplaceNewValue()

jblomer avatar Feb 14 '24 09:02 jblomer