[2] | 1 | #include "KtJet/KtLorentzVector.h"
|
---|
| 2 | #include "KtJet/KtUtil.h"
|
---|
| 3 | #include "KtJet/KtRecomInterface.h"
|
---|
| 4 | #include <iostream>
|
---|
| 5 | #include <climits>
|
---|
| 6 |
|
---|
| 7 | namespace KtJet {
|
---|
| 8 | unsigned int KtLorentzVector::m_num = 0;
|
---|
| 9 | //using CLHEP::HepLorentzVector;
|
---|
| 10 | using namespace CLHEP;
|
---|
| 11 |
|
---|
| 12 | /*************************************************
|
---|
| 13 | * Default constructor, used to create new jet *
|
---|
| 14 | *************************************************/
|
---|
| 15 | KtLorentzVector::KtLorentzVector() :
|
---|
| 16 | HepLorentzVector(), m_constituents(), m_isAtomic(false) {
|
---|
| 17 | if (m_num < UINT_MAX) {
|
---|
| 18 | ++m_num;
|
---|
| 19 | } else {
|
---|
| 20 | m_num = 0;
|
---|
| 21 | std::cout << "Warning: Number of KtLorentzVectors exceeds capacity of unsigned int" << std::endl;
|
---|
| 22 | }
|
---|
| 23 | m_id = m_num;
|
---|
| 24 | }
|
---|
| 25 |
|
---|
| 26 | /*****************************************************************
|
---|
| 27 | * Constructor for new "atomic" particle from HepLorentzVector *
|
---|
| 28 | *****************************************************************/
|
---|
| 29 | KtLorentzVector::KtLorentzVector(const HepLorentzVector &p) :
|
---|
| 30 | HepLorentzVector(p), m_id(m_num++), m_constituents(), m_isAtomic(true) {
|
---|
| 31 | }
|
---|
| 32 |
|
---|
| 33 | /***********************************************************
|
---|
| 34 | * Constructor for new "atomic" particle from 4-momentum *
|
---|
| 35 | ***********************************************************/
|
---|
| 36 | KtLorentzVector::KtLorentzVector(KtFloat px, KtFloat py, KtFloat pz, KtFloat e) :
|
---|
| 37 | HepLorentzVector(px,py,pz,e), m_id(m_num++), m_constituents(), m_isAtomic(true) {
|
---|
| 38 | }
|
---|
| 39 |
|
---|
| 40 | /**********************************************************/
|
---|
| 41 |
|
---|
| 42 | KtLorentzVector::~KtLorentzVector() {}
|
---|
| 43 |
|
---|
| 44 | /**********************************************************/
|
---|
| 45 |
|
---|
| 46 | std::vector<KtLorentzVector> KtLorentzVector::copyConstituents() const {
|
---|
| 47 | std::vector<KtLorentzVector> a;
|
---|
| 48 | std::vector<const KtLorentzVector*>::const_iterator itr = m_constituents.begin();
|
---|
| 49 | for (; itr != m_constituents.end(); ++itr) {
|
---|
| 50 | a.push_back(**itr);
|
---|
| 51 | }
|
---|
| 52 | return a;
|
---|
| 53 | }
|
---|
| 54 |
|
---|
| 55 | void KtLorentzVector::addConstituents(const KtLorentzVector* ktvec) {
|
---|
| 56 | if(!ktvec->isJet()) {
|
---|
| 57 | m_constituents.push_back((ktvec));
|
---|
| 58 | return;
|
---|
| 59 | }else{
|
---|
| 60 | std::vector<const KtLorentzVector*>::const_iterator itr = ktvec->getConstituents().begin();
|
---|
| 61 | for (; itr != ktvec->getConstituents().end() ; ++itr) this->addConstituents(*itr);
|
---|
| 62 | return;
|
---|
| 63 | }
|
---|
| 64 | }
|
---|
| 65 |
|
---|
| 66 | bool KtLorentzVector::contains(const KtLorentzVector & a) const {
|
---|
| 67 | if (a == *this) return true;
|
---|
| 68 | if (m_isAtomic) return false;
|
---|
| 69 | std::vector<const KtLorentzVector*>::const_iterator itr = m_constituents.begin();
|
---|
| 70 | for (; itr != m_constituents.end() ; ++itr) {
|
---|
| 71 | if (a == **itr) return true;
|
---|
| 72 | }
|
---|
| 73 | return false;
|
---|
| 74 | }
|
---|
| 75 |
|
---|
| 76 | void KtLorentzVector::add(const KtLorentzVector &p, KtRecom *recom) {
|
---|
| 77 | if (m_isAtomic) { // ???
|
---|
| 78 | std::cout << "Tried to add to atomic KtLorentzVector. You shouldn't do that!" << std::endl;
|
---|
| 79 | // exit(1);
|
---|
| 80 | }
|
---|
| 81 | this->addConstituents(&p);
|
---|
| 82 | HepLorentzVector::operator=((*recom)((*this),p));
|
---|
| 83 | calcRapidity();
|
---|
| 84 | }
|
---|
| 85 |
|
---|
| 86 | void KtLorentzVector::add(const KtLorentzVector &p) {
|
---|
| 87 | this->operator+=(p);
|
---|
| 88 | }
|
---|
| 89 |
|
---|
| 90 | KtLorentzVector & KtLorentzVector::operator+= (const KtLorentzVector &p){
|
---|
| 91 | if (m_isAtomic) { // ???
|
---|
| 92 | std::cout << "Tried to add to atomic KtLorentzVector. You shouldn't do that!" << std::endl;
|
---|
| 93 | // exit(1);
|
---|
| 94 | }
|
---|
| 95 | this->addConstituents(&p);
|
---|
| 96 | HepLorentzVector::operator+=(p);
|
---|
| 97 | calcRapidity();
|
---|
| 98 | return *this;
|
---|
| 99 | }
|
---|
| 100 |
|
---|
| 101 | // KtLorentzVector::KtLorentzVector(const KtLorentzVector & p) {} // Use default copy
|
---|
| 102 |
|
---|
| 103 | /**************************************
|
---|
| 104 | * Comparison functions for sorting *
|
---|
| 105 | **************************************/
|
---|
| 106 | bool greaterE(const HepLorentzVector & a, const HepLorentzVector & b) {
|
---|
| 107 | return (a.e()>b.e());
|
---|
| 108 | }
|
---|
| 109 |
|
---|
| 110 | bool greaterEt(const HepLorentzVector & a, const HepLorentzVector & b) {
|
---|
| 111 | return (a.et()>b.et());
|
---|
| 112 | }
|
---|
| 113 |
|
---|
| 114 | bool greaterPt(const HepLorentzVector & a, const HepLorentzVector & b) {
|
---|
| 115 | return (a.perp2()>b.perp2());
|
---|
| 116 | }
|
---|
| 117 |
|
---|
| 118 | bool greaterRapidity(const HepLorentzVector & a, const HepLorentzVector & b) {
|
---|
| 119 | return (a.rapidity()>b.rapidity());
|
---|
| 120 | }
|
---|
| 121 |
|
---|
| 122 | bool greaterEta(const HepLorentzVector & a, const HepLorentzVector & b) {
|
---|
| 123 | return (a.pseudoRapidity()>b.pseudoRapidity());
|
---|
| 124 | }
|
---|
| 125 |
|
---|
| 126 | }//end of namespace
|
---|