Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-06 08:17:45

0001 #include "FastJetOptions.h"
0002 
0003 #include <phool/phool.h>  // for PHWHERE
0004 
0005 #include <cassert>
0006 #include <iostream>
0007 
0008 /* Need simpler input logic -- it is too clever by half in this first iteration:
0009   float jet_max_eta  = 10; // essentially no cut, unless the user sets it
0010 
0011 
0012 
0013 
0014 */
0015 
0016 FastJetOptions& FastJetOptions::update(std::vector<FastJetOptItem> input)
0017 {
0018   int size = input.size();
0019   int i = 0;
0020   while (i < size)
0021   {
0022     auto& item = input[i];
0023     if (item.is_algo)
0024     {
0025       algo = item.algo;
0026     }
0027     else if (item.is_opt)
0028     {
0029       if (item.opt == JET_R)
0030       {
0031         jet_R = next_val(i, input);
0032       }
0033       else if (item.opt == JET_MIN_PT)
0034       {
0035         use_jet_min_pt = true;
0036         jet_min_pt = next_val(i, input);
0037       }
0038       else if (item.opt == JET_MAX_ETA)
0039       {
0040         use_jet_max_eta = true;
0041         jet_max_eta = next_val(i, input);
0042       }
0043       else if (item.opt == CONSTITUENT_MIN_PT)
0044       {
0045         use_constituent_min_pt = true;
0046         constituent_min_pt = next_val(i, input);
0047       }
0048       else if (item.opt == CONSTITUENT_MIN_E)
0049       {
0050         constituent_min_E = next_val(i, input);
0051       }
0052       else if (item.opt == DO_SOFTDROP)
0053       {
0054         doSoftDrop = true;
0055       }
0056       else if (item.opt == SD_BETA)
0057       {
0058         SD_beta = next_val(i, input);
0059       }
0060       else if (item.opt == SD_ZCUT)
0061       {
0062         SD_zcut = next_val(i, input);
0063       }
0064       else if (item.opt == SD_JET_MIN_PT)
0065       {
0066         SD_jet_min_pt = next_val(i, input);
0067       }
0068       else if (item.opt == CALC_AREA)
0069       {
0070         calc_area = true;
0071       }
0072       else if (item.opt == GHOST_AREA)
0073       {
0074         ghost_area = next_val(i, input);
0075       }
0076       else if (item.opt == GHOST_MAX_RAP)
0077       {
0078         ghost_max_rap = next_val(i, input);
0079       }
0080       else if (item.opt == CALC_RhoMedDens)
0081       {
0082         calc_jetmedbkgdens = true;
0083       }
0084       else if (item.opt == CUT_RhoMedNHardest)
0085       {
0086         nhardestcut_jetmedbkgdens = static_cast<int>(next_val(i, input));
0087       }
0088       else if (item.opt == FJCS_doConstSub)
0089       {
0090         cs_calc_constsub = true;
0091       }
0092       else if (item.opt == FJCS_max_eta)
0093       {
0094         cs_max_eta = next_val(i, input);
0095       }
0096       else if (item.opt == FJCS_GridMedBkgEst_Size)
0097       {
0098         cs_gridmedestsize = next_val(i, input);
0099       }
0100       else if (item.opt == FJCS_max_dist)
0101       {
0102         cs_max_dist = next_val(i, input);
0103       }
0104       else if (item.opt == FJCS_alpha)
0105       {
0106         cs_alpha = next_val(i, input);
0107       }
0108       else if (item.opt == FJCS_max_pt)
0109       {
0110         cs_max_pt = next_val(i, input);
0111       }
0112       else if (item.opt == FJCS_ghost_area)
0113       {
0114         cs_ghost_area = next_val(i, input);
0115       }
0116       else if (item.opt == VERBOSITY)
0117       {
0118         verbosity = static_cast<int>(next_val(i, input));
0119       }
0120       else if (item.opt == DONT_SAVE_JET_COMPONENTS)
0121       {
0122         save_jet_components = false;
0123       }
0124       else if (item.opt == SAVE_JET_COMPONENTS)
0125       {
0126         save_jet_components = true;
0127       }
0128     }
0129     ++i;
0130   }
0131   return *this;
0132 }
0133 
0134 float FastJetOptions::next_val(unsigned int i, std::vector<FastJetOptItem>& inputs)
0135 {
0136   if (inputs.size() > (i + 1) && inputs[i + 1].is_val)
0137   {
0138     ++i;
0139     return inputs[i].val;
0140   }
0141 
0142   std::cout << PHWHERE << std::endl;
0143   std::cout << "Error in FastJetOptions, option required to have a value which isn't provided." << std::endl;
0144   assert(false);
0145 }
0146 
0147 void FastJetOptions::print(std::ostream& os)
0148 {
0149   initialize();
0150 
0151   os << "FastJetOptions (input options for fastjet in FastJetAlgp)" << std::endl;
0152   os << " FastJet input options: " << std::endl
0153      << " - R: " << jet_R << std::endl;
0154   // if you insist on doing it this way - it is in one line
0155     os << " - algorithm: ";
0156     switch(algo)
0157     {
0158     case Jet::ALGO::ANTIKT:
0159       os << "ANTIKT";
0160     break;
0161     case Jet::ALGO::KT:
0162       os << "KT";
0163       break;
0164     case Jet::ALGO::CAMBRIDGE:
0165       os << "CAMBRIDGE";
0166       break;
0167     default:
0168       os << "none";
0169       break;
0170     }
0171     os << std::endl
0172      << " - save jet components ids: " << (save_jet_components ? "yes" : "no") << std::endl
0173      << " - verbosity: " << verbosity << std::endl;
0174   if (use_constituent_min_pt)
0175   {
0176     os << " - minimum constituent pT cut: " << constituent_min_pt << std::endl;
0177   }
0178   if (use_jet_min_pt)
0179   {
0180     os << " - minimum jet pt: " << jet_min_pt << std::endl;
0181   }
0182   if (use_jet_max_eta)
0183   {
0184     os << " - maximum |eta_jet|: " << jet_max_eta << std::endl;
0185   }
0186   if (doSoftDrop)
0187   {
0188     os << " - do softdrop with Beta(" << SD_beta << ") and Zcut(" << SD_zcut
0189        << ") for jets w/pT>" << SD_jet_min_pt << std::endl;
0190   }
0191   if (calc_area)
0192   {
0193     os << " - calculate jet areas (using KT jets) with ghost_area("
0194        << ghost_area << ") and ghost_max_rap(" << ghost_max_rap << ")" << std::endl;
0195   }
0196   if (calc_jetmedbkgdens)
0197   {
0198     os << " - calculate jet median background estimator density with cutting "
0199        << nhardestcut_jetmedbkgdens << " hardest jets within |eta|<" << etahardestcut_jetmedbkgdens << std::endl;
0200   }
0201 
0202   if (cs_calc_constsub)
0203   {
0204     os << " - calculate jet background constituent subtractor " << std::endl;
0205   }
0206 }
0207 
0208 void FastJetOptions::initialize()
0209 {
0210   // set some required derived options when first running FastJetAlgo
0211   if (calc_jetmedbkgdens)
0212   {
0213     calc_area = true;
0214   }
0215 
0216   if (calc_area && ghost_max_rap == 0)
0217   {
0218     if (use_jet_max_eta)
0219     {
0220       ghost_max_rap = (jet_max_eta + jet_R);
0221     }
0222     else
0223     {
0224       ghost_max_rap = 5.;
0225     }
0226   }
0227 
0228   if (calc_jetmedbkgdens)
0229   {
0230     if (nhardestcut_jetmedbkgdens > 0 && etahardestcut_jetmedbkgdens == 0)
0231     {
0232       if (use_jet_max_eta)
0233       {
0234         etahardestcut_jetmedbkgdens = jet_max_eta;
0235       }
0236       else
0237       {
0238         etahardestcut_jetmedbkgdens = ghost_max_rap;
0239       }
0240     }
0241   }
0242 
0243   use_jet_selection = (use_jet_max_eta || use_jet_min_pt);
0244 }