Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:57:17

0001 //FJSTARTHEADER
0002 // $Id$
0003 //
0004 // Copyright (c) 2005-2021, Matteo Cacciari, Gavin P. Salam and Gregory Soyez
0005 //
0006 //----------------------------------------------------------------------
0007 // This file is part of FastJet.
0008 //
0009 //  FastJet is free software; you can redistribute it and/or modify
0010 //  it under the terms of the GNU General Public License as published by
0011 //  the Free Software Foundation; either version 2 of the License, or
0012 //  (at your option) any later version.
0013 //
0014 //  The algorithms that underlie FastJet have required considerable
0015 //  development. They are described in the original FastJet paper,
0016 //  hep-ph/0512210 and in the manual, arXiv:1111.6097. If you use
0017 //  FastJet as part of work towards a scientific publication, please
0018 //  quote the version you use and include a citation to the manual and
0019 //  optionally also to hep-ph/0512210.
0020 //
0021 //  FastJet is distributed in the hope that it will be useful,
0022 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
0023 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0024 //  GNU General Public License for more details.
0025 //
0026 //  You should have received a copy of the GNU General Public License
0027 //  along with FastJet. If not, see <http://www.gnu.org/licenses/>.
0028 //----------------------------------------------------------------------
0029 //FJENDHEADER
0030 
0031 #ifndef __FASTJET_CLUSTERSEQUENCEACTIVEAREA_HH__
0032 #define __FASTJET_CLUSTERSEQUENCEACTIVEAREA_HH__
0033 
0034 
0035 #include "fastjet/PseudoJet.hh"
0036 #include "fastjet/ClusterSequenceAreaBase.hh"
0037 #include "fastjet/ClusterSequenceActiveAreaExplicitGhosts.hh"
0038 #include<iostream>
0039 #include<vector>
0040 
0041 //------------ backwards compatibility with version 2.1 -------------
0042 // for backwards compatibility make ActiveAreaSpec name available
0043 //#include "fastjet/ActiveAreaSpec.hh"
0044 //#include "fastjet/ClusterSequenceWithArea.hh"
0045 //--------------------------------------------------------------------
0046 
0047 
0048 FASTJET_BEGIN_NAMESPACE      // defined in fastjet/internal/base.hh
0049 
0050 //using namespace std;
0051 
0052 /// @ingroup sec_area_classes
0053 /// \class ClusterSequenceActiveArea
0054 /// Like ClusterSequence with computation of the active jet area
0055 ///
0056 /// Class that behaves essentially like ClusterSequence except
0057 /// that it also provides access to the area of a jet (which
0058 /// will be a random quantity... Figure out what to do about seeds 
0059 /// later...)
0060 ///
0061 /// This class should not be used directly. Rather use
0062 /// ClusterSequenceArea with the appropriate AreaDefinition
0063 class ClusterSequenceActiveArea : public ClusterSequenceAreaBase {
0064 public:
0065 
0066   /// default constructor
0067   ClusterSequenceActiveArea() {}
0068 
0069   /// constructor based on JetDefinition and GhostedAreaSpec
0070   template<class L> ClusterSequenceActiveArea
0071          (const std::vector<L> & pseudojets, 
0072       const JetDefinition & jet_def_in,
0073       const GhostedAreaSpec & ghost_spec,
0074       const bool & writeout_combinations = false) ;
0075 
0076   virtual double area (const PseudoJet & jet) const FASTJET_OVERRIDE{
0077                              return _average_area[jet.cluster_hist_index()];};
0078   virtual double area_error (const PseudoJet & jet) const FASTJET_OVERRIDE {
0079                              return _average_area2[jet.cluster_hist_index()];};
0080 
0081   virtual PseudoJet area_4vector (const PseudoJet & jet) const FASTJET_OVERRIDE{
0082                     return _average_area_4vector[jet.cluster_hist_index()];};
0083 
0084   /// enum providing a variety of tentative strategies for estimating
0085   /// the background (e.g. non-jet) activity in a highly populated event; the
0086   /// one that has been most extensively tested is median.
0087   /// 
0088   /// These strategies are OBSOLETE and deprecated (see comment
0089   /// for pt_per_unit_area).
0090   enum mean_pt_strategies{median=0, non_ghost_median, pttot_over_areatot, 
0091               pttot_over_areatot_cut, mean_ratio_cut, play,
0092               median_4vector};
0093 
0094   /// return the transverse momentum per unit area according to one
0095   /// of the above strategies; for some strategies (those with "cut"
0096   /// in their name) the parameter "range" allows one to exclude a
0097   /// subset of the jets for the background estimation, those that
0098   /// have pt/area > median(pt/area)*range.
0099   ///
0100   /// NB: This call is OBSOLETE and deprecated; use a
0101   /// JetMedianBackgroundEstimator or GridMedianBackgroundEstimator
0102   /// instead.
0103   double pt_per_unit_area(mean_pt_strategies strat=median, 
0104                           double range=2.0 ) const;
0105 
0106   /// rewrite the empty area from the parent class, so as to use
0107   /// all info at our disposal
0108   /// return the total area, corresponding to a given Selector, that
0109   /// consists of ghost jets or unclustered ghosts
0110   ///
0111   /// The selector passed as an argument needs to apply jet by jet.
0112   virtual double empty_area(const Selector & selector) const FASTJET_OVERRIDE;
0113 
0114   /// return the true number of empty jets (replaces
0115   /// ClusterSequenceAreaBase::n_empty_jets(...))
0116   virtual double n_empty_jets(const Selector & selector) const FASTJET_OVERRIDE;
0117 
0118 protected:
0119   void _resize_and_zero_AA ();
0120   void _initialise_AA(const JetDefinition & jet_def,
0121                       const GhostedAreaSpec & ghost_spec,
0122                       const bool & writeout_combinations,
0123                       bool & continue_running);
0124 
0125   void _run_AA(const GhostedAreaSpec & ghost_spec);
0126 
0127   void _postprocess_AA(const GhostedAreaSpec & ghost_spec);
0128 
0129   /// does the initialisation and running specific to the active
0130   /// areas class
0131   void _initialise_and_run_AA (const JetDefinition & jet_def,
0132                                const GhostedAreaSpec & ghost_spec,
0133                                const bool & writeout_combinations = false);
0134 
0135   /// transfer the history (and jet-momenta) from clust_seq to our
0136   /// own internal structure while removing ghosts
0137   void _transfer_ghost_free_history(
0138            const ClusterSequenceActiveAreaExplicitGhosts & clust_seq);
0139 
0140 
0141   /// transfer areas from the ClusterSequenceActiveAreaExplicitGhosts
0142   /// object into our internal area bookkeeping...
0143   void _transfer_areas(const std::vector<int> & unique_hist_order, 
0144                        const ClusterSequenceActiveAreaExplicitGhosts & );
0145 
0146   /// child classes benefit from having these at their disposal
0147   std::valarray<double> _average_area, _average_area2;
0148   std::valarray<PseudoJet> _average_area_4vector;
0149 
0150   /// returns true if there are any particles whose transverse momentum
0151   /// if so low that there's a risk of the ghosts having modified the
0152   /// clustering sequence
0153   bool has_dangerous_particles() const {return _has_dangerous_particles;}
0154 
0155 private:
0156 
0157 
0158   double           _non_jet_area, _non_jet_area2, _non_jet_number;
0159 
0160   double _maxrap_for_area; // max rap where we put ghosts
0161   double _safe_rap_for_area; // max rap where we trust jet areas
0162 
0163   bool   _has_dangerous_particles; 
0164 
0165 
0166   /// routine for extracting the tree in an order that will be independent
0167   /// of any degeneracies in the recombination sequence that don't
0168   /// affect the composition of the final jets
0169   void _extract_tree(std::vector<int> &) const;
0170   /// do the part of the extraction associated with pos, working
0171   /// through its children and their parents
0172   void _extract_tree_children(int pos, std::valarray<bool> &, const std::valarray<int> &, std::vector<int> &) const;
0173   /// do the part of the extraction associated with the parents of pos.
0174   void _extract_tree_parents (int pos, std::valarray<bool> &, const std::valarray<int> &,  std::vector<int> &) const;
0175 
0176   /// check if two jets have the same momentum to within the
0177   /// tolerance (and if pt's are not the same we're forgiving and
0178   /// look to see if the energy is the same)
0179   void _throw_unless_jets_have_same_perp_or_E(const PseudoJet & jet, 
0180                                               const PseudoJet & refjet, 
0181                                               double tolerance,
0182              const ClusterSequenceActiveAreaExplicitGhosts & jets_ghosted_seq
0183                                               ) const;
0184 
0185   /// since we are playing nasty games with seeds, we should warn
0186   /// the user a few times
0187   //static int _n_seed_warnings;
0188   //const static int _max_seed_warnings = 10;
0189 
0190   // record the number of repeats
0191   int _ghost_spec_repeat;
0192 
0193   /// a class for our internal storage of ghost jets
0194   class GhostJet : public PseudoJet {
0195   public:
0196     GhostJet(const PseudoJet & j, double a) : PseudoJet(j), area(a){}
0197     double area;
0198   };
0199 
0200   std::vector<GhostJet> _ghost_jets;
0201   std::vector<GhostJet> _unclustered_ghosts;
0202 };
0203 
0204 
0205 
0206 
0207 template<class L> ClusterSequenceActiveArea::ClusterSequenceActiveArea 
0208 (const std::vector<L> & pseudojets, 
0209  const JetDefinition & jet_def_in,
0210  const GhostedAreaSpec & ghost_spec,
0211  const bool & writeout_combinations) {
0212 
0213   // transfer the initial jets (type L) into our own array
0214   _transfer_input_jets(pseudojets);
0215 
0216   // run the clustering for active areas
0217   _initialise_and_run_AA(jet_def_in, ghost_spec, writeout_combinations);
0218 
0219 }
0220 
0221 
0222   
0223 FASTJET_END_NAMESPACE
0224 
0225 #endif // __FASTJET_CLUSTERSEQUENCEACTIVEAREA_HH__