File indexing completed on 2026-08-30 08:24:57
0001
0002
0003
0004
0005
0006
0007
0008 #include <fun4all/Fun4AllUtils.h>
0009 #include <GlobalVariables.C>
0010 #include <G4_ActsGeom.C>
0011
0012
0013
0014 #include <Trkr_Clustering.C>
0015 #include <Trkr_LaserClustering.C>
0016 #include <Trkr_RecoInit.C>
0017 #include <Trkr_TpcReadoutInit.C>
0018
0019 #include <fun4all/Fun4AllDstInputManager.h>
0020 #include <fun4all/Fun4AllDstOutputManager.h>
0021 #include <fun4all/Fun4AllInputManager.h>
0022 #include <fun4all/Fun4AllOutputManager.h>
0023 #include <fun4all/Fun4AllRunNodeInputManager.h>
0024 #include <fun4all/Fun4AllServer.h>
0025
0026 #include <ffamodules/FlagHandler.h>
0027 #include <ffamodules/CDBInterface.h>
0028
0029 #include <phool/recoConsts.h>
0030
0031 #include <tpc/LaserEventIdentifier.h>
0032
0033 #include <format>
0034 #include <fstream>
0035 #include <cstdio>
0036
0037 R__LOAD_LIBRARY(libfun4all.so)
0038 R__LOAD_LIBRARY(libffamodules.so)
0039 R__LOAD_LIBRARY(libtpc.so)
0040 void Fun4All_LaserClustering(
0041 const int nEvents = 10,
0042 const std::string& filelist = "/sphenix/lustre01/sphnxpro/commissioning/slurp/tpcbeam/run_00041900_00042000/",
0043 const std::string& outdir = "/sphenig/tg/tg01/jets/bkimelman/",
0044 const std::string& prod = "ana441_2024p007",
0045 const std::string& type = "run2pp")
0046
0047 {
0048 gSystem->Load("libg4dst.so");
0049
0050
0051 auto *se = Fun4AllServer::instance();
0052 se->Verbosity(1);
0053 auto *rc = recoConsts::instance();
0054 CDBInterface::instance()->Verbosity(1);
0055 Enable::CDB = true;
0056
0057 rc->set_StringFlag("CDB_GLOBALTAG", "newcdbtag");
0058
0059 FlagHandler *flag = new FlagHandler();
0060 se->registerSubsystem(flag);
0061
0062
0063 std::ifstream ifs(filelist);
0064 std::string filepath;
0065
0066
0067 int i=0;
0068
0069 int runnumber = 0;
0070 int segment = 0;
0071 bool process_endpoints = false;
0072 while(std::getline(ifs,filepath))
0073 {
0074 std::cout << "Adding DST with filepath: " << filepath << std::endl;
0075 if(i==0)
0076 {
0077 std::pair<int, int> runseg = Fun4AllUtils::GetRunSegment(filepath);
0078 runnumber = runseg.first;
0079 segment = runseg.second;
0080 rc->set_IntFlag("RUNNUMBER",runnumber);
0081 rc->set_uint64Flag("TIMESTAMP",runnumber);
0082 }
0083
0084 if(filepath.find("ebdc") != std::string::npos)
0085 {
0086
0087 if(filepath.find("_0_") != std::string::npos || filepath.find("_1_") != std::string::npos)
0088 {
0089
0090 process_endpoints = true;
0091 }
0092 }
0093
0094 std::string inputname = "InputManager" + std::to_string(i);
0095 auto *hitsin = new Fun4AllDstInputManager(inputname);
0096 hitsin->fileopen(filepath);
0097 se->registerInputManager(hitsin);
0098 i++;
0099 }
0100
0101 TRACKING::streaming_mode = false;
0102 TRACKING::tpc_zero_supp = true;
0103 G4TPC::ENABLE_CENTRAL_MEMBRANE_CLUSTERING = true;
0104 Enable::MVTX_APPLYMISALIGNMENT = true;
0105 ACTSGEOM::mvtx_applymisalignment = Enable::MVTX_APPLYMISALIGNMENT;
0106
0107
0108 TString out_DST = std::format(
0109 "{}/DST_LASER_CLUSTER_{}_{}-{:08d}-{:05d}.root",
0110 outdir, type, prod, runnumber, segment);
0111 std::string theOutDST = out_DST.Data();
0112
0113 std::string geofile = CDBInterface::instance()->getUrl("Tracking_Geometry");
0114 Fun4AllRunNodeInputManager *ingeo = new Fun4AllRunNodeInputManager("GeoIn");
0115 ingeo->AddFile(geofile);
0116 se->registerInputManager(ingeo);
0117
0118 TpcReadoutInit( runnumber );
0119
0120
0121
0122 G4TPC::ENABLE_MODULE_EDGE_CORRECTIONS = true;
0123
0124 G4TPC::ENABLE_STATIC_CORRECTIONS = true;
0125 G4TPC::USE_PHI_AS_RAD_STATIC_CORRECTIONS=false;
0126
0127
0128
0129 TRACKING::tpc_zero_supp = true;
0130
0131
0132
0133 TrackingInit();
0134
0135
0136 std::ostringstream ebdcname;
0137 for(int ebdc = 0; ebdc < 24; ebdc++)
0138 {
0139 if(!process_endpoints)
0140 {
0141 ebdcname.str("");
0142 if(ebdc < 10)
0143 {
0144 ebdcname<<"0";
0145 }
0146 ebdcname<<ebdc;
0147 Tpc_HitUnpacking(ebdcname.str());
0148 }
0149 else if(process_endpoints)
0150 {
0151 for(int endpoint = 0; endpoint < 2; endpoint++){
0152 ebdcname.str("");
0153 if(ebdc < 10)
0154 {
0155 ebdcname<<"0";
0156 }
0157 ebdcname << ebdc << "_" << endpoint;
0158 Tpc_HitUnpacking(ebdcname.str());
0159 }
0160 }
0161 else
0162 {
0163 std::cout << "Wrong number of tpc files input! Exiting now." << std::endl;
0164 gSystem->Exit(1);
0165 }
0166
0167 }
0168
0169
0170 G4TPC::laser_event_debug_filename =
0171 std::format("{}/laserEventQA-{:08d}-{:05d}.root",
0172 outdir, runnumber, segment);
0173 Tpc_LaserEventIdentifying();
0174
0175 G4TPC::ENABLE_CENTRAL_MEMBRANE_CLUSTERING = true;
0176 G4TPC::laser_adc_threshold = 100;
0177 G4TPC::LaserClusteringSequential = true;
0178 G4TPC::laserClusterFitting = false;
0179
0180 TPC_LaserClustering();
0181
0182
0183 Fun4AllOutputManager *out = new Fun4AllDstOutputManager("out",theOutDST);
0184
0185
0186 out->AddNode("Sync");
0187 out->AddNode("EventHeader");
0188 out->AddNode("GL1RAWHIT");
0189 out->AddNode("LaserEventInfo");
0190 out->AddNode("LASER_CLUSTER");
0191 se->registerOutputManager(out);
0192 se->run(nEvents);
0193
0194 se->End();
0195 se->PrintTimer();
0196
0197 CDBInterface::instance()->Print();
0198
0199
0200 delete se;
0201 std::cout << "Finished" << std::endl;
0202 gSystem->Exit(0);
0203 }