DeepLearnPhysics / larcv2

MIT License
13 stars 16 forks source link

Question: Why have EventImage2D be a const-only container? #28

Open twongjirad opened 6 years ago

twongjirad commented 6 years ago

Any reason to enforce this?

Here is my current use case that would require the underlying vector to be mutable. this would mean allowing an as_vector() command that doesnt pass a const reference.

I have a routine to crop a whole event image into many subimages (162), whose meta do not change, event-by-event. The need to allocate and reallocate the eventimage2d vector is inefficient. it would seem better to keep the images in memory, and just update the values. (of course, this also requires that iomanager does not clear the event container after writing it -- which is another question i guess.)

I do see that one could create two vector and swap them from event to event using eventimage::emplace. but for large vectors of images, that's double the memory.

maybe better yet is to just make eventimage2d inheret from both eventbase and std::vector.