FastJet 3.0beta1
|
00001 //STARTHEADER 00002 // $Id: CompositeJetStructure.cc 2214 2011-06-02 21:21:55Z soyez $ 00003 // 00004 // Copyright (c) 2005-2011, Matteo Cacciari, Gavin Salam and Gregory Soyez 00005 // 00006 //---------------------------------------------------------------------- 00007 // This file is part of FastJet. 00008 // 00009 // FastJet is free software; you can redistribute it and/or modify 00010 // it under the terms of the GNU General Public License as published by 00011 // the Free Software Foundation; either version 2 of the License, or 00012 // (at your option) any later version. 00013 // 00014 // The algorithms that underlie FastJet have required considerable 00015 // development and are described in hep-ph/0512210. If you use 00016 // FastJet as part of work towards a scientific publication, please 00017 // include a citation to the FastJet paper. 00018 // 00019 // FastJet is distributed in the hope that it will be useful, 00020 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00021 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00022 // GNU General Public License for more details. 00023 // 00024 // You should have received a copy of the GNU General Public License 00025 // along with FastJet; if not, write to the Free Software 00026 // Foundation, Inc.: 00027 // 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00028 //---------------------------------------------------------------------- 00029 //ENDHEADER 00030 00031 #include <fastjet/CompositeJetStructure.hh> 00032 00033 FASTJET_BEGIN_NAMESPACE // defined in fastjet/internal/base.hh 00034 00035 using namespace std; 00036 00037 00038 //------------------------------------------------------------------------------- 00039 // \class CompositeJetStructure 00040 // The structure for a jet made of pieces 00041 // 00042 // This stores the vector of the pieces that make the jet and provide 00043 // the methods to access them 00044 // ------------------------------------------------------------------------------- 00045 00046 CompositeJetStructure::CompositeJetStructure(const std::vector<PseudoJet> & initial_pieces, 00047 const JetDefinition::Recombiner * recombiner) 00048 : _pieces(initial_pieces){ 00049 // deal with area support (cache the area if needed) 00050 //-------------------------------------------------- 00051 // check if all the pieces have area, in which case store it 00052 bool has_area = true; 00053 for (vector<PseudoJet>::const_iterator pit=_pieces.begin(); pit!=_pieces.end(); pit++){ 00054 if (!pit->has_area()){ 00055 has_area = false; 00056 continue; 00057 } 00058 } 00059 00060 if (has_area){ 00061 _area_4vector_ptr = new PseudoJet(); 00062 for (unsigned int i=0; i<_pieces.size(); i++){ 00063 const PseudoJet & p = _pieces[i]; 00064 if (recombiner) 00065 recombiner->plus_equal(*_area_4vector_ptr, p.area_4vector()); 00066 else 00067 *_area_4vector_ptr += p.area_4vector(); 00068 } 00069 } else { 00070 _area_4vector_ptr = 0; 00071 } 00072 00073 } 00074 00075 00076 // description 00077 std::string CompositeJetStructure::description() const{ 00078 string str = "Composite PseudoJet"; 00079 return str; 00080 } 00081 00082 00083 00084 // things reimplemented from the base structure 00085 //------------------------------------------------------------------------------ 00086 bool CompositeJetStructure::has_constituents() const{ 00087 //for (vector<PseudoJet>::const_iterator pit=_pieces.begin(); pit!=_pieces.end(); pit++) 00088 // if (!pit->has_constituents()) return false; 00089 // 00090 //return true; 00091 00092 // the only case where we do not have constituents is the case where 00093 // there is no pieces! 00094 return _pieces.size()!=0; 00095 } 00096 00097 std::vector<PseudoJet> CompositeJetStructure::constituents(const PseudoJet &jet) const{ 00098 // recurse into the pieces that ahve constituents, just append the others 00099 // the following code automatically throws an Error if any of the 00100 // pieces has no constituents 00101 vector<PseudoJet> all_constituents; 00102 for (unsigned i = 0; i < _pieces.size(); i++) { 00103 if (_pieces[i].has_constituents()){ 00104 vector<PseudoJet> constits = _pieces[i].constituents(); 00105 copy(constits.begin(), constits.end(), back_inserter(all_constituents)); 00106 } else { 00107 all_constituents.push_back(_pieces[i]); 00108 } 00109 } 00110 00111 return all_constituents; 00112 } 00113 00114 std::vector<PseudoJet> CompositeJetStructure::pieces(const PseudoJet &jet) const{ 00115 return _pieces; 00116 } 00117 00118 00119 // area-related material 00120 00121 // check if it has a well-defined area 00122 bool CompositeJetStructure::has_area() const{ 00123 return (_area_4vector_ptr != 0); 00124 } 00125 00126 // return the jet (scalar) area. 00127 double CompositeJetStructure::area(const PseudoJet &reference) const{ 00128 if (! has_area()) 00129 throw Error("One or more of this composite jet's pieces does not support area"); 00130 00131 double a=0; 00132 for (unsigned i = 0; i < _pieces.size(); i++) 00133 a += _pieces[i].area(); 00134 00135 return a; 00136 } 00137 00138 // return the error (uncertainty) associated with the determination 00139 // of the area of this jet. 00140 // 00141 // Be conservative: return the sum of the errors 00142 double CompositeJetStructure::area_error(const PseudoJet &reference) const{ 00143 if (! has_area()) 00144 throw Error("One or more of this composite jet's pieces does not support area"); 00145 00146 double a_err=0; 00147 for (unsigned i = 0; i < _pieces.size(); i++) 00148 a_err += _pieces[i].area(); 00149 00150 return a_err; 00151 } 00152 00153 // return the jet 4-vector area. 00154 PseudoJet CompositeJetStructure::area_4vector(const PseudoJet &reference) const{ 00155 if (! has_area()) 00156 throw Error("One or more of this composite jet's pieces does not support area"); 00157 00158 return *_area_4vector_ptr; // one is supposed to call has_area before! 00159 } 00160 00161 // true if this jet is made exclusively of ghosts. 00162 // 00163 // In this case, it will be true if all pieces are pure ghost 00164 bool CompositeJetStructure::is_pure_ghost(const PseudoJet &reference) const{ 00165 for (unsigned i = 0; i < _pieces.size(); i++) 00166 if (! _pieces[i].is_pure_ghost()) return false; 00167 00168 return true; 00169 } 00170 00171 00172 00173 FASTJET_END_NAMESPACE // defined in fastjet/internal/base.hh