#ifndef _CALOR_PREDICATES_HH_ #define _CALOR_PREDICATES_HH_ #ifdef USE_CDFEDM2 ///////////////////////////////////////////////////////////////////////////////////////////////////// // // Component: CalorPredicates.hh // Purpose: This class contains some predicate classes to be used // in the making of calorimeter objects. // // Created: 19/06/99 Pierre Savard // // History: 20/10/99 Pierre Savard: add templates // 07/07/00 Bob Wagner: added predicate to find PhysicTower in // PhysicsTowerData or PhysicsTowerView by // TowerKey. Requires #include // 16/01/01 Bob Wagner: add AnyTowerKey which returns true if any // TowerKey in passed vector is in PTView // 18/01/01 Bob Wagner: add operator() overload in TowerKey_eq // and AnyTowerKey_eq with argument // const PhysicsTower& and also one with // argument PhysicsTowerData::const_iterator // /////////////////////////////////////////////////////////////////////////////////////////////////// #include #include #include #include "CalorObjects/PhysicsTower.hh" #include "CalorObjects/PhysicsTowerData.hh" #include "Calor/TowerSummer.hh" // namespace calor { template class HadEnergyGreater{ public: HadEnergyGreater():_value(0.0) { } HadEnergyGreater(float x):_value(x) { } bool operator()(const T* t) const; bool operator()(T& t) const; private: float _value; }; template class EmEnergyGreater{ public: EmEnergyGreater():_value(0.0) { } EmEnergyGreater(float x):_value(x) { } bool operator()(const T* t) const; bool operator()(T& t) const; private: float _value; }; template class TotEnergyGreater{ public: TotEnergyGreater():_value(0.0) { } TotEnergyGreater(float x):_value(x) { } bool operator()(const T* t) const; bool operator()(T& t) const; private: float _value; }; template class HadEtGreater{ public: HadEtGreater():_value(0.0) { } HadEtGreater(float x):_value(x) { } bool operator()(const T* t) const; bool operator()(T& t) const; private: float _value; }; template class EmEtGreater{ public: EmEtGreater():_value(0.0) { } EmEtGreater(float x):_value(x) { } bool operator()(const T* t) const; bool operator()(T& t) const; private: float _value; }; // class EtGreater { // public: // bool operator () (const CdfJet& i, const CdfJet& j) { // return (i.totEt() > j.totEt()); // } // }; class TotEtGreater{ public: TotEtGreater():value(0.0) { } TotEtGreater(float x):value(x) { } bool operator()(PhysicsTowerData::const_iterator t) const { return t->totEt()>value; } // bool operator()(PhysicsTowerData::const_iterator t) const { return t->totEt()>value; } private: float value; }; //template class TotEtGreater{ //public: // TotEtGreater():_value(0.0) { } // TotEtGreater(float x):_value(x) { } // bool operator()(const T* t) const; // bool operator()(T& t) const; //private: // float _value; //}; // absolute Eta template class EtaGreater{ public: EtaGreater():_value(0.0) { } EtaGreater(float x):_value(x) { } bool operator()(const T* t) const; bool operator()(T& t) const; private: float _value; }; template class EtaLess{ public: EtaLess():_value(0.0) { } EtaLess(float x):_value(x) { } bool operator()(const T* t) const; bool operator()(T& t) const; private: float _value; }; class TowerKey_eq : public std::unary_function { public: explicit TowerKey_eq(const TowerKey& aKey) : _key(aKey) { } bool operator () (const PhysicsTower& crPT) const { return crPT.key() == _key; } bool operator () (const PhysicsTower* cpPT) const { return operator() (*cpPT); } bool operator () (PhysicsTowerData::const_iterator ci) const { return operator() (*ci); } private: TowerKey _key; }; class AnyTowerKey_eq : public std::unary_function { public: explicit AnyTowerKey_eq(const std::vector& keys) : _keys(keys) { } bool operator () (const PhysicsTower& crPT) const { for (std::vector::const_iterator i = _keys.begin(); i != _keys.end(); ++i) if (crPT.key() == *i) return true; return false; } bool operator () (const PhysicsTower* cpPT) const { return operator() (*cpPT); } bool operator () (PhysicsTowerData::const_iterator ci) const { return operator() (*ci); } private: const std::vector& _keys; }; class IndexMatch{ public: IndexMatch():_index(0,0) { } IndexMatch(Index i):_index(i) { } bool operator()(const PhysicsTower* t) const; // bool operator()(T& t) const; private: Index _index; }; class NeighborsInCone{ public: NeighborsInCone(float eta, float phi, float radius,TowerSummer* summer):_eta(eta), _phi(phi), _radius(radius),_summer(summer){ } NeighborsInCone(float eta, float phi, float radius):_eta(eta), _phi(phi), _radius(radius),_summer(0){ } bool operator()(PhysicsTowerData::const_iterator t) const; // bool operator()(PhysicsTower& t) const; private: float _eta; float _phi; float _radius; TowerSummer* _summer; }; class None{ public: bool operator()(PhysicsTowerData::const_iterator t) const; // bool operator()(PhysicsTower& t) const; }; inline bool None::operator()(PhysicsTowerData::const_iterator t) const { return true;} // inline bool None::operator()(PhysicsTower& t) const { return true; } template inline bool HadEnergyGreater::operator()( const T * t ) const { return this->operator()(*t); } template inline bool HadEnergyGreater::operator()(T& t) const { return t.hadEnergy()>_value; } template inline bool EmEnergyGreater::operator ()( const T * t ) const { return this->operator()(*t); } template inline bool EmEnergyGreater::operator()(T& t) const { return t.emEnergy()>_value; } template inline bool TotEnergyGreater::operator ()( const T * t ) const { return this->operator()(*t); } template inline bool TotEnergyGreater::operator()(T& t) const { return t.totEnergy()>_value; } template inline bool HadEtGreater::operator ()( const T * t ) const { return this->operator()(*t); } template inline bool HadEtGreater::operator()(T& t) const { return t.hadEt()>_value; } template inline bool EmEtGreater::operator ()( const T * t ) const { return this->operator()(*t); } template inline bool EmEtGreater::operator()(T& t) const { return t.emEt()>_value; } //template inline bool TotEtGreater::operator ()( const T * t ) const //{ return this->operator()(*t); } //template inline bool TotEtGreater::operator()(T& t) const //{ return t.totEt()>_value; } template inline bool EtaGreater::operator ()( const T * t ) const { return this->operator()(*t); } template inline bool EtaGreater::operator()(T& t) const { return t.eta()>_value; } template inline bool EtaLess::operator ()( const T * t ) const { return this->operator()(*t); } template inline bool EtaLess::operator()(T& t) const { return t.eta()<_value; } inline bool NeighborsInCone::operator()(PhysicsTowerData::const_iterator t ) const { if(_summer == 0){ return t->dR(_eta,_phi) < _radius; } else{ return( sqrt(_summer->dRsquared(&(*t), _eta, _phi)) < _radius);} } //inline bool NeighborsInCone::operator()(PhysicsTower& t) const //{ return this->operator()(&t); } inline bool IndexMatch::operator()(const PhysicsTower* t) const{ return (t->index() == _index); } // } // namespace calor #endif // USE_CDFEDM2 #endif // _CALOR_PREDICATES_HH_