Fork me on GitHub

source: git/external/fastjet/CompositeJetStructure.cc@ 84dd1c8

ImprovedOutputFile Timing dual_readout llp
Last change on this file since 84dd1c8 was d69dfe4, checked in by pavel <pavel@…>, 11 years ago

upgrade fastjet to 3.0.6

  • Property mode set to 100644
File size: 5.6 KB
Line 
1//STARTHEADER
2// $Id$
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
31FASTJET_BEGIN_NAMESPACE // defined in fastjet/internal/base.hh
32
33using 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
44CompositeJetStructure::CompositeJetStructure(const std::vector<PseudoJet> & initial_pieces,
45 const JetDefinition::Recombiner * recombiner)
46 : _pieces(initial_pieces){
47
48#ifndef __FJCORE__
49 // deal with area support (cache the area if needed)
50 //--------------------------------------------------
51 // check if all the pieces have area, in which case store it
52 bool has_area_local = true;
53 for (vector<PseudoJet>::const_iterator pit=_pieces.begin(); pit!=_pieces.end(); pit++){
54 if (!pit->has_area()){
55 has_area_local = false;
56 continue;
57 }
58 }
59
60 if (has_area_local){
61 _area_4vector_ptr = new PseudoJet();
62 for (unsigned int i=0; i<_pieces.size(); i++){
63 const PseudoJet & p = _pieces[i];
64 if (recombiner)
65 recombiner->plus_equal(*_area_4vector_ptr, p.area_4vector());
66 else
67 *_area_4vector_ptr += p.area_4vector();
68 }
69 } else {
70 _area_4vector_ptr = 0;
71 }
72#else
73 if (recombiner){}; // ugly trick to prevent a gcc warning
74 _area_4vector_ptr = 0;
75#endif
76
77}
78
79
80// description
81std::string CompositeJetStructure::description() const{
82 string str = "Composite PseudoJet";
83 return str;
84}
85
86
87
88// things reimplemented from the base structure
89//------------------------------------------------------------------------------
90bool CompositeJetStructure::has_constituents() const{
91 //for (vector<PseudoJet>::const_iterator pit=_pieces.begin(); pit!=_pieces.end(); pit++)
92 // if (!pit->has_constituents()) return false;
93 //
94 //return true;
95
96 // the only case where we do not have constituents is the case where
97 // there is no pieces!
98 return _pieces.size()!=0;
99}
100
101std::vector<PseudoJet> CompositeJetStructure::constituents(const PseudoJet & /*jet*/) const{
102 // recurse into the pieces that ahve constituents, just append the others
103 // the following code automatically throws an Error if any of the
104 // pieces has no constituents
105 vector<PseudoJet> all_constituents;
106 for (unsigned i = 0; i < _pieces.size(); i++) {
107 if (_pieces[i].has_constituents()){
108 vector<PseudoJet> constits = _pieces[i].constituents();
109 copy(constits.begin(), constits.end(), back_inserter(all_constituents));
110 } else {
111 all_constituents.push_back(_pieces[i]);
112 }
113 }
114
115 return all_constituents;
116}
117
118std::vector<PseudoJet> CompositeJetStructure::pieces(const PseudoJet & /*jet*/) const{
119 return _pieces;
120}
121
122
123#ifndef __FJCORE__
124// area-related material
125
126// check if it has a well-defined area
127bool CompositeJetStructure::has_area() const{
128 return (_area_4vector_ptr != 0);
129}
130
131// return the jet (scalar) area.
132double CompositeJetStructure::area(const PseudoJet & /*reference*/) const{
133 if (! has_area())
134 throw Error("One or more of this composite jet's pieces does not support area");
135
136 double a=0;
137 for (unsigned i = 0; i < _pieces.size(); i++)
138 a += _pieces[i].area();
139
140 return a;
141}
142
143// return the error (uncertainty) associated with the determination
144// of the area of this jet.
145//
146// Be conservative: return the sum of the errors
147double CompositeJetStructure::area_error(const PseudoJet & /*reference*/) const{
148 if (! has_area())
149 throw Error("One or more of this composite jet's pieces does not support area");
150
151 double a_err=0;
152 for (unsigned i = 0; i < _pieces.size(); i++)
153 a_err += _pieces[i].area();
154
155 return a_err;
156}
157
158// return the jet 4-vector area.
159PseudoJet CompositeJetStructure::area_4vector(const PseudoJet & /*reference*/) const{
160 if (! has_area())
161 throw Error("One or more of this composite jet's pieces does not support area");
162
163 return *_area_4vector_ptr; // one is supposed to call has_area before!
164}
165
166// true if this jet is made exclusively of ghosts.
167//
168// In this case, it will be true if all pieces are pure ghost
169bool CompositeJetStructure::is_pure_ghost(const PseudoJet & /*reference*/) const{
170 for (unsigned i = 0; i < _pieces.size(); i++)
171 if (! _pieces[i].is_pure_ghost()) return false;
172
173 return true;
174}
175
176#endif // __FJCORE__
177
178
179FASTJET_END_NAMESPACE // defined in fastjet/internal/base.hh
Note: See TracBrowser for help on using the repository browser.