Back to home page

sPhenix code displayed by LXR

 
 

    


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

0001 #ifndef MACRO_TRKRCLUS_C
0002 #define MACRO_TRKRCLUS_C
0003 
0004 #include <GlobalVariables.C>
0005 
0006 #include <G4_ActsGeom.C>
0007 #include <G4_TrkrVariables.C>
0008 
0009 #include <intt/InttClusterizer.h>
0010 #include <intt/InttCombinedRawDataDecoder.h>
0011 #include <intt/InttOdbcQuery.h>
0012 
0013 #include <micromegas/MicromegasCombinedDataDecoder.h>
0014 
0015 #include <mvtx/MvtxClusterPruner.h>
0016 #include <mvtx/MvtxClusterizer.h>
0017 #include <mvtx/MvtxCombinedRawDataDecoder.h>
0018 
0019 #include <tpc/LaserEventIdentifier.h>
0020 #include <tpc/TpcClusterCleaner.h>
0021 #include <tpc/TpcCombinedRawDataUnpacker.h>
0022 
0023 #pragma GCC diagnostic push
0024 #pragma GCC diagnostic ignored "-Wundefined-internal"
0025 #include <tpc/TpcClusterizer.h>
0026 #pragma GCC diagnostic pop
0027 
0028 #include <micromegas/MicromegasClusterizer.h>
0029 
0030 #include <fun4all/Fun4AllServer.h>
0031 
0032 #include <phool/recoConsts.h>
0033 
0034 R__LOAD_LIBRARY(libmvtx.so)
0035 R__LOAD_LIBRARY(libintt.so)
0036 R__LOAD_LIBRARY(libtpc.so)
0037 R__LOAD_LIBRARY(libmicromegas.so)
0038 R__LOAD_LIBRARY(libtrack_reco.so)
0039 R__LOAD_LIBRARY(libphool.so)
0040 
0041 void ClusteringInit()
0042 {
0043   ACTSGEOM::ActsGeomInit();
0044 }
0045 
0046 void Mvtx_HitUnpacking(const std::string &felix = "")
0047 {
0048   int verbosity = std::max(Enable::VERBOSITY, Enable::MVTX_VERBOSITY);
0049   Fun4AllServer *se = Fun4AllServer::instance();
0050 
0051   auto *mvtxunpacker = new MvtxCombinedRawDataDecoder("MvtxCombinedRawDataDecoder" + felix);
0052   mvtxunpacker->Verbosity(verbosity);
0053   if (!felix.empty())
0054   {
0055     mvtxunpacker->useRawHitNodeName("MVTXRAWHIT_" + felix);
0056     mvtxunpacker->useRawEvtHeaderNodeName("MVTXRAWEVTHEADER_" + felix);
0057   }
0058   se->registerSubsystem(mvtxunpacker);
0059 }
0060 
0061 void Mvtx_Clustering()
0062 {
0063   int verbosity = std::max(Enable::VERBOSITY, Enable::MVTX_VERBOSITY);
0064   auto *se = Fun4AllServer::instance();
0065 
0066   // clusterizer
0067   auto *mvtxclusterizer = new MvtxClusterizer;
0068   mvtxclusterizer->Verbosity(verbosity);
0069   se->registerSubsystem(mvtxclusterizer);
0070 
0071   // cluster pruner
0072   auto *mvtxClusterPruner = new MvtxClusterPruner;
0073   mvtxClusterPruner->set_use_strict_matching(true);
0074   se->registerSubsystem(mvtxClusterPruner);
0075 }
0076 
0077 void Intt_HitUnpacking(const std::string &server = "")
0078 {
0079   int verbosity = std::max(Enable::VERBOSITY, Enable::INTT_VERBOSITY);
0080   Fun4AllServer *se = Fun4AllServer::instance();
0081   auto *rc = recoConsts::instance();
0082   int runnumber = rc->get_IntFlag("RUNNUMBER");
0083   InttOdbcQuery query;
0084   bool isStreaming = true;
0085   if (runnumber != 0)
0086   {
0087     query.Query(runnumber);
0088     isStreaming = query.IsStreaming();
0089   }
0090   auto *inttunpacker = new InttCombinedRawDataDecoder("InttCombinedRawDataDecoder" + server);
0091   inttunpacker->Verbosity(verbosity);
0092   /// Only necessary to call the following method if using a non-default calibration
0093   inttunpacker->LoadBadChannelMap("INTT_HotMap");
0094   inttunpacker->set_triggeredMode(!isStreaming);
0095   if (!server.empty())
0096   {
0097     inttunpacker->useRawHitNodeName("INTTRAWHIT_" + server);
0098   }
0099   se->registerSubsystem(inttunpacker);
0100 }
0101 void Intt_Clustering()
0102 {
0103   int verbosity = std::max(Enable::VERBOSITY, Enable::INTT_VERBOSITY);
0104   Fun4AllServer *se = Fun4AllServer::instance();
0105 
0106   InttClusterizer *inttclusterizer = new InttClusterizer("InttClusterizer", G4MVTX::n_maps_layer, G4MVTX::n_maps_layer + G4INTT::n_intt_layer - 1);
0107   inttclusterizer->Verbosity(verbosity);
0108   // no Z clustering for Intt type 1 layers (we DO want Z clustering for type 0 layers)
0109   // turning off phi clustering for type 0 layers is not necessary, there is only one strip
0110   // per sensor in phi
0111   for (int i = G4MVTX::n_maps_layer; i < G4MVTX::n_maps_layer + G4INTT::n_intt_layer; i++)
0112   {
0113     if (G4INTT::laddertype[i - G4MVTX::n_maps_layer] == PHG4InttDefs::SEGMENTATION_PHI)
0114     {
0115       inttclusterizer->set_z_clustering(i, false);
0116     }
0117   }
0118   se->registerSubsystem(inttclusterizer);
0119 }
0120 
0121 void Tpc_HitUnpacking(const std::string &ebdc = "")
0122 {
0123   int verbosity = std::max(Enable::VERBOSITY, Enable::TPC_VERBOSITY);
0124   Fun4AllServer *se = Fun4AllServer::instance();
0125   // std::string name = "TpcCombinedRawDataUnpacker"+ebdc;
0126   auto *tpcunpacker = new TpcCombinedRawDataUnpacker("TpcCombinedRawDataUnpacker" + ebdc);
0127   tpcunpacker->set_presampleShift(TRACKING::reco_tpc_time_presample);
0128   tpcunpacker->set_t0(TRACKING::reco_t0);
0129   if (!ebdc.empty())
0130   {
0131     tpcunpacker->useRawHitNodeName("TPCRAWHIT_" + ebdc);
0132   }
0133   if (TRACKING::tpc_zero_supp)
0134   {
0135     tpcunpacker->ReadZeroSuppressedData();
0136   }
0137   tpcunpacker->doBaselineCorr(TRACKING::tpc_baseline_corr);
0138   tpcunpacker->Verbosity(verbosity);
0139   se->registerSubsystem(tpcunpacker);
0140 }
0141 
0142 void Tpc_LaserEventIdentifying()
0143 {
0144   //  int verbosity = std::max(Enable::VERBOSITY, Enable::TPC_VERBOSITY);
0145   Fun4AllServer *se = Fun4AllServer::instance();
0146   auto *rc = recoConsts::instance();
0147   int runnumber = rc->get_IntFlag("RUNNUMBER");
0148   auto *laserEventIdentifier = new LaserEventIdentifier;
0149   if (!G4TPC::laser_event_debug_filename.empty())
0150   {
0151     laserEventIdentifier->set_debug(true);
0152     laserEventIdentifier->set_debug_name(G4TPC::laser_event_debug_filename);
0153   }
0154   laserEventIdentifier->set_max_time_samples(TRACKING::reco_tpc_maxtime_sample);
0155   laserEventIdentifier->set_runnumber(runnumber);
0156   se->registerSubsystem(laserEventIdentifier);
0157 }
0158 
0159 void TPC_Clustering_run2pp()
0160 {
0161   //  int verbosity = std::max(Enable::VERBOSITY, Enable::TPC_VERBOSITY);
0162   ACTSGEOM::ActsGeomInit();
0163   Fun4AllServer *se = Fun4AllServer::instance();
0164 
0165   auto *tpcclusterizer = new TpcClusterizer;
0166   tpcclusterizer->Verbosity(0);
0167   tpcclusterizer->set_do_hit_association(G4TPC::DO_HIT_ASSOCIATION);
0168   tpcclusterizer->set_rawdata_reco();
0169   tpcclusterizer->set_reject_event(G4TPC::REJECT_LASER_EVENTS);
0170   se->registerSubsystem(tpcclusterizer);
0171 }
0172 void TPC_Clustering()
0173 {
0174   int verbosity = std::max(Enable::VERBOSITY, Enable::TPC_VERBOSITY);
0175   ACTSGEOM::ActsGeomInit();
0176   Fun4AllServer *se = Fun4AllServer::instance();
0177 
0178   //-------------
0179   // Cluster Hits
0180   //-------------
0181 
0182   // For the Tpc
0183   //==========
0184 
0185   auto *tpcclusterizer = new TpcClusterizer;
0186   tpcclusterizer->Verbosity(verbosity);
0187   tpcclusterizer->set_do_hit_association(G4TPC::DO_HIT_ASSOCIATION);
0188   tpcclusterizer->set_min_err_squared(0.000001);
0189   se->registerSubsystem(tpcclusterizer);
0190 
0191   auto *tpcclustercleaner = new TpcClusterCleaner;
0192   tpcclustercleaner->Verbosity(verbosity);
0193   tpcclustercleaner->set_rphi_error_low_cut(0.001);
0194   se->registerSubsystem(tpcclustercleaner);
0195 }
0196 
0197 void Micromegas_HitUnpacking()
0198 {
0199   //  int verbosity = std::max(Enable::VERBOSITY, Enable::MICROMEGAS_VERBOSITY);
0200   Fun4AllServer *se = Fun4AllServer::instance();
0201 
0202   auto *tpotunpacker = new MicromegasCombinedDataDecoder;
0203   std::string calibrationFile = CDBInterface::instance()->getUrl("TPOT_Pedestal");
0204   tpotunpacker->set_calibration_file(calibrationFile);
0205   tpotunpacker->set_sample_max(1024);
0206   se->registerSubsystem(tpotunpacker);
0207 }
0208 
0209 void Micromegas_Clustering()
0210 {
0211   auto *se = Fun4AllServer::instance();
0212   auto *mm_clus = new MicromegasClusterizer;
0213   const auto calibrationFile = CDBInterface::instance()->getUrl("TPOT_Pedestal");
0214   mm_clus->set_calibration_file(calibrationFile);
0215   se->registerSubsystem(mm_clus);
0216 }
0217 
0218 #endif