|
fastjet 3.0alpha2
|
00001 //STARTHEADER 00002 // $Id: ClusterSequenceStructure.cc 1985 2011-03-09 22:26:40Z soyez $ 00003 // 00004 // Copyright (c) 2005-2010, 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/ClusterSequenceStructure.hh" 00032 #include "fastjet/Error.hh" 00033 #include "fastjet/PseudoJet.hh" 00034 #include "fastjet/ClusterSequence.hh" 00035 #include "fastjet/ClusterSequenceAreaBase.hh" 00036 #include <iostream> 00037 00038 FASTJET_BEGIN_NAMESPACE // defined in fastjet/internal/base.hh 00039 00040 using namespace std; 00041 00042 00043 //---------------------------------------------------------------------- 00044 // Direct access to the associated ClusterSequence object. 00045 //---------------------------------------------------------------------- 00046 00047 // check whether this PseudoJet has an associated parent 00048 // ClusterSequence 00049 bool ClusterSequenceStructure::has_associated_cluster_sequence() const{ 00050 return (_associated_cs != NULL); 00051 } 00052 00053 // get a (const) pointer to the associated ClusterSequence (NULL if 00054 // inexistent) 00055 const ClusterSequence* ClusterSequenceStructure::associated_cluster_sequence() const{ 00056 if (! has_associated_cluster_sequence()) return NULL; 00057 00058 return _associated_cs; 00059 } 00060 00061 00062 // If there is a valid cluster sequence associated with this jet, 00063 // returns a pointer to it; otherwise throws an Error. 00064 // 00065 // Open question: should these errors be upgraded to classes of their 00066 // own so that they can be caught? [Maybe, but later] 00067 const ClusterSequence * ClusterSequenceStructure::validated_cs() const { 00068 if (!_associated_cs) 00069 throw Error("you requested information about the internal structure of a jet, but its associated ClusterSequence has gone out of scope."); 00070 return _associated_cs; 00071 } 00072 00073 00074 //---------------------------------------------------------------------- 00075 // Methods for access to information about jet structure 00076 //---------------------------------------------------------------------- 00077 00078 // check if it has been recombined with another PseudoJet in which 00079 // case, return its partner through the argument. Otherwise, 00080 // 'partner' is set to 0. 00081 // 00082 // false is also returned if this PseudoJet has no associated 00083 // ClusterSequence 00084 bool ClusterSequenceStructure::has_partner(const PseudoJet &reference, PseudoJet &partner) const{ 00085 return validated_cs()->has_partner(reference, partner); 00086 } 00087 00088 // check if it has been recombined with another PseudoJet in which 00089 // case, return its child through the argument. Otherwise, 'child' 00090 // is set to 0. 00091 // 00092 // false is also returned if this PseudoJet has no associated 00093 // ClusterSequence, with the child set to 0 00094 bool ClusterSequenceStructure::has_child(const PseudoJet &reference, PseudoJet &child) const{ 00095 return validated_cs()->has_child(reference, child); 00096 } 00097 00098 // check if it is the product of a recombination, in which case 00099 // return the 2 parents through the 'parent1' and 'parent2' 00100 // arguments. Otherwise, set these to 0. 00101 // 00102 // false is also returned if this PseudoJet has no parent 00103 // ClusterSequence 00104 bool ClusterSequenceStructure::has_parents(const PseudoJet &reference, PseudoJet &parent1, PseudoJet &parent2) const{ 00105 return validated_cs()->has_parents(reference, parent1, parent2); 00106 } 00107 00108 00109 // check if the reference PseudoJet is inside the "jet" passed as an argument 00110 // 00111 // an error is thrown if there is no CS associated with one of the 2 jets. 00112 // fasle is returned if teh 2 jets do not belong to the same CS 00113 bool ClusterSequenceStructure::object_in_jet(const PseudoJet &reference, const PseudoJet &jet) const{ 00114 if ((!has_associated_cluster_sequence()) || (!jet.has_associated_cluster_sequence())) 00115 throw Error("you requested information about the internal structure of a jet, but it is not associated with a ClusterSequence or its associated ClusterSequence has gone out of scope."); 00116 00117 if (reference.associated_cluster_sequence() != jet.associated_cluster_sequence()) return false; 00118 00119 return validated_cs()->object_in_jet(reference, jet); 00120 } 00121 00122 00123 // return true if the structure supports constituents. 00124 // 00125 // an Error is thrown if this PseudoJet has no currently valid 00126 // associated ClusterSequence 00127 bool ClusterSequenceStructure::has_constituents() const{ 00128 if (!has_associated_cluster_sequence()) 00129 throw Error("you requested information about the internal structure of a jet, but it is not associated with a ClusterSequence or its associated ClusterSequence has gone out of scope."); 00130 00131 return true; 00132 } 00133 00134 00135 // retrieve the constituents. An empty vector is returned if there is 00136 // no associated ClusterSequence 00137 vector<PseudoJet> ClusterSequenceStructure::constituents(const PseudoJet &reference) const{ 00138 return validated_cs()->constituents(reference); 00139 } 00140 00141 // return true if the structure supports exclusive_subjets. 00142 // 00143 // an Error is thrown if this PseudoJet has no currently valid 00144 // associated ClusterSequence 00145 bool ClusterSequenceStructure::has_exclusive_subjets() const{ 00146 if (!has_associated_cluster_sequence()) 00147 throw Error("you requested information about the internal structure of a jet, but it is not associated with a ClusterSequence or its associated ClusterSequence has gone out of scope."); 00148 00149 return true; 00150 } 00151 00152 // return a vector of all subjets of the current jet (in the sense 00153 // of the exclusive algorithm) that would be obtained when running 00154 // the algorithm with the given dcut. 00155 // 00156 // Time taken is O(m ln m), where m is the number of subjets that 00157 // are found. If m gets to be of order of the total number of 00158 // constituents in the jet, this could be substantially slower than 00159 // just getting that list of constituents. 00160 // 00161 // an Error is thrown if this PseudoJet has no currently valid 00162 // associated ClusterSequence 00163 std::vector<PseudoJet> ClusterSequenceStructure::exclusive_subjets (const PseudoJet &reference, const double & dcut) const { 00164 return validated_cs()->exclusive_subjets(reference, dcut); 00165 } 00166 00167 // return the size of exclusive_subjets(...); still n ln n with same 00168 // coefficient, but marginally more efficient than manually taking 00169 // exclusive_subjets.size() 00170 // 00171 // an Error is thrown if this PseudoJet has no currently valid 00172 // associated ClusterSequence 00173 int ClusterSequenceStructure::n_exclusive_subjets(const PseudoJet &reference, const double & dcut) const { 00174 return validated_cs()->n_exclusive_subjets(reference, dcut); 00175 } 00176 00177 // return the list of subjets obtained by unclustering the supplied 00178 // jet down to n subjets (or all constituents if there are fewer 00179 // than n). 00180 // 00181 // requires n ln n time 00182 // 00183 // an Error is thrown if this PseudoJet has no currently valid 00184 // associated ClusterSequence 00185 std::vector<PseudoJet> ClusterSequenceStructure::exclusive_subjets (const PseudoJet &reference, int nsub) const { 00186 return validated_cs()->exclusive_subjets(reference, nsub); 00187 } 00188 00189 // return the dij that was present in the merging nsub+1 -> nsub 00190 // subjets inside this jet. 00191 // 00192 // an Error is thrown if this PseudoJet has no currently valid 00193 // associated ClusterSequence 00194 double ClusterSequenceStructure::exclusive_subdmerge(const PseudoJet &reference, int nsub) const { 00195 return validated_cs()->exclusive_subdmerge(reference, nsub); 00196 } 00197 00198 // return the maximum dij that occurred in the whole event at the 00199 // stage that the nsub+1 -> nsub merge of subjets occurred inside 00200 // this jet. 00201 // 00202 // an Error is thrown if this PseudoJet has no currently valid 00203 // associated ClusterSequence 00204 double ClusterSequenceStructure::exclusive_subdmerge_max(const PseudoJet &reference, int nsub) const { 00205 return validated_cs()->exclusive_subdmerge_max(reference, nsub); 00206 } 00207 00208 00209 //---------------------------------------------------------------------- 00210 // the following ones require a computation of the area in the 00211 // associated ClusterSequence (See ClusterSequenceAreaBase for details) 00212 //---------------------------------------------------------------------- 00213 00214 // if possible, return a valid ClusterSequenceAreaBase pointer; otherwise 00215 // throw an error 00216 const ClusterSequenceAreaBase * ClusterSequenceStructure::validated_csab() const { 00217 const ClusterSequenceAreaBase *csab = dynamic_cast<const ClusterSequenceAreaBase*>(validated_cs()); 00218 if (csab == NULL) throw Error("you requested jet-area related information, but the PseudoJet does not have associated area information."); 00219 return csab; 00220 } 00221 00222 00223 // check if it has a defined area 00224 bool ClusterSequenceStructure::has_area() const{ 00225 if (! has_associated_cluster_sequence()) return false; 00226 return (dynamic_cast<const ClusterSequenceAreaBase*>(_associated_cs) != NULL); 00227 } 00228 00229 // return the jet (scalar) area. 00230 // throw an Error if there is no support for area in the associated CS 00231 double ClusterSequenceStructure::area(const PseudoJet &reference) const{ 00232 return validated_csab()->area(reference); 00233 } 00234 00235 // return the error (uncertainty) associated with the determination 00236 // of the area of this jet. 00237 // throws an Error if there is no support for area in the associated CS 00238 double ClusterSequenceStructure::area_error(const PseudoJet &reference) const{ 00239 return validated_csab()->area_error(reference); 00240 } 00241 00242 // return the jet 4-vector area 00243 // throws an Error if there is no support for area in the associated CS 00244 PseudoJet ClusterSequenceStructure::area_4vector(const PseudoJet &reference) const{ 00245 return validated_csab()->area_4vector(reference); 00246 } 00247 00248 // true if this jet is made exclusively of ghosts 00249 // throws an Error if there is no support for area in the associated CS 00250 bool ClusterSequenceStructure::is_pure_ghost(const PseudoJet &reference) const{ 00251 return validated_csab()->is_pure_ghost(reference); 00252 } 00253 00254 00255 00256 FASTJET_END_NAMESPACE
1.7.3