fastjet 2.4.5
ClusterSequenceActiveAreaExplicitGhosts.hh
Go to the documentation of this file.
00001 //STARTHEADER
00002 // $Id: ClusterSequenceActiveAreaExplicitGhosts.hh 1595 2009-05-28 09:43:26Z soyez $
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_CLUSTERSEQUENCEACTIVEAREAEXPLICITGHOSTS_HH_
00032 #define __FASTJET_CLUSTERSEQUENCEACTIVEAREAEXPLICITGHOSTS_HH_ 
00033 
00034 #include "fastjet/PseudoJet.hh"
00035 #include "fastjet/ClusterSequenceAreaBase.hh"
00036 #include "fastjet/GhostedAreaSpec.hh"
00037 #include "fastjet/internal/LimitedWarning.hh"
00038 #include<iostream>
00039 #include<vector>
00040 #include <cstdio>
00041 
00042 FASTJET_BEGIN_NAMESPACE      // defined in fastjet/internal/base.hh
00043 
00044 //======================================================================
00049 class ClusterSequenceActiveAreaExplicitGhosts : 
00050   public ClusterSequenceAreaBase {
00051 public:
00054   template<class L> ClusterSequenceActiveAreaExplicitGhosts
00055          (const std::vector<L> & pseudojets, 
00056           const JetDefinition & jet_def,
00057           const GhostedAreaSpec & ghost_spec,
00058           const bool & writeout_combinations = false) 
00059            : ClusterSequenceAreaBase() {
00060            std::vector<L> * ghosts = NULL;
00061            _initialise(pseudojets,jet_def,&ghost_spec,ghosts,0.0,
00062                        writeout_combinations); }
00063 
00064   template<class L> ClusterSequenceActiveAreaExplicitGhosts
00065          (const std::vector<L> & pseudojets, 
00066           const JetDefinition & jet_def,
00067           const std::vector<L> & ghosts,
00068           double ghost_area,
00069           const bool & writeout_combinations = false) 
00070            : ClusterSequenceAreaBase() {
00071            const GhostedAreaSpec * ghost_spec = NULL;
00072            _initialise(pseudojets,jet_def,ghost_spec,&ghosts,ghost_area,
00073                        writeout_combinations); }
00074 
00075 
00077   template<class L> void _initialise
00078          (const std::vector<L> & pseudojets, 
00079           const JetDefinition & jet_def,
00080           const GhostedAreaSpec * ghost_spec,
00081           const std::vector<L> * ghosts,
00082           double                 ghost_area,
00083           const bool & writeout_combinations); 
00084 
00085   //vector<PseudoJet> constituents (const PseudoJet & jet) const;
00086 
00088   unsigned int n_hard_particles() const;
00089 
00091   virtual double area (const PseudoJet & jet) const;
00092 
00097   virtual PseudoJet area_4vector (const PseudoJet & jet) const;
00098 
00100   virtual bool is_pure_ghost(const PseudoJet & jet) const;
00101 
00105   bool is_pure_ghost(int history_index) const;
00106 
00108   virtual bool has_explicit_ghosts() const {return true;}
00109 
00112   virtual double empty_area(const RangeDefinition & range) const;
00113 
00115   double total_area () const;
00116   
00119   double max_ghost_perp2() const {return _max_ghost_perp2;}
00120 
00124   bool has_dangerous_particles() const {return _has_dangerous_particles;}
00125 
00127   //double ghost_area() const{return _ghost_area;}
00128 
00129 private:
00130 
00131   int    _n_ghosts;
00132   double _ghost_area;
00133   std::vector<bool> _is_pure_ghost;
00134   std::vector<double> _areas;
00135   std::vector<PseudoJet> _area_4vectors;
00136   
00137   // things related to checks for dangerous particles
00138   double _max_ghost_perp2;
00139   bool   _has_dangerous_particles; 
00140   static LimitedWarning _warnings;
00141 
00142   //static int _n_warn_dangerous_particles;
00143   //static const int _max_warn_dangerous_particles = 5;
00144 
00145   
00146   unsigned int _initial_hard_n;
00147 
00150   void _add_ghosts(const GhostedAreaSpec & ghost_spec); 
00151 
00153   template<class L> void _add_ghosts (
00154           const std::vector<L> & ghosts,
00155           double                 ghost_area);
00156 
00160   void _post_process();
00161 
00162 };
00163 
00164 
00165 //----------------------------------------------------------------------
00166 // initialise from some generic type... Has to be made available
00167 // here in order for the template aspect of it to work...
00168 template<class L> void ClusterSequenceActiveAreaExplicitGhosts::_initialise
00169          (const std::vector<L> & pseudojets, 
00170           const JetDefinition & jet_def,
00171           const GhostedAreaSpec * ghost_spec,
00172           const std::vector<L> * ghosts,
00173           double                 ghost_area,
00174           const bool & writeout_combinations) {
00175   // don't reserve space yet -- will be done below
00176 
00177   // insert initial jets this way so that any type L that can be
00178   // converted to a pseudojet will work fine (basically PseudoJet
00179   // and any type that has [] subscript access to the momentum
00180   // components, such as CLHEP HepLorentzVector).
00181   for (unsigned int i = 0; i < pseudojets.size(); i++) {
00182     PseudoJet mom(pseudojets[i]);
00183     //mom.set_user_index(0); // for user's particles (user index now lost...)
00184     _jets.push_back(mom);
00185     _is_pure_ghost.push_back(false);
00186   }
00187 
00188   _initial_hard_n = _jets.size();
00189 
00190   if (ghost_spec != NULL) {
00191     _add_ghosts(*ghost_spec);
00192   } else {
00193     _add_ghosts(*ghosts, ghost_area);
00194   }
00195 
00196   if (writeout_combinations) {
00197     std::cout << "# Printing particles including ghosts\n";
00198     for (unsigned j = 0; j < _jets.size(); j++) {
00199       printf("%5u %20.13f %20.13f %20.13e\n",
00200                j,_jets[j].rap(),_jets[j].phi_02pi(),_jets[j].kt2());
00201     }
00202     std::cout << "# Finished printing particles including ghosts\n";
00203   }
00204 
00205   // this will ensure that we can still point to jets without
00206   // difficulties arising!
00207   _jets.reserve(_jets.size()*2);
00208 
00209   // run the clustering
00210   _initialise_and_run(jet_def,writeout_combinations);
00211 
00212   // set up all other information
00213   _post_process();
00214 }
00215 
00216 
00217 inline unsigned int ClusterSequenceActiveAreaExplicitGhosts::n_hard_particles() const {return _initial_hard_n;}
00218 
00219 
00220 //----------------------------------------------------------------------
00222 template<class L> void ClusterSequenceActiveAreaExplicitGhosts::_add_ghosts (
00223           const std::vector<L> & ghosts,
00224           double                 ghost_area) {
00225 
00226   
00227   for (unsigned i = 0; i < ghosts.size(); i++) {
00228     _is_pure_ghost.push_back(true);
00229     _jets.push_back(ghosts[i]);
00230   }
00231   // and record some info about ghosts
00232   _ghost_area = ghost_area;
00233   _n_ghosts   = ghosts.size();
00234 }
00235 
00236 
00237 FASTJET_END_NAMESPACE
00238 
00239 #endif // __FASTJET_CLUSTERSEQUENCEACTIVEAREAEXPLICITGHOSTS_HH_
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines