00001
00010 #ifndef __BASECUTHELPERS_H
00011 #define __BASECUTHELPERS_H
00012
00013 #include "jbltools/sfh/BaseCut.h"
00014 #include "jbltools/sfh/IntFunBase.h"
00015 #include "jbltools/sfh/FloatFunBase.h"
00016 #include "jbltools/sfh/ROListPoR.h"
00017 #include "jbltools/sfh/BaseCutPoR.h"
00018 #include "jbltools/sfh/FillIteratorPoR.h"
00019 #include "jbltools/sfh/CachedO.h"
00020
00021 #include <vector>
00022
00023
00024
00025
00026 class FloatBaseCut: public FloatFun {
00027 public:
00029 explicit FloatBaseCut (const BaseCut& theBaseCut_,
00030 const char *name_ = 0
00031 );
00033 virtual Float_FF operator() () const { return theBaseCut();}
00035 virtual const FillIterator *getIterator() const {
00036 return theBaseCut.getIterator();
00037 }
00038
00039 protected:
00041 virtual ~FloatBaseCut() {}
00042 const BaseCut& theBaseCut;
00043 };
00044
00045
00046
00047 class IntBaseCut: public IntFun {
00048 public:
00050 explicit IntBaseCut (const BaseCut& theBaseCut_,
00051 const char *name_ = 0
00052 );
00054 virtual int operator() () const { return theBaseCut();}
00056 virtual const FillIterator *getIterator() const {
00057 return theBaseCut.getIterator();
00058 }
00059 protected:
00061 virtual ~IntBaseCut() {}
00062 const BaseCut& theBaseCut;
00063 };
00064
00065
00066
00067
00068
00069
00070
00071
00072 class TwoCutCompound : public BaseCut {
00073 public:
00075 TwoCutCompound (const BaseCut& lhs_,
00076 const std::string opname_,
00077 const BaseCut& rhs_
00078 );
00079 TwoCutCompound (const BaseCut& lhs_,
00080 const BaseCut& rhs_,
00081 const std::string name_
00082 );
00083
00084 virtual const FillIterator *getIterator() const;
00085
00086 protected:
00088 virtual ~TwoCutCompound() {}
00089 const BaseCut& lhs;
00090 const BaseCut& rhs;
00091 };
00092
00093
00094
00095
00096
00097
00098
00099
00100 class AndOfTwoCuts : public TwoCutCompound {
00101 public:
00102 AndOfTwoCuts (const BaseCut& lhs_,
00103 const BaseCut& rhs_
00104 )
00105 : TwoCutCompound (lhs_, "&&", rhs_)
00106 {}
00108 virtual bool operator() () const {
00109 return lhs() && rhs();
00110 };
00111
00112 protected:
00114 virtual ~AndOfTwoCuts() {}
00115 };
00116
00117
00118
00119
00120
00121
00122
00123
00124 class OrOfTwoCuts : public TwoCutCompound {
00125 public:
00126 OrOfTwoCuts (const BaseCut& lhs_,
00127 const BaseCut& rhs_
00128 )
00129 : TwoCutCompound (lhs_, "||", rhs_)
00130 {}
00132 virtual bool operator() () const {
00133 return lhs() || rhs();
00134 }
00135 protected:
00137 virtual ~OrOfTwoCuts() {}
00138 };
00139
00140
00141
00142
00143
00144
00145
00146
00147 class OneCutCompound : public BaseCut {
00148 public:
00149 OneCutCompound (const std::string& funname_,
00150 const BaseCut& arg_
00151 );
00152 OneCutCompound (const BaseCut& arg_,
00153 const std::string& name_
00154 );
00155
00156 virtual const FillIterator *getIterator() const {
00157 return arg.getIterator();
00158 }
00159
00160 protected:
00162 virtual ~OneCutCompound() {}
00163
00164 const BaseCut& arg;
00165 };
00166
00167
00168
00169
00170
00171
00172 class NotOfACut : public OneCutCompound {
00173 public:
00174 NotOfACut (const BaseCut& arg_
00175 )
00176 : OneCutCompound ("!", arg_){}
00178 virtual bool operator() () const {
00179 return !arg();
00180 }
00181 protected:
00183 virtual ~NotOfACut() {};
00184 };
00185
00186
00187 class CachedBaseCut: public BaseCut, public CachedO {
00188 public:
00190 CachedBaseCut (const ROListPoR& rol,
00191 const BaseCut& arg_
00192 );
00193 CachedBaseCut (const ROListPoR& rol,
00194 const BaseCut& arg_,
00195 const std::string& name_
00196 );
00197
00199 virtual bool operator() () const;
00200
00202 virtual void invalidateCache() { cacheValid = false; }
00203
00204 protected:
00206 virtual ~CachedBaseCut() {}
00207
00208
00209 const BaseCut& arg;
00210 mutable bool cacheValid;
00211 mutable bool cachedValue;
00212 };
00213
00214 class CachedBaseCutIt: public BaseCut, public CachedO {
00215 public:
00217 CachedBaseCutIt (const ROListPoR& rol,
00218 const BaseCut& arg_
00219 );
00221 CachedBaseCutIt (const ROListPoR& rol,
00222 const BaseCut& arg_,
00223 const FillIterator& iter_
00224 );
00226 CachedBaseCutIt (const ROListPoR& rol,
00227 const BaseCut& arg_,
00228 const std::string& name_
00229 );
00231 CachedBaseCutIt (const ROListPoR& rol,
00232 const BaseCut& arg_,
00233 const FillIterator& iter_,
00234 const std::string& name_
00235 );
00236
00238 virtual bool operator() () const;
00239
00241 virtual const FillIterator *getIterator() const {
00242 return &iter;
00243 }
00244
00246 virtual void invalidateCache() {
00247 cacheValid.resize(0);
00248 cachedValues.resize(0);
00249 }
00250
00251 protected:
00253 void growCache (unsigned int s) const;
00254
00256 virtual ~CachedBaseCutIt() {}
00257
00258
00259 const BaseCut& arg;
00260 const FillIterator& iter;
00261 mutable std::vector<bool> cacheValid;
00262 mutable std::vector<bool> cachedValues;
00263 };
00264
00265
00266
00267
00268 #endif