10 _Cut(
const std::function<CutFunc_t>& func,
11 const std::function<ExposureFunc_t>& liveFunc,
12 const std::function<ExposureFunc_t>& potFunc)
13 : fFunc(func), fLiveFunc(liveFunc), fPOTFunc(potFunc),
25 std::function<ExposureFunc_t>
27 const std::function<ExposureFunc_t>& b)
29 if(!a && !b)
return 0;
33 return [
a, b](
const caf::SRSpill* spill){
34 const double va =
a(spill);
35 const double vb = b(spill);
37 if(va >= 0 && vb >= 0){
38 std::cout <<
"Inconsistent pot/livetime values of "
39 << va <<
" and " << vb
40 <<
" from two cuts being combined." << std::endl;
44 return std::max(va, vb);
53 static std::map<std::pair<int, int>,
int> ids;
54 const std::pair<int, int> key(a.
ID(), b.
ID());
57 return _Cut<T>([
a, b](
const T* sr){
return a(sr) && b(sr);},
63 const _Cut<T> ret([a, b](
const T* sr){
return a(sr) && b(sr);},
78 static std::map<std::pair<int, int>,
int> ids;
79 const std::pair<int, int> key(a.
ID(), b.
ID());
81 return _Cut<T>([
a, b](
const T* sr){
return a(sr) || b(sr);},
87 const _Cut<T> ret([a, b](
const T* sr){
return a(sr) || b(sr);},
102 static std::map<int, int> ids;
103 if(ids.count(a.
ID())){
104 return _Cut<T>([
a](
const T* sr){
return !
a(sr);},
108 const _Cut<T> ret([a](
const T* sr){
return !
a(sr);});
109 ids[a.
ID()] = ret.ID();
120 template<
class T> _Cut<T>
123 return _Cut<T>([v, c](
const T* sr){
return v(sr) > c;});
127 template<
class T> _Cut<T>
130 return _Cut<T>([v, c](
const T* sr){
return v(sr) >= c;});
134 template<
class T> _Cut<T>
135 operator<(const _Var<T>& v,
double c)
137 return _Cut<T>([v, c](
const T* sr){
return v(sr) < c;});
141 template<
class T> _Cut<T>
142 operator<=(const _Var<T>& v,
double c)
144 return _Cut<T>([v, c](
const T* sr){
return v(sr) <= c;});
148 template<
class T> _Cut<T>
151 return _Cut<T>([v, c](
const T* sr){
return v(sr) == c;});
155 template<
class T> _Cut<T>
162 template<
class T> _Cut<T>
165 return _Cut<T>([
a, b](
const T* sr){
return a(sr) > b(sr);});
169 template<
class T> _Cut<T>
172 return _Cut<T>([
a, b](
const T* sr){
return a(sr) >= b(sr);});
176 template<
class T> _Cut<T>
179 return _Cut<T>([
a, b](
const T* sr){
return a(sr) == b(sr);});
185 template<
class T>
_Cut<T> operator<(double c, const _Var<T>& v){
return v > c;}
187 template<
class T>
_Cut<T> operator<=(double c, const _Var<T>& v){
return v >= c;}
195 template class _Cut<caf::SRSpillProxy>;
196 template class _Cut<caf::SRSliceProxy>;
198 template<
class T>
int _Cut<T>::fgNextID = 0;
_Cut< T > operator<(const _Var< T > &v, double c)
std::function< ExposureFunc_t > fPOTFunc
_Cut< T > operator<=(const _Var< T > &v, double c)
_Cut< T > operator!(const _Cut< T > &a)
_Cut< T > operator&&(const _Cut< T > &a, const _Cut< T > &b)
std::function< ExposureFunc_t > CombineExposures(const std::function< ExposureFunc_t > &a, const std::function< ExposureFunc_t > &b)
_Cut(const std::function< CutFunc_t > &func, const std::function< ExposureFunc_t > &liveFunc=0, const std::function< ExposureFunc_t > &potFunc=0)
std::function can wrap a real function, function object, or lambda
_Cut< T > operator||(const _Cut< T > &a, const _Cut< T > &b)
process_name opflashCryoW ana
caf::Proxy< caf::SRSlice > SRSliceProxy
_Var< caf::SRSliceProxy > Var
Representation of a variable to be retrieved from a caf::StandardRecord object.
_Cut< T > operator>=(const _Var< T > &v, double c)
_Var< caf::SRSpillProxy > SpillVar
Equivalent of Var acting on caf::SRSpill.
_Cut< caf::SRSliceProxy > Cut
caf::Proxy< caf::StandardRecord > SRSpillProxy
int ID() const
Cuts with the same definition will have the same ID.
std::function< ExposureFunc_t > fLiveFunc
_Cut< T > operator!=(const _Var< T > &v, double c)
_Cut< caf::SRSpillProxy > SpillCut
Equivalent of Cut acting on caf::SRSpill. For use in spill-by-spill data quality cuts.
_Cut< T > operator==(const _Var< T > &v, double c)
Template for Cut and SpillCut.
_Cut< T > operator>(const _Var< T > &v, double c)
Most useful for combining weights.
BEGIN_PROLOG could also be cout