1 | //STARTHEADER |
---|
2 | // $Id: CompositeJetStructure.cc 859 2012-11-28 01:49:23Z pavel $ |
---|
3 | // |
---|
4 | // Copyright (c) 2005-2011, Matteo Cacciari, Gavin P. Salam and Gregory Soyez |
---|
5 | // |
---|
6 | //---------------------------------------------------------------------- |
---|
7 | // This file is part of FastJet. |
---|
8 | // |
---|
9 | // FastJet is free software; you can redistribute it and/or modify |
---|
10 | // it under the terms of the GNU General Public License as published by |
---|
11 | // the Free Software Foundation; either version 2 of the License, or |
---|
12 | // (at your option) any later version. |
---|
13 | // |
---|
14 | // The algorithms that underlie FastJet have required considerable |
---|
15 | // development and are described in hep-ph/0512210. If you use |
---|
16 | // FastJet as part of work towards a scientific publication, please |
---|
17 | // include a citation to the FastJet paper. |
---|
18 | // |
---|
19 | // FastJet is distributed in the hope that it will be useful, |
---|
20 | // but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
21 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
22 | // GNU General Public License for more details. |
---|
23 | // |
---|
24 | // You should have received a copy of the GNU General Public License |
---|
25 | // along with FastJet. If not, see <http://www.gnu.org/licenses/>. |
---|
26 | //---------------------------------------------------------------------- |
---|
27 | //ENDHEADER |
---|
28 | |
---|
29 | #include <fastjet/CompositeJetStructure.hh> |
---|
30 | |
---|
31 | FASTJET_BEGIN_NAMESPACE // defined in fastjet/internal/base.hh |
---|
32 | |
---|
33 | using namespace std; |
---|
34 | |
---|
35 | |
---|
36 | //------------------------------------------------------------------------------- |
---|
37 | // \class CompositeJetStructure |
---|
38 | // The structure for a jet made of pieces |
---|
39 | // |
---|
40 | // This stores the vector of the pieces that make the jet and provide |
---|
41 | // the methods to access them |
---|
42 | // ------------------------------------------------------------------------------- |
---|
43 | |
---|
44 | CompositeJetStructure::CompositeJetStructure(const std::vector<PseudoJet> & initial_pieces, |
---|
45 | const JetDefinition::Recombiner * recombiner) |
---|
46 | : _pieces(initial_pieces){ |
---|
47 | // deal with area support (cache the area if needed) |
---|
48 | //-------------------------------------------------- |
---|
49 | // check if all the pieces have area, in which case store it |
---|
50 | bool has_area_local = true; |
---|
51 | for (vector<PseudoJet>::const_iterator pit=_pieces.begin(); pit!=_pieces.end(); pit++){ |
---|
52 | if (!pit->has_area()){ |
---|
53 | has_area_local = false; |
---|
54 | continue; |
---|
55 | } |
---|
56 | } |
---|
57 | |
---|
58 | if (has_area_local){ |
---|
59 | _area_4vector_ptr = new PseudoJet(); |
---|
60 | for (unsigned int i=0; i<_pieces.size(); i++){ |
---|
61 | const PseudoJet & p = _pieces[i]; |
---|
62 | if (recombiner) |
---|
63 | recombiner->plus_equal(*_area_4vector_ptr, p.area_4vector()); |
---|
64 | else |
---|
65 | *_area_4vector_ptr += p.area_4vector(); |
---|
66 | } |
---|
67 | } else { |
---|
68 | _area_4vector_ptr = 0; |
---|
69 | } |
---|
70 | |
---|
71 | } |
---|
72 | |
---|
73 | |
---|
74 | // description |
---|
75 | std::string CompositeJetStructure::description() const{ |
---|
76 | string str = "Composite PseudoJet"; |
---|
77 | return str; |
---|
78 | } |
---|
79 | |
---|
80 | |
---|
81 | |
---|
82 | // things reimplemented from the base structure |
---|
83 | //------------------------------------------------------------------------------ |
---|
84 | bool CompositeJetStructure::has_constituents() const{ |
---|
85 | //for (vector<PseudoJet>::const_iterator pit=_pieces.begin(); pit!=_pieces.end(); pit++) |
---|
86 | // if (!pit->has_constituents()) return false; |
---|
87 | // |
---|
88 | //return true; |
---|
89 | |
---|
90 | // the only case where we do not have constituents is the case where |
---|
91 | // there is no pieces! |
---|
92 | return _pieces.size()!=0; |
---|
93 | } |
---|
94 | |
---|
95 | std::vector<PseudoJet> CompositeJetStructure::constituents(const PseudoJet & /*jet*/) const{ |
---|
96 | // recurse into the pieces that ahve constituents, just append the others |
---|
97 | // the following code automatically throws an Error if any of the |
---|
98 | // pieces has no constituents |
---|
99 | vector<PseudoJet> all_constituents; |
---|
100 | for (unsigned i = 0; i < _pieces.size(); i++) { |
---|
101 | if (_pieces[i].has_constituents()){ |
---|
102 | vector<PseudoJet> constits = _pieces[i].constituents(); |
---|
103 | copy(constits.begin(), constits.end(), back_inserter(all_constituents)); |
---|
104 | } else { |
---|
105 | all_constituents.push_back(_pieces[i]); |
---|
106 | } |
---|
107 | } |
---|
108 | |
---|
109 | return all_constituents; |
---|
110 | } |
---|
111 | |
---|
112 | std::vector<PseudoJet> CompositeJetStructure::pieces(const PseudoJet & /*jet*/) const{ |
---|
113 | return _pieces; |
---|
114 | } |
---|
115 | |
---|
116 | |
---|
117 | // area-related material |
---|
118 | |
---|
119 | // check if it has a well-defined area |
---|
120 | bool CompositeJetStructure::has_area() const{ |
---|
121 | return (_area_4vector_ptr != 0); |
---|
122 | } |
---|
123 | |
---|
124 | // return the jet (scalar) area. |
---|
125 | double CompositeJetStructure::area(const PseudoJet & /*reference*/) const{ |
---|
126 | if (! has_area()) |
---|
127 | throw Error("One or more of this composite jet's pieces does not support area"); |
---|
128 | |
---|
129 | double a=0; |
---|
130 | for (unsigned i = 0; i < _pieces.size(); i++) |
---|
131 | a += _pieces[i].area(); |
---|
132 | |
---|
133 | return a; |
---|
134 | } |
---|
135 | |
---|
136 | // return the error (uncertainty) associated with the determination |
---|
137 | // of the area of this jet. |
---|
138 | // |
---|
139 | // Be conservative: return the sum of the errors |
---|
140 | double CompositeJetStructure::area_error(const PseudoJet & /*reference*/) const{ |
---|
141 | if (! has_area()) |
---|
142 | throw Error("One or more of this composite jet's pieces does not support area"); |
---|
143 | |
---|
144 | double a_err=0; |
---|
145 | for (unsigned i = 0; i < _pieces.size(); i++) |
---|
146 | a_err += _pieces[i].area(); |
---|
147 | |
---|
148 | return a_err; |
---|
149 | } |
---|
150 | |
---|
151 | // return the jet 4-vector area. |
---|
152 | PseudoJet CompositeJetStructure::area_4vector(const PseudoJet & /*reference*/) const{ |
---|
153 | if (! has_area()) |
---|
154 | throw Error("One or more of this composite jet's pieces does not support area"); |
---|
155 | |
---|
156 | return *_area_4vector_ptr; // one is supposed to call has_area before! |
---|
157 | } |
---|
158 | |
---|
159 | // true if this jet is made exclusively of ghosts. |
---|
160 | // |
---|
161 | // In this case, it will be true if all pieces are pure ghost |
---|
162 | bool CompositeJetStructure::is_pure_ghost(const PseudoJet & /*reference*/) const{ |
---|
163 | for (unsigned i = 0; i < _pieces.size(); i++) |
---|
164 | if (! _pieces[i].is_pure_ghost()) return false; |
---|
165 | |
---|
166 | return true; |
---|
167 | } |
---|
168 | |
---|
169 | |
---|
170 | |
---|
171 | FASTJET_END_NAMESPACE // defined in fastjet/internal/base.hh |
---|