Project

General

Profile

Adjusting your macro to SRProxy

The latest SRProxy-based version of CAFAna should make many macros run faster, and frees us from the error-prone tyranny of the Requires() line. It does take a few syntactic adjustments to your macro though. These should only take a few minutes.

Header inclusion

Adjust any #include lines like this

#include "StandardRecord/StandardRecord.h" 

to include SRProxy.h instead

#include "StandardRecord/Proxy/SRProxy.h" 

If you include any of the individual StandardRecord classes (e.g. SRSlice.h) you now only need SRProxy.h

Signature of Cut and Var

Variable definitions like

Var kMyVar({"my.var"},
           [](const caf::StandardRecord* sr)
           {
             return sr->my.var;
           });

should now look like this

Var kMyVar([](const caf::SRProxy* sr)
           {
             return sr->my.var;
           });

that's right. No need to specify your Requires() line anymore!

and the same for Cut or MultiVar.

SpillCuts now take a caf::SRSpillProxy argument.

If you assign to a temporary variable inside your Var, like const SRSlice& slc = sr->slc;, that type now gains a Proxy too: const SRSliceProxy& slc = sr->slc;

Similarly ISyst now takes an SRProxy, no need for Restorer anymore, and no need for a Requires() function.

"inconsistent types ‘float’ and ‘caf::Proxy<float>’ deduced for lambda return type"

You may have run into this previously. C++ is very picky about return values from lambdas and won't apply its normal type conversion rules. So, if you have an `if()` returning a default value, or something like that, you need to force your main return value taken from the proxy to be the same type. Just add a cast to float or whatever type you need to make things match.