3 #include "fastjet/ClusterSequence.hh" 
    4 #include "fastjet/SISConeSphericalPlugin.hh" 
    7 #include "siscone/spherical/momentum.h" 
    8 #include "siscone/spherical/siscone.h" 
   13 FASTJET_BEGIN_NAMESPACE      
 
   16 using namespace siscone_spherical;
 
   19 template<> PseudoJet::PseudoJet(
const siscone_spherical::CSphmomentum & four_vector) {
 
   20   (*this) = 
PseudoJet(four_vector.px,four_vector.py,four_vector.pz,
 
   27 namespace siscone_plugin_internal{
 
   34   class SISConeSphericalUserScale  : 
public siscone_spherical::CSphsplit_merge::Cuser_scale_base{
 
   41       : _user_scale(user_scale), _cs(cs){}
 
   44     virtual double operator()(
const siscone_spherical::CSphjet &jet)
 const{
 
   45       return _user_scale->result(_build_PJ_from_Cjet(jet));
 
   50     virtual bool is_larger(
const siscone_spherical::CSphjet &a, 
const siscone_spherical::CSphjet &b)
 const{
 
   51       return _user_scale->is_larger(_build_PJ_from_Cjet(a), _build_PJ_from_Cjet(b));
 
   62     PseudoJet _build_PJ_from_Cjet(
const siscone_spherical::CSphjet &jet)
 const{
 
   63       PseudoJet j(jet.v.px, jet.v.py, jet.v.pz, jet.v.E);
 
   64       j.set_structure_shared_ptr(SharedPtr<PseudoJetStructureBase>(
 
   65                                    new SISConeSphericalPlugin::UserScaleBaseStructureType<siscone_spherical::CSphjet>(jet,_cs)));      
 
   69     const SISConeSphericalPlugin::UserScaleBase *_user_scale;
 
   70     const ClusterSequence & _cs;
 
   81 SharedPtr<SISConeSphericalPlugin>  SISConeSphericalPlugin::stored_plugin;
 
   82 SharedPtr<std::vector<PseudoJet> > SISConeSphericalPlugin::stored_particles;
 
   83 SharedPtr<CSphsiscone>             SISConeSphericalPlugin::stored_siscone;
 
   89 string SISConeSphericalPlugin::description ()
 const {
 
   92   const string on = 
"on";
 
   93   const string off = 
"off";
 
   95   string sm_scale_string = 
"split-merge uses " + 
 
   96     split_merge_scale_name(Esplit_merge_scale(split_merge_scale()));
 
   98   desc << 
"Spherical SISCone jet algorithm with " ;
 
   99   desc << 
"cone_radius = "       << cone_radius        () << 
", ";
 
  100   if (_progressive_removal)
 
  101     desc << 
"progressive-removal mode, ";
 
  103     desc << 
"overlap_threshold = " << overlap_threshold  () << 
", ";
 
  104   desc << 
"n_pass_max = "        << n_pass_max         () << 
", ";
 
  105   desc << 
"protojet_Emin = "     << protojet_Emin()      << 
", ";
 
  106   if (_progressive_removal && _user_scale) {
 
  107     desc << 
"using a user-defined scale for ordering of stable cones";
 
  108     string user_scale_desc = _user_scale->description();
 
  109     if (user_scale_desc != 
"") desc << 
" (" << user_scale_desc << 
")";
 
  111     desc <<  sm_scale_string;
 
  113   if (!_progressive_removal){
 
  114     desc << 
"caching turned "      << (caching() ? on : off);
 
  115     desc << 
", SM stop scale = "     << _split_merge_stopping_scale;
 
  119   if (_use_E_weighted_splitting){
 
  120     desc << 
", using E-weighted splitting";
 
  123   if (_use_jet_def_recombiner){
 
  124     desc << 
", using jet-definition's own recombiner";
 
  129   if (siscone.merge_identical_protocones) {
 
  130     desc << 
", and (IR unsafe) merge_indentical_protocones=true" ;
 
  133   desc << 
", SISCone code v" << siscone_version();
 
  144   CSphsiscone   local_siscone;
 
  145   CSphsiscone * siscone;
 
  147   unsigned n = clust_seq.
jets().size();
 
  149   bool new_siscone = 
true; 
 
  151   if (caching() && !_progressive_removal) {
 
  157     if (stored_siscone.get() != 0) {
 
  158       new_siscone = !(stored_plugin->cone_radius()   == cone_radius()
 
  159                       && stored_plugin->n_pass_max() == n_pass_max()
 
  160                       && stored_particles->size()    == n);
 
  162         for(
unsigned i = 0; i < n; i++) {
 
  166                                              (*stored_particles)[i]);
 
  173       stored_siscone  .reset( 
new CSphsiscone );
 
  174       stored_particles.reset( 
new std::vector<PseudoJet>(clust_seq.
jets()));
 
  175       reset_stored_plugin();
 
  178     siscone = stored_siscone.get();
 
  180     siscone = &local_siscone;
 
  184   siscone->SM_var2_hardest_cut_off = _split_merge_stopping_scale*_split_merge_stopping_scale;
 
  189   siscone->stable_cone_soft_E2_cutoff = ghost_separation_scale()
 
  190                                       * ghost_separation_scale();
 
  192   siscone->set_E_weighted_splitting(_use_E_weighted_splitting);
 
  197     std::vector<CSphmomentum> siscone_momenta(n);
 
  198     for(
unsigned i = 0; i < n; i++) {
 
  200       siscone_momenta[i] = CSphmomentum(p.px(), p.py(), p.pz(), p.E());
 
  205     if (_progressive_removal){
 
  209         internal_scale.
reset(
new siscone_plugin_internal::SISConeSphericalUserScale(_user_scale, clust_seq));
 
  210         siscone->set_user_scale(internal_scale.
get());
 
  212       siscone->compute_jets_progressive_removal(siscone_momenta, cone_radius(),
 
  213                                                 n_pass_max(), protojet_or_ghost_Emin(), 
 
  214                                                 Esplit_merge_scale(split_merge_scale()));
 
  216       siscone->compute_jets(siscone_momenta, cone_radius(), overlap_threshold(),
 
  217                             n_pass_max(), protojet_or_ghost_Emin(), 
 
  218                             Esplit_merge_scale(split_merge_scale()));
 
  224     siscone->recompute_jets(overlap_threshold(), protojet_or_ghost_Emin(), 
 
  225                             Esplit_merge_scale(split_merge_scale()));
 
  229   int njet = siscone->jets.size();
 
  238   for (
int ijet = njet-1; ijet >= 0; ijet--) {
 
  239     const CSphjet & jet = siscone->jets[ijet]; 
 
  244     int jet_k = jet.contents[0];
 
  245     for (
unsigned ipart = 1; ipart < jet.contents.size(); ipart++) {
 
  249       int jet_j = jet.contents[ipart];
 
  253       if (_use_jet_def_recombiner) {
 
  269     double d_iB = clust_seq.
jets()[jet_k].perp2();
 
  273     extras->_pass[clust_seq.
jets()[jet_k].cluster_hist_index()] = jet.pass;
 
  277   for (
unsigned ipass = 0; ipass < siscone->protocones_list.size(); ipass++) {
 
  278     for (
unsigned ipc = 0; ipc < siscone->protocones_list[ipass].size(); ipc++) {
 
  279       PseudoJet protocone(siscone->protocones_list[ipass][ipc]);
 
  281       extras->_protocones.push_back(protocone);
 
  284   extras->_most_ambiguous_split = siscone->most_ambiguous_split;
 
  287   extras->_jet_def_plugin = 
this;
 
  297 void SISConeSphericalPlugin::reset_stored_plugin()
 const{
 
  302 FASTJET_END_NAMESPACE