JeffersonLab / japan-MOLLER

Just Another Parity ANalyzer --- Development for MOLLER
3 stars 10 forks source link

QwCopyArray still needed? #10

Open hansenjo opened 9 months ago

hansenjo commented 9 months ago

My recent fix in the japan repo related to copying C-arrays in constructors was updated here: The C-arrays in the japan classes were replaced with std::array objects. Good.

Now, with this replacement done, I think you don't need the workaround with the QwCopyArray function anymore since, unlike C-arrays, std::array can be initialized via copy construction from another std::array (same size and element type assumed).

If you then still have a problem with operator= assignment, then I'd suspect a design flaw in the classes involved. Shouldn't an assignment a = b give you an a that is (functionally) equal to b?

paulmking commented 8 months ago

The operator=, operator+, and operator- functions are written to act on the event-level data and not on the initialization data. The idea is to allow arithmetic of different channels together, like newbcm = bcm1 + bcm2.

hansenjo commented 8 months ago

Ah, yes, I realized this recently as well. A bit of "unexpected behavior" when one comes from standard C++, but certainly an interesting design. The question the is, does the copy constructor work differently from operator=? If it does, odd things may happen in the code:

A a1 = b;
A a2(b);

Will these two lines give different results? I'll let this sink into my mind for a while.