Skip to content

Commit

Permalink
Adding definitions for cuts and vars at SR and Interaction, RecoParti…
Browse files Browse the repository at this point in the history
…cle levels
  • Loading branch information
mcasales committed Dec 14, 2023
1 parent 490285a commit 10c4aad
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 18 deletions.
29 changes: 27 additions & 2 deletions CAFAna/Core/Cut.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,33 @@

namespace ana
{
using Cut = _Cut<caf::SRProxy>;
// using Cut = _Cut<caf::SRProxy>;

/// \brief Representation of a cut (selection) to be applied to a \ref
/// caf::StandardRecord object
///
/// A Cut consists of a function, taking a StandardRecord and returning a
/// boolean indicating if that event passes the cut.
///
/// Cut objects may be combined with the standard boolean operations && ||
/// and !
typedef _Cut<caf::SRInteractionProxy> InteractionCut;
typedef _Cut<caf::SRInteractionProxy> Cut;

/// \brief Equivalent of \ref Cut acting on \ref caf::StandardRecord. For use in
/// spill-by-spill data quality cuts ????
typedef _Cut<caf::SRProxy> SRCut;


/// The simplest possible cut: pass everything, used as a default
const Cut kNoCut(NoCut<caf::SRInteractionProxy>{});

/// The simplest possible cut: pass everything, used as a default
const Cut kNoCut(NoCut<caf::SRProxy>{});
const SRCut kNoSRCut(NoCut<caf::SRProxy>{});


typedef _Cut<caf::SRRecoParticleProxy> RecoPartCut;

const RecoPartCut kNoPartCut(NoCut<caf::SRRecoParticleProxy>{});

}
20 changes: 14 additions & 6 deletions CAFAna/Core/OscillatableSpectrum.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
#include "CAFAna/Core/Utilities.h"

#include "duneanaobj/StandardRecord/Proxy/SRProxy.h"

#include "OscLib/IOscCalc.h"

#include "TDirectory.h"
Expand All @@ -22,15 +21,24 @@ namespace ana
{
namespace{
// Duplicate here because we can't include Vars.h
const Var kTrueE([](const caf::SRProxy* sr)
const Var kTrueE([](const caf::SRInteractionProxy* ixn)
{
assert(sr->mc.nnu == 1);
return sr->mc.nu[0].E;
//assert(sr->mc.nnu == 1);
assert(ixn->truth.size()>0);
/// uuumm what do we
return ixn->Enu;
});
const Cut kHasNu([](const caf::SRInteractionProxy* ixn)
{
//return sr->truth.index >= 0;
// this should return something at the true level,
//in the meantime just check there's interaction or whatever placeholder cut
return ixn->truth.size()>0;//dlp.size()>0;
});
}
//----------------------------------------------------------------------
OscillatableSpectrum::OscillatableSpectrum(IRecordSource& src, const HistAxis& axis)
: ReweightableSpectrum(src, axis, HistAxis("True Energy (GeV)", kTrueEnergyBins, kTrueE))
OscillatableSpectrum::OscillatableSpectrum(IInteractionSource& src, const HistAxis& axis)
: ReweightableSpectrum(src[kHasNu], axis, HistAxis("True Energy (GeV)", kTrueEnergyBins, kTrueE))
{
}

Expand Down
18 changes: 11 additions & 7 deletions CAFAna/Core/OscillatableSpectrum.h
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
#pragma once

#include "CAFAna/Core/ReweightableSpectrum.h"
#include "cafanacore/ReweightableSpectrum.h"
#include "cafanacore/FwdDeclare.h"
#include "cafanacore/Spectrum.h"
#include "cafanacore/ThreadLocal.h"

#include "CAFAna/Core/Binning.h"
#include "CAFAna/Core/FwdDeclare.h"
#include "CAFAna/Core/IRecordSource.h"
//#include "CAFAna/Core/FwdDeclare.h"
#include "CAFAna/Core/OscCalcFwdDeclare.h"
#include "CAFAna/Core/Spectrum.h"
//#include "CAFAna/Core/Spectrum.h"
#include "CAFAna/Core/SpectrumLoaderBase.h"
#include "CAFAna/Core/StanTypedefs.h"
#include "CAFAna/Core/ThreadLocal.h"
//#include "CAFAna/Core/ThreadLocal.h"

#include "CAFAna/Core/IRecordSource.h"

#include <string>

Expand All @@ -18,7 +22,7 @@
class TH2;
class TH2D;

#include "CAFAna/Core/FwdDeclare.h"
//#include "CAFAna/Core/FwdDeclare.h"

namespace ana
{
Expand All @@ -38,7 +42,7 @@ namespace ana
class OscillatableSpectrum: public ReweightableSpectrum
{
public:
OscillatableSpectrum(IRecordSource& src, const HistAxis& axis);
OscillatableSpectrum(ana::IInteractionSource& src, const HistAxis& axis);

OscillatableSpectrum(const Eigen::MatrixXd&& mat,
const HistAxis& recoAxis,
Expand Down
14 changes: 11 additions & 3 deletions CAFAna/Core/Var.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,21 @@ namespace ana
///
/// A Var consists of a function, taking a StandardRecord and returning the
/// value of the variable (which may be some complicated function).
using Var = _Var<caf::SRProxy>;
typedef _Var<caf::SRInteractionProxy> Var;

/// \brief Equivalent of \ref Var acting on \ref caf::SRSpill
typedef _Var<caf::SRProxy> SRVar;

/// \brief For Vars where literally all you need is a single CAF variable
///
/// eg Var myVar = SIMPLEVAR(my.var.str);
/// NB lack of quotes quotes around my.var.str
#define SIMPLEVAR(CAFNAME) Var([](const caf::SRProxy* sr){return sr->CAFNAME;})
#define SIMPLEVAR(CAFNAME) Var([](const caf::SRInteractionProxy* sr){return sr->CAFNAME;})


inline Var Constant(double v){return Var([v](const caf::SRInteractionProxy*){return v;});}


typedef _Var<caf::SRRecoParticleProxy> RecoPartVar;

inline Var Constant(double v){return Var([v](const caf::SRProxy*){return v;});}
}

0 comments on commit 10c4aad

Please sign in to comment.