Fork me on GitHub

source: git/external/fastjet/CompositeJetStructure.hh@ a0f5d71

3.4.3pre03
Last change on this file since a0f5d71 was b7b836a, checked in by Pavel Demin <pavel-demin@…>, 6 years ago

update FastJet library to 3.3.1 and FastJet Contrib library to 1.036

  • Property mode set to 100644
File size: 10.2 KB
Line 
1//FJSTARTHEADER
2// $Id: CompositeJetStructure.hh 4354 2018-04-22 07:12:37Z salam $
3//
4// Copyright (c) 2005-2018, 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. They are described in the original FastJet paper,
16// hep-ph/0512210 and in the manual, arXiv:1111.6097. If you use
17// FastJet as part of work towards a scientific publication, please
18// quote the version you use and include a citation to the manual and
19// optionally also to hep-ph/0512210.
20//
21// FastJet is distributed in the hope that it will be useful,
22// but WITHOUT ANY WARRANTY; without even the implied warranty of
23// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24// GNU General Public License for more details.
25//
26// You should have received a copy of the GNU General Public License
27// along with FastJet. If not, see <http://www.gnu.org/licenses/>.
28//----------------------------------------------------------------------
29//FJENDHEADER
30
31
32#ifndef __FASTJET_COMPOSITEJET_STRUCTURE_HH__
33#define __FASTJET_COMPOSITEJET_STRUCTURE_HH__
34
35#include <fastjet/PseudoJet.hh>
36#include <fastjet/PseudoJetStructureBase.hh>
37
38// to have access to the recombiner we need to include the JetDefinition header
39#include <fastjet/JetDefinition.hh>
40
41FASTJET_BEGIN_NAMESPACE // defined in fastjet/internal/base.hh
42
43/// @ingroup extra_info
44/// \class CompositeJetStructure
45/// The structure for a jet made of pieces
46///
47/// This stores the vector of the pieces that make the jet and provide
48/// the methods to access them
49class CompositeJetStructure : public PseudoJetStructureBase{
50public:
51 // basic class info
52 //-------------------------------------------------------------------
53 /// default ctor
54 CompositeJetStructure() : _area_4vector_ptr(0){};
55
56 /// ctor with initialisation
57 CompositeJetStructure(const std::vector<PseudoJet> & initial_pieces,
58 const JetDefinition::Recombiner * recombiner = 0);
59
60 /// default dtor
61 virtual ~CompositeJetStructure(){
62 if (_area_4vector_ptr) delete _area_4vector_ptr;
63 };
64
65 /// description
66 virtual std::string description() const FASTJET_OVERRIDE;
67
68 // things reimplemented from the base structure
69 //-------------------------------------------------------------------
70 /// true unless the jet has no pieces (see also the description of
71 /// constituents() below)
72 virtual bool has_constituents() const FASTJET_OVERRIDE;
73
74 /// return the constituents (i.e. the union of the constituents of each piece)
75 ///
76 /// If any of the pieces has no constituent, the piece itself is
77 /// considered as a constituent
78 /// Note that as a consequence, a composite jet with no pieces will
79 /// have an empty vector as constituents
80 virtual std::vector<PseudoJet> constituents(const PseudoJet &jet) const FASTJET_OVERRIDE;
81
82 //-------------------------------------------------------------------
83 // information related to the pieces of the jet
84 //-------------------------------------------------------------------
85 /// true if it has pieces (always the case)
86 virtual bool has_pieces(const PseudoJet & /*jet*/) const FASTJET_OVERRIDE {return true;}
87
88 /// returns the pieces
89 virtual std::vector<PseudoJet> pieces(const PseudoJet &jet) const FASTJET_OVERRIDE;
90
91 // area-related material
92#ifndef __FJCORE__
93
94 /// check if it has a well-defined area
95 virtual bool has_area() const FASTJET_OVERRIDE;
96
97 /// return the jet (scalar) area.
98 virtual double area(const PseudoJet &reference) const FASTJET_OVERRIDE;
99
100 /// return the error (uncertainty) associated with the determination
101 /// of the area of this jet.
102 ///
103 /// Be conservative: return the sum of the errors
104 virtual double area_error(const PseudoJet &reference) const FASTJET_OVERRIDE;
105
106 /// return the jet 4-vector area.
107 virtual PseudoJet area_4vector(const PseudoJet &reference) const FASTJET_OVERRIDE;
108
109 /// true if this jet is made exclusively of ghosts.
110 ///
111 /// In this case, it will be true if all pieces are pure ghost
112 virtual bool is_pure_ghost(const PseudoJet &reference) const FASTJET_OVERRIDE;
113
114 //unused: // allows one to modify the area information
115 //unused: // (for use in join())
116 //unused: //
117 //unused: // This member cannot be used by users who need to create a jet with
118 //unused: // user-supplied area information, because it sets only the 4-vector
119 //unused: // part of the area, but not all the other area information
120 //unused: // (e.g. scalar area) -- that other information is always deduced
121 //unused: // dynamically from the individual constituents.
122 //unused: // ------------------------------------------------------------------------------
123 //unused: void set_area_information(PseudoJet *area_4vector_ptr){
124 //unused: _area_4vector_ptr = area_4vector_ptr;
125 //unused: }
126
127 /// disable the area of the composite jet
128 ///
129 /// this can be used e.g. to discard the area of a composite jet
130 /// made of pieces with non-explicit-ghost area since the area may
131 /// by erroneous in that case
132 void discard_area(){
133 if (_area_4vector_ptr) delete _area_4vector_ptr;
134 _area_4vector_ptr = 0;
135 }
136
137#endif // __FJCORE__
138
139protected:
140 std::vector<PseudoJet> _pieces; ///< the pieces building the jet
141 PseudoJet * _area_4vector_ptr; ///< pointer to the 4-vector jet area
142};
143
144
145
146// helpers to "join" jets and produce a structure derived from
147// CompositeJetStructure
148//
149// The template structure T must have a constructor accepting as
150// argument the pieces and of the composite jet
151// ------------------------------------------------------------------------
152
153/// build a "CompositeJet" from the vector of its pieces with an
154/// extended structure of type T derived from CompositeJetStructure
155template<typename T> PseudoJet join(const std::vector<PseudoJet> & pieces){
156 PseudoJet result(0.0,0.0,0.0,0.0);
157 for (unsigned int i=0; i<pieces.size(); i++){
158 const PseudoJet it = pieces[i];
159 result += it;
160 }
161
162 T *cj_struct = new T(pieces);
163 result.set_structure_shared_ptr(SharedPtr<PseudoJetStructureBase>(cj_struct));
164
165 return result;
166}
167
168
169/// build a "CompositeJet" from a single PseudoJet with an extended
170/// structure of type T derived from CompositeJetStructure
171template<typename T> PseudoJet join(const PseudoJet & j1){
172 return join<T>(std::vector<PseudoJet>(1,j1));
173}
174
175/// build a "CompositeJet" from two PseudoJet with an extended
176/// structure of type T derived from CompositeJetStructure
177template<typename T> PseudoJet join(const PseudoJet & j1, const PseudoJet & j2){
178 std::vector<PseudoJet> pieces;
179 pieces.push_back(j1);
180 pieces.push_back(j2);
181 return join<T>(pieces);
182}
183
184/// build a "CompositeJet" from 3 PseudoJet with an extended structure
185/// of type T derived from CompositeJetStructure
186template<typename T> PseudoJet join(const PseudoJet & j1, const PseudoJet & j2,
187 const PseudoJet & j3){
188 std::vector<PseudoJet> pieces;
189 pieces.push_back(j1);
190 pieces.push_back(j2);
191 pieces.push_back(j3);
192 return join<T>(pieces);
193}
194
195/// build a "CompositeJet" from 4 PseudoJet with an extended structure
196/// of type T derived from CompositeJetStructure
197template<typename T> PseudoJet join(const PseudoJet & j1, const PseudoJet & j2,
198 const PseudoJet & j3, const PseudoJet & j4){
199 std::vector<PseudoJet> pieces;
200 pieces.push_back(j1);
201 pieces.push_back(j2);
202 pieces.push_back(j3);
203 pieces.push_back(j4);
204 return join<T>(pieces);
205}
206
207
208// the same as above with an additional argument for a
209// user-defined recombiner
210//
211// The template structure T must be derived from CompositeJetStructure
212// and have a constructor accepting as arguments the pieces and a
213// pointer to the recombination scheme
214// ----------------------------------------------------------------------
215
216/// build a "CompositeJet" from the vector of its pieces with an
217/// extended structure of type T derived from CompositeJetStructure
218template<typename T> PseudoJet join(const std::vector<PseudoJet> & pieces,
219 const JetDefinition::Recombiner & recombiner){
220 PseudoJet result;
221 if (pieces.size()>0){
222 result = pieces[0];
223 for (unsigned int i=1; i<pieces.size(); i++){
224 recombiner.plus_equal(result, pieces[i]);
225 }
226 }
227
228 T *cj_struct = new T(pieces, &recombiner);
229 result.set_structure_shared_ptr(SharedPtr<PseudoJetStructureBase>(cj_struct));
230
231 return result;
232}
233
234/// build a "CompositeJet" from a single PseudoJet with an extended
235/// structure of type T derived from CompositeJetStructure
236template<typename T> PseudoJet join(const PseudoJet & j1,
237 const JetDefinition::Recombiner & recombiner){
238 return join<T>(std::vector<PseudoJet>(1,j1), recombiner);
239}
240
241/// build a "CompositeJet" from two PseudoJet with an extended
242/// structure of type T derived from CompositeJetStructure
243template<typename T> PseudoJet join(const PseudoJet & j1, const PseudoJet & j2,
244 const JetDefinition::Recombiner & recombiner){
245 std::vector<PseudoJet> pieces;
246 pieces.reserve(2);
247 pieces.push_back(j1);
248 pieces.push_back(j2);
249 return join<T>(pieces, recombiner);
250}
251
252/// build a "CompositeJet" from 3 PseudoJet with an extended structure
253/// of type T derived from CompositeJetStructure
254template<typename T> PseudoJet join(const PseudoJet & j1, const PseudoJet & j2,
255 const PseudoJet & j3,
256 const JetDefinition::Recombiner & recombiner){
257 std::vector<PseudoJet> pieces;
258 pieces.reserve(3);
259 pieces.push_back(j1);
260 pieces.push_back(j2);
261 pieces.push_back(j3);
262 return join<T>(pieces, recombiner);
263}
264
265/// build a "CompositeJet" from 4 PseudoJet with an extended structure
266/// of type T derived from CompositeJetStructure
267template<typename T> PseudoJet join(const PseudoJet & j1, const PseudoJet & j2,
268 const PseudoJet & j3, const PseudoJet & j4,
269 const JetDefinition::Recombiner & recombiner){
270 std::vector<PseudoJet> pieces;
271 pieces.reserve(4);
272 pieces.push_back(j1);
273 pieces.push_back(j2);
274 pieces.push_back(j3);
275 pieces.push_back(j4);
276 return join<T>(pieces, recombiner);
277}
278
279
280FASTJET_END_NAMESPACE // defined in fastjet/internal/base.hh
281
282#endif // __FASTJET_MERGEDJET_STRUCTURE_HH__
Note: See TracBrowser for help on using the repository browser.