Fork me on GitHub

source: git/external/fastjet/CompositeJetStructure.cc@ 239e1d0

ImprovedOutputFile Timing dual_readout llp 3.3.3pre11
Last change on this file since 239e1d0 was 35cdc46, checked in by Pavel Demin <demin@…>, 10 years ago

upgrade FastJet to version 3.1.0-beta.1, upgrade Nsubjettiness to version 2.1.0, add SoftKiller version 1.0.0

  • Property mode set to 100644
File size: 5.8 KB
RevLine 
[35cdc46]1//FJSTARTHEADER
2// $Id: CompositeJetStructure.cc 3433 2014-07-23 08:17:03Z salam $
[d7d2da3]3//
[35cdc46]4// Copyright (c) 2005-2014, Matteo Cacciari, Gavin P. Salam and Gregory Soyez
[d7d2da3]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
[35cdc46]15// development. They are described in the original FastJet paper,
16// hep-ph/0512210 and in the manual, arXiv:1111.6097. If you use
[d7d2da3]17// FastJet as part of work towards a scientific publication, please
[35cdc46]18// quote the version you use and include a citation to the manual and
19// optionally also to hep-ph/0512210.
[d7d2da3]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//----------------------------------------------------------------------
[35cdc46]29//FJENDHEADER
[d7d2da3]30
31#include <fastjet/CompositeJetStructure.hh>
32
33FASTJET_BEGIN_NAMESPACE // defined in fastjet/internal/base.hh
34
35using 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
46CompositeJetStructure::CompositeJetStructure(const std::vector<PseudoJet> & initial_pieces,
47 const JetDefinition::Recombiner * recombiner)
48 : _pieces(initial_pieces){
[d69dfe4]49
50#ifndef __FJCORE__
[d7d2da3]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){
63 _area_4vector_ptr = new PseudoJet();
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
69 *_area_4vector_ptr += p.area_4vector();
70 }
71 } else {
72 _area_4vector_ptr = 0;
73 }
[d69dfe4]74#else
75 if (recombiner){}; // ugly trick to prevent a gcc warning
76 _area_4vector_ptr = 0;
77#endif
[d7d2da3]78
79}
80
81
82// description
83std::string CompositeJetStructure::description() const{
84 string str = "Composite PseudoJet";
85 return str;
86}
87
88
89
90// things reimplemented from the base structure
91//------------------------------------------------------------------------------
92bool CompositeJetStructure::has_constituents() const{
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
103std::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
120std::vector<PseudoJet> CompositeJetStructure::pieces(const PseudoJet & /*jet*/) const{
121 return _pieces;
122}
123
124
[d69dfe4]125#ifndef __FJCORE__
[d7d2da3]126// area-related material
127
128// check if it has a well-defined area
129bool CompositeJetStructure::has_area() const{
130 return (_area_4vector_ptr != 0);
131}
132
133// return the jet (scalar) area.
134double 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
149double 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++)
[35cdc46]155 a_err += _pieces[i].area_error();
[d7d2da3]156
157 return a_err;
158}
159
160// return the jet 4-vector area.
161PseudoJet CompositeJetStructure::area_4vector(const PseudoJet & /*reference*/) const{
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
171bool 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
[d69dfe4]178#endif // __FJCORE__
[d7d2da3]179
180
181FASTJET_END_NAMESPACE // defined in fastjet/internal/base.hh
Note: See TracBrowser for help on using the repository browser.