31 #include "fastjet/tools/Pruner.hh" 32 #include "fastjet/ClusterSequenceActiveAreaExplicitGhosts.hh" 33 #include "fastjet/Selector.hh" 42 FASTJET_BEGIN_NAMESPACE
57 : _jet_def(jet_def), _zcut(0), _Rcut_factor(0),
58 _zcut_dyn(zcut_dyn), _Rcut_dyn(Rcut_dyn), _get_recombiner_from_jet(false) {
59 assert(_zcut_dyn != 0 && _Rcut_dyn != 0);
67 throw Error(
"Pruner: trying to apply the Pruner transformer to a jet that has no constituents");
72 bool do_areas = jet.
has_area() && _check_explicit_ghosts(jet);
75 double Rcut = (_Rcut_dyn) ? (*_Rcut_dyn)(jet) : _Rcut_factor * 2.0*jet.
m()/jet.
perp();
76 double zcut = (_zcut_dyn) ? (*_zcut_dyn)(jet) : _zcut;
77 PruningPlugin * pruning_plugin;
81 if (_get_recombiner_from_jet) {
87 if (_check_common_recombiner(jet, jet_def_for_recombiner)){
90 pruning_plugin =
new PruningPlugin(jet_def, zcut, Rcut);
92 pruning_plugin =
new PruningPlugin(_jet_def, zcut, Rcut);
104 vector<PseudoJet> particles, ghosts;
109 double ghost_area = (ghosts.size()) ? ghosts[0].area() : 0.01;
134 bool Pruner::_check_explicit_ghosts(
const PseudoJet &jet)
const{
142 vector<PseudoJet> pieces = jet.
pieces();
143 for (
unsigned int i=0;i<pieces.size(); i++)
144 if (!_check_explicit_ghosts(pieces[i]))
return false;
159 bool Pruner::_check_common_recombiner(
const PseudoJet &jet,
161 bool assigned)
const{
175 vector<PseudoJet> pieces = jet.
pieces();
176 if (pieces.size() == 0)
return false;
177 for (
unsigned int i=0;i<pieces.size(); i++)
178 if (!_check_common_recombiner(pieces[i], jet_def_for_recombiner, assigned))
return false;
191 oss <<
"Pruner with jet_definition = (" << _jet_def.
description() <<
")";
193 oss <<
", dynamic zcut (" << _zcut_dyn->
description() <<
")" 194 <<
", dynamic Rcut (" << _Rcut_dyn->
description() <<
")";
196 oss <<
", zcut = " << _zcut
197 <<
", Rcut_factor = " << _Rcut_factor;
221 void PruningRecombiner::recombine(
const PseudoJet &pa,
225 _recombiner->recombine(pa, pb, p);
232 double pt2a = pa.
perp2();
233 double pt2b = pb.
perp2();
237 if (pt2a<_zcut2*p.
perp2()){
243 if (pt2b<_zcut2*p.
perp2()) {
252 string PruningRecombiner::description()
const{
254 oss <<
"Pruning recombiner with zcut = " << sqrt(_zcut2)
255 <<
", Rcut = " << sqrt(_Rcut2)
256 <<
", and underlying recombiner = " << _recombiner->
description();
269 PruningRecombiner pruning_recombiner(_zcut, _Rcut, _jet_def.
recombiner());
275 const vector<ClusterSequence::history_element> & internal_hist = internal_cs.
history();
278 vector<bool> kept(internal_hist.size(),
true);
279 const vector<unsigned int> &pr_rej = pruning_recombiner.rejected();
280 for (
unsigned int i=0;i<pr_rej.size(); i++) kept[pr_rej[i]]=
false;
286 vector<unsigned int> internal2input(internal_hist.size());
287 for (
unsigned int i=0; i<input_cs.
jets().size(); i++)
288 internal2input[i] = i;
290 for (
unsigned int i=input_cs.
jets().size(); i<internal_hist.size(); i++){
294 if (he.
parent2 == ClusterSequence::BeamJet){
295 int internal_jetp_index = internal_hist[he.parent1].
jetp_index;
296 int internal_hist_index = internal_cs.jets()[internal_jetp_index].cluster_hist_index();
298 int input_jetp_index = input_cs.
history()[internal2input[internal_hist_index]].jetp_index;
308 if (!kept[he.parent1]){
309 internal2input[i]=internal2input[he.
parent2];
315 internal2input[i]=internal2input[he.parent1];
325 internal2input[i]=input_cs.
jets()[new_index].cluster_hist_index();
334 string PruningPlugin::description()
const{
336 oss <<
"Pruning plugin with jet_definition = (" << _jet_def.
description()
337 <<
"), zcut = " << _zcut
338 <<
", Rcut = " << _Rcut;
343 FASTJET_END_NAMESPACE
const std::vector< PseudoJet > & jets() const
allow the user to access the internally stored _jets() array, which contains both the initial particl...
std::string description() const
return a string describing what kind of PseudoJet we are dealing with
const ClusterSequenceAreaBase * validated_csab() const
shorthand for validated_cluster_sequence_area_base()
vector< PseudoJet > sorted_by_pt(const vector< PseudoJet > &jets)
return a vector of jets sorted into decreasing kt2
void sift(const std::vector< PseudoJet > &jets, std::vector< PseudoJet > &jets_that_pass, std::vector< PseudoJet > &jets_that_fail) const
sift the input jets into two vectors – those that pass the selector and those that do not ...
Selector SelectorNHardest(unsigned int n)
select the n hardest objects
int cluster_hist_index() const
return the cluster_hist_index, intended to be used by clustering routines.
void delete_plugin_when_unused()
calling this causes the JetDefinition to handle the deletion of the plugin when it is no longer used ...
std::vector< PseudoJet > inclusive_jets(const double ptmin=0.0) const
return a vector of all jets (in the sense of the inclusive algorithm) with pt >= ptmin.
int jetp_index
index in _history where the current jet is recombined with another jet to form its child...
virtual bool has_explicit_ghosts() const
returns true if ghosts are explicitly included within jets for this ClusterSequence; ...
const ClusterSequence * validated_cs() const
shorthand for validated_cluster_sequence()
virtual bool has_constituents() const
returns true if the PseudoJet has constituents
virtual std::vector< PseudoJet > pieces() const
retrieve the pieces that make up the jet.
void plugin_record_ij_recombination(int jet_i, int jet_j, double dij, int &newjet_k)
record the fact that there has been a recombination between jets()[jet_i] and jets()[jet_k], with the specified dij, and return the index (newjet_k) allocated to the new jet, whose momentum is assumed to be the 4-vector sum of that of jet_i and jet_j
const JetDefinition & jet_def() const
return a reference to the jet definition
int parent2
index in _history where first parent of this jet was created (InexistentParent if this jet is an orig...
virtual bool has_pieces() const
returns true if a jet has pieces
double dij
index in the _jets vector where we will find the
void plugin_record_iB_recombination(int jet_i, double diB)
record the fact that there has been a recombination between jets()[jet_i] and the beam...
The structure associated with a PseudoJet thas has gone through a Pruner transformer.
std::string description() const
return a textual description of the current jet definition
const std::vector< history_element > & history() const
allow the user to access the raw internal history.
base class corresponding to errors that can be thrown by FastJet
Like ClusterSequence with computation of the active jet area with the addition of explicit ghosts...
double squared_distance(const PseudoJet &other) const
returns squared cylinder (rap-phi) distance between this jet and another
virtual std::string description() const
returns a description of the function (an empty string by default)
virtual std::string description() const
description
std::vector< PseudoJet > extra_jets() const
return the other jets that may have been found along with the result of the pruning The resulting vec...
an implementation of C++0x shared pointers (or boost's)
const Recombiner * recombiner() const
returns a pointer to the currently defined recombiner.
a single element in the clustering history
void set_recombiner(const Recombiner *recomb)
set the recombiner class to the one provided
double perp() const
returns the scalar transverse momentum
bool has_associated_cluster_sequence() const
returns true if this PseudoJet has an associated ClusterSequence.
virtual bool has_area() const
check if it has a defined area
Selector SelectorIsPureGhost()
select objects that are (or are only made of) ghosts.
double m() const
returns the invariant mass (If m2() is negative then -sqrt(-m2()) is returned, as in CLHEP) ...
void delete_self_when_unused()
by calling this routine you tell the ClusterSequence to delete itself when all the Pseudojets associa...
virtual std::vector< PseudoJet > constituents() const
retrieve the constituents.
Class to contain pseudojets, including minimal information of use to jet-clustering routines...
double perp2() const
returns the squared transverse momentum
class that is intended to hold a full definition of the jet clusterer
bool has_same_recombiner(const JetDefinition &other_jd) const
returns true if the current jet definitions shares the same recombiner as the one passed as an argume...
virtual PseudoJet result(const PseudoJet &jet) const
action on a single jet