FastJet 3.0alpha3
GhostedAreaSpec.cc
00001 //STARTHEADER
00002 // $Id: GhostedAreaSpec.cc 2081 2011-05-09 08:25:13Z 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 #include "fastjet/GhostedAreaSpec.hh"
00032 #include "fastjet/Error.hh"
00033 #include<iostream>
00034 #include<sstream>
00035 
00036 using namespace std;
00037 
00038 FASTJET_BEGIN_NAMESPACE      // defined in fastjet/internal/base.hh
00039 
00040 BasicRandom<double> GhostedAreaSpec::_random_generator;
00041 
00042 /// explicit constructor
00043 GhostedAreaSpec::GhostedAreaSpec(
00044                            const Selector & selector,
00045                            int    repeat        ,
00046                            double ghost_area    ,   
00047                            double grid_scatter  , 
00048                            double kt_scatter    ,   
00049                            double mean_ghost_kt 
00050                           ): 
00051     _repeat(repeat), 
00052     _ghost_area(ghost_area), 
00053     _grid_scatter(grid_scatter),  
00054     _kt_scatter(kt_scatter), 
00055     _mean_ghost_kt(mean_ghost_kt),
00056     _selector(selector),
00057     _actual_ghost_area(-1.0)
00058   {
00059     // check the selector has the properties needed -- an area and
00060     // applicability jet-by-jet (the latter follows automatically from
00061     // the former?)
00062     if (!_selector.has_finite_area()) throw Error("To construct a GhostedAreaSpec with a Selector, the selector must have a finite area");
00063     if (!_selector.applies_jet_by_jet()) throw Error("To construct a GhostedAreaSpec with a Selector, the selector must apply jet-by-jet");
00064     // get the internal rapidity extent from the selector
00065     double ghost_maxrap, ghost_minrap;
00066     _selector.get_rapidity_extent(ghost_minrap, ghost_maxrap);
00067     _ghost_maxrap     = 0.5*(ghost_maxrap - ghost_minrap); 
00068     _ghost_rap_offset = 0.5*(ghost_maxrap + ghost_minrap);
00069     
00070     _initialize();
00071   
00072 }
00073 //======================================================================
00074 /// sets the detailed parameters for the ghosts (which may not be quite
00075 /// the same as those requested -- this is in order for things to fit
00076 /// in nicely into 2pi etc...
00077 void GhostedAreaSpec::_initialize() {
00078   // add on area-measuring dummy particles
00079   _drap = sqrt(_ghost_area);
00080   _dphi = _drap;
00081   _nphi = int(ceil(twopi/_dphi)); _dphi = twopi/_nphi;
00082   _nrap = int(ceil(_ghost_maxrap/_drap)); _drap = _ghost_maxrap / _nrap;
00083   _actual_ghost_area = _dphi * _drap;
00084   _n_ghosts   = (2*_nrap+1)*_nphi;
00085 
00086   // checkpoint the status of the random number generator.
00087   checkpoint_random();
00088   //_random_generator.info(cerr);
00089 }
00090 
00091 //----------------------------------------------------------------------
00092 /// adds the ghost 4-momenta to the vector of PseudoJet's
00093 void GhostedAreaSpec::add_ghosts(vector<PseudoJet> & event) const {
00094   // add momenta for ghosts
00095   for (int irap = -_nrap; irap <= _nrap; irap++) {
00096     for (int iphi = 0; iphi < _nphi; iphi++) {
00097      
00098       // include random offsets for all quantities
00099       //----------------------------------------------
00100       // NB: in FJ2 we'd exchanged the px and py components relative to a
00101       // standard definition of phi; to preserve the same areas as fj2
00102       // we now generate a "phi_fj2", and then convert to a standard phi
00103       double phi_fj2 = (iphi+0.5) * _dphi + _dphi*(_our_rand()-0.5)*_grid_scatter;
00104       double phi = 0.5*pi - phi_fj2;
00105       double rap = irap * _drap + _drap*(_our_rand()-0.5)*_grid_scatter
00106                                                          + _ghost_rap_offset ;
00107       double kt = _mean_ghost_kt*(1+(_our_rand()-0.5)*_kt_scatter);
00108 
00109       double exprap = exp(+rap);
00110       double pminus = kt/exprap;
00111       double pplus  = kt*exprap;
00112       double px = kt*cos(phi);
00113       double py = kt*sin(phi);
00114       PseudoJet mom(px,py,0.5*(pplus-pminus),0.5*(pplus+pminus));
00115       // this call fills in the PseudoJet's cached rap,phi information,
00116       // based on pre-existing knowledge. Watch out: if you get the hint
00117       // wrong nobody will tell you, but you will certainly mess up
00118       // your results.
00119       mom.set_cached_rap_phi(rap,phi);
00120 
00121       // if we have an active selector and the particle does not pass the 
00122       // selection condition, move on to the next momentum
00123       if (_selector.worker().get() && !_selector.pass(mom)) continue;
00124       event.push_back(mom);
00125     }
00126   }
00127 }
00128 
00129 string GhostedAreaSpec::description() const {
00130 
00131   ostringstream ostr;
00132   ostr << "ghosts of area " << actual_ghost_area() 
00133        << " (had requested " << ghost_area() << ")";
00134   if (_selector.worker().get()) 
00135     ostr << ", placed according to selector (" << _selector.description() << ")";
00136   else
00137     ostr << ", placed up to y = " << ghost_maxrap() ;
00138   ostr << ", scattered wrt to perfect grid by (rel) " << grid_scatter() 
00139        << ", mean_ghost_kt = " << mean_ghost_kt()
00140        << ", rel kt_scatter =  " << kt_scatter()
00141        << ", n repetitions of ghost distributions =  " << repeat();
00142   return ostr.str();
00143 }
00144 
00145 FASTJET_END_NAMESPACE
00146 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends