Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2026-07-16 08:16:53

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 #include <GlobalVariables.C>
0009 
0010 #include <G4_ActsGeom.C>
0011 #include <Trkr_Clustering.C>
0012 #include <Trkr_LaserClustering.C>
0013 #include <Trkr_RecoInit.C>
0014 #include <Trkr_TpcReadoutInit.C>
0015 
0016 #include <tpc/DiffuseLaserEventSelector.h>
0017 #include <tpc/LaserEventIdentifier.h>
0018 
0019 #include <ffamodules/CDBInterface.h>
0020 
0021 #include <fun4all/Fun4AllDstInputManager.h>
0022 #include <fun4all/Fun4AllDstOutputManager.h>
0023 #include <fun4all/Fun4AllOutputManager.h>
0024 #include <fun4all/Fun4AllInputManager.h>
0025 #include <fun4all/Fun4AllRunNodeInputManager.h>
0026 #include <fun4all/Fun4AllServer.h>
0027 #include <fun4all/Fun4AllUtils.h>
0028 
0029 
0030 #include <phool/recoConsts.h>
0031 
0032 #include <format>
0033 #include <fstream>
0034 
0035 R__LOAD_LIBRARY(libfun4all.so)
0036 R__LOAD_LIBRARY(libffamodules.so)
0037 R__LOAD_LIBRARY(libtpc.so)
0038 R__LOAD_LIBRARY(libtpccalib.so)
0039 
0040 
0041 
0042 void Fun4All_DiffuseLaser(
0043     const int nEvents = 100,
0044     const std::string& filelist = "filelist.list",
0045     const std::string& outdir = "./",
0046     const std::string& outfilename = "diffuse_laser")
0047 {
0048 
0049   gSystem->Load("libg4dst.so");
0050   
0051   auto *se = Fun4AllServer::instance();
0052   se->Verbosity(0);
0053   auto *rc = recoConsts::instance();
0054   CDBInterface::instance()->Verbosity(1);
0055   
0056   rc->set_StringFlag("CDB_GLOBALTAG", "newcdbtag");
0057 
0058 
0059 
0060   std::ifstream ifs(filelist);
0061   std::string filepath;
0062 
0063   int i = 0;
0064   int runnumber = std::numeric_limits<int>::quiet_NaN();
0065   int segment = std::numeric_limits<int>::quiet_NaN();
0066   
0067    while (std::getline(ifs, filepath))
0068   {
0069     std::cout << "Adding DST with filepath: " << filepath << std::endl;
0070     if (i == 0)
0071     {
0072       std::pair<int, int>
0073           runseg = Fun4AllUtils::GetRunSegment(filepath);
0074       runnumber = runseg.first;
0075       segment = runseg.second;
0076       rc->set_IntFlag("RUNNUMBER", runnumber);
0077       rc->set_uint64Flag("TIMESTAMP", runnumber);
0078     }
0079   
0080     std::string inputname = "InputManager" + std::to_string(i);
0081     auto *hitsin = new Fun4AllDstInputManager(inputname);
0082     hitsin->fileopen(filepath);
0083     se->registerInputManager(hitsin);
0084     i++;
0085   }
0086 
0087   TpcReadoutInit(runnumber);
0088 
0089   
0090   TRACKING::tpc_zero_supp = true;
0091   Enable::MVTX_APPLYMISALIGNMENT = true;
0092   ACTSGEOM::mvtx_applymisalignment = Enable::MVTX_APPLYMISALIGNMENT;
0093   
0094 
0095   std::string geofile = CDBInterface::instance()->getUrl("Tracking_Geometry");
0096   Fun4AllRunNodeInputManager *ingeo = new Fun4AllRunNodeInputManager("GeoIn");
0097   ingeo->AddFile(geofile);
0098   se->registerInputManager(ingeo);
0099 
0100   G4TPC::ENABLE_MODULE_EDGE_CORRECTIONS = false;
0101   //G4TPC::ENABLE_STATIC_CORRECTIONS = false;
0102   //G4TPC::USE_PHI_AS_RAD_STATIC_CORRECTIONS=false;
0103 
0104 
0105   G4TPC::ENABLE_AVERAGE_CORRECTIONS = false;
0106 
0107   TRACKING::streaming_mode = true;
0108   
0109   TrackingInit();
0110 
0111   std::ostringstream ebdcname;
0112   for (int ebdc = 0; ebdc < 24; ebdc++)
0113   {
0114     for (int endpoint = 0; endpoint < 2; endpoint++)
0115     {
0116         ebdcname.str("");
0117         if (ebdc < 10)
0118         {
0119           ebdcname << "0";
0120         }
0121         ebdcname << ebdc << "_" << endpoint;
0122         Tpc_HitUnpacking(ebdcname.str());
0123     }
0124   }
0125 
0126   Tpc_LaserEventIdentifying();
0127 
0128   se->registerSubsystem( new DiffuseLaserEventSelector());
0129 
0130 
0131   std::cout<< "Output DST "<<std::format("{}/{}_{}_{}.root",outdir, outfilename, runnumber, segment)  << std::endl;
0132   Fun4AllOutputManager *out = new Fun4AllDstOutputManager("out", std::format("{}/{}_{}_{}.root",outdir, outfilename, runnumber, segment));
0133   out->AddEventSelector("DiffuseLaserEventSelector");
0134   out->AddNode("Sync");
0135   out->AddNode("EventHeader");
0136   out->AddNode("TRKR_HITSET");
0137   se->registerOutputManager(out);
0138 
0139   se->run(nEvents);
0140   se->End();
0141 
0142   CDBInterface::instance()->Print();
0143   se->PrintTimer();
0144 
0145   delete se;
0146   std::cout << "Finished" << std::endl;
0147   gSystem->Exit(0);
0148 }