File indexing completed on 2026-05-23 08:10:29
0001 #include <fun4all/Fun4AllServer.h>
0002
0003 #include <calotrigger/TriggerRunInfoReco.h>
0004 #include <globalvertex/GlobalVertexReco.h>
0005
0006 #pragma GCC diagnostic push
0007
0008 #pragma GCC diagnostic ignored "-Wundefined-internal"
0009
0010 #include <kfparticle_sphenix/KFParticle_sPHENIX.h>
0011
0012 #pragma GCC diagnostic pop
0013
0014 R__LOAD_LIBRARY(libkfparticle_sphenix.so)
0015 R__LOAD_LIBRARY(libcalotrigger.so)
0016 R__LOAD_LIBRARY(libkfparticleqa.so)
0017
0018 namespace HeavyFlavorReco
0019 {
0020 int VERBOSITY_HF = 0;
0021
0022 bool run_pipi_reco = false;
0023 bool run_ppi_reco = false;
0024 bool run_anti_ppi_reco = false;
0025 bool run_KK_reco = false;
0026 bool run_Kpi_reco = false;
0027 bool run_ee_reco = false;
0028 bool run_cascade_reco = false;
0029
0030 std::string output_dir = "./";
0031 std::string kfp_header = "outputKFParticle_";
0032 std::string processing_folder = "inReconstruction/";
0033 std::string trailer = ".root";
0034
0035
0036 std::string pipi_decay_descriptor = "K_S0 -> pi^+ pi^-";
0037 std::string pipi_reconstruction_name = "pipi_reco";
0038 std::string pipi_output_reco_file;
0039 std::string pipi_output_dir;
0040
0041 std::string ppi_decay_descriptor = "[Lambda0 -> proton^+ pi^-]cc";
0042
0043 std::string ppi_reconstruction_name = "ppi_reco";
0044 std::string ppi_output_reco_file;
0045 std::string ppi_output_dir;
0046
0047 std::string anti_ppi_decay_descriptor = "Lambda0 -> proton^- pi^+";
0048 std::string anti_ppi_reconstruction_name = "anti_ppi_reco";
0049 std::string anti_ppi_output_reco_file;
0050 std::string anti_ppi_output_dir;
0051
0052 std::string cascade_decay_descriptor = "[Xi- -> {Lambda0 -> proton^+ pi^-} pi^-]cc";
0053 std::string cascade_reconstruction_name = "cascade_reco";
0054 std::string cascade_output_reco_file;
0055 std::string cascade_output_dir;
0056
0057 bool truthMatch = true;
0058 bool save_kfpntuple = true;
0059 bool use_pid = false;
0060 bool save_tracks_to_DST = false;
0061 bool dont_use_global_vertex = true;
0062 bool require_track_and_vertex_match = true;
0063 bool save_all_vtx_info = true;
0064 bool constrain_phi_mass = true;
0065 bool use_2D_matching = false;
0066 bool get_trigger_info = false;
0067 bool get_detector_info = true;
0068 bool get_dEdx_info = false;
0069 bool get_calo_info = false;
0070 float pid_frac = 0.4;
0071 float cemc_proj_radius = 102.9;
0072 bool constrain_lambda_mass = true;
0073 bool extraolate_tracks_to_secondary_vertex = false;
0074
0075
0076 float lf_cuts_setMinDIRA{-1.1};
0077 float lf_cuts_setDecayLengthRange_min{-1.};
0078 float lf_cuts_setMinimumTrackIP_XY{-1.};
0079 float lf_cuts_setMinMVTXhits{0};
0080 float lf_cuts_setMinINTThits{0};
0081 float lf_cuts_setMinTPChits{0};
0082 float lf_cuts_setMaximumVertexchi2nDOF{2000};
0083 float lf_cuts_setMaximumDaughterDCA{10};
0084
0085
0086 float lf_cuts_setMotherIPchi2{FLT_MAX};
0087 float lf_cuts_setFlightDistancechi2{-1.};
0088 float lf_cuts_setMinDIRA_XY{-1.1};
0089 float lf_cuts_setDecayLengthRange_max{FLT_MAX};
0090 float lf_cuts_setDecayLengthRange_XY_min{-10.};
0091 float lf_cuts_setDecayLengthRange_XY_max{FLT_MAX};
0092 float lf_cuts_setDecayTimeRange_XY_min{-10000};
0093 float lf_cuts_setDecayTimeRange_XY_max{FLT_MAX};
0094 float lf_cuts_setDecayTimeRange_min{-10000};
0095 float lf_cuts_setDecayTimeRange_max{FLT_MAX};
0096 float lf_cuts_setMinDecayTimeSignificance{-1e5};
0097 float lf_cuts_setMinDecayLengthSignificance{-1e5};
0098 float lf_cuts_setMinDecayLengthSignificance_XY{-1e5};
0099 float lf_cuts_setMinimumTrackPT{0.0};
0100 float lf_cuts_setMinimumTrackIPchi2{-1.};
0101 float lf_cuts_setMinimumTrackIPchi2_XY{-1.};
0102 float lf_cuts_setMinimumTrackIP{-1.};
0103 float lf_cuts_setMaximumTrackchi2nDOF{3000.};
0104 float lf_cuts_setMaximumDaughterDCA_XY{10};
0105 float lf_cuts_setMotherPT{0};
0106 float lf_cuts_setMaximumMotherVertexVolume{100};
0107
0108
0109
0110
0111
0112
0113
0114
0115
0116
0117
0118
0119
0120
0121
0122
0123
0124
0125
0126
0127
0128
0129
0130
0131
0132
0133
0134
0135
0136
0137
0138
0139
0140
0141 };
0142
0143 using namespace HeavyFlavorReco;
0144
0145 void init_kfp_dependencies()
0146 {
0147
0148 Fun4AllServer *se = Fun4AllServer::instance();
0149
0150 GlobalVertexReco* gblvertex = new GlobalVertexReco();
0151 gblvertex->Verbosity(VERBOSITY_HF);
0152 se->registerSubsystem(gblvertex);
0153
0154 if (get_trigger_info)
0155 {
0156 TriggerRunInfoReco *triggerruninforeco = new TriggerRunInfoReco();
0157 se->registerSubsystem(triggerruninforeco);
0158 }
0159 }
0160
0161 void create_hf_directories(std::string reconstruction_name, std::string &final_output_dir, std::string &output_reco_file, std::string ID)
0162 {
0163 std::string output_file_name = kfp_header + reconstruction_name + "_" + ID + trailer;
0164 final_output_dir = output_dir + reconstruction_name + "/";
0165 std::string output_reco_dir = final_output_dir + processing_folder;
0166 output_reco_file = output_reco_dir + output_file_name;
0167
0168 std::string makeDirectory = "mkdir -p " + output_reco_dir;
0169 system(makeDirectory.c_str());
0170 }
0171
0172 void reconstruct_pipi_mass()
0173 {
0174 Fun4AllServer *se = Fun4AllServer::instance();
0175
0176 KFParticle_sPHENIX *kfparticle = new KFParticle_sPHENIX(pipi_reconstruction_name);
0177 kfparticle->Verbosity(VERBOSITY_HF);
0178
0179 kfparticle->setDecayDescriptor(pipi_decay_descriptor);
0180
0181 kfparticle->setTrackMapNodeName("HFSelected_SvtxTrackMap");
0182 kfparticle->extraolateTracksToSV(extraolate_tracks_to_secondary_vertex);
0183 kfparticle->saveOutput(save_kfpntuple);
0184
0185 kfparticle->doTruthMatching(truthMatch);
0186 kfparticle->usePID(use_pid);
0187 kfparticle->setPIDacceptFraction(pid_frac);
0188 kfparticle->get_dEdx_info();
0189 kfparticle->dontUseGlobalVertex(dont_use_global_vertex);
0190 kfparticle->requireTrackVertexBunchCrossingMatch(require_track_and_vertex_match);
0191 kfparticle->getAllPVInfo(save_all_vtx_info);
0192 kfparticle->allowZeroMassTracks();
0193 kfparticle->use2Dmatching(use_2D_matching);
0194 kfparticle->getTriggerInfo(get_trigger_info);
0195 kfparticle->getDetectorInfo(get_detector_info);
0196 kfparticle->get_dEdx_info(get_dEdx_info);
0197 kfparticle->saveDST(save_tracks_to_DST);
0198 kfparticle->setContainerName(pipi_reconstruction_name);
0199 kfparticle->saveParticleContainer(true);
0200 kfparticle->magFieldFile("FIELDMAP_TRACKING");
0201
0202
0203 kfparticle->constrainToPrimaryVertex();
0204 kfparticle->setMotherIPchi2(lf_cuts_setMotherIPchi2);
0205 kfparticle->setFlightDistancechi2(lf_cuts_setFlightDistancechi2);
0206 kfparticle->setMinDIRA(lf_cuts_setMinDIRA);
0207 kfparticle->setMinDIRA_XY(lf_cuts_setMinDIRA_XY);
0208 kfparticle->setDecayLengthRange(lf_cuts_setDecayLengthRange_min, lf_cuts_setDecayLengthRange_max);
0209 kfparticle->setDecayLengthRange_XY(lf_cuts_setDecayLengthRange_XY_min, lf_cuts_setDecayLengthRange_XY_max);
0210 kfparticle->setDecayTimeRange_XY(lf_cuts_setDecayTimeRange_XY_min, lf_cuts_setDecayTimeRange_XY_max);
0211 kfparticle->setDecayTimeRange(lf_cuts_setDecayTimeRange_min, lf_cuts_setDecayTimeRange_max);
0212 kfparticle->setMinDecayTimeSignificance(lf_cuts_setMinDecayTimeSignificance);
0213 kfparticle->setMinDecayLengthSignificance(lf_cuts_setMinDecayLengthSignificance);
0214 kfparticle->setMinDecayLengthSignificance_XY(lf_cuts_setMinDecayLengthSignificance_XY);
0215
0216
0217 kfparticle->setMinimumTrackPT(lf_cuts_setMinimumTrackPT);
0218 kfparticle->setMinimumTrackIPchi2(lf_cuts_setMinimumTrackIPchi2);
0219 kfparticle->setMinimumTrackIPchi2_XY(lf_cuts_setMinimumTrackIPchi2_XY);
0220 kfparticle->setMinimumTrackIP(lf_cuts_setMinimumTrackIP);
0221 kfparticle->setMinimumTrackIP_XY(lf_cuts_setMinimumTrackIP_XY);
0222 kfparticle->setMaximumTrackchi2nDOF(lf_cuts_setMaximumTrackchi2nDOF);
0223 kfparticle->setMinMVTXhits(lf_cuts_setMinMVTXhits);
0224 kfparticle->setMinINTThits(lf_cuts_setMinINTThits);
0225 kfparticle->setMinTPChits(lf_cuts_setMinTPChits);
0226
0227
0228 kfparticle->setMaximumVertexchi2nDOF(lf_cuts_setMaximumVertexchi2nDOF);
0229 kfparticle->setMaximumDaughterDCA(lf_cuts_setMaximumDaughterDCA);
0230 kfparticle->setMaximumDaughterDCA_XY(lf_cuts_setMaximumDaughterDCA_XY);
0231
0232
0233 kfparticle->setMotherPT(lf_cuts_setMotherPT);
0234 kfparticle->setMinimumMass(0.40);
0235 kfparticle->setMaximumMass(0.60);
0236 kfparticle->setMaximumMotherVertexVolume(lf_cuts_setMaximumMotherVertexVolume);
0237 kfparticle->setOutputName(pipi_output_reco_file);
0238
0239 se->registerSubsystem(kfparticle);
0240 }
0241
0242 void reconstruct_ppi_mass()
0243 {
0244 Fun4AllServer *se = Fun4AllServer::instance();
0245
0246 KFParticle_sPHENIX *kfparticle = new KFParticle_sPHENIX(ppi_reconstruction_name);
0247 kfparticle->Verbosity(VERBOSITY_HF);
0248
0249 if (run_ppi_reco) kfparticle->setDecayDescriptor(ppi_decay_descriptor);
0250 else kfparticle->setDecayDescriptor(anti_ppi_decay_descriptor);
0251
0252 kfparticle->setTrackMapNodeName("HFSelected_SvtxTrackMap");
0253 kfparticle->extraolateTracksToSV(extraolate_tracks_to_secondary_vertex);
0254 kfparticle->saveOutput(save_kfpntuple);
0255
0256 kfparticle->doTruthMatching(truthMatch);
0257 kfparticle->usePID(use_pid);
0258 kfparticle->setPIDacceptFraction(pid_frac);
0259 kfparticle->get_dEdx_info();
0260 kfparticle->dontUseGlobalVertex(dont_use_global_vertex);
0261 kfparticle->requireTrackVertexBunchCrossingMatch(require_track_and_vertex_match);
0262 kfparticle->getAllPVInfo(save_all_vtx_info);
0263 kfparticle->allowZeroMassTracks();
0264 kfparticle->use2Dmatching(use_2D_matching);
0265 kfparticle->getTriggerInfo(get_trigger_info);
0266 kfparticle->getDetectorInfo(get_detector_info);
0267 kfparticle->get_dEdx_info(get_dEdx_info);
0268 kfparticle->saveDST(save_tracks_to_DST);
0269 kfparticle->setContainerName(ppi_reconstruction_name);
0270 kfparticle->saveParticleContainer(true);
0271 kfparticle->magFieldFile("FIELDMAP_TRACKING");
0272
0273
0274 kfparticle->constrainToPrimaryVertex();
0275 kfparticle->setMotherIPchi2(lf_cuts_setMotherIPchi2);
0276 kfparticle->setFlightDistancechi2(lf_cuts_setFlightDistancechi2);
0277 kfparticle->setMinDIRA(lf_cuts_setMinDIRA);
0278 kfparticle->setMinDIRA_XY(lf_cuts_setMinDIRA_XY);
0279 kfparticle->setDecayLengthRange(lf_cuts_setDecayLengthRange_min, lf_cuts_setDecayLengthRange_max);
0280 kfparticle->setDecayLengthRange_XY(lf_cuts_setDecayLengthRange_XY_min, lf_cuts_setDecayLengthRange_XY_max);
0281 kfparticle->setDecayTimeRange_XY(lf_cuts_setDecayTimeRange_XY_min, lf_cuts_setDecayTimeRange_XY_max);
0282 kfparticle->setDecayTimeRange(lf_cuts_setDecayTimeRange_min, lf_cuts_setDecayTimeRange_max);
0283 kfparticle->setMinDecayTimeSignificance(lf_cuts_setMinDecayTimeSignificance);
0284 kfparticle->setMinDecayLengthSignificance(lf_cuts_setMinDecayLengthSignificance);
0285 kfparticle->setMinDecayLengthSignificance_XY(lf_cuts_setMinDecayLengthSignificance_XY);
0286
0287
0288 kfparticle->setMinimumTrackPT(lf_cuts_setMinimumTrackPT);
0289 kfparticle->setMinimumTrackIPchi2(lf_cuts_setMinimumTrackIPchi2);
0290 kfparticle->setMinimumTrackIPchi2_XY(lf_cuts_setMinimumTrackIPchi2_XY);
0291 kfparticle->setMinimumTrackIP(lf_cuts_setMinimumTrackIP);
0292 kfparticle->setMinimumTrackIP_XY(lf_cuts_setMinimumTrackIP_XY);
0293 kfparticle->setMaximumTrackchi2nDOF(lf_cuts_setMaximumTrackchi2nDOF);
0294 kfparticle->setMinMVTXhits(lf_cuts_setMinMVTXhits);
0295 kfparticle->setMinINTThits(lf_cuts_setMinINTThits);
0296 kfparticle->setMinTPChits(lf_cuts_setMinTPChits);
0297
0298
0299 kfparticle->setMaximumVertexchi2nDOF(lf_cuts_setMaximumVertexchi2nDOF);
0300 kfparticle->setMaximumDaughterDCA(lf_cuts_setMaximumDaughterDCA);
0301 kfparticle->setMaximumDaughterDCA_XY(lf_cuts_setMaximumDaughterDCA_XY);
0302
0303
0304 kfparticle->setMotherPT(lf_cuts_setMotherPT);
0305 kfparticle->setMinimumMass(1.08);
0306 kfparticle->setMaximumMass(1.15);
0307 kfparticle->setMaximumMotherVertexVolume(lf_cuts_setMaximumMotherVertexVolume);
0308 kfparticle->setOutputName(ppi_output_reco_file);
0309
0310 se->registerSubsystem(kfparticle);
0311 }
0312
0313 void reconstruct_Lambdapi_mass()
0314 {
0315 Fun4AllServer *se = Fun4AllServer::instance();
0316
0317 KFParticle_sPHENIX *kfparticle = new KFParticle_sPHENIX(cascade_reconstruction_name);
0318 kfparticle->Verbosity(VERBOSITY_HF);
0319
0320 kfparticle->setDecayDescriptor(cascade_decay_descriptor);
0321
0322
0323 kfparticle->saveOutput(save_kfpntuple);
0324
0325 kfparticle->usePID(use_pid);
0326
0327 kfparticle->dontUseGlobalVertex(dont_use_global_vertex);
0328 kfparticle->requireTrackVertexBunchCrossingMatch(require_track_and_vertex_match);
0329 kfparticle->getAllPVInfo(save_all_vtx_info);
0330 kfparticle->allowZeroMassTracks();
0331 kfparticle->use2Dmatching(use_2D_matching);
0332 kfparticle->getTriggerInfo(get_trigger_info);
0333 kfparticle->getDetectorInfo(get_detector_info);
0334 kfparticle->saveDST(save_tracks_to_DST);
0335 kfparticle->setContainerName(cascade_reconstruction_name);
0336 kfparticle->magFieldFile("FIELDMAP_TRACKING");
0337
0338
0339
0340 kfparticle->constrainToPrimaryVertex(false);
0341 kfparticle->useFakePrimaryVertex(true);
0342 kfparticle->setMotherIPchi2(100);
0343 kfparticle->setFlightDistancechi2(-1.);
0344 kfparticle->setMinDIRA(-1.1);
0345 kfparticle->setDecayLengthRange(-1*FLT_MAX, FLT_MAX);
0346
0347
0348 kfparticle->setMinimumTrackPT(0.0);
0349 kfparticle->setMaximumTrackPTchi2(FLT_MAX);
0350 kfparticle->setMaximumTrackchi2nDOF(FLT_MAX);
0351 kfparticle->setMinTPChits(0);
0352 kfparticle->setMinMVTXhits(0);
0353 kfparticle->setMinINTThits(0);
0354 kfparticle->setMinimumTrackIP_XY(-100.);
0355 kfparticle->setMinimumTrackIPchi2_XY(-1000.);
0356 kfparticle->setMinimumTrackIP(-100.);
0357 kfparticle->setMinimumTrackIPchi2(-1000.);
0358
0359
0360 kfparticle->setMaximumVertexchi2nDOF(FLT_MAX);
0361 kfparticle->setMaximumDaughterDCA(5);
0362 kfparticle->setMaximumDaughterDCA_XY(5);
0363
0364
0365 kfparticle->setMotherPT(0);
0366 kfparticle->setMinimumMass(1.0);
0367 kfparticle->setMaximumMass(2.0);
0368 kfparticle->setMaximumMotherVertexVolume(10);
0369
0370
0371 kfparticle->constrainIntermediateMasses(constrain_lambda_mass);
0372
0373 std::vector<std::pair<float, float>> intermediate_mass_range;
0374 intermediate_mass_range.push_back(make_pair(1.0, 2.0));
0375 kfparticle->setIntermediateMassRange(intermediate_mass_range);
0376
0377 std::vector<float> intermediate_min_dira = {-1.1};
0378 kfparticle->setIntermediateMinDIRA(intermediate_min_dira);
0379
0380 std::vector<float> intermediate_min_pt = {0.0};
0381 kfparticle->setIntermediateMinPT(intermediate_min_pt);
0382
0383 std::vector<std::pair<float, float>> intermediate_IP_range;
0384 intermediate_IP_range.push_back(make_pair(-1., FLT_MAX));
0385 kfparticle->setIntermediateIPRange(intermediate_IP_range);
0386
0387 std::vector<std::pair<float, float>> intermediate_IPchi2_range;
0388 intermediate_IPchi2_range.push_back(make_pair(-1., FLT_MAX));
0389 kfparticle->setIntermediateIPchi2Range(intermediate_IPchi2_range);
0390
0391 std::vector<float> intermediate_min_FDchi2 = {-1.};
0392 kfparticle->setIntermediateMinFDchi2(intermediate_min_FDchi2);
0393
0394 std::vector<float> intermediate_max_vertex_vol = {1.1};
0395 kfparticle->setIntermediateMaxVertexVolume(intermediate_max_vertex_vol);
0396
0397 std::vector<std::pair<float, float>> intermediate_IPxy_range;
0398 intermediate_IPxy_range.push_back(make_pair(-1., FLT_MAX));
0399 kfparticle->setIntermediateIPRange_XY(intermediate_IPxy_range);
0400
0401 std::vector<std::pair<float, float>> intermediate_IPchi2xy_range;
0402 intermediate_IPchi2xy_range.push_back(make_pair(-1., FLT_MAX));
0403 kfparticle->setIntermediateIPchi2Range_XY(intermediate_IPchi2xy_range);
0404
0405 kfparticle->setOutputName(cascade_output_reco_file);
0406
0407 se->registerSubsystem(kfparticle);
0408 }
0409
0410 void end_kfparticle(std::string full_file_name, std::string final_path)
0411 {
0412 ifstream file(full_file_name.c_str());
0413 if (file.good())
0414 {
0415 string moveOutput = "mv " + full_file_name + " " + final_path;
0416 system(moveOutput.c_str());
0417 }
0418 }
0419