Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-03 08:20:27

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