IsolationProjection.hh
Go to the documentation of this file.
00001 // -*- C++ -*- 00002 #ifndef RIVET_IsolationProjection_HH 00003 #define RIVET_IsolationProjection_HH 00004 00005 #include "Rivet/Event.hh" 00006 #include "Rivet/Projection.hh" 00007 #include "Rivet/Math/Units.hh" 00008 #include "Rivet/Projections/IsolationEstimators.hh" 00009 #include <boost/shared_ptr.hpp> 00010 00011 namespace Rivet{ 00012 00013 00014 /// PROJ1 can be either FinalState projections or JetAlg projections 00015 /// PROJ1::entity_type and PROJ2::entity_type can be either Particle of Jet 00016 template <typename PROJ1, typename PROJ2, 00017 typename EST = typename isohelper<typename PROJ1::entity_type, typename PROJ2::collection_type>::estimatorhelper> 00018 class IsolationProjection : public Projection { 00019 public: 00020 /// Constructor 00021 IsolationProjection(PROJ1& iso, 00022 PROJ2& ctrl, 00023 EST* estimator, 00024 double ptmin = 0*GeV) : 00025 _estimator(estimator), 00026 _ptmin(ptmin) 00027 { 00028 setName("IsolationProjection"); 00029 addProjection(iso, "ToBeIsolated"); 00030 addProjection(ctrl, "Control"); 00031 } 00032 00033 /// Get the isolation values for the isofinalstate 00034 const vector<pair<const typename PROJ1::entity_type*, double> > 00035 isolatedParticles(double maxiso = numeric_limits<double>::max()) const; 00036 00037 virtual const Projection* clone() const { 00038 return new IsolationProjection(*this); 00039 } 00040 00041 protected: 00042 00043 /// Apply the projection to the event. 00044 virtual void project(const Event& e); 00045 00046 /// Compare projections. 00047 virtual int compare(const Projection& p) const; 00048 00049 00050 private: 00051 00052 /// the estimator 00053 boost::shared_ptr<EST> _estimator; 00054 00055 /// The isolation cone radius 00056 //double _coneRadius; 00057 00058 /// The minimum pt to trigger isolation calculation 00059 double _ptmin; 00060 00061 /// the isolation parameter value for each particle in _isofsp 00062 /// the _isofsp MUST live, these particle pointers are potentially dangerous, let's try.... 00063 vector<pair<const typename PROJ1::entity_type*, double> > _isovalues; 00064 }; 00065 00066 00067 template<typename PROJ1, typename PROJ2, typename EST> 00068 inline const vector<pair<const typename PROJ1::entity_type*, double> > IsolationProjection<PROJ1, PROJ2, EST> 00069 ::isolatedParticles(double maxiso) const { 00070 vector<pair<const typename PROJ1::entity_type*, double> > out; 00071 for (typename vector<pair<const typename PROJ1::entity_type*, double> >::const_iterator i = _isovalues.begin(); i != _isovalues.end(); ++i){ 00072 if (i->second < maxiso) out.push_back(*i); 00073 } 00074 return out; 00075 } 00076 00077 00078 template<typename PROJ1, typename PROJ2, typename EST> 00079 inline void IsolationProjection<PROJ1, PROJ2, EST>::project(const Event& e){ 00080 Log& log = getLog(); 00081 _isovalues.clear(); 00082 /// projetc the final states 00083 const PROJ1& isofs = applyProjection<PROJ1>(e, "ToBeIsolated"); 00084 /// copy of particles is suboptimal, but FinalState returns 00085 /// particles by referencem while JetAlg returns jets by value 00086 const typename PROJ1::collection_type isopart = isofs.entities(); 00087 const PROJ2& ctrlfs = applyProjection<PROJ2>(e, "Control"); 00088 const typename PROJ2::collection_type ctrlpart = ctrlfs.entities(); 00089 for (typename PROJ1::collection_type::const_iterator iiso = isopart.begin(); iiso != isopart.end(); ++iiso){ 00090 if (iiso->getMomentum().pT() < _ptmin) continue; 00091 double isolation = _estimator->estimate(*iiso, ctrlpart); 00092 log << Log::DEBUG << "Isolation for particle with momentum " << iiso->getMomentum() 00093 << " is " << isolation << endl; 00094 _isovalues.push_back(make_pair(&(*iiso), isolation)); 00095 } 00096 } 00097 00098 template<typename PROJ1, typename PROJ2, typename EST> 00099 inline int IsolationProjection<PROJ1, PROJ2, EST>::compare(const Projection& p) const{ 00100 const IsolationProjection & other = dynamic_cast<const IsolationProjection &>(p); 00101 //first check the final states 00102 int isofscmp = mkNamedPCmp(other, "ToBeIsolated"); 00103 if (isofscmp != EQUIVALENT) return isofscmp; 00104 int isoctrlcmp = mkNamedPCmp(other, "Control"); 00105 if (isoctrlcmp != EQUIVALENT) return isoctrlcmp; 00106 // compare the ptmin of the isolated colection 00107 int ptmincmp = cmp(_ptmin, other._ptmin); 00108 if (ptmincmp != EQUIVALENT) return ptmincmp; 00109 // compare the estimators 00110 //if (cmp(*(_estimator.get()),*(other._estimator.get())) == EQUIVALENT) cout << "Estimatori uguali!" << endl; 00111 return cmp(*(_estimator.get()),*(other._estimator.get())); 00112 } 00113 00114 } 00115 00116 #endif Generated on Fri Dec 21 2012 15:03:41 for The Rivet MC analysis system by ![]() |