fastjet 2.4.5
ClusterSequenceActiveArea.hh
Go to the documentation of this file.
00001 //STARTHEADER
00002 // $Id: ClusterSequenceActiveArea.hh 1571 2009-05-25 15:32:40Z salam $
00003 //
00004 // Copyright (c) 2005-2006, Matteo Cacciari and Gavin Salam
00005 //
00006 //----------------------------------------------------------------------
00007 // This file is part of FastJet.
00008 //
00009 //  FastJet is free software; you can redistribute it and/or modify
00010 //  it under the terms of the GNU General Public License as published by
00011 //  the Free Software Foundation; either version 2 of the License, or
00012 //  (at your option) any later version.
00013 //
00014 //  The algorithms that underlie FastJet have required considerable
00015 //  development and are described in hep-ph/0512210. If you use
00016 //  FastJet as part of work towards a scientific publication, please
00017 //  include a citation to the FastJet paper.
00018 //
00019 //  FastJet is distributed in the hope that it will be useful,
00020 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
00021 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00022 //  GNU General Public License for more details.
00023 //
00024 //  You should have received a copy of the GNU General Public License
00025 //  along with FastJet; if not, write to the Free Software
00026 //  Foundation, Inc.:
00027 //      59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00028 //----------------------------------------------------------------------
00029 //ENDHEADER
00030 
00031 #ifndef __FASTJET_CLUSTERSEQUENCEACTIVEAREA_HH__
00032 #define __FASTJET_CLUSTERSEQUENCEACTIVEAREA_HH__
00033 
00034 
00035 #include "fastjet/PseudoJet.hh"
00036 #include "fastjet/ClusterSequenceAreaBase.hh"
00037 #include "fastjet/ClusterSequenceActiveAreaExplicitGhosts.hh"
00038 #include<iostream>
00039 #include<vector>
00040 
00041 //------------ backwards compatibility with version 2.1 -------------
00042 // for backwards compatibility make ActiveAreaSpec name available
00043 #include "fastjet/ActiveAreaSpec.hh"
00044 #include "fastjet/ClusterSequenceWithArea.hh"
00045 //--------------------------------------------------------------------
00046 
00047 
00048 FASTJET_BEGIN_NAMESPACE      // defined in fastjet/internal/base.hh
00049 
00050 //using namespace std;
00051 
00056 class ClusterSequenceActiveArea : public ClusterSequenceAreaBase {
00057 public:
00058 
00060   ClusterSequenceActiveArea() {}
00061 
00063   template<class L> ClusterSequenceActiveArea
00064          (const std::vector<L> & pseudojets, 
00065           const JetDefinition & jet_def,
00066           const GhostedAreaSpec & ghost_spec,
00067           const bool & writeout_combinations = false) ;
00068 
00069   virtual double area (const PseudoJet & jet) const {
00070                              return _average_area[jet.cluster_hist_index()];};
00071   virtual double area_error (const PseudoJet & jet) const {
00072                              return _average_area2[jet.cluster_hist_index()];};
00073 
00074   virtual PseudoJet area_4vector (const PseudoJet & jet) const {
00075                     return _average_area_4vector[jet.cluster_hist_index()];};
00076 
00080   enum mean_pt_strategies{median=0, non_ghost_median, pttot_over_areatot, 
00081                           pttot_over_areatot_cut, mean_ratio_cut, play,
00082                           median_4vector};
00083 
00091   //      ClusterSequenceAreaBase class instead
00092   double pt_per_unit_area(mean_pt_strategies strat=median, 
00093                           double range=2.0 ) const;
00094 
00095   // following code removed -- now dealt with by AreaBase class (and
00096   // this definition here conflicts with it).
00097 //   /// fits a form pt_per_unit_area(y) = a + b*y^2 in the range
00098 //   /// abs(y)<raprange (for negative raprange, it defaults to
00099 //   /// _safe_rap_for_area).
00100 //   void parabolic_pt_per_unit_area(double & a,double & b, double raprange=-1.0,
00101 //                                double exclude_above=-1.0, 
00102 //                                bool use_area_4vector=false ) const;
00103 // 
00108   virtual double empty_area(const RangeDefinition & range) const;
00109 
00112   virtual double n_empty_jets(const RangeDefinition & range) const;
00113 
00114 protected:
00115   void _resize_and_zero_AA ();
00116   void _initialise_AA(const JetDefinition & jet_def,
00117                       const GhostedAreaSpec & ghost_spec,
00118                       const bool & writeout_combinations,
00119                       bool & continue_running);
00120 
00121   void _run_AA(const GhostedAreaSpec & ghost_spec);
00122 
00123   void _postprocess_AA(const GhostedAreaSpec & ghost_spec);
00124 
00127   void _initialise_and_run_AA (const JetDefinition & jet_def,
00128                                const GhostedAreaSpec & ghost_spec,
00129                                const bool & writeout_combinations = false);
00130 
00133   void _transfer_ghost_free_history(
00134            const ClusterSequenceActiveAreaExplicitGhosts & clust_seq);
00135 
00136 
00139   void _transfer_areas(const std::vector<int> & unique_hist_order, 
00140                        const ClusterSequenceActiveAreaExplicitGhosts & );
00141 
00143   std::valarray<double> _average_area, _average_area2;
00144   std::valarray<PseudoJet> _average_area_4vector;
00145 
00149   bool has_dangerous_particles() const {return _has_dangerous_particles;}
00150 
00151 private:
00152 
00153 
00154   double           _non_jet_area, _non_jet_area2, _non_jet_number;
00155 
00156   double _maxrap_for_area; // max rap where we put ghosts
00157   double _safe_rap_for_area; // max rap where we trust jet areas
00158 
00159   bool   _has_dangerous_particles; 
00160 
00161 
00165   void _extract_tree(std::vector<int> &) const;
00168   void _extract_tree_children(int pos, std::valarray<bool> &, const std::valarray<int> &, std::vector<int> &) const;
00170   void _extract_tree_parents (int pos, std::valarray<bool> &, const std::valarray<int> &,  std::vector<int> &) const;
00171 
00175   void _throw_unless_jets_have_same_perp_or_E(const PseudoJet & jet, 
00176                                               const PseudoJet & refjet, 
00177                                               double tolerance,
00178              const ClusterSequenceActiveAreaExplicitGhosts & jets_ghosted_seq
00179                                               ) const;
00180 
00183   //static int _n_seed_warnings;
00184   //const static int _max_seed_warnings = 10;
00185 
00186   // record the number of repeats
00187   int _ghost_spec_repeat;
00188 
00190   class GhostJet : public PseudoJet {
00191   public:
00192     GhostJet(const PseudoJet & j, double a) : PseudoJet(j), area(a){}
00193     double area;
00194   };
00195 
00196   std::vector<GhostJet> _ghost_jets;
00197   std::vector<GhostJet> _unclustered_ghosts;
00198 };
00199 
00200 
00201 
00202 
00203 template<class L> ClusterSequenceActiveArea::ClusterSequenceActiveArea 
00204 (const std::vector<L> & pseudojets, 
00205  const JetDefinition & jet_def,
00206  const GhostedAreaSpec & ghost_spec,
00207  const bool & writeout_combinations) {
00208 
00209   // transfer the initial jets (type L) into our own array
00210   _transfer_input_jets(pseudojets);
00211 
00212   // run the clustering for active areas
00213   _initialise_and_run_AA(jet_def, ghost_spec, writeout_combinations);
00214 
00215 }
00216 
00217 
00218   
00219 FASTJET_END_NAMESPACE
00220 
00221 #endif // __FASTJET_CLUSTERSEQUENCEACTIVEAREA_HH__
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines