ClusterSequenceActiveAreaExplicitGhosts.hh

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

Generated on Tue Dec 18 17:05:02 2007 for fastjet by  doxygen 1.5.2