Fork me on GitHub

Ignore:
Timestamp:
Sep 3, 2014, 3:18:54 PM (10 years ago)
Author:
Pavel Demin <demin@…>
Branches:
ImprovedOutputFile, Timing, dual_readout, llp, master
Children:
be2222c
Parents:
5b5a56b
Message:

upgrade FastJet to version 3.1.0-beta.1, upgrade Nsubjettiness to version 2.1.0, add SoftKiller version 1.0.0

File:
1 edited

Legend:

Unmodified
Added
Removed
  • external/fastjet/tools/Subtractor.cc

    r5b5a56b r35cdc46  
    1 //STARTHEADER
    2 // $Id$
     1//FJSTARTHEADER
     2// $Id: Subtractor.cc 3594 2014-08-12 15:25:11Z soyez $
    33//
    4 // Copyright (c) 2005-2011, Matteo Cacciari, Gavin P. Salam and Gregory Soyez
     4// Copyright (c) 2005-2014, Matteo Cacciari, Gavin P. Salam and Gregory Soyez
    55//
    66//----------------------------------------------------------------------
     
    1313//
    1414//  The algorithms that underlie FastJet have required considerable
    15 //  development and are described in hep-ph/0512210. If you use
     15//  development. They are described in the original FastJet paper,
     16//  hep-ph/0512210 and in the manual, arXiv:1111.6097. If you use
    1617//  FastJet as part of work towards a scientific publication, please
    17 //  include a citation to the FastJet paper.
     18//  quote the version you use and include a citation to the manual and
     19//  optionally also to hep-ph/0512210.
    1820//
    1921//  FastJet is distributed in the hope that it will be useful,
     
    2527//  along with FastJet. If not, see <http://www.gnu.org/licenses/>.
    2628//----------------------------------------------------------------------
    27 //ENDHEADER
     29//FJENDHEADER
    2830
    2931#include "fastjet/tools/Subtractor.hh"
     
    3840
    3941
     42//----------------------------------------------------------------------
     43// ctor
    4044Subtractor::Subtractor(double rho) : _bge(0), _rho(rho) {
    4145  assert(_rho>0.0);
     46  set_defaults();
    4247}
    4348
     49//----------------------------------------------------------------------
     50void Subtractor::set_defaults(){
     51  _use_rho_m = false; // likely to change in future releases!!
     52  _safe_mass = false; // likely to change in future releases!!
     53
     54  _sel_known_vertex = Selector();
     55  _sel_leading_vertex = Selector();
     56}
     57
     58//----------------------------------------------------------------------
     59// perform the subtraction of a given jet
    4460PseudoJet Subtractor::result(const PseudoJet & jet) const {
    4561  if (!jet.has_area()){
    4662    throw Error("Trying to subtract a jet without area support");
    4763  }
    48  
     64
     65  PseudoJet known_lv, known_pu;
     66  PseudoJet unknown = jet;
     67  if (_sel_known_vertex.worker()){
     68    // separate the jet constituents in 3 groups:
     69    //   unknown vertex
     70    //   known vertex, leading vertex
     71    //   known vertex, non-leading vertex (PU)
     72    vector<PseudoJet> constits_unknown, constits_known;
     73    _sel_known_vertex.sift(jet.constituents(),
     74                           constits_known,
     75                           constits_unknown);
     76    vector<PseudoJet> constits_known_lv, constits_known_pu;
     77    _sel_leading_vertex.sift(constits_known,
     78                             constits_known_lv,
     79                             constits_known_pu);
     80
     81    // For the parts related to the known vertices (LV or PU), we just
     82    // sum the 4-momenta. For the unknown part, we assign it the full
     83    // jet area.
     84    known_lv = (constits_known_lv.size()!=0)
     85      ? SelectorIdentity().sum(constits_known_lv) : 0.0*jet;
     86    known_pu = (constits_known_pu.size()!=0)
     87      ? SelectorIdentity().sum(constits_known_pu) : 0.0*jet;
     88    if (constits_unknown.size()==0){
     89      // no need for any form of subtraction!
     90      PseudoJet subtracted_jet = jet;
     91      subtracted_jet.reset_momentum(known_lv);
     92      return subtracted_jet;
     93    }
     94    unknown = jet; // that keeps all info including area
     95    unknown.reset_momentum(SelectorIdentity().sum(constits_unknown));
     96  } else {
     97    known_lv = jet; // ensures correct rap-phi!
     98    known_lv *= 0.0;
     99    known_pu = known_lv;
     100  }
     101
     102  // prepare for the subtraction and compute the 4-vector to be
     103  // subtracted
     104  PseudoJet subtracted_jet = jet;
     105  PseudoJet to_subtract = known_pu + _amount_to_subtract(unknown);
     106
     107  // sanity check for the transverse momentum
     108  if (to_subtract.pt2() < jet.pt2() ) {
     109    // this subtraction should retain the jet's structural
     110    // information
     111    subtracted_jet -= to_subtract;
     112  } else {
     113    // this sets the jet's momentum while maintaining all of the jet's
     114    // structural information
     115    subtracted_jet.reset_momentum(known_lv);
     116    return subtracted_jet;
     117  }
     118
     119  // make sure that in the end the pt is at least the one known to
     120  // come from the leading vertex
     121  if (subtracted_jet.pt2() < known_lv.pt2()){
     122    subtracted_jet.reset_momentum(known_lv);
     123    return subtracted_jet;
     124  }
     125
     126  // sanity check for the mass (if needed)
     127  if ((_safe_mass) && (subtracted_jet.m2() < known_lv.m2())){
     128    // in this case, we keep pt and phi as obtained from the
     129    // subtraction above and take rap and m from the part that comes
     130    // from the leading vertex (or the original jet if nothing comes
     131    // from the leading vertex)
     132    subtracted_jet.reset_momentum(PtYPhiM(subtracted_jet.pt(),
     133                                          known_lv.rap(),
     134                                          subtracted_jet.phi(),
     135                                          known_lv.m()));
     136  }
     137
     138  return subtracted_jet;
     139}
     140
     141//----------------------------------------------------------------------
     142std::string Subtractor::description() const{
     143  if (_bge != 0) {
     144    string desc = "Subtractor that uses the following background estimator to determine rho: "+_bge->description();
     145    if (use_rho_m()) desc += "; including the rho_m correction";
     146    if (safe_mass()) desc += "; including mass safety tests";
     147    if (_sel_known_vertex.worker()){
     148      desc += "; using known vertex selection: "+_sel_known_vertex.description()+" and leading vertex selection: "+_sel_leading_vertex.description();
     149    }
     150    return desc;
     151  } else if (_rho != _invalid_rho) {
     152    ostringstream ostr;
     153    ostr << "Subtractor that uses a fixed value of rho = " << _rho;
     154    return ostr.str();
     155  } else {
     156    return "Uninitialised subtractor";
     157  }
     158}
     159
     160//----------------------------------------------------------------------
     161// compute the 4-vector that should be subtracted from the given
     162// jet
     163PseudoJet Subtractor::_amount_to_subtract(const PseudoJet &jet) const{
     164  // the "transverse momentum" part
    49165  double rho;
    50166  if (_bge != 0) {
     
    56172  }
    57173
    58   PseudoJet subtracted_jet = jet;
    59   PseudoJet area4vect = jet.area_4vector();
    60   // sanity check
    61   if (rho*area4vect.perp() < jet.perp() ) {
    62     // this subtraction should retain the jet's structural
    63     // information
    64     subtracted_jet -= rho*area4vect;
    65   } else {
    66     // this sets the jet's momentum to zero while
    67     // maintaining all of the jet's structural information
    68     subtracted_jet *= 0;
     174  PseudoJet area = jet.area_4vector();
     175  PseudoJet to_subtract = rho*area;
     176
     177  double const rho_m_warning_threshold = 1e-5;
     178
     179  // add an optional contribution from the unknown particles masses
     180  if (_use_rho_m){
     181    assert(_bge != 0); // test done in "set_use_rho_m()"
     182    to_subtract += _bge->rho_m(jet) * PseudoJet(0.0, 0.0, area.pz(), area.E());
     183  } else if (_bge &&
     184             _bge->has_rho_m() &&
     185             _bge->rho_m(jet) > rho_m_warning_threshold * rho) {
     186    _unused_rho_m_warning.warn("Background estimator indicates non-zero rho_m, but use_rho_m()==false in subtractor; consider calling set_use_rho_m(true) to include the rho_m information");
    69187  }
    70   return subtracted_jet;
     188
     189  return to_subtract;
    71190}
    72191
    73 //----------------------------------------------------------------------
    74 std::string Subtractor::description() const{
    75   if (_bge != 0) {
    76     return "Subtractor that uses the following background estimator to determine rho: "+_bge->description();
    77   } else if (_rho != _invalid_rho) {
    78     ostringstream ostr;
    79     ostr << "Subtractor that uses a fixed value of rho = " << _rho;
    80     return ostr.str();
    81   } else {
    82     return "Uninitialised subtractor";
    83   }
    84 }
    85192
    86193FASTJET_END_NAMESPACE
Note: See TracChangeset for help on using the changeset viewer.