FastJet 3.0.6
|
00001 //STARTHEADER 00002 // $Id: CompositeJetStructure.cc 3071 2013-04-01 12:52:46Z cacciari $ 00003 // 00004 // Copyright (c) 2005-2011, Matteo Cacciari, Gavin P. 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, see <http://www.gnu.org/licenses/>. 00026 //---------------------------------------------------------------------- 00027 //ENDHEADER 00028 00029 #include <fastjet/CompositeJetStructure.hh> 00030 00031 FASTJET_BEGIN_NAMESPACE // defined in fastjet/internal/base.hh 00032 00033 using namespace std; 00034 00035 00036 //------------------------------------------------------------------------------- 00037 // \class CompositeJetStructure 00038 // The structure for a jet made of pieces 00039 // 00040 // This stores the vector of the pieces that make the jet and provide 00041 // the methods to access them 00042 // ------------------------------------------------------------------------------- 00043 00044 CompositeJetStructure::CompositeJetStructure(const std::vector<PseudoJet> & initial_pieces, 00045 const JetDefinition::Recombiner * recombiner) 00046 : _pieces(initial_pieces){ 00047 00048 #ifndef __FJCORE__ 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_local = true; 00053 for (vector<PseudoJet>::const_iterator pit=_pieces.begin(); pit!=_pieces.end(); pit++){ 00054 if (!pit->has_area()){ 00055 has_area_local = false; 00056 continue; 00057 } 00058 } 00059 00060 if (has_area_local){ 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 #else 00073 if (recombiner){}; // ugly trick to prevent a gcc warning 00074 _area_4vector_ptr = 0; 00075 #endif 00076 00077 } 00078 00079 00080 // description 00081 std::string CompositeJetStructure::description() const{ 00082 string str = "Composite PseudoJet"; 00083 return str; 00084 } 00085 00086 00087 00088 // things reimplemented from the base structure 00089 //------------------------------------------------------------------------------ 00090 bool CompositeJetStructure::has_constituents() const{ 00091 //for (vector<PseudoJet>::const_iterator pit=_pieces.begin(); pit!=_pieces.end(); pit++) 00092 // if (!pit->has_constituents()) return false; 00093 // 00094 //return true; 00095 00096 // the only case where we do not have constituents is the case where 00097 // there is no pieces! 00098 return _pieces.size()!=0; 00099 } 00100 00101 std::vector<PseudoJet> CompositeJetStructure::constituents(const PseudoJet & /*jet*/) const{ 00102 // recurse into the pieces that ahve constituents, just append the others 00103 // the following code automatically throws an Error if any of the 00104 // pieces has no constituents 00105 vector<PseudoJet> all_constituents; 00106 for (unsigned i = 0; i < _pieces.size(); i++) { 00107 if (_pieces[i].has_constituents()){ 00108 vector<PseudoJet> constits = _pieces[i].constituents(); 00109 copy(constits.begin(), constits.end(), back_inserter(all_constituents)); 00110 } else { 00111 all_constituents.push_back(_pieces[i]); 00112 } 00113 } 00114 00115 return all_constituents; 00116 } 00117 00118 std::vector<PseudoJet> CompositeJetStructure::pieces(const PseudoJet & /*jet*/) const{ 00119 return _pieces; 00120 } 00121 00122 00123 #ifndef __FJCORE__ 00124 // area-related material 00125 00126 // check if it has a well-defined area 00127 bool CompositeJetStructure::has_area() const{ 00128 return (_area_4vector_ptr != 0); 00129 } 00130 00131 // return the jet (scalar) area. 00132 double CompositeJetStructure::area(const PseudoJet & /*reference*/) const{ 00133 if (! has_area()) 00134 throw Error("One or more of this composite jet's pieces does not support area"); 00135 00136 double a=0; 00137 for (unsigned i = 0; i < _pieces.size(); i++) 00138 a += _pieces[i].area(); 00139 00140 return a; 00141 } 00142 00143 // return the error (uncertainty) associated with the determination 00144 // of the area of this jet. 00145 // 00146 // Be conservative: return the sum of the errors 00147 double CompositeJetStructure::area_error(const PseudoJet & /*reference*/) const{ 00148 if (! has_area()) 00149 throw Error("One or more of this composite jet's pieces does not support area"); 00150 00151 double a_err=0; 00152 for (unsigned i = 0; i < _pieces.size(); i++) 00153 a_err += _pieces[i].area(); 00154 00155 return a_err; 00156 } 00157 00158 // return the jet 4-vector area. 00159 PseudoJet CompositeJetStructure::area_4vector(const PseudoJet & /*reference*/) const{ 00160 if (! has_area()) 00161 throw Error("One or more of this composite jet's pieces does not support area"); 00162 00163 return *_area_4vector_ptr; // one is supposed to call has_area before! 00164 } 00165 00166 // true if this jet is made exclusively of ghosts. 00167 // 00168 // In this case, it will be true if all pieces are pure ghost 00169 bool CompositeJetStructure::is_pure_ghost(const PseudoJet & /*reference*/) const{ 00170 for (unsigned i = 0; i < _pieces.size(); i++) 00171 if (! _pieces[i].is_pure_ghost()) return false; 00172 00173 return true; 00174 } 00175 00176 #endif // __FJCORE__ 00177 00178 00179 FASTJET_END_NAMESPACE // defined in fastjet/internal/base.hh