Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-12-16 09:24:05

0001 #ifndef MACRO_TRKREVAL_C
0002 #define MACRO_TRKREVAL_C
0003 
0004 #include <GlobalVariables.C>
0005 
0006 #include <G4_TrkrVariables.C>
0007 #include <Trkr_TruthTables.C>
0008 
0009 #include <g4eval/FillClusMatchTree.h>
0010 #include <g4eval/SvtxEvaluator.h>
0011 #include <g4eval/TrkrClusterIsMatcher.h>
0012 #include <g4eval/TruthRecoTrackMatching.h>
0013 
0014 R__LOAD_LIBRARY(libg4eval.so)
0015 
0016 void Tracking_Eval(const std::string& outputfile)
0017 {
0018   int verbosity = std::max(Enable::VERBOSITY, Enable::TRACKING_VERBOSITY);
0019 
0020   //---------------
0021   // Fun4All server
0022   //---------------
0023 
0024   Fun4AllServer* se = Fun4AllServer::instance();
0025   build_truthreco_tables();
0026 
0027   //----------------
0028   // Tracking evaluation
0029   //----------------
0030   SvtxEvaluator* eval;
0031   eval = new SvtxEvaluator("SVTXEVALUATOR", outputfile, "SvtxTrackMap",
0032                            G4MVTX::n_maps_layer,
0033                            G4INTT::n_intt_layer,
0034                            G4TPC::n_gas_layer,
0035                            G4MICROMEGAS::n_micromegas_layer);
0036   eval->do_cluster_eval(true);
0037   eval->do_g4hit_eval(false);
0038   eval->do_hit_eval(false);  // enable to see the hits that includes the chamber physics...
0039   eval->do_gpoint_eval(true);
0040   eval->do_vtx_eval_light(true);
0041   eval->do_eval_light(true);
0042   eval->do_track_eval(true);
0043   eval->do_gtrack_eval(true);
0044   eval->do_track_match(true);
0045   eval->set_use_initial_vertex(G4TRACKING::g4eval_use_initial_vertex);
0046   bool embed_scan = true;
0047   if (TRACKING::pp_mode) embed_scan = false;
0048   eval->scan_for_embedded(embed_scan);   // take all tracks if false - take only embedded tracks if true
0049   eval->scan_for_primaries(embed_scan);  // defaults to only thrown particles for ntp_gtrack
0050   std::cout << "SvtxEvaluator: pp_mode set to " << TRACKING::pp_mode << " and scan_for_embedded set to " << embed_scan << std::endl;
0051   eval->Verbosity(verbosity);
0052 
0053   se->registerSubsystem(eval);
0054 
0055   return;
0056 }
0057 
0058 void Track_Matching(const std::string& ttreefilename)
0059 {
0060   TrkrClusterIsMatcher* ismatcher = new TrkrClusterIsMatcher();
0061   // These are the default values -- uncomment and change as desired
0062   //  ismatcher->single_pixel_phi_MVTX = false ; // default to pitch*max(N_pixels_M,N_pixels_T)*tol_MVTX
0063   //  ismatcher->single_pixel_phi_INTT = false ; // ... same as for MVTX
0064   //  ismatcher->single_bin_phi_TPC    = true  ;  // default to pitch*tol_phi_TPC
0065   //
0066   //  ismatcher->single_pixel_z_MVTX = false ; // default to pitch*max(N_pixels_M,N_pixels_T)*tol_z_MVTX
0067   //  ismatcher->single_pixel_z_INTT = false ; // ... same as for MVTX
0068   //  ismatcher->single_bin_t_TPC    = true  ;  // default to pitch*tol_t_TPC
0069   //
0070   //  ismatcher-> tol_phi_MVTX = 0.5;
0071   //  ismatcher-> tol_phi_INTT = 0.5;
0072   //  ismatcher-> tol_phi_TPC  = 1.0;
0073 
0074   //  ismatcher-> tol_z_MVTX  = 0.5;
0075   //  ismatcher-> tol_t_TPC   = 1.0;
0076   auto* trackmatcher = new TruthRecoTrackMatching(ismatcher);
0077   trackmatcher->set_min_cl_match(5);         // minimum number of matched clusters to make a matched track
0078   trackmatcher->set_min_cl_ratio(0.1);       // at least 10% of truth clusters must be matched
0079   trackmatcher->set_cutoff_deta(0.3);        // won't compare tracks with |Δeta|>0.3 away
0080   trackmatcher->set_cutoff_dphi(0.3);        // won't compare tracks with |Δphi|>0.3 away
0081   trackmatcher->set_smallsearch_deta(0.05);  // will first compare tracks within this |Δphi|
0082   trackmatcher->set_smallsearch_dphi(0.05);  // will first compare tracks within this |Δeta|
0083   trackmatcher->set_max_nreco_per_truth(4);  // maximum reco tracks matched for any truth track
0084   trackmatcher->set_max_ntruth_per_reco(4);  // maximum truth tracks matched for any reco track
0085   int verbosity = std::max(Enable::VERBOSITY, Enable::TRACKING_VERBOSITY);
0086 
0087   Fun4AllServer* se = Fun4AllServer::instance();
0088   trackmatcher->Verbosity(verbosity);
0089   se->registerSubsystem(trackmatcher);
0090 
0091   if (Enable::TRACK_MATCHING_TREE)
0092   {
0093     auto* treefiller = new FillClusMatchTree(ismatcher, ttreefilename);  //, true, true, true, outputFile);
0094     treefiller->Verbosity(verbosity);
0095     if (Enable::TRACK_MATCHING_TREE_CLUSTERS)
0096     {
0097       treefiller->m_fill_clusters = true;
0098       treefiller->m_fill_SvUnmatched = true;
0099     }
0100     else
0101     {
0102       treefiller->m_fill_clusters = false;
0103       treefiller->m_fill_SvUnmatched = false;
0104     }
0105     treefiller->m_fill_clusverbose = false;
0106     se->registerSubsystem(treefiller);
0107   }
0108 }
0109 
0110 #endif