1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226
|
//----------------------------------------------------------------------
// This file distributed with FastJet has been obtained from SpartyJet
// v2.20.0 by Pierre-Antoine Delsart, Kurtis L. Geerlings, Joey
// Huston, Brian T. Martin and Chris Vermilion
// For details, see http://www.pa.msu.edu/~huston/SpartyJet/
// http://projects.hepforge.org/spartyjet/
//
// Changes from the original file are listed below.
//----------------------------------------------------------------------
//*******************************************************************************
// Filename : JetSplitMergeTool.cxx
// Author : Ambreesh Gupta
// Created : Nov, 2001
//
// File taken from SpartyJet v2.20.0
// Modifications:
// removed the string name in the ctor
// removed the Message m_log
// replaced px() -> px, ... in the LorentzVector calls
// cleaned the comments
//*******************************************************************************
// History of changes from the original JetSplitMergeTool.cc file in
// SpartyJet v2.20
//
// 2009-01-15 Gregory Soyez <soyez@fastjet.fr>
//
// * put the code in the fastjet::atlas namespace
//
// 2009-02-14 Gregory Soyez <soyez@fastjet.fr>
//
// * imported into FastJet
// * removed the string name in the ctor
// * removed the Message m_log
// * replaced px() -> px, ... in the LorentzVector calls
// * cleaned the comments
#include <iostream>
#include "JetSplitMergeTool.hh"
#include "Jet.hh"
#include "JetDistances.hh"
#include "CommonUtils.hh"
#include "fastjet/internal/base.hh"
FASTJET_BEGIN_NAMESPACE
namespace atlas {
JetSplitMergeTool::JetSplitMergeTool()
: m_f( 0.5 )
{}
JetSplitMergeTool::~JetSplitMergeTool()
{}
/////////////////////////////////////////////////////////////////////////////////
//Execution /
/////////////////////////////////////////////////////////////////////////////////
int JetSplitMergeTool::execute( jetcollection_t* theJets )
{
m_ctr = 0;
m_dctr = 0;
////////////////////////////////////////////////////
// From the input, collection create a list of Jet//
////////////////////////////////////////////////////
m_preJet.clear();
m_jet.clear();
jetcollection_t::iterator itrB = theJets->begin();
jetcollection_t::iterator itrE = theJets->end();
double etot =0.;
for (;itrB!=itrE;itrB++) {
Jet* j = new Jet(); j->addJet(*itrB);
m_ctr +=1;
m_preJet.push_back(j);
etot += j->e();
}
/////////////////////
// Split Merge Jets//
/////////////////////
this->split_merge();
/////////////////////////////////////////////
// Empty and re-fill input jetcollection_t //
/////////////////////////////////////////////
clear_list(*theJets);
jetcollection_t::iterator it = m_jet.begin();
jetcollection_t::iterator itE = m_jet.end();
for(; it!=itE; ++it){
theJets->push_back(*it);
}
return 1;
}
///////////////////////////////////////////////////////////////////////////////
// Reconstruction algorithm specific methods /
///////////////////////////////////////////////////////////////////////////////
void JetSplitMergeTool::split_merge()
{
if ( m_preJet.size() >= 2 ) {
do {
sort_list_et(m_preJet);
jetcollection_t::iterator itr;
jetcollection_t::iterator first = m_preJet.begin();
jetcollection_t::iterator last = m_preJet.end();
itr=first;
++itr;
bool overlap = false;
for (;itr != last;++itr) {
double etaF = (*first)->eta();
double phiF = (*first)->phi();
double etaS = (*itr)->eta();
double phiS = (*itr)->phi();
Jet* oJet = jet_from_overlap( (*first),*itr);
m_ctr +=1;
Jet::constit_vect_t::iterator itro = oJet->firstConstituent();
Jet::constit_vect_t::iterator itroE = oJet->lastConstituent();
if ( oJet->getConstituentNum() != 0 ) {
overlap = true;
// fraction
double f = sqrt(pow(oJet->px,2)+pow(oJet->py,2))/
sqrt(pow((*itr)->px,2)+pow((*itr)->py,2));
// merge
if ( f > m_f) {
// we need to remove constituents !
Jet *j = (*first);
for ( ;itro != itroE; ++itro ) j->removeConstituent(*itro);
(*first)->addJet(*itr);
//m_preJet.remove(*itr);
delete *itr;
m_preJet.erase(itr);
m_dctr +=1;
}
// split
if ( f <= m_f) {
for ( ;itro != itroE; ++itro ) {
// Distance of first jet from ProtoJet
double deta1 = etaF - (*itro)->eta();
double dphi1 = fabs(JetDistances::deltaPhi(phiF,(*itro)->phi()));
double dist1 = pow( deta1 , 2 ) + pow( dphi1 , 2 );
// Distance of second jet from ProtoJet
double deta2 = etaS - (*itro)->eta();
double dphi2 = fabs(JetDistances::deltaPhi(phiS,(*itro)->phi()));
double dist2 = pow( deta2 , 2 ) + pow( dphi2 , 2 );
// Remove protojet from farther Jet
if ( dist1 > dist2 ) (*first)->removeConstituent(*itro);
if ( dist1 <= dist2 ) (*itr)->removeConstituent(*itro);
}
}
// Delete overlap jet
delete oJet;
m_dctr +=1;
break;
}
else {
// Delete overlap jet
delete oJet;
m_dctr +=1;
}
}
if ( overlap == false ) {
m_jet.push_back(*first);
//m_preJet.remove(*first);
m_preJet.erase(first);
}
} while ( m_preJet.size() != 0 );
}
else if ( m_preJet.size() == 1) {
m_jet.push_back( *(m_preJet.begin()) );
}
}
//////////////////////////////////////////////////////////////////////
// "True" eta and phi ASSUMING the 4-vector is filled as
// ex -> e * sin(theta) * cos(phi)
// ey -> e * sin(theta) * sin(phi)
// ez -> e * cos(theta)
// e -> e
// Jet phi range is (-pi,pi].
double JetSplitMergeTool::etaTrue(Jet::constit_vect_t::iterator pj)
{
double s = ((*pj)->e() > 0) ? +1.0 : -1.0;
double px = (*pj)->px;
double py = (*pj)->py;
double pz = (*pj)->pz;
double theta = acos(pz*s/sqrt(px*px+py*py+pz*pz));
return -log(tan(theta/2.0));
}
double JetSplitMergeTool::phiTrue(Jet::constit_vect_t::iterator pj)
{
double s = ((*pj)->e() > 0) ? +1.0 : -1.0;
double px = (*pj)->px;
double py = (*pj)->py;
return atan2(py*s,px*s);
}
} // namespace atlas
FASTJET_END_NAMESPACE
|