File: RestFrameNSubjettinessTagger.cc

package info (click to toggle)
fastjet 3.0.6%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, stretch
  • size: 9,468 kB
  • ctags: 3,766
  • sloc: cpp: 21,498; sh: 10,546; fortran: 673; makefile: 518; ansic: 131
file content (120 lines) | stat: -rw-r--r-- 4,728 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
//STARTHEADER
// $Id: RestFrameNSubjettinessTagger.cc 2689 2011-11-14 14:51:06Z soyez $
//
// Copyright (c) 2005-2011, Matteo Cacciari, Gavin P. Salam and Gregory Soyez
//
//----------------------------------------------------------------------
// This file is part of FastJet.
//
//  FastJet is free software; you can redistribute it and/or modify
//  it under the terms of the GNU General Public License as published by
//  the Free Software Foundation; either version 2 of the License, or
//  (at your option) any later version.
//
//  The algorithms that underlie FastJet have required considerable
//  development and are described in hep-ph/0512210. If you use
//  FastJet as part of work towards a scientific publication, please
//  include a citation to the FastJet paper.
//
//  FastJet is distributed in the hope that it will be useful,
//  but WITHOUT ANY WARRANTY; without even the implied warranty of
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//  GNU General Public License for more details.
//
//  You should have received a copy of the GNU General Public License
//  along with FastJet. If not, see <http://www.gnu.org/licenses/>.
//----------------------------------------------------------------------
//ENDHEADER

#include <fastjet/tools/RestFrameNSubjettinessTagger.hh>
#include <fastjet/tools/Boost.hh>
#include <fastjet/ClusterSequence.hh>
#include <sstream>

using namespace std;

FASTJET_BEGIN_NAMESPACE      // defined in fastjet/internal/base.hh

//------------------------------------------------------------------------
// RestFrameNSubjettinessTagger class implementation
//------------------------------------------------------------------------

//------------------------------------------------------------------------
// tagger description
string RestFrameNSubjettinessTagger::description() const{ 
  ostringstream oss;
  oss << "RestFrameNSubjettiness tagger that performs clustering in the jet rest frame with " 
      << _subjet_def.description() 
      << ", supplemented with cuts tau_2 < " << _t2cut 
      << " and cos(theta_s) < " << _costscut;
  return oss.str();
}


//------------------------------------------------------------------------
// action on a single jet
// returns the tagged PseudoJet if successful, 0 otherwise
PseudoJet RestFrameNSubjettinessTagger::result(const PseudoJet & jet) const{
  // make sure that the jet has constituents
  if (!jet.has_constituents())
    throw("The jet you try to tag needs to have accessible constituents");
   
  // get the constituents and boost them into the rest frame of the jet
  vector<PseudoJet> rest_input = jet.constituents();
  for (unsigned int i=0; i<rest_input.size(); i++)
    rest_input[i].unboost(jet);

  ClusterSequence cs_rest(rest_input, _subjet_def);
  vector<PseudoJet> subjets = (_use_exclusive)
    ? cs_rest.exclusive_jets(2)
    : sorted_by_E(cs_rest.inclusive_jets());

  // impose the cuts in the rest-frame
  if (subjets.size()<2) return PseudoJet();

  const PseudoJet &j0 = subjets[0];
  const PseudoJet &j1 = subjets[1];

  /// impose the cut on cos(theta_s)
  double ct0 = (j0.px()*jet.px() + j0.py()*jet.py() + j0.pz()*jet.pz())
    /sqrt(j0.modp2()*jet.modp2());
  double ct1 = (j1.px()*jet.px() + j1.py()*jet.py() + j1.pz()*jet.pz())
    /sqrt(j1.modp2()*jet.modp2());
  if ((ct0 > _costscut) || (ct1 > _costscut)) return PseudoJet();
  
  // ccompute the 2-subjettiness and impose the coresponding cut
  double tau2 = 0.0;
  for (unsigned int i=0; i<rest_input.size(); i++)
    tau2 += min(dot_product(rest_input[i], j0), 
                dot_product(rest_input[i], j1));

  tau2 *= (2.0/jet.m2());

  if (tau2 > _t2cut) return PseudoJet();

  // We have a positive tag, 
  //  - boost everything back into the lab frame
  //  - record the info in the interface
  // Note that in order to point to the correct Clustersequence, the
  // subjets must be taken from the boosted one. We extract that
  // through the history index of the rest-frame subjets
  ClusterSequence * cs_structure = new ClusterSequence();
  Boost boost(jet);
  cs_structure->transfer_from_sequence(cs_rest, &boost);
  PseudoJet subjet_lab1 = cs_structure->jets()[cs_rest.history()[subjets[0].cluster_hist_index()].jetp_index];
  PseudoJet subjet_lab2 = cs_structure->jets()[cs_rest.history()[subjets[0].cluster_hist_index()].jetp_index];
    
  PseudoJet result_local = join<StructureType>(subjet_lab1,subjet_lab2);
  StructureType * s = (StructureType *) result_local.structure_non_const_ptr();
//  s->_original_jet = jet;
  s->_tau2 = tau2;
  s->_costhetas = max(ct0, ct1);

  // keep the rest-frame CS alive
  cs_structure->delete_self_when_unused();

  return result_local;
}


FASTJET_END_NAMESPACE