CMS 3D CMS Logo

CMSBoostedTauSeedingAlgorithm.cc
Go to the documentation of this file.
1 // CMSBoostedTauSeedingAlgorithm Package
2 //
3 //----------------------------------------------------------------------
4 // This file is part of FastJet contrib.
5 //
6 // It is free software; you can redistribute it and/or modify it under
7 // the terms of the GNU General Public License as published by the
8 // Free Software Foundation; either version 2 of the License, or (at
9 // your option) any later version.
10 //
11 // It is distributed in the hope that it will be useful, but WITHOUT
12 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 // or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
14 // License for more details.
15 //
16 // You should have received a copy of the GNU General Public License
17 // along with this code. If not, see <http://www.gnu.org/licenses/>.
18 
19 //CG: From CMSSW 8_0_X cut on eta subjets <3. Anyways taus are cut at 2.3
20 
21 //----------------------------------------------------------------------
22 
24 
25 FASTJET_BEGIN_NAMESPACE // defined in fastjet/internal/base.hh
26 
27  namespace contrib {
29  // constructor
31  double iminMassDrop,
32  double imaxMassDrop,
33  double iminY,
34  double imaxY,
35  double iminDeltaR,
36  double imaxDeltaR,
37  int maxDepth,
38  int verbosity)
39  : ptMin_(iminPt),
40  muMin_(iminMassDrop),
41  muMax_(imaxMassDrop),
42  yMin_(iminY),
43  yMax_(imaxY),
44  dRMin_(iminDeltaR),
45  dRMax_(imaxDeltaR),
46  maxDepth_(maxDepth),
47  verbosity_(verbosity) {}
48 
50  // description
52  std::ostringstream oss;
53  oss << "CMSBoostedTauSeedingAlgorithm algorithm";
54  return oss.str();
55  }
56 
59  const fastjet::PseudoJet& jet, int depth, int maxDepth, const std::string& depth_and_idx_string) const {
60  if (maxDepth != -1 && depth > maxDepth)
61  return;
62  fastjet::PseudoJet subjet1, subjet2;
63  bool hasSubjets = jet.has_parents(subjet1, subjet2);
64  if (!hasSubjets)
65  return;
66  std::string depth_and_idx_string_subjet1 = depth_and_idx_string;
67  if (depth_and_idx_string_subjet1.length() > 0)
68  depth_and_idx_string_subjet1.append(".");
69  depth_and_idx_string_subjet1.append("0");
70  for (int iSpace = 0; iSpace < depth; ++iSpace) {
71  std::cout << " ";
72  }
73  std::cout << " jetConstituent #" << depth_and_idx_string_subjet1 << " (depth = " << depth
74  << "): Pt = " << subjet1.pt() << ","
75  << " eta = " << subjet1.eta() << ", phi = " << subjet1.phi() << ", mass = " << subjet1.m()
76  << " (constituents = " << subjet1.constituents().size() << ")" << std::endl;
77  dumpSubJetStructure(subjet1, depth + 1, maxDepth, depth_and_idx_string_subjet1);
78  std::string depth_and_idx_string_subjet2 = depth_and_idx_string;
79  if (depth_and_idx_string_subjet2.length() > 0)
80  depth_and_idx_string_subjet2.append(".");
81  depth_and_idx_string_subjet2.append("1");
82  for (int iSpace = 0; iSpace < depth; ++iSpace) {
83  std::cout << " ";
84  }
85  std::cout << " jetConstituent #" << depth_and_idx_string_subjet2 << " (depth = " << depth
86  << "): Pt = " << subjet2.pt() << ","
87  << " eta = " << subjet2.eta() << ", phi = " << subjet2.phi() << ", mass = " << subjet2.m()
88  << " (constituents = " << subjet2.constituents().size() << ")" << std::endl;
89  dumpSubJetStructure(subjet2, depth + 1, maxDepth, depth_and_idx_string_subjet2);
90  for (int iSpace = 0; iSpace < depth; ++iSpace) {
91  std::cout << " ";
92  }
93  double dR = subjet1.delta_R(subjet2);
94  std::cout << " (mass-drop @ " << depth_and_idx_string << " = " << std::max(subjet1.m(), subjet2.m()) / jet.m()
95  << ", dR = " << dR << ")" << std::endl;
96  }
97 
98  std::pair<PseudoJet, PseudoJet> CMSBoostedTauSeedingAlgorithm::findSubjets(
99  const PseudoJet& jet, int depth, bool& subjetsFound) const {
100  const float etaMax_ = 3.0; // cut on eta subjets <3. Anyway taus are cut at 2.3
101  if (verbosity_ >= 2) {
102  std::cout << "<CMSBoostedTauSeedingAlgorithm::findSubjets>:" << std::endl;
103  std::cout << " jet: Pt = " << jet.pt() << ", eta = " << jet.eta() << ", phi = " << jet.phi()
104  << ", mass = " << jet.m() << std::endl;
105  }
106 
107  PseudoJet subjet1, subjet2;
108  bool hasSubjets = jet.has_parents(subjet1, subjet2);
109  if (hasSubjets && (maxDepth_ == -1 || depth <= maxDepth_)) {
110  // make subjet1 the more massive jet
111  if (subjet1.m2() < subjet2.m2()) {
112  std::swap(subjet1, subjet2);
113  }
114  double dR = subjet1.delta_R(subjet2);
115  double kT = subjet1.kt_distance(subjet2);
116  double mu = (jet.m() > 0.) ? sqrt(std::max(subjet1.m2(), subjet2.m2()) / jet.m2()) : -1.;
117  // check if subjets pass selection required for seeding boosted tau reconstruction
118  if (subjet1.pt() > ptMin_ && fabs(subjet1.eta()) < etaMax_ && subjet2.pt() > ptMin_ &&
119  fabs(subjet2.eta()) < etaMax_ && dR > dRMin_ && dR < dRMax_ && mu > muMin_ && mu < muMax_ &&
120  kT < (yMax_ * jet.m2()) && kT > (yMin_ * jet.m2())) {
121  subjetsFound = true;
122  return std::make_pair(subjet1, subjet2);
123  } else if (subjet1.pt() > ptMin_) {
124  return findSubjets(subjet1, depth + 1, subjetsFound);
125  } else if (subjet2.pt() > ptMin_) {
126  return findSubjets(subjet2, depth + 1, subjetsFound);
127  }
128  }
129  subjetsFound = false;
130  PseudoJet dummy_subjet1, dummy_subjet2;
131  return std::make_pair(dummy_subjet1, dummy_subjet2);
132  }
133 
134  PseudoJet CMSBoostedTauSeedingAlgorithm::result(const PseudoJet& jet) const {
135  if (verbosity_ >= 1) {
136  std::cout << "<CMSBoostedTauSeedingAlgorithm::findSubjets>:" << std::endl;
137  std::cout << " jet: Pt = " << jet.pt() << ", eta = " << jet.eta() << ", phi = " << jet.phi()
138  << ", mass = " << jet.m() << std::endl;
139  }
140 
141  if (verbosity_ >= 2) {
143  }
144 
145  bool subjetsFound = false;
146  std::pair<PseudoJet, PseudoJet> subjets = findSubjets(jet, 0, subjetsFound);
147  if (subjetsFound) {
148  // fill structure for returning result
149  PseudoJet subjet1 = subjets.first;
150  PseudoJet subjet2 = subjets.second;
151  if (verbosity_ >= 1) {
152  std::cout << "before recombination:" << std::endl;
153  std::cout << " subjet #1: Pt = " << subjet1.pt() << ", eta = " << subjet1.eta() << ", phi = " << subjet1.phi()
154  << ", mass = " << subjet1.m() << std::endl;
155  std::cout << " subjet #2: Pt = " << subjet2.pt() << ", eta = " << subjet2.eta() << ", phi = " << subjet2.phi()
156  << ", mass = " << subjet2.m() << std::endl;
157  }
158 
159  const JetDefinition::Recombiner* rec = jet.associated_cluster_sequence()->jet_def().recombiner();
160  PseudoJet result_local = join(subjet1, subjet2, *rec);
161  if (verbosity_ >= 1) {
162  std::cout << "after recombination:" << std::endl;
163  std::vector<fastjet::PseudoJet> subjets = result_local.pieces();
164  int idx_subjet = 0;
165  for (std::vector<fastjet::PseudoJet>::const_iterator subjet = subjets.begin(); subjet != subjets.end();
166  ++subjet) {
167  std::cout << " subjet #" << idx_subjet << ": Pt = " << subjet->pt() << ", eta = " << subjet->eta()
168  << ", phi = " << subjet->phi() << ", mass = " << subjet->m()
169  << " (#constituents = " << subjet->constituents().size() << ")" << std::endl;
170  std::vector<fastjet::PseudoJet> constituents = subjet->constituents();
171  int idx_constituent = 0;
172  for (std::vector<fastjet::PseudoJet>::const_iterator constituent = constituents.begin();
173  constituent != constituents.end();
174  ++constituent) {
175  if (constituent->pt() < 1.e-3)
176  continue; // CV: skip ghosts
177  std::cout << " constituent #" << idx_constituent << ": Pt = " << constituent->pt()
178  << ", eta = " << constituent->eta() << ", phi = " << constituent->phi() << ","
179  << " mass = " << constituent->m() << std::endl;
180  ++idx_constituent;
181  }
182  ++idx_subjet;
183  }
184  }
185 
187  //s->_original_jet = jet;
188  s->_mu = (jet.m2() > 0.) ? sqrt(std::max(subjet1.m2(), subjet2.m2()) / jet.m2()) : 0.;
189  s->_y = (jet.m2() > 0.) ? subjet1.kt_distance(subjet2) / jet.m2() : 0.;
190  s->_dR = subjet1.delta_R(subjet2);
191  s->_pt = subjet2.pt();
192 
193  result_local.set_structure_shared_ptr(SharedPtr<PseudoJetStructureBase>(s));
194 
195  return result_local;
196  } else {
197  // no subjets for seeding boosted tau reconstruction found, return an empty PseudoJet
198  if (verbosity_ >= 1) {
199  std::cout << "No subjets found." << std::endl;
200  }
201  return PseudoJet();
202  }
203  }
204 
205 } // namespace contrib
206 
207 FASTJET_END_NAMESPACE
ctppsCommonDQMSource_cfi.verbosity
verbosity
Definition: ctppsCommonDQMSource_cfi.py:14
contrib::CMSBoostedTauSeedingAlgorithm::muMin_
double muMin_
the min value of the mass-drop parameter
Definition: CMSBoostedTauSeedingAlgorithm.h:85
contrib::CMSBoostedTauSeedingAlgorithm::muMax_
double muMax_
the max value of the mass-drop parameter
Definition: CMSBoostedTauSeedingAlgorithm.h:86
amptDefaultParameters_cff.mu
mu
Definition: amptDefaultParameters_cff.py:16
contrib::CMSBoostedTauSeedingAlgorithm::CMSBoostedTauSeedingAlgorithm
CMSBoostedTauSeedingAlgorithm(double ptMin, double muMin, double muMax, double yMin, double yMax, double dRMin, double dRMax, int maxDepth, int verbosity=0)
Definition: CMSBoostedTauSeedingAlgorithm.cc:30
gather_cfg.cout
cout
Definition: gather_cfg.py:144
join
static std::string join(char **cmd)
Definition: RemoteFile.cc:17
contrib::CMSBoostedTauSeedingAlgorithm::ptMin_
double ptMin_
minimum sub-jet pt
Definition: CMSBoostedTauSeedingAlgorithm.h:84
contrib::CMSBoostedTauSeedingAlgorithm::yMax_
double yMax_
the max value of the asymmetry parameter
Definition: CMSBoostedTauSeedingAlgorithm.h:88
contrib::CMSBoostedTauSeedingAlgorithm::verbosity_
int verbosity_
flag to enable/disable debug output
Definition: CMSBoostedTauSeedingAlgorithm.h:93
HLT_FULL_cff.maxDepth
maxDepth
Definition: HLT_FULL_cff.py:8665
alignCSCRings.s
s
Definition: alignCSCRings.py:92
contrib
Definition: CMSBoostedTauSeedingAlgorithm.h:45
std::swap
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
Definition: DataFrameContainer.h:209
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
contrib::CMSBoostedTauSeedingAlgorithm::dRMin_
double dRMin_
the min value of the dR parameter
Definition: CMSBoostedTauSeedingAlgorithm.h:89
LEDCalibrationChannels.depth
depth
Definition: LEDCalibrationChannels.py:65
SiStripPI::max
Definition: SiStripPayloadInspectorHelper.h:169
contrib::CMSBoostedTauSeedingAlgorithm::dumpSubJetStructure
void dumpSubJetStructure(const fastjet::PseudoJet &jet, int depth, int maxDepth, const std::string &depth_and_idx_string) const
Definition: CMSBoostedTauSeedingAlgorithm.cc:58
contrib::CMSBoostedTauSeedingAlgorithmStructure
Definition: CMSBoostedTauSeedingAlgorithm.h:104
contrib::CMSBoostedTauSeedingAlgorithm::findSubjets
std::pair< PseudoJet, PseudoJet > findSubjets(const PseudoJet &jet, int depth, bool &subjetsFound) const
Definition: CMSBoostedTauSeedingAlgorithm.cc:98
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
contrib::CMSBoostedTauSeedingAlgorithm::result
PseudoJet result(const PseudoJet &jet) const override
Definition: CMSBoostedTauSeedingAlgorithm.cc:134
metsig::jet
Definition: SignAlgoResolutions.h:47
HGC3DClusterGenMatchSelector_cfi.dR
dR
Definition: HGC3DClusterGenMatchSelector_cfi.py:7
contrib::CMSBoostedTauSeedingAlgorithm::maxDepth_
int maxDepth_
the max depth for descending into clustering sequence
Definition: CMSBoostedTauSeedingAlgorithm.h:91
contrib::CMSBoostedTauSeedingAlgorithm::yMin_
double yMin_
the min value of the asymmetry parameter
Definition: CMSBoostedTauSeedingAlgorithm.h:87
CMSBoostedTauSeedingAlgorithm.h
contrib::CMSBoostedTauSeedingAlgorithm::description
std::string description() const override
Definition: CMSBoostedTauSeedingAlgorithm.cc:51