Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2026-07-16 08:11:22

0001 #include <fun4all/Fun4AllServer.h>
0002 
0003 #include <calotrigger/TriggerRunInfoReco.h>
0004 #include <globalvertex/GlobalVertexReco.h>
0005 
0006 #include <kfparticleqa/QAKFParticle.h>
0007 #include <kfparticleqa/QAKFParticleTrackPtAsymmetry.h>
0008 
0009 #pragma GCC diagnostic push
0010 
0011 #pragma GCC diagnostic ignored "-Wundefined-internal"
0012 
0013 #include <kfparticle_sphenix/KFParticle_sPHENIX.h>
0014 
0015 #pragma GCC diagnostic pop
0016 
0017 R__LOAD_LIBRARY(libkfparticle_sphenix.so)
0018 R__LOAD_LIBRARY(libcalotrigger.so)
0019 R__LOAD_LIBRARY(libkfparticleqa.so)
0020 
0021 namespace HeavyFlavorReco
0022 {
0023   int VERBOSITY_HF = 0;
0024 
0025   bool run_pipi_reco = false;
0026   bool run_ppi_reco = false; // set to true if needed
0027   bool run_KK_reco = false; // set to true if needed
0028   bool run_Kpi_reco = false; // set to true if needed
0029   bool run_ee_reco = false; // set to true if needed
0030   bool run_Lambdapi_reco = true;
0031   bool run_LambdaK_reco = false;
0032 
0033   std::string output_dir = "./"; //Top dir of where the output nTuples will be written
0034   std::string kfp_header = "outputKFParticle_";
0035   std::string processing_folder = "inReconstruction/";
0036   std::string trailer = ".root";
0037 
0038   // https://wiki.bnl.gov/sPHENIX/index.php/KFParticle
0039   std::string pipi_decay_descriptor = "K_S0 -> pi^+ pi^-"; //See twiki on how to set this
0040   std::string pipi_reconstruction_name = "pipi_reco"; //Used for naming output folder, file and node
0041   std::string pipi_output_reco_file;
0042   std::string pipi_output_dir;
0043 
0044   std::string ppi_decay_descriptor = "[Lambda0 -> proton^+ pi^-]cc"; //See twiki on how to set this
0045   std::string ppi_reconstruction_name = "ppi_reco"; //Used for naming output folder, file and node
0046   std::string ppi_output_reco_file;
0047   std::string ppi_output_dir;
0048 
0049   std::string KK_decay_descriptor = "phi -> K^+ K^-"; //See twiki on how to set this
0050   std::string KK_reconstruction_name = "KK_reco"; //Used for naming output folder, file and node
0051   std::string KK_output_reco_file;
0052   std::string KK_output_dir;
0053 
0054   std::string Kpi_decay_descriptor = "[D0 -> K^- pi^+]cc"; //See twiki on how to set this
0055   std::string Kpi_reconstruction_name = "Kpi_reco"; //Used for naming output folder, file and node
0056   std::string Kpi_output_reco_file;
0057   std::string Kpi_output_dir;
0058 
0059   std::string ee_decay_descriptor = "[gamma -> e^+ e^-]cc"; //See twiki on how to set this
0060   std::string ee_reconstruction_name = "ee_reco"; //Used for naming output folder, file and node
0061   std::string ee_output_reco_file;
0062   std::string ee_output_dir;
0063 
0064   std::string Lambdapi_decay_descriptor = "[Xi- -> {Lambda0 -> proton^+ pi^-} pi^-]cc"; //See twiki on how to set this
0065   std::string Lambdapi_reconstruction_name = "Lambdapi_reco"; //Used for naming output folder, file and node
0066   std::string Lambdapi_output_reco_file;
0067   std::string Lambdapi_output_dir;
0068 
0069   std::string LambdaK_decay_descriptor = "[Omega- -> {Lambda0 -> proton^+ pi^-} K^-]cc"; //See twiki on how to set this
0070   std::string LambdaK_reconstruction_name = "LambdaK_reco"; //Used for naming output folder, file and node
0071   std::string LambdaK_output_reco_file;
0072   std::string LambdaK_output_dir;
0073 
0074   bool save_kfpntuple = true;
0075   bool use_pid = false;
0076   bool save_tracks_to_DST = true;
0077   bool dont_use_global_vertex = true;
0078   //bool require_track_and_vertex_match = true; //original setting
0079   bool require_track_and_vertex_match = false;
0080   bool save_all_vtx_info = true;
0081   bool constrain_phi_mass = true;
0082   bool use_2D_matching = false;
0083   bool get_trigger_info = false;
0084   bool get_detector_info = true;
0085   bool get_dEdx_info = true;
0086   bool get_calo_info = false;
0087   float pid_frac = 0.6;
0088   float cemc_proj_radius = 102.9; //Virgile recommendation according to DetailedCalorimeterGeometry
0089   bool constrain_lambda_mass = true;
0090   bool extraolate_tracks_to_secondary_vertex = true; // Set to false to ensure the pT map is accurate for asymmetry study
0091 };  // namespace HeavyFlavorReco'
0092 
0093 using namespace HeavyFlavorReco;
0094 
0095 void init_kfp_dependencies()
0096 {
0097   //dE/dx needs TRKR_CLUSTER and CYLINDERCELLGEOM_SVTX which need to be in the DST or loaded from a geo file
0098   Fun4AllServer *se = Fun4AllServer::instance();
0099 
0100   GlobalVertexReco* gblvertex = new GlobalVertexReco();
0101   gblvertex->Verbosity(VERBOSITY_HF);
0102   se->registerSubsystem(gblvertex);
0103 
0104 
0105   if (get_trigger_info)
0106   {
0107     TriggerRunInfoReco *triggerruninforeco = new TriggerRunInfoReco();
0108     se->registerSubsystem(triggerruninforeco);
0109   }
0110 }
0111 
0112 void create_hf_directories(std::string reconstruction_name, std::string &final_output_dir, std::string &output_reco_file)
0113 {
0114   std::string output_file_name = kfp_header + reconstruction_name + trailer;
0115   final_output_dir = output_dir + reconstruction_name + "/";
0116   std::string output_reco_dir = final_output_dir + processing_folder;
0117   output_reco_file = output_reco_dir + output_file_name;
0118 
0119   std::string makeDirectory = "mkdir -p " + output_reco_dir;
0120   system(makeDirectory.c_str());
0121 }
0122 
0123 void reconstruct_pipi_mass()
0124 {
0125   Fun4AllServer *se = Fun4AllServer::instance();
0126 
0127   KFParticle_sPHENIX *kfparticle = new KFParticle_sPHENIX(pipi_reconstruction_name);
0128 
0129   kfparticle->setDecayDescriptor(pipi_decay_descriptor);
0130 
0131   kfparticle->extraolateTracksToSV(extraolate_tracks_to_secondary_vertex);
0132 
0133   kfparticle->saveOutput(save_kfpntuple);
0134 
0135   kfparticle->usePID(use_pid);
0136   kfparticle->setPIDacceptFraction(pid_frac);
0137   kfparticle->dontUseGlobalVertex(dont_use_global_vertex);
0138   kfparticle->requireTrackVertexBunchCrossingMatch(require_track_and_vertex_match);
0139   kfparticle->getAllPVInfo(save_all_vtx_info);
0140   kfparticle->allowZeroMassTracks();
0141   kfparticle->use2Dmatching(use_2D_matching);
0142   kfparticle->getTriggerInfo(get_trigger_info);
0143   kfparticle->getDetectorInfo(get_detector_info);
0144   kfparticle->get_dEdx_info(get_dEdx_info);
0145   kfparticle->saveDST(save_tracks_to_DST);
0146   kfparticle->setContainerName(pipi_reconstruction_name);
0147   kfparticle->saveParticleContainer(true);
0148   kfparticle->magFieldFile("FIELDMAP_TRACKING");
0149 
0150   //PV to SV cuts
0151   kfparticle->constrainToPrimaryVertex();
0152   kfparticle->setMotherIPchi2(100);
0153   kfparticle->setFlightDistancechi2(-1.);
0154   kfparticle->setMinDIRA(0.88);
0155   kfparticle->setMinDIRA_XY(-1.1);
0156   kfparticle->setDecayLengthRange(0.1, FLT_MAX);
0157   kfparticle->setDecayLengthRange_XY(-10000, FLT_MAX);
0158   kfparticle->setDecayTimeRange_XY(-10000, FLT_MAX);
0159   kfparticle->setDecayTimeRange(-10000, FLT_MAX);
0160   kfparticle->setMinDecayTimeSignificance(-1e5);
0161   kfparticle->setMinDecayLengthSignificance(-1e5);
0162   kfparticle->setMinDecayLengthSignificance_XY(-1e5);
0163 
0164   //Track parameters
0165   kfparticle->setMinimumTrackPT(0.0);
0166   kfparticle->setMinimumTrackIPchi2(-1.);
0167   kfparticle->setMinimumTrackIPchi2_XY(-1.);
0168   kfparticle->setMinimumTrackIP(-1.);
0169   kfparticle->setMinimumTrackIP_XY(-100.);
0170   kfparticle->setMaximumTrackchi2nDOF(100.);
0171   kfparticle->setMinMVTXhits(1);
0172   kfparticle->setMinINTThits(1);
0173   kfparticle->setMinTPChits(25);
0174 
0175   //Vertex parameters
0176   kfparticle->setMaximumVertexchi2nDOF(20);
0177   kfparticle->setMaximumDaughterDCA(0.5);
0178   kfparticle->setMaximumDaughterDCA_XY(100);
0179 
0180   //Parent parameters
0181   kfparticle->setMotherPT(0);
0182   kfparticle->setMinimumMass(0.40);
0183   kfparticle->setMaximumMass(0.60);
0184   kfparticle->setMaximumMotherVertexVolume(0.1);
0185 
0186   kfparticle->setOutputName(pipi_output_reco_file);
0187 
0188   se->registerSubsystem(kfparticle);
0189 
0190   QAKFParticle *kfpqa = new QAKFParticle("QAKFParticle_K_S0","K_S0",0.4,0.6);
0191   kfpqa->setKFParticleNodeName(pipi_reconstruction_name);
0192   kfpqa->enableTrackPtAsymmetry(true); 
0193   kfpqa->Verbosity(VERBOSITY_HF);
0194   se->registerSubsystem(kfpqa);
0195 
0196 }
0197 
0198 void reconstruct_KK_mass()
0199 {
0200   Fun4AllServer *se = Fun4AllServer::instance();
0201 
0202   KFParticle_sPHENIX *kfparticle = new KFParticle_sPHENIX(KK_reconstruction_name);
0203 
0204   kfparticle->setDecayDescriptor(KK_decay_descriptor);
0205 
0206   kfparticle->extraolateTracksToSV(extraolate_tracks_to_secondary_vertex);
0207 
0208   kfparticle->saveOutput(save_kfpntuple);
0209 
0210   kfparticle->usePID(use_pid);
0211   kfparticle->setPIDacceptFraction(pid_frac);
0212   kfparticle->dontUseGlobalVertex(dont_use_global_vertex);
0213   kfparticle->requireTrackVertexBunchCrossingMatch(require_track_and_vertex_match);
0214   kfparticle->getAllPVInfo(save_all_vtx_info);
0215   kfparticle->allowZeroMassTracks();
0216   kfparticle->use2Dmatching(use_2D_matching);
0217   kfparticle->getTriggerInfo(get_trigger_info);
0218   kfparticle->getDetectorInfo(get_detector_info);
0219   kfparticle->get_dEdx_info(get_dEdx_info);
0220   kfparticle->saveDST(save_tracks_to_DST);
0221   kfparticle->setContainerName(KK_reconstruction_name);
0222   kfparticle->saveParticleContainer(true);
0223   kfparticle->magFieldFile("FIELDMAP_TRACKING");
0224 
0225   //PV to SV cuts
0226   kfparticle->constrainToPrimaryVertex();
0227   kfparticle->setMotherIPchi2(100);
0228   kfparticle->setFlightDistancechi2(-1.);
0229 
0230   //Track parameters
0231   kfparticle->setMinimumTrackPT(0.1);
0232   //kfparticle->setMaximumTrackPT(0.7);
0233   kfparticle->setMaximumTrackchi2nDOF(400.);
0234   kfparticle->setMinTPChits(20);
0235   kfparticle->setMinMVTXhits(1);
0236   kfparticle->setMinINTThits(1);
0237   kfparticle->setMinimumTrackIP_XY(-100.);
0238   kfparticle->setMinimumTrackIPchi2_XY(-1000.);
0239   kfparticle->setMinimumTrackIP(-100.);
0240   kfparticle->setMinimumTrackIPchi2(-1000.);
0241 
0242   //Vertex parameters
0243   kfparticle->setMaximumVertexchi2nDOF(50);
0244   kfparticle->setMaximumDaughterDCA(0.5);
0245   kfparticle->setMaximumDaughterDCA_XY(100);
0246 
0247   //Parent parameters
0248   kfparticle->setMotherPT(0);
0249   kfparticle->setMinimumMass(0.98);
0250   kfparticle->setMaximumMass(1.1);
0251   kfparticle->setMaximumMotherVertexVolume(0.1);
0252 
0253   kfparticle->setOutputName(KK_output_reco_file);
0254 
0255   se->registerSubsystem(kfparticle);
0256 }
0257 
0258 void reconstruct_ppi_mass()
0259 {
0260   Fun4AllServer *se = Fun4AllServer::instance();
0261 
0262   KFParticle_sPHENIX *kfparticle = new KFParticle_sPHENIX(ppi_reconstruction_name);
0263 
0264   kfparticle->setDecayDescriptor(ppi_decay_descriptor);
0265 
0266   kfparticle->extraolateTracksToSV(extraolate_tracks_to_secondary_vertex);
0267 
0268   kfparticle->saveOutput(save_kfpntuple);
0269 
0270   kfparticle->usePID(use_pid);
0271   kfparticle->setPIDacceptFraction(pid_frac);
0272   kfparticle->dontUseGlobalVertex(dont_use_global_vertex);
0273   kfparticle->requireTrackVertexBunchCrossingMatch(require_track_and_vertex_match);
0274   kfparticle->getAllPVInfo(save_all_vtx_info);
0275   kfparticle->allowZeroMassTracks();
0276   kfparticle->use2Dmatching(use_2D_matching);
0277   kfparticle->getTriggerInfo(get_trigger_info);
0278   kfparticle->getDetectorInfo(get_detector_info);
0279   kfparticle->get_dEdx_info(get_dEdx_info);
0280   kfparticle->saveDST(save_tracks_to_DST);
0281   kfparticle->setContainerName(ppi_reconstruction_name);
0282   kfparticle->saveParticleContainer(true);
0283   kfparticle->magFieldFile("FIELDMAP_TRACKING");
0284 
0285   //PV to SV cuts
0286   kfparticle->constrainToPrimaryVertex(true);
0287   kfparticle->setMotherIPchi2(100);
0288   kfparticle->setFlightDistancechi2(-1.);
0289   kfparticle->setMinDIRA(0.88);
0290   kfparticle->setDecayLengthRange(0.1, FLT_MAX);
0291 
0292   //Track parameters
0293   kfparticle->setMinimumTrackPT(0.1);
0294   kfparticle->setMinimumTrackIP_XY(0.05);
0295   kfparticle->setMinTPChits(25);
0296   kfparticle->setMinMVTXhits(1);
0297   kfparticle->setMinINTThits(0);
0298 
0299   //Vertex parameters
0300   kfparticle->setMaximumVertexchi2nDOF(20);
0301   kfparticle->setMaximumDaughterDCA(0.5);
0302   kfparticle->setMaximumDaughterDCA_XY(100);
0303 
0304   //Parent parameters
0305   kfparticle->setMotherPT(0);
0306   kfparticle->setMinimumMass(1.08);
0307   kfparticle->setMaximumMass(1.15);
0308   kfparticle->setMaximumMotherVertexVolume(0.1);
0309 
0310   kfparticle->setOutputName(ppi_output_reco_file);
0311 
0312   se->registerSubsystem(kfparticle);
0313 
0314   QAKFParticle *kfpqa = new QAKFParticle("QAKFParticle_Lambda0","Lambda0",1.08,1.15);
0315   kfpqa->setKFParticleNodeName(ppi_reconstruction_name);
0316   se->registerSubsystem(kfpqa);
0317 }
0318 
0319 void reconstruct_Kpi_mass()
0320 {
0321   Fun4AllServer *se = Fun4AllServer::instance();
0322 
0323   KFParticle_sPHENIX *kfparticle = new KFParticle_sPHENIX(Kpi_reconstruction_name);
0324   kfparticle->Verbosity(0);
0325 
0326   kfparticle->setDecayDescriptor(Kpi_decay_descriptor);
0327 
0328   //kfparticle->extraolateTracksToSV(extraolate_tracks_to_secondary_vertex);
0329 
0330   kfparticle->saveOutput(save_kfpntuple);
0331 
0332   kfparticle->usePID(use_pid);
0333   kfparticle->setPIDacceptFraction(pid_frac);
0334   kfparticle->get_dEdx_info();
0335   kfparticle->dontUseGlobalVertex(dont_use_global_vertex);
0336   kfparticle->requireTrackVertexBunchCrossingMatch(require_track_and_vertex_match);
0337   kfparticle->getAllPVInfo(save_all_vtx_info);
0338   kfparticle->allowZeroMassTracks();
0339   kfparticle->use2Dmatching(use_2D_matching);
0340   kfparticle->getTriggerInfo(get_trigger_info);
0341   kfparticle->getDetectorInfo(get_detector_info);
0342   kfparticle->get_dEdx_info(get_dEdx_info);
0343   kfparticle->saveDST(save_tracks_to_DST);
0344   kfparticle->setContainerName(Kpi_reconstruction_name);
0345   kfparticle->saveParticleContainer(true);
0346   kfparticle->magFieldFile("FIELDMAP_TRACKING");
0347 
0348   //PV to SV cuts
0349   kfparticle->constrainToPrimaryVertex();
0350   //kfparticle->setMotherIPchi2(100);
0351   kfparticle->setMotherIPchi2(FLT_MAX);
0352   //kfparticle->setMotherIP(100);
0353   //kfparticle->setMotherIP_XY(0.02);
0354   kfparticle->setFlightDistancechi2(-1.);
0355   kfparticle->setMinDIRA(0.95);
0356   kfparticle->setMinDIRA_XY(-1.1);
0357   kfparticle->setDecayLengthRange(0., FLT_MAX);
0358   kfparticle->setDecayLengthRange_XY(-10., FLT_MAX);
0359   kfparticle->setDecayTimeRange_XY(-10000, FLT_MAX);
0360   kfparticle->setDecayTimeRange(-10000, FLT_MAX);
0361   kfparticle->setMinDecayTimeSignificance(-1e5);
0362   kfparticle->setMinDecayLengthSignificance(-1e5);
0363   kfparticle->setMinDecayLengthSignificance_XY(-1e5);
0364 
0365   //Track parameters
0366   kfparticle->setMinimumTrackPT(0.0);
0367   kfparticle->setMinimumTrackIPchi2(-1.);
0368   kfparticle->setMinimumTrackIPchi2_XY(-1.);
0369   kfparticle->setMinimumTrackIP(-1.);
0370   kfparticle->setMinimumTrackIP_XY(0.005);
0371   kfparticle->setMaximumTrackchi2nDOF(300.);
0372   kfparticle->setMinTPChits(20);
0373   kfparticle->setMinMVTXhits(1);
0374   kfparticle->setMinINTThits(1);
0375 
0376   //Vertex parameters
0377   kfparticle->setMaximumVertexchi2nDOF(20);
0378   kfparticle->setMaximumDaughterDCA(0.1);
0379   kfparticle->setMaximumDaughterDCA_XY(100); //5 mm
0380 
0381   //Parent parameters
0382   kfparticle->setMotherPT(0.0);
0383   kfparticle->setMinimumMass(1.75);
0384   kfparticle->setMaximumMass(1.95);
0385   kfparticle->setMaximumMotherVertexVolume(0.1);
0386 
0387   kfparticle->setOutputName(Kpi_output_reco_file);
0388 
0389   se->registerSubsystem(kfparticle);
0390 
0391   QAKFParticle *kfpqa = new QAKFParticle("QAKFParticle_D0","D0",1.75,1.95);
0392   kfpqa->setKFParticleNodeName(Kpi_reconstruction_name);
0393   se->registerSubsystem(kfpqa);
0394 }
0395 
0396 void reconstruct_ee_mass()
0397 {
0398   Fun4AllServer *se = Fun4AllServer::instance();
0399 
0400   KFParticle_sPHENIX *kfparticle = new KFParticle_sPHENIX(ee_reconstruction_name);
0401 
0402   kfparticle->setDecayDescriptor(ee_decay_descriptor);
0403 
0404   kfparticle->extraolateTracksToSV(extraolate_tracks_to_secondary_vertex);
0405 
0406   kfparticle->saveOutput(save_kfpntuple);
0407 
0408   //kfparticle->usePID(use_pid);
0409   //kfparticle->setPIDacceptFraction(pid_frac);
0410   kfparticle->dontUseGlobalVertex(false);
0411   kfparticle->requireTrackVertexBunchCrossingMatch(false);
0412   kfparticle->getAllPVInfo(false);
0413   kfparticle->allowZeroMassTracks();
0414   kfparticle->use2Dmatching(use_2D_matching);
0415   kfparticle->getTriggerInfo(get_trigger_info);
0416   kfparticle->getDetectorInfo(get_detector_info);
0417   kfparticle->get_dEdx_info(get_dEdx_info);
0418   kfparticle->getCaloInfo(get_calo_info);
0419   kfparticle->saveDST(save_tracks_to_DST);
0420   kfparticle->setContainerName(ee_reconstruction_name);
0421   kfparticle->saveParticleContainer(true);
0422   kfparticle->magFieldFile("FIELDMAP_TRACKING");
0423 
0424   //PV to SV cuts
0425   kfparticle->constrainToPrimaryVertex();
0426   kfparticle->setMotherIPchi2(FLT_MAX);
0427   kfparticle->setFlightDistancechi2(-1.);
0428   kfparticle->setMinDIRA(-1.1);
0429   kfparticle->setMinDIRA_XY(-1.1);
0430   kfparticle->setDecayLengthRange(0., FLT_MAX);
0431   kfparticle->setDecayLengthRange_XY(-10000, FLT_MAX);
0432   kfparticle->setDecayTimeRange_XY(-10000, FLT_MAX);
0433   kfparticle->setDecayTimeRange(-10000, FLT_MAX);
0434   kfparticle->setMinDecayTimeSignificance(-1e5);
0435   kfparticle->setMinDecayLengthSignificance(-1e5);
0436   kfparticle->setMinDecayLengthSignificance_XY(-1e5);
0437 
0438   //Track parameters
0439   kfparticle->bunchCrossingZeroOnly(true);
0440   kfparticle->setMinimumTrackPT(0.2);
0441   kfparticle->setMaximumTrackPTchi2(FLT_MAX);
0442   kfparticle->setMinimumTrackIPchi2(-1.);
0443   kfparticle->setMinimumTrackIPchi2_XY(-1.);
0444   kfparticle->setMinimumTrackIP(-1.);
0445   kfparticle->setMinimumTrackIP_XY(-100.);
0446   kfparticle->setMaximumTrackchi2nDOF(300.);
0447   kfparticle->setMinMVTXhits(0);
0448   kfparticle->setMinINTThits(0);
0449   kfparticle->setMinTPChits(25);
0450 
0451   //Track-Calo matching
0452   kfparticle->set_emcal_radius_user(cemc_proj_radius);
0453   //narrow window
0454   kfparticle->set_dphi_cut_low(-0.02); //rad
0455   kfparticle->set_dphi_cut_high(0.09); //rad
0456   kfparticle->set_dz_cut_low(-4); //cm
0457   kfparticle->set_dz_cut_high(4); //cm
0458   //loose window
0459   /*
0460   kfparticle->set_dphi_cut_low(-0.2); //rad
0461   kfparticle->set_dphi_cut_high(0.2); //rad
0462   kfparticle->set_dz_cut_low(-10); //cm
0463   kfparticle->set_dz_cut_high(10); //cm
0464   */
0465   kfparticle->set_emcal_e_low_cut(0.2); //GeV
0466   kfparticle->requireTrackEMCalMatch(true);
0467 
0468   //Vertex parameters
0469   kfparticle->setMaximumVertexchi2nDOF(FLT_MAX);
0470   kfparticle->setMaximumDaughterDCA(0.5);
0471   kfparticle->setMaximumDaughterDCA_XY(100);
0472 
0473   //Parent parameters
0474   kfparticle->setMotherPT(0);
0475   kfparticle->setMinimumMass(0.0);
0476   kfparticle->setMaximumMass(0.1);
0477   kfparticle->setMaximumMotherVertexVolume(0.1);
0478 
0479   kfparticle->setOutputName(ee_output_reco_file);
0480 
0481   se->registerSubsystem(kfparticle);
0482 
0483   QAKFParticle *kfpqa = new QAKFParticle("QAKFParticle_gamma","gamma",0.0,0.1);
0484   kfpqa->setKFParticleNodeName(ee_reconstruction_name);
0485   kfpqa->Verbosity(VERBOSITY_HF);
0486   se->registerSubsystem(kfpqa);
0487 }
0488 
0489 //adding xi and omega
0490 void reconstruct_Lambdapi_mass()
0491 {
0492   Fun4AllServer *se = Fun4AllServer::instance();
0493 
0494   KFParticle_sPHENIX *kfparticle = new KFParticle_sPHENIX(Lambdapi_reconstruction_name);
0495   kfparticle->Verbosity(VERBOSITY_HF);
0496 
0497   kfparticle->setDecayDescriptor(Lambdapi_decay_descriptor);
0498 
0499   kfparticle->usePID(use_pid);
0500   //kfparticle->setPIDacceptFraction(pid_frac);
0501   kfparticle->requireBunchCrossingMatch(false); // new setting
0502   kfparticle->dontUseGlobalVertex(dont_use_global_vertex);
0503   kfparticle->requireTrackVertexBunchCrossingMatch(require_track_and_vertex_match);
0504   kfparticle->getAllPVInfo(save_all_vtx_info);
0505   kfparticle->allowZeroMassTracks();
0506   kfparticle->use2Dmatching(use_2D_matching);
0507   kfparticle->getTriggerInfo(get_trigger_info);
0508   kfparticle->getDetectorInfo(get_detector_info);
0509   kfparticle->saveDST(save_tracks_to_DST);
0510   kfparticle->setContainerName(Lambdapi_reconstruction_name);
0511   kfparticle->magFieldFile("FIELDMAP_TRACKING");
0512 
0513   //PV to SV cuts
0514   kfparticle->constrainToPrimaryVertex(true);
0515   kfparticle->setMotherIPchi2(100);
0516   kfparticle->setFlightDistancechi2(-1.);
0517   kfparticle->setMinDIRA(0.8); // originally -1.1
0518   kfparticle->setDecayLengthRange(-FLT_MAX, FLT_MAX); //originally -FLT_MAX, FLT_MAX
0519   kfparticle->setDecayLengthRange_XY(0.01, FLT_MAX); //originally -FLT_MAX, FLT_MAX
0520 
0521   //Track parameters
0522   kfparticle->setMinimumTrackPT(0.1);
0523   kfparticle->setMaximumTrackchi2nDOF(400.);
0524   kfparticle->setMinTPChits(20);
0525   kfparticle->setMinMVTXhits(0); // originally 1 
0526   kfparticle->setMinINTThits(0); // originally 1 
0527   kfparticle->setMinimumTrackIP_XY(-100.);
0528   kfparticle->setMinimumTrackIPchi2_XY(-1000.);
0529   kfparticle->setMinimumTrackIP(-100.);
0530   kfparticle->setMinimumTrackIPchi2(-1000.);
0531 
0532   //Vertex parameters
0533   kfparticle->setMaximumVertexchi2nDOF(50);
0534   kfparticle->setMaximumDaughterDCA(0.5); //1 mm
0535 
0536   //Parent parameters
0537   kfparticle->setMotherPT(0);
0538   kfparticle->setMinimumMass(1.2); //Check mass ranges
0539   kfparticle->setMaximumMass(1.4); // originally 1.5
0540   kfparticle->setMaximumMotherVertexVolume(0.1);
0541 
0542   //Intermediate parameters
0543   kfparticle->constrainIntermediateMasses(constrain_lambda_mass);
0544 
0545   std::vector<std::pair<float, float>> intermediate_mass_range;
0546   intermediate_mass_range.push_back(make_pair(1.08, 1.15));
0547   kfparticle->setIntermediateMassRange(intermediate_mass_range);
0548 
0549   std::vector<float> intermediate_min_pt = {0.0};
0550   kfparticle->setIntermediateMinPT(intermediate_min_pt);
0551 
0552   std::vector<std::pair<float, float>> intermediate_IP_range;
0553   intermediate_IP_range.push_back(make_pair(-1., FLT_MAX));
0554   kfparticle->setIntermediateIPRange(intermediate_IP_range);
0555 
0556   std::vector<std::pair<float, float>> intermediate_IPchi2_range;
0557   intermediate_IPchi2_range.push_back(make_pair(-1., FLT_MAX));
0558   kfparticle->setIntermediateIPchi2Range(intermediate_IPchi2_range);
0559 
0560   std::vector<float> intermediate_min_dira = {0.8}; // originally 0.0
0561   kfparticle->setIntermediateMinDIRA(intermediate_min_dira);
0562 
0563   std::vector<float> intermediate_min_FDchi2 = {-1.};
0564   kfparticle->setIntermediateMinFDchi2(intermediate_min_FDchi2);
0565 
0566   std::vector<float> intermediate_max_vertex_vol = {1.1};
0567   kfparticle->setIntermediateMaxVertexVolume(intermediate_max_vertex_vol);
0568 
0569   std::vector<std::pair<float, float>> intermediate_IPxy_range;
0570   intermediate_IPxy_range.push_back(make_pair(-1., FLT_MAX));
0571   kfparticle->setIntermediateIPRange_XY(intermediate_IPxy_range);
0572   
0573   std::vector<std::pair<float, float>> intermediate_IPchi2xy_range;
0574   intermediate_IPchi2xy_range.push_back(make_pair(-1., FLT_MAX));
0575   kfparticle->setIntermediateIPchi2Range_XY(intermediate_IPchi2xy_range);
0576   
0577   kfparticle->setOutputName(Lambdapi_output_reco_file);
0578 
0579   se->registerSubsystem(kfparticle);
0580 }
0581 
0582 void reconstruct_LambdaK_mass()
0583 {
0584   Fun4AllServer *se = Fun4AllServer::instance();
0585 
0586   KFParticle_sPHENIX *kfparticle = new KFParticle_sPHENIX(LambdaK_reconstruction_name);
0587   kfparticle->Verbosity(VERBOSITY_HF);
0588 
0589   kfparticle->setDecayDescriptor(LambdaK_decay_descriptor);
0590 
0591   kfparticle->usePID(use_pid);
0592   kfparticle->setPIDacceptFraction(pid_frac);
0593   kfparticle->dontUseGlobalVertex(dont_use_global_vertex);
0594   kfparticle->requireTrackVertexBunchCrossingMatch(require_track_and_vertex_match);
0595   kfparticle->getAllPVInfo(save_all_vtx_info);
0596   kfparticle->allowZeroMassTracks();
0597   kfparticle->use2Dmatching(use_2D_matching);
0598   kfparticle->getTriggerInfo(get_trigger_info);
0599   kfparticle->getDetectorInfo(get_detector_info);
0600   kfparticle->saveDST(save_tracks_to_DST);
0601   kfparticle->setContainerName(LambdaK_reconstruction_name);
0602   kfparticle->magFieldFile("FIELDMAP_TRACKING");
0603 
0604   //PV to SV cuts
0605   kfparticle->constrainToPrimaryVertex(true);
0606   kfparticle->setMotherIPchi2(100);
0607   kfparticle->setFlightDistancechi2(-1.);
0608   kfparticle->setMinDIRA(-1.1);
0609   kfparticle->setDecayLengthRange(-1*FLT_MAX, FLT_MAX);
0610 
0611   //Track parameters
0612   kfparticle->setMinimumTrackPT(0.1);
0613   kfparticle->setMinimumTrackIPchi2(-1.);
0614   kfparticle->setMinimumTrackIP(-1.);
0615   kfparticle->setMaximumTrackchi2nDOF(400.);
0616   kfparticle->setMinTPChits(20);
0617 
0618   //Vertex parameters
0619   kfparticle->setMaximumVertexchi2nDOF(50);
0620   kfparticle->setMaximumDaughterDCA(0.75); //1 mm
0621 
0622   //Parent parameters
0623   kfparticle->setMotherPT(0);
0624   kfparticle->setMinimumMass(1.5); //Check mass ranges
0625   kfparticle->setMaximumMass(1.8);
0626   kfparticle->setMaximumMotherVertexVolume(0.1);
0627 
0628   //Intermediate parameters
0629   kfparticle->constrainIntermediateMasses(constrain_lambda_mass);
0630 
0631   std::vector<std::pair<float, float>> intermediate_mass_range;
0632   intermediate_mass_range.push_back(make_pair(1.08, 1.15));
0633   kfparticle->setIntermediateMassRange(intermediate_mass_range);
0634 
0635   std::vector<float> intermediate_min_pt = {0.0};
0636   kfparticle->setIntermediateMinPT(intermediate_min_pt);
0637 
0638   std::vector<std::pair<float, float>> intermediate_IP_range;
0639   intermediate_IP_range.push_back(make_pair(-1., FLT_MAX));
0640   kfparticle->setIntermediateIPRange(intermediate_IP_range);
0641 
0642   std::vector<std::pair<float, float>> intermediate_IPchi2_range;
0643   intermediate_IPchi2_range.push_back(make_pair(-1., FLT_MAX));
0644   kfparticle->setIntermediateIPchi2Range(intermediate_IPchi2_range);
0645 
0646   std::vector<float> intermediate_min_dira = {-1.1};
0647   kfparticle->setIntermediateMinDIRA(intermediate_min_dira);
0648 
0649   std::vector<float> intermediate_min_FDchi2 = {-1.};
0650   kfparticle->setIntermediateMinFDchi2(intermediate_min_FDchi2);
0651 
0652   std::vector<float> intermediate_max_vertex_vol = {1.1};
0653   kfparticle->setIntermediateMaxVertexVolume(intermediate_max_vertex_vol);
0654 
0655   std::vector<std::pair<float, float>> intermediate_IPxy_range;
0656   intermediate_IPxy_range.push_back(make_pair(-1., FLT_MAX));
0657   kfparticle->setIntermediateIPRange_XY(intermediate_IPxy_range);
0658   
0659   std::vector<std::pair<float, float>> intermediate_IPchi2xy_range;
0660   intermediate_IPchi2xy_range.push_back(make_pair(-1., FLT_MAX));
0661   kfparticle->setIntermediateIPchi2Range_XY(intermediate_IPchi2xy_range);
0662 
0663   kfparticle->setOutputName(LambdaK_output_reco_file);
0664 
0665   se->registerSubsystem(kfparticle);
0666 }
0667 
0668 void end_kfparticle(std::string full_file_name, std::string final_path)
0669 {
0670   ifstream file(full_file_name.c_str());
0671   if (file.good())
0672   {
0673     string moveOutput = "mv " + full_file_name + " " + final_path;
0674     system(moveOutput.c_str());
0675   }
0676 }