SISCone  2.0.5
siscone/spherical/protocones.h
00001 // -*- C++ -*-
00003 // File: protocones.h                                                        //
00004 // Description: header file for stable cones determination (Cstable_cones)   //
00005 // This file is part of the SISCone project.                                 //
00006 // WARNING: this is not the main SISCone trunk but                           //
00007 //          an adaptation to spherical coordinates                           //
00008 // For more details, see http://projects.hepforge.org/siscone                //
00009 //                                                                           //
00010 // Copyright (c) 2006-2008 Gavin Salam and Gregory Soyez                          //
00011 //                                                                           //
00012 // This program is free software; you can redistribute it and/or modify      //
00013 // it under the terms of the GNU General Public License as published by      //
00014 // the Free Software Foundation; either version 2 of the License, or         //
00015 // (at your option) any later version.                                       //
00016 //                                                                           //
00017 // This program is distributed in the hope that it will be useful,           //
00018 // but WITHOUT ANY WARRANTY; without even the implied warranty of            //
00019 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the             //
00020 // GNU General Public License for more details.                              //
00021 //                                                                           //
00022 // You should have received a copy of the GNU General Public License         //
00023 // along with this program; if not, write to the Free Software               //
00024 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA //
00025 //                                                                           //
00026 // $Revision:: 255                                                          $//
00027 // $Date:: 2008-07-12 17:40:35 +0200 (Sat, 12 Jul 2008)                     $//
00029 
00030 #ifndef __SPH_PROTOCONES_H__
00031 #define __SPH_PROTOCONES_H__
00032 
00033 #include "momentum.h"
00034 #include "vicinity.h"
00035 #include <stdio.h>
00036 #include <vector>
00037 #include <list>
00038 #include "hash.h"
00039 
00040 #include <siscone/defines.h>
00041 
00042 namespace siscone_spherical{
00043 
00055 class CSphborder_store{
00056 public:
00058   CSphborder_store(CSphmomentum * momentum, CSph3vector &centre, CSph3vector &angl_dir1, CSph3vector &angl_dir2) : 
00059     mom(momentum),  is_in(false) {
00060     CSph3vector diff = (*momentum) - centre;
00061     angle = atan2(dot_product3(diff, angl_dir2), dot_product3(diff, angl_dir1));
00062 #ifdef DEBUG_STABLE_CONES
00063     std::cout << "  adding point " << momentum->_theta << ", " << momentum->_phi
00064               << " at an angle of " << angle << std::endl;
00065 #endif
00066   }
00067 
00068   CSphmomentum * mom;  
00069   double angle;     
00070   bool   is_in;     
00071 };
00072 
00073 
00076 inline bool operator<(const CSphborder_store & a, const CSphborder_store & b) {
00077   return a.angle < b.angle;
00078 }
00079 
00080 
00089 class CSphstable_cones : public CSphvicinity{
00090  public:
00092   CSphstable_cones();
00093 
00095   CSphstable_cones(std::vector<CSphmomentum> &_particle_list);
00096 
00098   ~CSphstable_cones();
00099 
00104   void init(std::vector<CSphmomentum> &_particle_list);
00105 
00113   int get_stable_cones(double _radius);
00114 
00116   std::vector<CSphmomentum> protocones;
00117 
00119   sph_hash_cones *hc;
00120 
00122   int nb_tot;
00123 #ifdef DEBUG_STABLE_CONES
00124   int nb_hash_cones, nb_hash_occupied;
00125 #endif
00126 
00127  protected:
00129   double R;
00130 
00132   double R2;
00133 
00135   double tan2R;
00136 
00137  private:
00140   CSphmomentum cone;
00141 
00143   CSphmomentum *child;
00144 
00146   CSphvicinity_elm *centre;
00147 
00149   unsigned int centre_idx;
00150 
00152   unsigned int first_cone;
00153 
00159   int init_cone();
00160 
00167   int test_cone();
00168 
00174   int update_cone();
00175 
00176   /*
00177    * run through the vicinity of the current parent and for each child
00178    * indicate which members are cocircular...
00179    */
00180   void prepare_cocircular_lists();
00181 
00189   bool cocircular_check();
00190 
00195   void test_cone_cocircular(CSphmomentum & borderless_cone, 
00196                             std::list<CSphmomentum *> & border_list);
00197 
00204   void test_stability(CSphmomentum & candidate, 
00205                       const std::vector<CSphborder_store> & border_vect);
00206 
00213   void compute_cone_contents();
00214 
00220   void recompute_cone_contents();
00221 
00222   /*
00223    * if we have gone beyond the acceptable threshold of change, compute
00224    * the cone momentum from particle list.  in this version, we use the
00225    * 'pincluded' information from the CSphvicinity class, but we don't
00226    * change the member cone, only the locally supplied one
00227    */
00228   void recompute_cone_contents_if_needed(CSphmomentum & this_cone, double & this_dpt);
00229 
00235   int proceed_with_stability();
00236 
00237   /*
00238    * circle intersection.
00239    * computes the intersection with a circle of given centre and radius.
00240    * The output takes the form of a checkxor of the intersection's particles
00241    *  - cx    circle centre x coordinate
00242    *  - cy    circle centre y coordinate
00243    * return the checkxor for the intersection
00244    ******************************************************************/
00245   siscone::Creference circle_intersect(CSph3vector &cone_centre);
00246 
00248   CSphmomentum cone_candidate;
00249 
00251   std::vector<CSphmomentum*> child_list;
00252 
00255   std::vector< std::pair<siscone::Creference,siscone::Creference> > multiple_centre_done;
00256 
00257   // information for updating cone contents to avoid rounding errors
00258   double dpt;          
00259 };
00260 
00261 }
00262 #endif
The SISCone project has been developed by Gavin Salam and Gregory Soyez
Documentation generated on Mon Jun 4 2012 18:23:38 for SISCone by  Doxygen 1.7.6.1