File indexing completed on 2025-12-17 09:24:02
0001 #ifndef MACRO_NOBKGDSUBJETRECO_C
0002 #define MACRO_NOBKGDSUBJETRECO_C
0003
0004 #include <GlobalVariables.C>
0005
0006 #include <g4jets/TruthJetInput.h>
0007
0008 #include <globalvertex/GlobalVertex.h>
0009
0010 #include <jetbackground/FastJetAlgoSub.h>
0011 #include <jetbackground/RetowerCEMC.h>
0012
0013 #include <jetbase/FastJetOptions.h>
0014 #include <jetbase/JetReco.h>
0015 #include <jetbase/TowerJetInput.h>
0016 #include <jetbase/TrackJetInput.h>
0017
0018 #include <particleflowreco/ParticleFlowJetInput.h>
0019
0020 #include <fun4all/Fun4AllServer.h>
0021
0022 #include <Rtypes.h> // resolves R__LOAD_LIBRARY for clang-tidy
0023
0024 R__LOAD_LIBRARY(libg4jets.so)
0025 R__LOAD_LIBRARY(libjetbackground.so)
0026 R__LOAD_LIBRARY(libjetbase.so)
0027 R__LOAD_LIBRARY(libparticleflow.so)
0028
0029
0030
0031
0032 namespace Enable
0033 {
0034 int NSJETS_VERBOSITY = 0;
0035 bool NSJETS = false;
0036 bool NSJETS_MC = false;
0037 bool NSJETS_TRUTH = false;
0038 bool NSJETS_TOWER = false;
0039 bool NSJETS_TRACK = true;
0040 bool NSJETS_PFLOW = false;
0041 }
0042
0043
0044
0045
0046 namespace NSJETS
0047 {
0048
0049
0050 bool is_pp = false;
0051
0052
0053
0054 std::string tower_prefix = "TOWERINFO_CALIB";
0055
0056
0057
0058 bool do_vertex_type = true;
0059
0060
0061 GlobalVertex::VTXTYPE vertex_type = GlobalVertex::MBD;
0062
0063
0064
0065
0066 FastJetOptions fj_opts({Jet::ANTIKT, JET_R, 0.4, VERBOSITY, static_cast<float>(Enable::NSJETS_VERBOSITY)});
0067
0068
0069 std::string jet_node = "ANTIKT";
0070
0071
0072 std::string algo_prefix = "AntiKt";
0073
0074
0075
0076 enum Res
0077 {
0078 R02 = 0,
0079 R03 = 1,
0080 R04 = 2,
0081 R05 = 3
0082 };
0083
0084
0085
0086
0087 FastJetAlgoSub* GetFJAlgo(const float reso)
0088 {
0089
0090
0091 FastJetOptions opts = fj_opts;
0092 opts.jet_R = reso;
0093
0094
0095 return new FastJetAlgoSub(opts);
0096
0097 }
0098 }
0099
0100
0101
0102
0103 void MakeNSTruthJets()
0104 {
0105
0106 int verbosity = std::max(Enable::VERBOSITY, Enable::NSJETS_VERBOSITY);
0107
0108
0109
0110
0111 Fun4AllServer* se = Fun4AllServer::instance();
0112
0113
0114 if (Enable::NSJETS_TRACK)
0115 {
0116
0117 JetReco* chrgTruthJets = new JetReco();
0118 chrgTruthJets->add_input(new TruthJetInput(Jet::SRC::CHARGED_PARTICLE));
0119 chrgTruthJets->add_algo(NSJETS::GetFJAlgo(0.2), NSJETS::algo_prefix + "_ChargedTruth_r02");
0120 chrgTruthJets->add_algo(NSJETS::GetFJAlgo(0.3), NSJETS::algo_prefix + "_ChargedTruth_r03");
0121 chrgTruthJets->add_algo(NSJETS::GetFJAlgo(0.4), NSJETS::algo_prefix + "_ChargedTruth_r04");
0122 chrgTruthJets->add_algo(NSJETS::GetFJAlgo(0.5), NSJETS::algo_prefix + "_ChargedTruth_r05");
0123 chrgTruthJets->set_algo_node(NSJETS::jet_node);
0124 chrgTruthJets->set_input_node("TRUTH");
0125 chrgTruthJets->Verbosity(verbosity);
0126 se->registerSubsystem(chrgTruthJets);
0127 }
0128
0129
0130 if (Enable::NSJETS_TOWER || Enable::NSJETS_PFLOW)
0131 {
0132
0133 JetReco* fullTruthJets = new JetReco();
0134 fullTruthJets->add_input(new TruthJetInput(Jet::PARTICLE));
0135 fullTruthJets->add_algo(NSJETS::GetFJAlgo(0.2), NSJETS::algo_prefix + "_Truth_r02");
0136 fullTruthJets->add_algo(NSJETS::GetFJAlgo(0.3), NSJETS::algo_prefix + "_Truth_r03");
0137 fullTruthJets->add_algo(NSJETS::GetFJAlgo(0.4), NSJETS::algo_prefix + "_Truth_r04");
0138 fullTruthJets->add_algo(NSJETS::GetFJAlgo(0.5), NSJETS::algo_prefix + "_Truth_r05");
0139 fullTruthJets->set_algo_node(NSJETS::jet_node);
0140 fullTruthJets->set_input_node("TRUTH");
0141 fullTruthJets->Verbosity(verbosity);
0142 se->registerSubsystem(fullTruthJets);
0143 }
0144
0145
0146 return;
0147
0148 }
0149
0150
0151
0152
0153 void MakeNSTowerJets()
0154 {
0155
0156 int verbosity = std::max(Enable::VERBOSITY, Enable::NSJETS_VERBOSITY);
0157
0158
0159
0160
0161 Fun4AllServer* se = Fun4AllServer::instance();
0162
0163
0164 RetowerCEMC* rcemc = new RetowerCEMC();
0165 rcemc->Verbosity(verbosity);
0166 rcemc->set_towerinfo(true);
0167 rcemc->set_frac_cut(0.5);
0168 rcemc->set_towerNodePrefix(NSJETS::tower_prefix);
0169 se->registerSubsystem(rcemc);
0170
0171
0172 TowerJetInput* emTwrInput = new TowerJetInput(Jet::CEMC_TOWERINFO_RETOWER, NSJETS::tower_prefix);
0173 TowerJetInput* ihTwrInput = new TowerJetInput(Jet::HCALIN_TOWERINFO, NSJETS::tower_prefix);
0174 TowerJetInput* ohTwrInput = new TowerJetInput(Jet::HCALOUT_TOWERINFO, NSJETS::tower_prefix);
0175 if (NSJETS::do_vertex_type)
0176 {
0177 emTwrInput->set_GlobalVertexType(NSJETS::vertex_type);
0178 ihTwrInput->set_GlobalVertexType(NSJETS::vertex_type);
0179 ohTwrInput->set_GlobalVertexType(NSJETS::vertex_type);
0180 }
0181
0182
0183 JetReco* twrRecoJets = new JetReco();
0184 twrRecoJets->add_input(emTwrInput);
0185 twrRecoJets->add_input(ihTwrInput);
0186 twrRecoJets->add_input(ohTwrInput);
0187 twrRecoJets->add_algo(NSJETS::GetFJAlgo(0.2), NSJETS::algo_prefix + "_Tower_r02");
0188 twrRecoJets->add_algo(NSJETS::GetFJAlgo(0.3), NSJETS::algo_prefix + "_Tower_r03");
0189 twrRecoJets->add_algo(NSJETS::GetFJAlgo(0.4), NSJETS::algo_prefix + "_Tower_r04");
0190 twrRecoJets->add_algo(NSJETS::GetFJAlgo(0.5), NSJETS::algo_prefix + "_Tower_r05");
0191 twrRecoJets->set_algo_node(NSJETS::jet_node);
0192 twrRecoJets->set_input_node("TOWER");
0193 twrRecoJets->Verbosity(verbosity);
0194 se->registerSubsystem(twrRecoJets);
0195
0196
0197 return;
0198
0199 }
0200
0201
0202
0203
0204 void MakeNSTrackJets()
0205 {
0206
0207 int verbosity = std::max(Enable::VERBOSITY, Enable::NSJETS_VERBOSITY);
0208
0209
0210
0211
0212 Fun4AllServer* se = Fun4AllServer::instance();
0213
0214
0215 JetReco* trkRecoJets = new JetReco();
0216 trkRecoJets->add_input(new TrackJetInput(Jet::SRC::TRACK));
0217 trkRecoJets->add_algo(NSJETS::GetFJAlgo(0.2), NSJETS::algo_prefix + "_Track_r02");
0218 trkRecoJets->add_algo(NSJETS::GetFJAlgo(0.3), NSJETS::algo_prefix + "_Track_r03");
0219 trkRecoJets->add_algo(NSJETS::GetFJAlgo(0.4), NSJETS::algo_prefix + "_Track_r04");
0220 trkRecoJets->add_algo(NSJETS::GetFJAlgo(0.5), NSJETS::algo_prefix + "_Track_r05");
0221 trkRecoJets->set_algo_node(NSJETS::jet_node);
0222 trkRecoJets->set_input_node("TRACK");
0223 trkRecoJets->Verbosity(verbosity);
0224 se->registerSubsystem(trkRecoJets);
0225
0226
0227 return;
0228
0229 }
0230
0231
0232
0233
0234 void MakeNSPFlowJets()
0235 {
0236
0237 int verbosity = std::max(Enable::VERBOSITY, Enable::NSJETS_VERBOSITY);
0238
0239
0240
0241
0242 Fun4AllServer* se = Fun4AllServer::instance();
0243
0244
0245 JetReco* pfRecoJets = new JetReco();
0246 pfRecoJets->add_input(new ParticleFlowJetInput());
0247 pfRecoJets->add_algo(NSJETS::GetFJAlgo(0.2), NSJETS::algo_prefix + "_ParticleFlow_r02");
0248 pfRecoJets->add_algo(NSJETS::GetFJAlgo(0.3), NSJETS::algo_prefix + "_ParticleFlow_r03");
0249 pfRecoJets->add_algo(NSJETS::GetFJAlgo(0.4), NSJETS::algo_prefix + "_ParticleFlow_r04");
0250 pfRecoJets->add_algo(NSJETS::GetFJAlgo(0.5), NSJETS::algo_prefix + "_ParticleFlow_r05");
0251 pfRecoJets->set_algo_node(NSJETS::jet_node);
0252 pfRecoJets->set_input_node("ELEMENT");
0253 pfRecoJets->Verbosity(verbosity);
0254 se->registerSubsystem(pfRecoJets);
0255
0256
0257 return;
0258
0259 }
0260
0261
0262
0263
0264 void NoBkgdSubJetReco()
0265 {
0266
0267 if (Enable::NSJETS_MC && Enable::NSJETS_TRUTH)
0268 {
0269 MakeNSTruthJets();
0270 }
0271
0272
0273 if (Enable::NSJETS_TOWER)
0274 {
0275 MakeNSTowerJets();
0276 }
0277 if (Enable::NSJETS_TRACK)
0278 {
0279 MakeNSTrackJets();
0280 }
0281 if (Enable::NSJETS_PFLOW)
0282 {
0283 MakeNSPFlowJets();
0284 }
0285
0286 }
0287
0288 #endif