FastJet  3.1.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Modules Pages
CompositeJetStructure.cc
1 //FJSTARTHEADER
2 // $Id: CompositeJetStructure.cc 3433 2014-07-23 08:17:03Z salam $
3 //
4 // Copyright (c) 2005-2014, 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 #include <fastjet/CompositeJetStructure.hh>
32 
33 FASTJET_BEGIN_NAMESPACE // defined in fastjet/internal/base.hh
34 
35 using namespace std;
36 
37 
38 //-------------------------------------------------------------------------------
39 // \class CompositeJetStructure
40 // The structure for a jet made of pieces
41 //
42 // This stores the vector of the pieces that make the jet and provide
43 // the methods to access them
44 // -------------------------------------------------------------------------------
45 
46 CompositeJetStructure::CompositeJetStructure(const std::vector<PseudoJet> & initial_pieces,
47  const JetDefinition::Recombiner * recombiner)
48  : _pieces(initial_pieces){
49 
50 #ifndef __FJCORE__
51  // deal with area support (cache the area if needed)
52  //--------------------------------------------------
53  // check if all the pieces have area, in which case store it
54  bool has_area_local = true;
55  for (vector<PseudoJet>::const_iterator pit=_pieces.begin(); pit!=_pieces.end(); pit++){
56  if (!pit->has_area()){
57  has_area_local = false;
58  continue;
59  }
60  }
61 
62  if (has_area_local){
64  for (unsigned int i=0; i<_pieces.size(); i++){
65  const PseudoJet & p = _pieces[i];
66  if (recombiner)
67  recombiner->plus_equal(*_area_4vector_ptr, p.area_4vector());
68  else
70  }
71  } else {
73  }
74 #else
75  if (recombiner){}; // ugly trick to prevent a gcc warning
77 #endif
78 
79 }
80 
81 
82 // description
84  string str = "Composite PseudoJet";
85  return str;
86 }
87 
88 
89 
90 // things reimplemented from the base structure
91 //------------------------------------------------------------------------------
93  //for (vector<PseudoJet>::const_iterator pit=_pieces.begin(); pit!=_pieces.end(); pit++)
94  // if (!pit->has_constituents()) return false;
95  //
96  //return true;
97 
98  // the only case where we do not have constituents is the case where
99  // there is no pieces!
100  return _pieces.size()!=0;
101 }
102 
103 std::vector<PseudoJet> CompositeJetStructure::constituents(const PseudoJet & /*jet*/) const{
104  // recurse into the pieces that ahve constituents, just append the others
105  // the following code automatically throws an Error if any of the
106  // pieces has no constituents
107  vector<PseudoJet> all_constituents;
108  for (unsigned i = 0; i < _pieces.size(); i++) {
109  if (_pieces[i].has_constituents()){
110  vector<PseudoJet> constits = _pieces[i].constituents();
111  copy(constits.begin(), constits.end(), back_inserter(all_constituents));
112  } else {
113  all_constituents.push_back(_pieces[i]);
114  }
115  }
116 
117  return all_constituents;
118 }
119 
120 std::vector<PseudoJet> CompositeJetStructure::pieces(const PseudoJet & /*jet*/) const{
121  return _pieces;
122 }
123 
124 
125 #ifndef __FJCORE__
126 // area-related material
127 
128 // check if it has a well-defined area
130  return (_area_4vector_ptr != 0);
131 }
132 
133 // return the jet (scalar) area.
134 double CompositeJetStructure::area(const PseudoJet & /*reference*/) const{
135  if (! has_area())
136  throw Error("One or more of this composite jet's pieces does not support area");
137 
138  double a=0;
139  for (unsigned i = 0; i < _pieces.size(); i++)
140  a += _pieces[i].area();
141 
142  return a;
143 }
144 
145 // return the error (uncertainty) associated with the determination
146 // of the area of this jet.
147 //
148 // Be conservative: return the sum of the errors
149 double CompositeJetStructure::area_error(const PseudoJet & /*reference*/) const{
150  if (! has_area())
151  throw Error("One or more of this composite jet's pieces does not support area");
152 
153  double a_err=0;
154  for (unsigned i = 0; i < _pieces.size(); i++)
155  a_err += _pieces[i].area_error();
156 
157  return a_err;
158 }
159 
160 // return the jet 4-vector area.
162  if (! has_area())
163  throw Error("One or more of this composite jet's pieces does not support area");
164 
165  return *_area_4vector_ptr; // one is supposed to call has_area before!
166 }
167 
168 // true if this jet is made exclusively of ghosts.
169 //
170 // In this case, it will be true if all pieces are pure ghost
171 bool CompositeJetStructure::is_pure_ghost(const PseudoJet & /*reference*/) const{
172  for (unsigned i = 0; i < _pieces.size(); i++)
173  if (! _pieces[i].is_pure_ghost()) return false;
174 
175  return true;
176 }
177 
178 #endif // __FJCORE__
179 
180 
181 FASTJET_END_NAMESPACE // defined in fastjet/internal/base.hh
virtual PseudoJet area_4vector(const PseudoJet &reference) const
return the jet 4-vector area.
virtual std::vector< PseudoJet > pieces(const PseudoJet &jet) const
returns the pieces
virtual bool has_area() const
check if it has a well-defined area
std::vector< PseudoJet > _pieces
the pieces building the jet
virtual double area(const PseudoJet &reference) const
return the jet (scalar) area.
virtual bool is_pure_ghost(const PseudoJet &reference) const
true if this jet is made exclusively of ghosts.
PseudoJet * _area_4vector_ptr
pointer to the 4-vector jet area
virtual bool has_constituents() const
true unless the jet has no pieces (see also the description of constituents() below) ...
base class corresponding to errors that can be thrown by FastJet
Definition: Error.hh:47
void plus_equal(PseudoJet &pa, const PseudoJet &pb) const
pa += pb in the given recombination scheme.
virtual std::string description() const
description
An abstract base class that will provide the recombination scheme facilities and/or allow a user to e...
virtual double area_error(const PseudoJet &reference) const
return the error (uncertainty) associated with the determination of the area of this jet...
Class to contain pseudojets, including minimal information of use to jet-clustering routines...
Definition: PseudoJet.hh:67
virtual std::vector< PseudoJet > constituents(const PseudoJet &jet) const
return the constituents (i.e.
virtual PseudoJet area_4vector() const
return the jet 4-vector area.
Definition: PseudoJet.cc:732