IsolationProjection.hh
// -*- C++ -*-
#ifndef RIVET_IsolationProjection_HH
#define RIVET_IsolationProjection_HH
#include "Rivet/Event.hh"
#include "Rivet/Projection.hh"
#include "Rivet/Math/Units.hh"
#include "Rivet/Projections/IsolationEstimators.hh"
#include <boost/shared_ptr.hpp>
namespace Rivet{
template <typename PROJ1, typename PROJ2,
typename EST = typename isohelper<typename PROJ1::entity_type, typename PROJ2::collection_type>::estimatorhelper>
class IsolationProjection : public Projection {
public:
IsolationProjection(PROJ1& iso,
PROJ2& ctrl,
EST* estimator,
double ptmin = 0*GeV) :
_estimator(estimator),
_ptmin(ptmin)
{
setName("IsolationProjection");
addProjection(iso, "ToBeIsolated");
addProjection(ctrl, "Control");
}
const vector<pair<const typename PROJ1::entity_type*, double> >
isolatedParticles(double maxiso = numeric_limits<double>::max()) const;
virtual const Projection* clone() const {
return new IsolationProjection(*this);
}
protected:
virtual void project(const Event& e);
virtual int compare(const Projection& p) const;
private:
boost::shared_ptr<EST> _estimator;
//double _coneRadius;
double _ptmin;
vector<pair<const typename PROJ1::entity_type*, double> > _isovalues;
};
template<typename PROJ1, typename PROJ2, typename EST>
inline const vector<pair<const typename PROJ1::entity_type*, double> > IsolationProjection<PROJ1, PROJ2, EST>
::isolatedParticles(double maxiso) const {
vector<pair<const typename PROJ1::entity_type*, double> > out;
for (typename vector<pair<const typename PROJ1::entity_type*, double> >::const_iterator i = _isovalues.begin(); i != _isovalues.end(); ++i){
if (i->second < maxiso) out.push_back(*i);
}
return out;
}
template<typename PROJ1, typename PROJ2, typename EST>
inline void IsolationProjection<PROJ1, PROJ2, EST>::project(const Event& e){
Log& log = getLog();
_isovalues.clear();
const PROJ1& isofs = applyProjection<PROJ1>(e, "ToBeIsolated");
const typename PROJ1::collection_type isopart = isofs.entities();
const PROJ2& ctrlfs = applyProjection<PROJ2>(e, "Control");
const typename PROJ2::collection_type ctrlpart = ctrlfs.entities();
for (typename PROJ1::collection_type::const_iterator iiso = isopart.begin(); iiso != isopart.end(); ++iiso){
if (iiso->getMomentum().pT() < _ptmin) continue;
double isolation = _estimator->estimate(*iiso, ctrlpart);
log << Log::DEBUG << "Isolation for particle with momentum " << iiso->getMomentum()
<< " is " << isolation << endl;
_isovalues.push_back(make_pair(&(*iiso), isolation));
}
}
template<typename PROJ1, typename PROJ2, typename EST>
inline int IsolationProjection<PROJ1, PROJ2, EST>::compare(const Projection& p) const{
const IsolationProjection & other = dynamic_cast<const IsolationProjection &>(p);
//first check the final states
int isofscmp = mkNamedPCmp(other, "ToBeIsolated");
if (isofscmp != EQUIVALENT) return isofscmp;
int isoctrlcmp = mkNamedPCmp(other, "Control");
if (isoctrlcmp != EQUIVALENT) return isoctrlcmp;
// compare the ptmin of the isolated colection
int ptmincmp = cmp(_ptmin, other._ptmin);
if (ptmincmp != EQUIVALENT) return ptmincmp;
// compare the estimators
//if (cmp(*(_estimator.get()),*(other._estimator.get())) == EQUIVALENT) cout << "Estimatori uguali!" << endl;
return cmp(*(_estimator.get()),*(other._estimator.get()));
}
}
#endif
Rivet::Projection::setName
void setName(const std::string &name)
Used by derived classes to set their name.
Definition: Projection.hh:120
Rivet::IsolationProjection::IsolationProjection
IsolationProjection(PROJ1 &iso, PROJ2 &ctrl, EST *estimator, double ptmin=0 *GeV)
Constructor.
Definition: IsolationProjection.hh:21
Rivet::IsolationProjection::isolatedParticles
const vector< pair< const typename PROJ1::entity_type *, double > > isolatedParticles(double maxiso=numeric_limits< double >::max()) const
Get the isolation values for the isofinalstate.
Definition: IsolationProjection.hh:69
Rivet::IsolationProjection
Definition: IsolationProjection.hh:18
Rivet::Log
Definition: Logging.hh:9
Rivet::IsolationProjection::clone
virtual const Projection * clone() const
Clone on the heap.
Definition: IsolationProjection.hh:37
Rivet::IsolationProjection::compare
virtual int compare(const Projection &p) const
Compare projections.
Definition: IsolationProjection.hh:99
Rivet::Event
Definition: Event.hh:22
Rivet::IsolationProjection::project
virtual void project(const Event &e)
Apply the projection to the event.
Definition: IsolationProjection.hh:79
Rivet::ProjectionApplier::addProjection
const PROJ & addProjection(const PROJ &proj, const std::string &name)
Definition: ProjectionApplier.hh:113
Rivet::Projection
Base class for all Rivet projections.
Definition: Projection.hh:28
Rivet::cmp
Cmp< T > cmp(const T &t1, const T &t2)
Global helper function for easy creation of Cmp objects.
Definition: Cmp.hh:285