Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-12-17 09:24:07

0001 /*
0002  * This macro shows a minimum working example of running the tracking
0003  * hit unpackers with some basic seeding algorithms to try to put together
0004  * tracks. There are some analysis modules run at the end which package
0005  * hits, clusters, and clusters on tracks into trees for analysis.
0006  */
0007 
0008 // leave the GlobalVariables.C at the beginning, an empty line afterwards
0009 // protects its position against reshuffling by clang-format
0010 #include <GlobalVariables.C>
0011 
0012 #include <G4_ActsGeom.C>
0013 #include <G4_Global.C>
0014 #include <G4_Magnet.C>
0015 #include <G4_Mbd.C>
0016 #include <QA.C>
0017 #include <Trkr_Clustering.C>
0018 #include <Trkr_LaserClustering.C>
0019 #include <Trkr_Reco.C>
0020 #include <Trkr_RecoInit.C>
0021 #include <Trkr_TpcReadoutInit.C>
0022 
0023 #include <cdbobjects/CDBTTree.h>
0024 
0025 #include <tpccalib/PHTpcResiduals.h>
0026 
0027 #include <mvtxrawhitqa/MvtxRawHitQA.h>
0028 
0029 #include <inttrawhitqa/InttRawHitQA.h>
0030 
0031 #include <trackingqa/InttClusterQA.h>
0032 #include <trackingqa/MicromegasClusterQA.h>
0033 #include <trackingqa/MvtxClusterQA.h>
0034 #include <trackingqa/SiliconSeedsQA.h>
0035 #include <trackingqa/TpcClusterQA.h>
0036 #include <trackingqa/TpcSeedsQA.h>
0037 #include <trackingqa/TpcSiliconQA.h>
0038 
0039 #include <tpcqa/TpcRawHitQA.h>
0040 
0041 #include <trackingdiagnostics/KshortReconstruction.h>
0042 #include <trackingdiagnostics/TrackResiduals.h>
0043 #include <trackingdiagnostics/TrkrNtuplizer.h>
0044 
0045 #include <kfparticle_sphenix/KFParticle_sPHENIX.h>
0046 
0047 #include <ffamodules/CDBInterface.h>
0048 #include <ffamodules/FlagHandler.h>
0049 
0050 #include <fun4all/Fun4AllDstInputManager.h>
0051 #include <fun4all/Fun4AllDstOutputManager.h>
0052 #include <fun4all/Fun4AllInputManager.h>
0053 #include <fun4all/Fun4AllOutputManager.h>
0054 #include <fun4all/Fun4AllRunNodeInputManager.h>
0055 #include <fun4all/Fun4AllServer.h>
0056 #include <fun4all/Fun4AllUtils.h>
0057 
0058 #include <phool/recoConsts.h>
0059 
0060 R__LOAD_LIBRARY(libkfparticle_sphenix.so)
0061 R__LOAD_LIBRARY(libfun4all.so)
0062 R__LOAD_LIBRARY(libffamodules.so)
0063 R__LOAD_LIBRARY(libphool.so)
0064 R__LOAD_LIBRARY(libcdbobjects.so)
0065 R__LOAD_LIBRARY(libmvtx.so)
0066 R__LOAD_LIBRARY(libintt.so)
0067 R__LOAD_LIBRARY(libtpc.so)
0068 R__LOAD_LIBRARY(libmicromegas.so)
0069 R__LOAD_LIBRARY(libTrackingDiagnostics.so)
0070 R__LOAD_LIBRARY(libtrackingqa.so)
0071 R__LOAD_LIBRARY(libtpcqa.so)
0072 
0073 namespace HeavyFlavorReco
0074 {
0075   int VERBOSITY = 0;
0076 
0077   std::string output_dir = "./";  // Top dir of where the output nTuples will be written
0078   std::string kfp_header = "outputKFParticle_";
0079   std::string processing_folder = "inReconstruction/";
0080   std::string trailer = ".root";
0081 
0082   std::string pipi_decay_descriptor = "K_S0 -> pi^+ pi^-";  // See twiki on how to set this
0083   std::string pipi_reconstruction_name = "pipi_reco";       // Used for naming output folder, file and node
0084   std::string pipi_output_reco_file;
0085   std::string pipi_output_dir;
0086 
0087   std::string ppi_decay_descriptor = "[Lambda0 -> proton^+ pi^-]cc";  // See twiki on how to set this
0088   std::string ppi_reconstruction_name = "ppi_reco";                   // Used for naming output folder, file and node
0089   std::string ppi_output_reco_file;
0090   std::string ppi_output_dir;
0091 
0092   bool save_tracks_to_DST = false;
0093   bool dont_use_global_vertex = true;
0094   bool require_track_and_vertex_match = true;
0095   bool save_all_vtx_info = true;
0096   bool constrain_phi_mass = false;
0097   bool constrain_lambda_mass = false;
0098   bool constrain_D_mass = false;
0099   bool use_2D_matching = false;
0100   bool get_trigger_info = true;
0101   bool get_detector_info = true;
0102   bool get_dEdx_info = true;
0103   bool constrain_to_primary_vertex = true;
0104   bool use_pid = true;
0105   float pid_frac = 0.4;
0106 };  // namespace HeavyFlavorReco
0107 
0108 //using namespace HeavyFlavorReco;
0109 
0110 void create_hf_directories(const std::string& reconstruction_name, std::string &final_output_dir, std::string &output_reco_file)
0111 {
0112   std::string output_file_name = HeavyFlavorReco::kfp_header + reconstruction_name + HeavyFlavorReco::trailer;
0113   final_output_dir = HeavyFlavorReco::output_dir + reconstruction_name + "/";
0114   std::string output_reco_dir = final_output_dir + HeavyFlavorReco::processing_folder;
0115   output_reco_file = output_reco_dir + output_file_name;
0116 
0117   std::string makeDirectory = "mkdir -p " + output_reco_dir;
0118   system(makeDirectory.c_str());
0119 }
0120 
0121 void end_kfparticle(const std::string& full_file_name, const std::string& final_path)
0122 {
0123   std::ifstream file(full_file_name.c_str());
0124   if (file.good())
0125   {
0126     std::string moveOutput = "mv " + full_file_name + " " + final_path;
0127     system(moveOutput.c_str());
0128   }
0129 }
0130 
0131 void Fun4All_raw_hit_KFP(
0132     const int nEvents = 10,
0133     const std::string& filelist = "filelist.list",
0134     const std::string& outfilename = "clusters_seeds",
0135     const bool convertSeeds = false,
0136     const int nSkip = 0,
0137     const bool doKFParticle = false)
0138 {
0139   auto *se = Fun4AllServer::instance();
0140   se->Verbosity(1);
0141   auto *rc = recoConsts::instance();
0142 
0143   // input manager for QM production raw hit DST file
0144   std::ifstream ifs(filelist);
0145   std::string filepath;
0146 
0147   int i = 0;
0148   int runnumber = std::numeric_limits<int>::quiet_NaN();
0149   int segment = std::numeric_limits<int>::quiet_NaN();
0150   
0151 
0152   while (std::getline(ifs, filepath))
0153   {
0154     std::cout << "Adding DST with filepath: " << filepath << std::endl;
0155     if (i == 0)
0156     {
0157       std::pair<int, int>
0158           runseg = Fun4AllUtils::GetRunSegment(filepath);
0159       runnumber = runseg.first;
0160       segment = runseg.second;
0161       rc->set_IntFlag("RUNNUMBER", runnumber);
0162       rc->set_uint64Flag("TIMESTAMP", runnumber);
0163     }
0164   
0165     std::string inputname = "InputManager" + std::to_string(i);
0166     auto *hitsin = new Fun4AllDstInputManager(inputname);
0167     hitsin->fileopen(filepath);
0168     se->registerInputManager(hitsin);
0169     i++;
0170   }
0171 
0172   rc->set_IntFlag("RUNNUMBER", runnumber);
0173   rc->set_IntFlag("RUNSEGMENT", segment);
0174 
0175   Enable::QA = false;
0176   Enable::CDB = true;
0177   rc->set_StringFlag("CDB_GLOBALTAG", "newcdbtag");
0178   rc->set_uint64Flag("TIMESTAMP", runnumber);
0179 
0180   std::stringstream nice_runnumber;
0181   nice_runnumber << std::setw(8) << std::setfill('0') << std::to_string(runnumber);
0182 
0183   int rounded_up = 100 * (std::ceil((float) runnumber / 100));
0184   std::stringstream nice_rounded_up;
0185   nice_rounded_up << std::setw(8) << std::setfill('0') << std::to_string(rounded_up);
0186 
0187   int rounded_down = 100 * (std::floor((float) runnumber / 100));
0188   std::stringstream nice_rounded_down;
0189   nice_rounded_down << std::setw(8) << std::setfill('0') << std::to_string(rounded_down);
0190 
0191   std::stringstream nice_segment;
0192   nice_segment << std::setw(5) << std::setfill('0') << std::to_string(segment);
0193 
0194   std::stringstream nice_skip;
0195   nice_skip << std::setw(5) << std::setfill('0') << std::to_string(nSkip);
0196 
0197   HeavyFlavorReco::output_dir = "./";  // Top dir of where the output nTuples will be written
0198   HeavyFlavorReco::trailer = "_" + nice_runnumber.str() + "_" + nice_segment.str() + "_" + nice_skip.str() + ".root";
0199 
0200   if (doKFParticle)
0201   {
0202     create_hf_directories(HeavyFlavorReco::pipi_reconstruction_name, HeavyFlavorReco::pipi_output_dir, HeavyFlavorReco::pipi_output_reco_file);
0203     create_hf_directories(HeavyFlavorReco::ppi_reconstruction_name, HeavyFlavorReco::ppi_output_dir, HeavyFlavorReco::ppi_output_reco_file);
0204   }
0205 
0206   G4TRACKING::convert_seeds_to_svtxtracks = convertSeeds;
0207   std::cout << "Converting to seeds : " << G4TRACKING::convert_seeds_to_svtxtracks << std::endl;
0208 
0209   std::cout << " run: " << runnumber
0210             << " samples: " << TRACKING::reco_tpc_maxtime_sample
0211             << " pre: " << TRACKING::reco_tpc_time_presample
0212             << " vdrift: " << G4TPC::tpc_drift_velocity_reco
0213             << std::endl;
0214 
0215   TRACKING::pp_mode = true;
0216 
0217   // distortion calibration mode
0218   /*
0219    * set to true to enable residuals in the TPC with
0220    * TPC clusters not participating to the ACTS track fit
0221    */
0222 
0223   TString outfile = outfilename + "_" + runnumber + "-" + segment + ".root";
0224   std::string theOutfile = outfile.Data();
0225 
0226   FlagHandler *flag = new FlagHandler();
0227   se->registerSubsystem(flag);
0228 
0229   std::string geofile = CDBInterface::instance()->getUrl("Tracking_Geometry");
0230 
0231   Fun4AllRunNodeInputManager *ingeo = new Fun4AllRunNodeInputManager("GeoIn");
0232   ingeo->AddFile(geofile);
0233   se->registerInputManager(ingeo);
0234 
0235   TpcReadoutInit(runnumber);
0236   G4TPC::REJECT_LASER_EVENTS = true;
0237   G4TPC::ENABLE_MODULE_EDGE_CORRECTIONS = true;
0238   // Flag for running the tpc hit unpacker with zero suppression on
0239   TRACKING::tpc_zero_supp = true;
0240 
0241   // MVTX
0242   Enable::MVTX_APPLYMISALIGNMENT = true;
0243   ACTSGEOM::mvtx_applymisalignment = Enable::MVTX_APPLYMISALIGNMENT;
0244 
0245   // to turn on the default static corrections, enable the two lines below
0246   G4TPC::ENABLE_STATIC_CORRECTIONS = true;
0247   G4TPC::USE_PHI_AS_RAD_STATIC_CORRECTIONS = false;
0248 
0249   // to turn on the average corrections derived from simulation, enable the three lines below
0250   // note: these are designed to be used only if static corrections are also applied
0251   // G4TPC::ENABLE_AVERAGE_CORRECTIONS = true;
0252   // G4TPC::USE_PHI_AS_RAD_AVERAGE_CORRECTIONS = false;
0253   // G4TPC::average_correction_filename = std::string(getenv("CALIBRATIONROOT")) + "/distortion_maps/average_minus_static_distortion_inverted_10-new.root";
0254 
0255   G4MAGNET::magfield_rescale = 1;
0256 
0257   TrackingInit();
0258 
0259   for (int felix = 0; felix < 6; felix++)
0260   {
0261     Mvtx_HitUnpacking(std::to_string(felix));
0262   }
0263   for (int server = 0; server < 8; server++)
0264   {
0265     Intt_HitUnpacking(std::to_string(server));
0266   }
0267   std::ostringstream ebdcname;
0268   for (int ebdc = 0; ebdc < 24; ebdc++)
0269   {
0270     for (int endpoint = 0; endpoint < 2; endpoint++)
0271       {
0272         ebdcname.str("");
0273         if (ebdc < 10)
0274       {
0275         ebdcname << "0";
0276       }
0277         ebdcname << ebdc << "_" << endpoint;
0278         Tpc_HitUnpacking(ebdcname.str());
0279       }
0280   }
0281 
0282 
0283   Micromegas_HitUnpacking();
0284 
0285   Mvtx_Clustering();
0286 
0287   Intt_Clustering();
0288 
0289   Tpc_LaserEventIdentifying();
0290 
0291   auto *tpcclusterizer = new TpcClusterizer;
0292   tpcclusterizer->Verbosity(0);
0293   tpcclusterizer->set_do_hit_association(G4TPC::DO_HIT_ASSOCIATION);
0294   tpcclusterizer->set_rawdata_reco();
0295   tpcclusterizer->set_reject_event(G4TPC::REJECT_LASER_EVENTS);
0296   se->registerSubsystem(tpcclusterizer);
0297 
0298   Micromegas_Clustering();
0299 
0300   Reject_Laser_Events();
0301   /*
0302    * Begin Track Seeding
0303    */
0304   
0305   Tracking_Reco_TrackSeed_run2pp();
0306   Tracking_Reco_TrackMatching_run2pp();
0307   /*
0308    * Either converts seeds to tracks with a straight line/helix fit
0309    * or run the full Acts track kalman filter fit
0310    */
0311   if (G4TRACKING::convert_seeds_to_svtxtracks)
0312   {
0313     auto *converter = new TrackSeedTrackMapConverter;
0314     // Default set to full SvtxTrackSeeds. Can be set to
0315     // SiliconTrackSeedContainer or TpcTrackSeedContainer
0316     converter->setTrackSeedName("SvtxTrackSeedContainer");
0317     converter->setFieldMap(G4MAGNET::magfield_tracking);
0318     converter->Verbosity(0);
0319     se->registerSubsystem(converter);
0320   }
0321   else
0322   {
0323     auto *deltazcorr = new PHTpcDeltaZCorrection;
0324     deltazcorr->Verbosity(0);
0325     se->registerSubsystem(deltazcorr);
0326 
0327     // perform final track fit with ACTS
0328     auto *actsFit = new PHActsTrkFitter;
0329     actsFit->Verbosity(0);
0330     actsFit->commissioning(G4TRACKING::use_alignment);
0331     // in calibration mode, fit only Silicons and Micromegas hits
0332     actsFit->fitSiliconMMs(G4TRACKING::SC_CALIBMODE);
0333     actsFit->setUseMicromegas(G4TRACKING::SC_USE_MICROMEGAS);
0334     actsFit->set_pp_mode(TRACKING::pp_mode);
0335     actsFit->set_use_clustermover(true);  // default is true for now
0336     actsFit->useActsEvaluator(false);
0337     actsFit->useOutlierFinder(false);
0338     actsFit->setFieldMap(G4MAGNET::magfield_tracking);
0339     se->registerSubsystem(actsFit);
0340 
0341     auto *cleaner = new PHTrackCleaner();
0342     cleaner->Verbosity(0);
0343     cleaner->set_pp_mode(TRACKING::pp_mode);
0344     se->registerSubsystem(cleaner);
0345 
0346     if (G4TRACKING::SC_CALIBMODE)
0347     {
0348       /*
0349        * in calibration mode, calculate residuals between TPC and fitted tracks,
0350        * store in dedicated structure for distortion correction
0351        */
0352       auto *residuals = new PHTpcResiduals;
0353       const TString tpc_residoutfile = theOutfile + "_PhTpcResiduals.root";
0354       residuals->setOutputfile(tpc_residoutfile.Data());
0355       residuals->setUseMicromegas(G4TRACKING::SC_USE_MICROMEGAS);
0356 
0357       // matches Tony's analysis
0358       residuals->setMinPt(0.2);
0359 
0360       // reconstructed distortion grid size (phi, r, z)
0361       residuals->setGridDimensions(36, 48, 80);
0362       se->registerSubsystem(residuals);
0363     }
0364   }
0365 
0366   auto *finder = new PHSimpleVertexFinder;
0367   finder->Verbosity(0);
0368   finder->setDcaCut(0.5);
0369   finder->setTrackPtCut(0.3);
0370   finder->setBeamLineCut(1);
0371   finder->setTrackQualityCut(1000);
0372   finder->setNmvtxRequired(3);
0373   finder->setOutlierPairCut(0.1);
0374   se->registerSubsystem(finder);
0375 
0376   if (!G4TRACKING::convert_seeds_to_svtxtracks)
0377   {
0378     // Propagate track positions to the vertex position
0379     auto *vtxProp = new PHActsVertexPropagator;
0380     vtxProp->Verbosity(0);
0381     vtxProp->fieldMap(G4MAGNET::magfield_tracking);
0382     se->registerSubsystem(vtxProp);
0383   }
0384 
0385   TString residoutfile = theOutfile + "_resid.root";
0386   std::string residstring(residoutfile.Data());
0387 
0388   auto *resid = new TrackResiduals("TrackResiduals");
0389   resid->outfileName(residstring);
0390   resid->alignment(false);
0391   resid->vertexTree();
0392   //   // adjust track map name
0393   //   if(G4TRACKING::SC_CALIBMODE && !G4TRACKING::convert_seeds_to_svtxtracks)
0394   //   {
0395   //     resid->trackmapName("SvtxSiliconMMTrackMap");
0396   //     if( G4TRACKING::SC_USE_MICROMEGAS )
0397   //     { resid->set_doMicromegasOnly(true); }
0398   //   }
0399 
0400   //   resid->clusterTree();
0401   //   resid->hitTree();
0402   resid->convertSeeds(G4TRACKING::convert_seeds_to_svtxtracks);
0403 
0404   //   resid->Verbosity(0);
0405   // se->registerSubsystem(resid);
0406 
0407   // auto ntuplizer = new TrkrNtuplizer("TrkrNtuplizer");
0408   // se->registerSubsystem(ntuplizer);
0409 
0410   /*
0411     // To write an output DST
0412     TString dstfile = theOutfile;
0413    std::string theDSTFile = dstfile.Data();
0414    Fun4AllOutputManager *out = new Fun4AllDstOutputManager("DSTOUT", theDSTFile.c_str());
0415    out->AddNode("Sync");
0416    out->AddNode("EventHeader");
0417    out->AddNode("TRKR_CLUSTER");
0418    out->AddNode("SiliconTrackSeedContainer");
0419    out->AddNode("TpcTrackSeedContainer");
0420    out->AddNode("SvtxTrackSeedContainer");
0421    out->AddNode("SvtxTrackMap");
0422    out->AddNode("SvtxVertexMap");
0423    out->AddNode("MbdVertexMap");
0424    out->AddNode("GL1RAWHIT");
0425    se->registerOutputManager(out);
0426 
0427   */
0428   if (Enable::QA)
0429   {
0430     se->registerSubsystem(new MvtxRawHitQA);
0431     se->registerSubsystem(new InttRawHitQA);
0432     se->registerSubsystem(new TpcRawHitQA);
0433     se->registerSubsystem(new MvtxClusterQA);
0434     se->registerSubsystem(new InttClusterQA);
0435     se->registerSubsystem(new TpcClusterQA);
0436     se->registerSubsystem(new MicromegasClusterQA);
0437 
0438     auto *converter = new TrackSeedTrackMapConverter("SiliconSeedConverter");
0439     // Default set to full SvtxTrackSeeds. Can be set to
0440     // SiliconTrackSeedContainer or TpcTrackSeedContainer
0441     converter->setTrackSeedName("SiliconTrackSeedContainer");
0442     converter->setTrackMapName("SiliconSvtxTrackMap");
0443     converter->setFieldMap(G4MAGNET::magfield_tracking);
0444     converter->Verbosity(0);
0445     se->registerSubsystem(converter);
0446 
0447     auto *finder_svx = new PHSimpleVertexFinder("SiliconVertexFinder");
0448     finder_svx->Verbosity(0);
0449     finder_svx->setDcaCut(0.1);
0450     finder_svx->setTrackPtCut(0.2);
0451     finder_svx->setBeamLineCut(1);
0452     finder_svx->setTrackQualityCut(500);
0453     finder_svx->setNmvtxRequired(3);
0454     finder_svx->setOutlierPairCut(0.1);
0455     finder_svx->setTrackMapName("SiliconSvtxTrackMap");
0456     finder_svx->setVertexMapName("SiliconSvtxVertexMap");
0457     se->registerSubsystem(finder_svx);
0458 
0459     auto *siliconqa = new SiliconSeedsQA;
0460     siliconqa->setTrackMapName("SiliconSvtxTrackMap");
0461     siliconqa->setVertexMapName("SiliconSvtxVertexMap");
0462     se->registerSubsystem(siliconqa);
0463 
0464     auto *convertertpc = new TrackSeedTrackMapConverter("TpcSeedConverter");
0465     // Default set to full SvtxTrackSeeds. Can be set to
0466     // SiliconTrackSeedContainer or TpcTrackSeedContainer
0467     convertertpc->setTrackSeedName("TpcTrackSeedContainer");
0468     convertertpc->setTrackMapName("TpcSvtxTrackMap");
0469     convertertpc->setFieldMap(G4MAGNET::magfield_tracking);
0470     convertertpc->Verbosity(0);
0471     se->registerSubsystem(convertertpc);
0472 
0473     auto *findertpc = new PHSimpleVertexFinder("TpcSimpleVertexFinder");
0474     findertpc->Verbosity(0);
0475     findertpc->setDcaCut(0.5);
0476     findertpc->setTrackPtCut(0.2);
0477     findertpc->setBeamLineCut(1);
0478     findertpc->setTrackQualityCut(1000000000);
0479     // findertpc->setNmvtxRequired(3);
0480     findertpc->setRequireMVTX(false);
0481     findertpc->setOutlierPairCut(0.1);
0482     findertpc->setTrackMapName("TpcSvtxTrackMap");
0483     findertpc->setVertexMapName("TpcSvtxVertexMap");
0484     se->registerSubsystem(findertpc);
0485 
0486     auto *tpcqa = new TpcSeedsQA;
0487     tpcqa->setTrackMapName("TpcSvtxTrackMap");
0488     tpcqa->setVertexMapName("TpcSvtxVertexMap");
0489     tpcqa->setSegment(rc->get_IntFlag("RUNSEGMENT"));
0490     se->registerSubsystem(tpcqa);
0491 
0492     se->registerSubsystem(new TpcSiliconQA);
0493   }
0494 
0495   if (doKFParticle)
0496   {
0497     // KFParticle dependancy
0498     Global_Reco();
0499 
0500     // KFParticle setup
0501 
0502     KFParticle_sPHENIX *kfparticle = new KFParticle_sPHENIX("pipi_reco");
0503     kfparticle->Verbosity(10);
0504     kfparticle->setDecayDescriptor("K_S0 -> pi^+ pi^-");
0505     // kfparticle->setDecayDescriptor("[K_S0 -> pi^+ pi^+]cc");
0506 
0507     kfparticle->usePID(HeavyFlavorReco::use_pid);
0508     kfparticle->setPIDacceptFraction(HeavyFlavorReco::pid_frac);
0509     kfparticle->dontUseGlobalVertex(HeavyFlavorReco::dont_use_global_vertex);
0510     kfparticle->requireTrackVertexBunchCrossingMatch(HeavyFlavorReco::require_track_and_vertex_match);
0511     kfparticle->getAllPVInfo(HeavyFlavorReco::save_all_vtx_info);
0512     kfparticle->allowZeroMassTracks();
0513     kfparticle->use2Dmatching(HeavyFlavorReco::use_2D_matching);
0514     kfparticle->getTriggerInfo(HeavyFlavorReco::get_trigger_info);
0515     kfparticle->getDetectorInfo(HeavyFlavorReco::get_detector_info);
0516     kfparticle->saveDST(HeavyFlavorReco::save_tracks_to_DST);
0517     kfparticle->saveParticleContainer(false);
0518     kfparticle->magFieldFile("FIELDMAP_TRACKING");
0519 
0520     // PV to SV cuts
0521     kfparticle->constrainToPrimaryVertex(HeavyFlavorReco::constrain_to_primary_vertex);
0522     kfparticle->setMotherIPchi2(100);
0523     kfparticle->setFlightDistancechi2(-1.);
0524     kfparticle->setMinDIRA(0.88);                    // was .95
0525     kfparticle->setDecayLengthRange(-0.1, FLT_MAX);  // was 0.1 min
0526 
0527     kfparticle->setDecayLengthRange_XY(-10000, FLT_MAX);
0528     kfparticle->setDecayTimeRange_XY(-10000, FLT_MAX);
0529     kfparticle->setDecayTimeRange(-10000, FLT_MAX);
0530     kfparticle->setMinDecayTimeSignificance(-1e5);
0531     kfparticle->setMinDecayLengthSignificance(-1e5);
0532     kfparticle->setMinDecayLengthSignificance_XY(-1e5);
0533     kfparticle->setMaximumDaughterDCA_XY(100);
0534 
0535     // Track parameters
0536     kfparticle->setMinimumTrackPT(0.0);
0537     kfparticle->setMinimumTrackIPchi2(-1.);
0538     kfparticle->setMinimumTrackIP(-1.);
0539     kfparticle->setMaximumTrackchi2nDOF(100.);
0540     kfparticle->setMinINTThits(0);
0541     kfparticle->setMinMVTXhits(0);
0542     kfparticle->setMinTPChits(20);
0543 
0544     // Vertex parameters
0545     kfparticle->setMaximumVertexchi2nDOF(20);
0546     kfparticle->setMaximumDaughterDCA(0.5);  // 5 mm
0547 
0548     // Parent parameters
0549     kfparticle->setMotherPT(0);
0550     kfparticle->setMinimumMass(0.40);  // Check mass ranges
0551     kfparticle->setMaximumMass(0.60);
0552     kfparticle->setMaximumMotherVertexVolume(0.1);
0553 
0554     kfparticle->setOutputName(HeavyFlavorReco::pipi_output_reco_file);
0555 
0556     se->registerSubsystem(kfparticle);
0557 
0558     // Lambda reconstruction
0559     KFParticle_sPHENIX *kfparticleLambda = new KFParticle_sPHENIX("ppi_reco");
0560     kfparticleLambda->Verbosity(0);
0561     kfparticleLambda->setDecayDescriptor("[Lambda0 -> proton^+ pi^-]cc");
0562 
0563     kfparticle->usePID(HeavyFlavorReco::use_pid);
0564     kfparticle->setPIDacceptFraction(HeavyFlavorReco::pid_frac);
0565     kfparticle->dontUseGlobalVertex(HeavyFlavorReco::dont_use_global_vertex);
0566     kfparticle->requireTrackVertexBunchCrossingMatch(HeavyFlavorReco::require_track_and_vertex_match);
0567     kfparticle->getAllPVInfo(HeavyFlavorReco::save_all_vtx_info);
0568     kfparticle->allowZeroMassTracks();
0569     kfparticle->use2Dmatching(HeavyFlavorReco::use_2D_matching);
0570     kfparticle->getTriggerInfo(HeavyFlavorReco::get_trigger_info);
0571     kfparticle->getDetectorInfo(HeavyFlavorReco::get_detector_info);
0572     kfparticle->saveDST(HeavyFlavorReco::save_tracks_to_DST);
0573     kfparticle->saveParticleContainer(false);
0574     kfparticle->magFieldFile("FIELDMAP_TRACKING");
0575 
0576     // PV to SV cuts
0577     kfparticle->constrainToPrimaryVertex(HeavyFlavorReco::constrain_to_primary_vertex);
0578     kfparticle->setMotherIPchi2(100);
0579     kfparticle->setFlightDistancechi2(-1.);
0580     kfparticle->setMinDIRA(0.88);
0581     kfparticle->setDecayLengthRange(0.2, FLT_MAX);
0582 
0583     // Track parameters
0584     kfparticle->setMinimumTrackPT(0.1);
0585     kfparticle->setMinimumTrackIPchi2(-1.);
0586     kfparticle->setMinimumTrackIP(-1.);
0587     kfparticle->setMaximumTrackchi2nDOF(100.);
0588     kfparticle->setMinTPChits(25);
0589 
0590     // Vertex parameters
0591     kfparticle->setMaximumVertexchi2nDOF(20);
0592     kfparticle->setMaximumDaughterDCA(0.5);  // 5 mm
0593 
0594     // Parent parameters
0595     kfparticle->setMotherPT(0);
0596     kfparticle->setMinimumMass(0.900);  // Check mass ranges
0597     kfparticle->setMaximumMass(1.300);
0598     kfparticle->setMaximumMotherVertexVolume(0.1);
0599 
0600     kfparticle->setOutputName(HeavyFlavorReco::ppi_output_reco_file);
0601 
0602     se->registerSubsystem(kfparticleLambda);
0603   }
0604 
0605   se->skip(nSkip);
0606   se->run(nEvents);
0607   se->End();
0608   se->PrintTimer();
0609 
0610   if (doKFParticle)
0611   {
0612     end_kfparticle(HeavyFlavorReco::pipi_output_reco_file, HeavyFlavorReco::pipi_output_dir);
0613     end_kfparticle(HeavyFlavorReco::ppi_output_reco_file, HeavyFlavorReco::ppi_output_dir);
0614   }
0615   if (Enable::QA)
0616   {
0617     std::string qaOutputFileName = theOutfile + "_qa.root";
0618     QAHistManagerDef::saveQARootFile(qaOutputFileName);
0619   }
0620   CDBInterface::instance()->Print();
0621   delete se;
0622   std::cout << "Finished" << std::endl;
0623   gSystem->Exit(0);
0624 }