Back to home page

sPhenix code displayed by LXR

 
 

    


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

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 //#include <dstarreco/DstarReco.h>
0018 
0019 R__LOAD_LIBRARY(libkfparticle_sphenix.so)
0020 R__LOAD_LIBRARY(libcalotrigger.so)
0021 //R__LOAD_LIBRARY(libDstarReco.so)
0022 R__LOAD_LIBRARY(libkfparticleqa.so)
0023 
0024 namespace HeavyFlavorReco
0025 {
0026   int VERBOSITY_HF = 1;
0027 
0028   std::string output_dir = "/sphenix/tg/tg01/hf/rosstom/HF-analysis/"; //Top dir of where the output nTuples will be written
0029   std::string kfp_header = "outputKFParticle_";
0030   std::string processing_folder = "inReconstruction/";
0031   std::string trailer = ".root";
0032 
0033   bool run_Lambdapi_reco = true;
0034 
0035   std::string Lambdapi_decay_descriptor = "[Xi- -> {Lambda0 -> proton^+ pi^-} pi^-]cc"; //See twiki on how to set this
0036   std::string Lambdapi_reconstruction_name = "Lambdapi_reco"; //Used for naming output folder, file and node
0037   std::string Lambdapi_output_reco_file;
0038   std::string Lambdapi_output_dir;
0039 
0040   bool truthMatch = true;  
0041   bool save_kfpntuple = true;
0042   bool use_pid = false;
0043   bool save_tracks_to_DST = false;
0044   bool dont_use_global_vertex = true;
0045   bool require_track_and_vertex_match = true;
0046   //bool require_track_and_vertex_match = false;
0047   bool save_all_vtx_info = true;
0048   bool constrain_phi_mass = true;
0049   bool use_2D_matching = false;
0050   bool get_trigger_info = false;
0051   bool get_detector_info = true;
0052   bool get_dEdx_info = false; 
0053   bool get_calo_info = false;
0054   float pid_frac = 0.6;
0055   float cemc_proj_radius = 102.9; //Virgile recommendation according to DetailedCalorimeterGeometry
0056   bool constrain_lambda_mass = true;
0057   bool extraolate_tracks_to_secondary_vertex = true; // Set to false to ensure the pT map is accurate for asymmetry study  
0058 };  // namespace HeavyFlavorReco'
0059 
0060 using namespace HeavyFlavorReco;
0061 
0062 void init_kfp_dependencies()
0063 {
0064   //dE/dx needs TRKR_CLUSTER and CYLINDERCELLGEOM_SVTX which need to be in the DST or loaded from a geo file
0065   Fun4AllServer *se = Fun4AllServer::instance();
0066 
0067   GlobalVertexReco* gblvertex = new GlobalVertexReco();
0068   gblvertex->Verbosity(VERBOSITY_HF);
0069   se->registerSubsystem(gblvertex);
0070 
0071   if (get_trigger_info)
0072   {
0073     TriggerRunInfoReco *triggerruninforeco = new TriggerRunInfoReco();
0074     se->registerSubsystem(triggerruninforeco);
0075   }
0076 }
0077 
0078 void create_hf_directories(std::string reconstruction_name, std::string &final_output_dir, std::string &output_reco_file, std::string ID)
0079 {
0080   std::string output_file_name = kfp_header + reconstruction_name + "_" + ID + trailer;
0081   final_output_dir = output_dir + reconstruction_name + "/";
0082   std::string output_reco_dir = final_output_dir + processing_folder;
0083   output_reco_file = output_reco_dir + output_file_name;
0084 
0085   std::string makeDirectory = "mkdir -p " + output_reco_dir;
0086   system(makeDirectory.c_str());
0087 }
0088 
0089 void reconstruct_Lambdapi_mass()
0090 {
0091   Fun4AllServer *se = Fun4AllServer::instance();
0092 
0093   KFParticle_sPHENIX *kfparticle = new KFParticle_sPHENIX(Lambdapi_reconstruction_name);
0094   kfparticle->Verbosity(VERBOSITY_HF);
0095 
0096   kfparticle->setDecayDescriptor(Lambdapi_decay_descriptor);
0097   //kfparticle->setTrackMapNodeName("HFSelected_SvtxTrackMap");
0098 
0099   kfparticle->saveOutput(save_kfpntuple);
0100 
0101   kfparticle->doTruthMatching(truthMatch);
0102   kfparticle->usePID(use_pid);
0103   //kfparticle->setPIDacceptFraction(pid_frac);
0104   kfparticle->dontUseGlobalVertex(dont_use_global_vertex);
0105   kfparticle->requireTrackVertexBunchCrossingMatch(require_track_and_vertex_match);
0106   kfparticle->getAllPVInfo(save_all_vtx_info);
0107   kfparticle->allowZeroMassTracks();
0108   kfparticle->use2Dmatching(use_2D_matching);
0109   kfparticle->getTriggerInfo(get_trigger_info);
0110   kfparticle->getDetectorInfo(get_detector_info);
0111   kfparticle->saveDST(save_tracks_to_DST);
0112   kfparticle->setContainerName(Lambdapi_reconstruction_name);
0113   kfparticle->magFieldFile("FIELDMAP_TRACKING");
0114 
0115   //PV to SV cuts
0116   kfparticle->constrainToPrimaryVertex(true);
0117   //kfparticle->constrainToPrimaryVertex(false);
0118   //kfparticle->useFakePrimaryVertex(true);
0119   //kfparticle->useTruthPrimaryVertex(true);
0120   kfparticle->setMotherIPchi2(1000);
0121   kfparticle->setFlightDistancechi2(-1.);
0122   kfparticle->setMinDIRA(-1.1);
0123   kfparticle->setDecayLengthRange(-1*FLT_MAX, FLT_MAX);
0124 
0125   //Track parameters
0126   kfparticle->setMinimumTrackPT(0.0);
0127   kfparticle->setMaximumTrackPTchi2(FLT_MAX);
0128   kfparticle->setMaximumTrackchi2nDOF(FLT_MAX);
0129   kfparticle->setMinTPChits(0); // 20
0130   kfparticle->setMinMVTXhits(0); // 1
0131   kfparticle->setMinINTThits(0); // 1
0132   kfparticle->setMinimumTrackIP_XY(-100.);
0133   kfparticle->setMinimumTrackIPchi2_XY(-1000.);
0134   kfparticle->setMinimumTrackIP(-100.);
0135   kfparticle->setMinimumTrackIPchi2(-1000.);
0136 
0137   //Vertex parameters
0138   kfparticle->setMaximumVertexchi2nDOF(FLT_MAX);
0139   kfparticle->setMaximumDaughterDCA(5); //1 mm
0140   kfparticle->setMaximumDaughterDCA_XY(5);
0141 
0142   //Parent parameters
0143   kfparticle->setMotherPT(0);
0144   kfparticle->setMinimumMass(1.2); //Check mass ranges
0145   kfparticle->setMaximumMass(1.5);
0146   kfparticle->setMaximumMotherVertexVolume(10);
0147 
0148   //Intermediate parameters
0149   kfparticle->constrainIntermediateMasses(constrain_lambda_mass);
0150 
0151   std::vector<std::pair<float, float>> intermediate_mass_range;
0152   intermediate_mass_range.push_back(make_pair(1.0, 2.0));
0153   kfparticle->setIntermediateMassRange(intermediate_mass_range);
0154 
0155   std::vector<float> intermediate_min_dira = {-1.1};
0156   kfparticle->setIntermediateMinDIRA(intermediate_min_dira);
0157 
0158   std::vector<float> intermediate_min_pt = {0.0};
0159   kfparticle->setIntermediateMinPT(intermediate_min_pt);
0160 
0161   std::vector<std::pair<float, float>> intermediate_IP_range;
0162   intermediate_IP_range.push_back(make_pair(-1., FLT_MAX));
0163   kfparticle->setIntermediateIPRange(intermediate_IP_range);
0164 
0165   std::vector<std::pair<float, float>> intermediate_IPchi2_range;
0166   intermediate_IPchi2_range.push_back(make_pair(-1., FLT_MAX));
0167   kfparticle->setIntermediateIPchi2Range(intermediate_IPchi2_range);
0168 
0169   std::vector<float> intermediate_min_FDchi2 = {-1.};
0170   kfparticle->setIntermediateMinFDchi2(intermediate_min_FDchi2);
0171 
0172   std::vector<float> intermediate_max_vertex_vol = {1.1};
0173   kfparticle->setIntermediateMaxVertexVolume(intermediate_max_vertex_vol);
0174 
0175   std::vector<std::pair<float, float>> intermediate_IPxy_range;
0176   intermediate_IPxy_range.push_back(make_pair(-1., FLT_MAX));
0177   kfparticle->setIntermediateIPRange_XY(intermediate_IPxy_range);
0178 
0179   std::vector<std::pair<float, float>> intermediate_IPchi2xy_range;
0180   intermediate_IPchi2xy_range.push_back(make_pair(-1., FLT_MAX));
0181   kfparticle->setIntermediateIPchi2Range_XY(intermediate_IPchi2xy_range);
0182 
0183   kfparticle->setOutputName(Lambdapi_output_reco_file);
0184 
0185   se->registerSubsystem(kfparticle);
0186 }  
0187 
0188 void end_kfparticle(std::string full_file_name, std::string final_path)
0189 {
0190   ifstream file(full_file_name.c_str());
0191   if (file.good())
0192   {
0193     string moveOutput = "mv " + full_file_name + " " + final_path;
0194     system(moveOutput.c_str());
0195   }
0196 }