tom is hosted by Hepforge, IPPP Durham
Template Overlap Method  0.3.0
A Template Matching Tool for Jet Substructure
TemplateTagger.hh
1 // Template Tagger Package
2 // Version 0.3.0 (December 1, 2012)
3 // Questions/Comments? jose.juknevich@weizmann.ac.il
4 
5 // Copyright (c) 2011-12, Jose Juknevich, Mihailo Backovic, and Raz Alon.
6 //
7 //----------------------------------------------------------------------
8 // This file is part of the Template Tagger package ("Template Overlap").
9 //
10 // Template Tagger is free software; you can redistribute it and/or modify
11 // it under the terms of the GNU General Public License as published by
12 // the Free Software Foundation; either version 3 of the License, or
13 // (at your option) any later version.
14 //----------------------------------------------------------------------
15 
16 
17 #ifndef __TEMPLATE_TAGGER_HH__
18 #define __TEMPLATE_TAGGER_HH__
19 
20 #include "matching.hh"
21 
22 #include "fastjet/FunctionOfPseudoJet.hh"
23 #include <fastjet/Selector.hh>
24 #include <fastjet/CompositeJetStructure.hh> // to derive the FilterStructure from CompositeJetStructure
25 #include <fastjet/tools/Transformer.hh> // to derive Filter from Transformer
26 
27 
28 
29 #include <string>
30 #include <climits>
31 #include <utility>
32 
33 
34 using namespace TemplateOverlap;
35 
36 
37 
38 FASTJET_BEGIN_NAMESPACE // defined in fastjet/internal/base.hh
39 
40 
41 class TemplateTagger;
43 
47 
48 class Noverlap : public FunctionOfPseudoJet<templ_t> {
49 public:
50 
51  Noverlap(int N , double sigma, double R0, const string & templateFile)
52  : _N(N), _templateFinder(templateFile, Settings(R0, sigma)), _R0(R0), _sigma(sigma)
53 {}
54 
56  templ_t result(const PseudoJet& jet) const {return _templateFinder.getOv(jet);}
57 
58 private:
59 
60  int _N;
61  mutable TemplateOverlap::MatchingMethod _templateFinder;
62  double _R0, _sigma;
63 
64 };
65 
66 
67 class TemplateTagger : public Transformer {
68 public:
70 
71  TemplateTagger(FunctionOfPseudoJet<templ_t> *Ov_func, Selector selector, const double R1, const double ovcut ) :
72  _Ovfunc(Ov_func), _selector(selector), _R1(R1), _ovcut(ovcut){};
73 
75  virtual std::string description() const;
76 
80  virtual PseudoJet result(const PseudoJet & jet) const;
81 
84 
85 protected:
86 
87  FunctionOfPseudoJet<templ_t> *_Ovfunc;
88  mutable Selector _selector;
89  double _R1;
90  double _ovcut;
91 
92 };
93 
94 class TemplateTaggerStructure : public CompositeJetStructure{
95 public:
97  TemplateTaggerStructure(const std::vector<PseudoJet> & pieces_in) :
98  CompositeJetStructure(pieces_in), _ov(0.0){}
99 
101  inline double ov() const{return _ov;}
102  inline std::vector<PseudoJet> maxTempl() const {return _peak_template;}
103 
104  virtual std::string description() const { return "Template Tagger"; }
105 
106 
107 protected:
108  double _ov;
109  std::vector<PseudoJet> _peak_template;
110 
111  // allow the tagger to set these
112  friend class TemplateTagger;
113 };
114 
115 //----------------------------------------------------------------------
116 // TemplateTagger class implementation
117 //----------------------------------------------------------------------
118 
119 // class description
121  ostringstream ostr;
122  ostr << "Filter with subjet_def = ";
123  if (_Ovfunc)
124  ostr << "Template Tagger with cone";
125  ostr<< ", selection " << _selector.description();
126 
127  return ostr.str();
128 }
129 
130 
131 //----------------------------------------------------------------------
132 
133 // return a vector of subjets, which are the ones that would be kept
134 // by the filtering
135 PseudoJet TemplateTagger::result(const PseudoJet &jet) const {
136 
137  templ_t my_result = (*_Ovfunc)(jet);
138  if (my_result.first < _ovcut || ! _selector.pass(jet) ) return PseudoJet();
139 
140  std::vector<fastjet::PseudoJet> particles = jet.constituents();
141  fastjet::Selector sel = fastjet::SelectorCircle(_R1);
142  std::vector<fastjet::PseudoJet> subjets;
143  for (unsigned int i=0; i< my_result.second.size(); ++i){
144  sel.set_reference(my_result.second[i]);
145  fastjet::PseudoJet subjet = fastjet::join(sel(particles));
146  subjets.push_back(subjet);
147  }
148  PseudoJet result = join<StructureType>(subjets);
149  StructureType * s = (StructureType *) result.structure_non_const_ptr();
150  s->_ov = my_result.first;
151  s->_peak_template = my_result.second;
152  return result;
153 }
154 
155 
156 
157 
158 
159 FASTJET_END_NAMESPACE // defined in fastjet/internal/base.hh
160 
161 #endif // __TEMPLATE_TAGGER_HH__