Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-03-17 11:18:21

0001 //  2011 Christopher Vermilion
0002 //
0003 //----------------------------------------------------------------------
0004 //  This file is free software; you can redistribute it and/or modify
0005 //  it under the terms of the GNU General Public License as published by
0006 //  the Free Software Foundation; either version 3 of the License, or
0007 //  (at your option) any later version.
0008 //
0009 //  This file is distributed in the hope that it will be useful,
0010 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
0011 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0012 //  GNU General Public License for more details.
0013 //
0014 //  The GNU General Public License is available at
0015 //  http://www.gnu.org/licenses/gpl.html or you can write to the Free Software
0016 //  Foundation, Inc.:
0017 //      59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
0018 //----------------------------------------------------------------------
0019 
0020 #ifndef __HEPTOPTAGGER_WRAPPERV2_HH__
0021 #define __HEPTOPTAGGER_WRAPPERV2_HH__
0022 
0023 #include <fastjet/tools/TopTaggerBase.hh>
0024 #include <fastjet/CompositeJetStructure.hh>
0025 #include "CLHEP/Random/RandomEngine.h"
0026 #include <sstream>
0027 
0028 FASTJET_BEGIN_NAMESPACE
0029 
0030 /// A fastjet::Transformer wrapper for the HEP top tagger.  All of the work
0031 /// is done by the HEPTopTagger class in HEPTopTagger.hh, written by
0032 /// Tilman Plehn, Gavin Salam, Michael Spannowsky, and Michihisa Takeuchi.  The
0033 /// HEP top tagger was described in Phys. Rev. Lett. 104 (2010) 111801
0034 /// [arXiv:0910.5472] and JHEP 1010 (2010) 078 [arXiv:1006.2833].
0035 ///
0036 ///
0037 /// This code is based on JHTopTagger.{hh,cc}, part of the FastJet package,
0038 /// written by Matteo Cacciari, Gavin P. Salam and Gregory Soyez, and released
0039 /// under the GNU General Public License.
0040 ///
0041 /// The HEP top tagger produces information similar to the Johns Hopkins tagger.
0042 ///  Accordingly I simply reuse the JHTopTaggerStructure.
0043 
0044 // Removed legacy comments by CHRISTOPHER SILKWORTH
0045 
0046 class HEPTopTaggerV2Structure;
0047 
0048 class HEPTopTaggerV2 : public TopTaggerBase {
0049 public:
0050   HEPTopTaggerV2(bool DoOptimalR,
0051                  bool DoQjets,
0052                  double minSubjetPt,
0053                  double minCandPt,
0054                  double subjetMass,
0055                  double muCut,
0056                  double filtR,
0057                  int filtN,
0058                  int mode,
0059                  double minCandMass,
0060                  double maxCandMass,
0061                  double massRatioWidth,
0062                  double minM23Cut,
0063                  double minM13Cut,
0064                  double maxM13Cut,
0065                  bool optRrejectMin)
0066       : DoOptimalR_(DoOptimalR),
0067         DoQjets_(DoQjets),
0068         minSubjetPt_(minSubjetPt),
0069         minCandPt_(minCandPt),
0070         subjetMass_(subjetMass),
0071         muCut_(muCut),
0072         filtR_(filtR),
0073         filtN_(filtN),
0074         mode_(mode),
0075         minCandMass_(minCandMass),
0076         maxCandMass_(maxCandMass),
0077         massRatioWidth_(massRatioWidth),
0078         minM23Cut_(minM23Cut),
0079         minM13Cut_(minM13Cut),
0080         maxM13Cut_(maxM13Cut),
0081         optRrejectMin_(optRrejectMin),
0082         engine_(nullptr) {}
0083 
0084   /// returns a textual description of the tagger
0085   std::string description() const override;
0086 
0087   /// runs the tagger on the given jet and
0088   /// returns the tagged PseudoJet if successful, or a PseudoJet==0 otherwise
0089   /// (standard access is through operator()).
0090   ///  \param jet   the PseudoJet to tag
0091   PseudoJet result(const PseudoJet& jet) const override;
0092 
0093   void set_rng(CLHEP::HepRandomEngine* engine) { engine_ = engine; }
0094 
0095   // the type of the associated structure
0096   typedef HEPTopTaggerV2Structure StructureType;
0097 
0098 private:
0099   bool DoOptimalR_;  // Use optimalR mode
0100   bool DoQjets_;     // Use qjet mode
0101 
0102   double minSubjetPt_;  // Minimal pT for subjets [GeV]
0103   double minCandPt_;    // Minimal pT to return a candidate [GeV]
0104 
0105   double subjetMass_;  // Mass above which subjets are further unclustered
0106   double muCut_;       // Mass drop threshold
0107 
0108   double filtR_;  // maximal filtering radius
0109   int filtN_;     // number of filtered subjets to use
0110 
0111   // HEPTopTagger Mode
0112   // 0: do 2d-plane, return candidate with delta m_top minimal
0113   // 1: return candidate with delta m_top minimal IF passes 2d plane
0114   // 2: do 2d-plane, return candidate with max dj_sum
0115   // 3: return candidate with max dj_sum IF passes 2d plane
0116   // 4: return candidate built from leading three subjets after unclustering IF passes 2d plane
0117   // Note: Original HTT was mode==1
0118   int mode_;
0119 
0120   // Top Quark mass window in GeV
0121   double minCandMass_;
0122   double maxCandMass_;
0123 
0124   double massRatioWidth_;  // One sided width of the A-shaped window around m_W/m_top in %
0125   double minM23Cut_;       // minimal value of m23/m123
0126   double minM13Cut_;       // minimal value of atan(m13/m12)
0127   double maxM13Cut_;       // maximal value of atan(m13/m12)
0128 
0129   bool optRrejectMin_;  // set Ropt to zero for candidates that never leave the window around the initial mass
0130                         // otherwise (default) set them to R=0.5
0131 
0132   // Random engine for Q-jet HTT
0133   CLHEP::HepRandomEngine* engine_;
0134 };
0135 
0136 class HEPTopTaggerV2Structure : public CompositeJetStructure, public TopTaggerBaseStructure {
0137 public:
0138   /// ctor with pieces initialisation
0139   HEPTopTaggerV2Structure(const std::vector<PseudoJet>& pieces_in,
0140                           const JetDefinition::Recombiner* recombiner = nullptr)
0141       : CompositeJetStructure(pieces_in, recombiner),
0142         _fj_mass(0.0),
0143         _fj_pt(0.0),
0144         _fj_eta(0.0),
0145         _fj_phi(0.0),
0146         _top_mass(0.0),
0147         _unfiltered_mass(0.0),
0148         _pruned_mass(0.0),
0149         _fRec(-1.),
0150         _mass_ratio_passed(-1),
0151         _ptForRoptCalc(-1),
0152         _tau1Unfiltered(-1.),
0153         _tau2Unfiltered(-1.),
0154         _tau3Unfiltered(-1.),
0155         _tau1Filtered(-1.),
0156         _tau2Filtered(-1.),
0157         _tau3Filtered(-1.),
0158         _qweight(-1.),
0159         _qepsilon(-1.),
0160         _qsigmaM(-1.),
0161         W_rec(recombiner),
0162         rW_() {}
0163 
0164   // Return W subjet
0165   inline PseudoJet const& W() const override {
0166     rW_ = join(_pieces[0], _pieces[1], *W_rec);
0167     return rW_;
0168   }
0169 
0170   // Return leading subjet in W
0171   inline PseudoJet W1() const {
0172     assert(!W().pieces().empty());
0173     return W().pieces()[0];
0174   }
0175 
0176   /// returns the second W subjet
0177   inline PseudoJet W2() const {
0178     assert(W().pieces().size() > 1);
0179     return W().pieces()[1];
0180   }
0181 
0182   /// returns the non-W subjet
0183   /// It will have 1 or 2 pieces depending on whether the tagger has
0184   /// found 3 or 4 pieces
0185   inline const PseudoJet& non_W() const override { return _pieces[2]; }
0186 
0187   /// return the mass of the initial fatjet
0188   inline double fj_mass() const { return _fj_mass; }
0189 
0190   /// return the pt of the initial fatjet
0191   inline double fj_pt() const { return _fj_pt; }
0192 
0193   /// return the eta of the initial fatjet
0194   inline double fj_eta() const { return _fj_eta; }
0195 
0196   /// return the phi of the initial fatjet
0197   inline double fj_phi() const { return _fj_phi; }
0198 
0199   /// returns the candidate mass
0200   inline double top_mass() const { return _top_mass; }
0201 
0202   /// returns the unfiltered mass
0203   inline double unfiltered_mass() const { return _unfiltered_mass; }
0204 
0205   /// returns the pruned mass
0206   inline double pruned_mass() const { return _pruned_mass; }
0207 
0208   /// returns fRec
0209   inline double fRec() const { return _fRec; }
0210 
0211   /// returns if 2d-mass plane cuts were passed
0212   inline double mass_ratio_passed() const { return _mass_ratio_passed; }
0213 
0214   /// returns Ropt
0215   inline double ropt() const { return _ropt; }
0216 
0217   /// returns calculated Ropt
0218   inline double roptCalc() const { return _roptCalc; }
0219 
0220   /// returns the filtered pT for calculating R_opt
0221   inline double ptForRoptCalc() const { return _ptForRoptCalc; }
0222 
0223   // Nsubjettiness and Q-jet variables
0224   inline double Tau1Unfiltered() const { return _tau1Unfiltered; }
0225   inline double Tau2Unfiltered() const { return _tau2Unfiltered; }
0226   inline double Tau3Unfiltered() const { return _tau3Unfiltered; }
0227   inline double Tau1Filtered() const { return _tau1Filtered; }
0228   inline double Tau2Filtered() const { return _tau2Filtered; }
0229   inline double Tau3Filtered() const { return _tau3Filtered; }
0230 
0231   inline double qweight() const { return _qweight; }
0232   inline double qepsilon() const { return _qepsilon; }
0233   inline double qsigmaM() const { return _qsigmaM; }
0234 
0235 protected:
0236   double _fj_mass;
0237   double _fj_pt;
0238   double _fj_eta;
0239   double _fj_phi;
0240 
0241   double _top_mass;
0242   double _unfiltered_mass;
0243   double _pruned_mass;
0244   double _fRec;
0245   int _mass_ratio_passed;
0246   double _ptForRoptCalc;
0247   double _ropt;
0248   double _roptCalc;
0249 
0250   double _tau1Unfiltered;
0251   double _tau2Unfiltered;
0252   double _tau3Unfiltered;
0253   double _tau1Filtered;
0254   double _tau2Filtered;
0255   double _tau3Filtered;
0256   double _qweight;
0257   double _qepsilon;
0258   double _qsigmaM;
0259 
0260   const JetDefinition::Recombiner* W_rec;
0261 
0262   mutable PseudoJet rW_;
0263 
0264   // allow the tagger to set these
0265   friend class HEPTopTaggerV2;
0266 };
0267 
0268 //------------------------------------------------------------------------
0269 // description of the tagger
0270 inline std::string HEPTopTaggerV2::description() const {
0271   std::ostringstream oss;
0272   oss << "HEPTopTaggerV2 with: "
0273       << "minSubjetPt = " << minSubjetPt_ << "minCandPt = " << minCandPt_ << "subjetMass = " << subjetMass_
0274       << "muCut = " << muCut_ << "filtR = " << filtR_ << "filtN = " << filtN_ << "mode = " << mode_
0275       << "minCandMass = " << minCandMass_ << "maxCandMass = " << maxCandMass_ << "massRatioWidth = " << massRatioWidth_
0276       << "minM23Cut = " << minM23Cut_ << "minM13Cut = " << minM13Cut_ << "maxM13Cut = " << maxM13Cut_ << std::endl;
0277   return oss.str();
0278 }
0279 
0280 FASTJET_END_NAMESPACE
0281 
0282 #endif  // __HEPTOPTAGGER_HH__