Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
FastJetOptions.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file FastJetOptions.cc
1 #include "FastJetOptions.h"
2 
3 #include <phool/phool.h> // for PHWHERE
4 
5 #include <cassert>
6 #include <iostream>
7 
8 /* Need simpler input logic -- it is too clever by half in this first iteration:
9  float jet_max_eta = 10; // essentially no cut, unless the user sets it
10 
11 
12 
13 
14 */
15 
16 FastJetOptions& FastJetOptions::update(std::vector<FastJetOptItem> input)
17 {
18  int size = input.size();
19  int i = 0;
20  while (i < size)
21  {
22  auto& item = input[i];
23  if (item.is_algo)
24  {
25  algo = item.algo;
26  }
27  else if (item.is_opt)
28  {
29  if (item.opt == JET_R)
30  {
31  jet_R = next_val(i, input);
32  }
33  else if (item.opt == JET_MIN_PT)
34  {
35  use_jet_min_pt = true;
36  jet_min_pt = next_val(i, input);
37  }
38  else if (item.opt == JET_MAX_ETA)
39  {
40  use_jet_max_eta = true;
41  jet_max_eta = next_val(i, input);
42  }
43  else if (item.opt == CONSTITUENT_MIN_PT)
44  {
46  constituent_min_pt = next_val(i, input);
47  }
48  else if (item.opt == DO_SOFTDROP)
49  {
50  doSoftDrop = true;
51  }
52  else if (item.opt == SD_BETA)
53  {
54  SD_beta = next_val(i, input);
55  }
56  else if (item.opt == SD_ZCUT)
57  {
58  SD_zcut = next_val(i, input);
59  }
60  else if (item.opt == SD_JET_MIN_PT)
61  {
62  SD_jet_min_pt = next_val(i, input);
63  }
64  else if (item.opt == CALC_AREA)
65  {
66  calc_area = true;
67  }
68  else if (item.opt == GHOST_AREA)
69  {
70  ghost_area = next_val(i, input);
71  }
72  else if (item.opt == GHOST_MAX_RAP)
73  {
74  ghost_max_rap = next_val(i, input);
75  }
76  else if (item.opt == CALC_RhoMedDens)
77  {
78  calc_jetmedbkgdens = true;
79  }
80  else if (item.opt == CUT_RhoMedNHardest)
81  {
82  nhardestcut_jetmedbkgdens = static_cast<int>(next_val(i, input));
83  }
84  else if (item.opt == FJCS_doConstSub)
85  {
86  cs_calc_constsub = true;
87  }
88  else if (item.opt == FJCS_max_eta)
89  {
90  cs_max_eta = static_cast<float>(next_val(i, input));
91  }
92  else if (item.opt == FJCS_GridMedBkgEst_Size)
93  {
94  cs_gridmedestsize = static_cast<float>(next_val(i, input));
95  }
96  else if (item.opt == FJCS_max_dist)
97  {
98  cs_max_dist = static_cast<float>(next_val(i, input));
99  }
100  else if (item.opt == FJCS_alpha)
101  {
102  cs_alpha = static_cast<float>(next_val(i, input));
103  }
104  else if (item.opt == FJCS_max_pt)
105  {
106  cs_max_pt = static_cast<float>(next_val(i, input));
107  }
108  else if (item.opt == FJCS_ghost_area)
109  {
110  cs_ghost_area = static_cast<float>(next_val(i, input));
111  }
112  else if (item.opt == VERBOSITY)
113  {
114  verbosity = static_cast<int>(next_val(i, input));
115  }
116  else if (item.opt == DONT_SAVE_JET_COMPONENTS)
117  {
118  save_jet_components = false;
119  }
120  else if (item.opt == SAVE_JET_COMPONENTS)
121  {
122  save_jet_components = true;
123  }
124  }
125  ++i;
126  }
127  return *this;
128 }
129 
130 float FastJetOptions::next_val(int& i, std::vector<FastJetOptItem>& inputs)
131 {
132  if (inputs.size() > static_cast<size_t>(i + 1) && inputs[i + 1].is_val)
133  {
134  ++i;
135  return inputs[i].val;
136  }
137  else
138  {
139  std::cout << PHWHERE << std::endl;
140  std::cout << "Error in FastJetOptions, option required to have a value which isn't provided." << std::endl;
141  assert(false);
142  }
143 }
144 
145 void FastJetOptions::print(std::ostream& os)
146 {
147  initialize();
148 
149  os << "FastJetOptions (input options for fastjet in FastJetAlgp)" << std::endl;
150  os << " FastJet input options: " << std::endl
151  << " - R: " << jet_R << std::endl
152  << " - algorithm: " << (algo == Jet::ALGO::ANTIKT ? "ANTIKT" : algo == Jet::ALGO::KT ? "KT"
153  : algo == Jet::ALGO::CAMBRIDGE ? "CAMBRIDGE"
154  : "none")
155  << std::endl
156  << " - save jet components ids: " << (save_jet_components ? "yes" : "no") << std::endl
157  << " - verbosity: " << verbosity << std::endl;
159  {
160  os << " - minimum constituent pT cut: " << constituent_min_pt << std::endl;
161  }
162  if (use_jet_min_pt) {
163  os << " - minimum jet pt: " << jet_min_pt << std::endl;
164  }
165  if (use_jet_max_eta) {
166  os << " - maximum |eta_jet|: " << jet_max_eta << std::endl;
167  }
168  if (doSoftDrop)
169  {
170  os << " - do softdrop with Beta(" << SD_beta << ") and Zcut(" << SD_zcut
171  << ") for jets w/pT>" << SD_jet_min_pt << std::endl;
172  }
173  if (calc_area)
174  {
175  os << " - calculate jet areas (using KT jets) with ghost_area("
176  << ghost_area << ") and ghost_max_rap(" << ghost_max_rap << ")" << std::endl;
177  }
178  if (calc_jetmedbkgdens)
179  {
180  os << " - calculate jet median background estimator density with cutting "
181  << nhardestcut_jetmedbkgdens << " hardest jets within |eta|<" << etahardestcut_jetmedbkgdens << std::endl;
182  }
183 
184  if (cs_calc_constsub) {
185  os << " - calculate jet background constituent subtractor " << std::endl;
186  }
187 }
188 
190 {
191  // set some required derived options when first running FastJetAlgo
192  if (calc_jetmedbkgdens) {
193  calc_area = true;
194  }
195 
196  if (calc_area && ghost_max_rap == 0) {
198  else ghost_max_rap = 5.;
199  }
200 
201  if (calc_jetmedbkgdens) {
205  }
206  }
207 
209 }