FastJet 3.0beta1
RestFrameNSubjettinessTagger.cc
00001 //STARTHEADER
00002 // $Id: RestFrameNSubjettinessTagger.cc 2502 2011-08-04 16:50:13Z salam $
00003 //
00004 // Copyright (c) 2005-2011, Matteo Cacciari, Gavin Salam and Gregory Soyez
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/tools/RestFrameNSubjettinessTagger.hh>
00032 #include <fastjet/tools/Boost.hh>
00033 #include <fastjet/ClusterSequence.hh>
00034 #include <sstream>
00035 
00036 using namespace fastjet;
00037 using namespace std;
00038 
00039 //------------------------------------------------------------------------
00040 // RestFrameNSubjettinessTagger class implementation
00041 //------------------------------------------------------------------------
00042 
00043 //------------------------------------------------------------------------
00044 // tagger description
00045 string RestFrameNSubjettinessTagger::description() const{ 
00046   ostringstream oss;
00047   oss << "RestFrameNSubjettiness tagger that performs clustering in the jet rest frame with " 
00048       << _subjet_def.description() 
00049       << ", supplemented with cuts tau_2 < " << _t2cut 
00050       << " and cos(theta_s) < " << _costscut;
00051   return oss.str();
00052 }
00053 
00054 
00055 //------------------------------------------------------------------------
00056 // action on a single jet
00057 // returns the tagged PseudoJet if successful, 0 otherwise
00058 PseudoJet RestFrameNSubjettinessTagger::result(const PseudoJet & jet) const{
00059   // make sure that the jet has constituents
00060   if (!jet.has_constituents())
00061     throw("The jet you try to tag needs to have accessible constituents");
00062    
00063   // get the constituents and boost them into the rest frame of the jet
00064   vector<PseudoJet> rest_input = jet.constituents();
00065   for (unsigned int i=0; i<rest_input.size(); i++)
00066     rest_input[i].unboost(jet);
00067 
00068   ClusterSequence cs_rest(rest_input, _subjet_def);
00069   vector<PseudoJet> subjets = (_use_exclusive)
00070     ? cs_rest.exclusive_jets(2)
00071     : sorted_by_E(cs_rest.inclusive_jets());
00072 
00073   // impose the cuts in the rest-frame
00074   if (subjets.size()<2) return PseudoJet();
00075 
00076   const PseudoJet &j0 = subjets[0];
00077   const PseudoJet &j1 = subjets[1];
00078 
00079   /// impose the cut on cos(theta_s)
00080   double ct0 = (j0.px()*jet.px() + j0.py()*jet.py() + j0.pz()*jet.pz())
00081     /sqrt(j0.modp2()*jet.modp2());
00082   double ct1 = (j1.px()*jet.px() + j1.py()*jet.py() + j1.pz()*jet.pz())
00083     /sqrt(j1.modp2()*jet.modp2());
00084   if ((ct0 > _costscut) || (ct1 > _costscut)) return PseudoJet();
00085   
00086   // ccompute the 2-subjettiness and impose the coresponding cut
00087   double tau2 = 0.0;
00088   for (unsigned int i=0; i<rest_input.size(); i++)
00089     tau2 += min(dot_product(rest_input[i], j0), 
00090                 dot_product(rest_input[i], j1));
00091 
00092   tau2 *= (2.0/jet.m2());
00093 
00094   if (tau2 > _t2cut) return PseudoJet();
00095 
00096   // We have a positive tag, 
00097   //  - boost everything back into the lab frame
00098   //  - record the info in the interface
00099   // Note that in order to point to the correct Clustersequence, the
00100   // subjets must be taken from the boosted one. We extract that
00101   // through the history index of the rest-frame subjets
00102   ClusterSequence * cs_structure = new ClusterSequence();
00103   Boost boost(jet);
00104   cs_structure->transfer_from_sequence(cs_rest, &boost);
00105   PseudoJet subjet_lab1 = cs_structure->jets()[cs_rest.history()[subjets[0].cluster_hist_index()].jetp_index];
00106   PseudoJet subjet_lab2 = cs_structure->jets()[cs_rest.history()[subjets[0].cluster_hist_index()].jetp_index];
00107     
00108   PseudoJet result = join<StructureType>(subjet_lab1,subjet_lab2);
00109   StructureType * s = (StructureType *) result.structure_non_const_ptr();
00110 //  s->_original_jet = jet;
00111   s->_tau2 = tau2;
00112   s->_costhetas = max(ct0, ct1);
00113 
00114   // keep the rest-frame CS alive
00115   cs_structure->delete_self_when_unused();
00116 
00117   return result;
00118 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends