#include "AddOns/Analysis/Triggers/Kt_Algorithm.H" #include "ATOOLS/Phys/Particle_List.H" #include "ATOOLS/Org/Message.H" #include #include #ifdef PROFILE__all #define PROFILE__Analysis_Phase #endif #ifdef PROFILE__Analysis_Phase #include "prof.hh" #else #define PROFILE_HERE {} #define PROFILE_LOCAL(LOCALNAME) {} #endif using namespace ANALYSIS; using namespace ATOOLS; using namespace std; void Jet_Algorithm_Base::SortE(Particle_List * jets) { if (jets) { std::sort(jets->begin(), jets->end(),Order_E()); } } void Jet_Algorithm_Base::SortPT(Particle_List * jets) { if (jets) { std::sort(jets->begin(), jets->end(),Order_PT()); } } Kt_Algorithm::Kt_Algorithm(ATOOLS::Particle_Qualifier_Base * const qualifier) : Jet_Algorithm_Base(qualifier), m_matrixsize(0), p_ktij(NULL), p_imap(NULL), p_kis(NULL), p_jets(NULL), p_kts(NULL) { } Kt_Algorithm::~Kt_Algorithm() { if (p_ktij) { for (int i=0;ipush_back(kt2); } } void Kt_Algorithm::AddToJetlist(const Vec4D & mom, int bf) { if (p_jets) { if(!bf) p_jets->push_back(new Particle(p_jets->size(),Flavour(kf_jet),mom)); else p_jets->push_back(new Particle(p_jets->size(),bf>0?Flavour(kf_bjet): Flavour(kf_bjet).Bar(),mom)); } } bool Kt_Algorithm::ConstructJets(const Particle_List * pl, Particle_List * jets, std::vector * kts, double rmin) { // assume empty containers p_jets = jets; p_kts = kts; m_r2min = sqr(rmin); // create vector list from particle list int n=0; Vec4D * moms = new Vec4D[pl->size()]; int * bflag = new int[pl->size()]; static Particle_Qualifier_Base *bhad(Particle_Qualifier_Getter::GetObject("DecayedBHadron","")); for (Particle_List::const_iterator it=pl->begin(); it!=pl->end();++it) { if ((*p_qualifier)(*it)) { // if (!(*it)->Flav().IsLepton()) { moms[n] = ((*it)->Momentum()); bflag[n] = false; if (m_bflag==0) bflag[n] = (((*it)->Flav()).Kfcode()==kf_b || (*bhad)(*it) || ((*it)->Flav()).Kfcode()==kf_bjet); else if (m_bflag==-1) bflag[n] = (1-2*(*it)->Flav().IsAnti())* (((*it)->Flav()).Kfcode()==kf_b || (*bhad)(*it) || ((*it)->Flav()).Kfcode()==kf_bjet); ++n; } } // cluster Ktmin(moms,bflag,n); delete [] moms; delete [] bflag; // finalize (sort and release used containers) SortPT(p_jets); p_jets=0; p_kts =0; return true; } void Kt_Algorithm::Init(int size) { PROFILE_HERE; if (size>m_matrixsize ) { if (p_ktij) { for (int i=0;i0) { PROFILE_LOCAL(" main loop "); if (ii!=jj) { // combine precluster #ifdef DEBUG_JETRATES msg_Debugging()<<"jetrate Q_{"<" <" <" <Momentum()[0] > b->Momentum()[0]) return 1; return 0; } }; class Order_PT { public: int operator()(const Particle * a, const Particle * b) { if (Kt_Algorithm::Kt2(a->Momentum()) > Kt_Algorithm::Kt2(b->Momentum())) return 1; return 0; } }; double Kt_Algorithm::CosDPhi12(const Vec4D & p1,const Vec4D & p2) const { double pt1=sqrt(p1[1]*p1[1]+p1[2]*p1[2]); double pt2=sqrt(p2[1]*p2[1]+p2[2]*p2[2]); return (p1[1]*p2[1]+p1[2]*p2[2])/(pt1*pt2); } double Kt_Algorithm::DCos12(const Vec4D & p1,const Vec4D & p2) const { return Vec3D(p1)*Vec3D(p2)/(Vec3D(p1).Abs()*Vec3D(p2).Abs()); } double Kt_Algorithm::DEta12(const Vec4D & p1, const Vec4D & p2) const { // eta1,2 = -log(tan(theta_1,2)/2) double c1=p1[3]/Vec3D(p1).Abs(); double c2=p2[3]/Vec3D(p2).Abs(); return 0.5 *log( (1 + c1)*(1 - c2)/((1-c1)*(1+c2))); } double Kt_Algorithm::DPhi12(const Vec4D & p1,const Vec4D & p2) const { double pt1=sqrt(p1[1]*p1[1]+p1[2]*p1[2]); double pt2=sqrt(p2[1]*p2[1]+p2[2]*p2[2]); return acos(Min(1.0,Max(-1.0,((p1[1]*p2[1]+p1[2]*p2[2])/(pt1*pt2))))); } Jet_Algorithm_Base::~Jet_Algorithm_Base() { }