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 #include <G4_Global.C>
0012 #include <G4_Magnet.C>
0013 #include <G4_Mbd.C>
0014 #include <Trkr_Clustering.C>
0015 #include <Trkr_LaserClustering.C>
0016 #include <Trkr_RecoInit.C>
0017 #include <Trkr_TpcReadoutInit.C>
0018
0019 #include <ffamodules/CDBInterface.h>
0020 #include <fun4all/Fun4AllDstInputManager.h>
0021 #include <fun4all/Fun4AllDstOutputManager.h>
0022 #include <fun4all/Fun4AllInputManager.h>
0023 #include <fun4all/Fun4AllOutputManager.h>
0024 #include <fun4all/Fun4AllRunNodeInputManager.h>
0025 #include <fun4all/Fun4AllServer.h>
0026
0027 #include <phool/recoConsts.h>
0028
0029
0030
0031 #include <tpccalib/TpcCentralMembraneMatching.h>
0032
0033
0034 #include <fstream>
0035 #include <cstdio>
0036 #include <format>
0037 R__LOAD_LIBRARY(libfun4all.so)
0038 R__LOAD_LIBRARY(libffamodules.so)
0039 R__LOAD_LIBRARY(libtpc.so)
0040 R__LOAD_LIBRARY(libtpccalib.so)
0041
0042 void Fun4All_LaserMatching(
0043 const int nEvents = 10,
0044 const std::string& filelist = "",
0045 const std::string& distortionCorrection = "",
0046 const std::string& outdir = "/sphenig/tg/tg01/jets/bkimelman/")
0047 {
0048
0049 auto *se = Fun4AllServer::instance();
0050 se->Verbosity(2);
0051
0052
0053
0054
0055
0056
0057
0058
0059 auto *rc = recoConsts::instance();
0060
0061 Enable::CDB = true;
0062 rc->set_StringFlag("CDB_GLOBALTAG", "newcdbtag");
0063
0064
0065
0066 std::ifstream ifs(filelist);
0067 std::string filepath;
0068
0069
0070 int i=0;
0071 int runnumber = 0;
0072 int segment = 0;
0073 while(std::getline(ifs,filepath))
0074 {
0075 std::cout << "Adding DST with filepath: " << filepath << std::endl;
0076 if(i==0)
0077 {
0078 std::pair<int, int> runseg = Fun4AllUtils::GetRunSegment(filepath);
0079 runnumber = runseg.first;
0080 segment = runseg.second;
0081 rc->set_IntFlag("RUNNUMBER",runnumber);
0082 rc->set_uint64Flag("TIMESTAMP",runnumber);
0083 }
0084
0085
0086
0087
0088
0089 i++;
0090 }
0091
0092
0093 auto *hitsin = new Fun4AllDstInputManager("InputManager");
0094 hitsin->AddListFile(filelist);
0095 se->registerInputManager(hitsin);
0096
0097
0098
0099
0100
0101
0102 TRACKING::tpc_zero_supp = true;
0103 Enable::MVTX_APPLYMISALIGNMENT = true;
0104 ACTSGEOM::mvtx_applymisalignment = Enable::MVTX_APPLYMISALIGNMENT;
0105
0106 std::string geofile = CDBInterface::instance()->getUrl("Tracking_Geometry");
0107 Fun4AllRunNodeInputManager *ingeo = new Fun4AllRunNodeInputManager("GeoIn");
0108 ingeo->AddFile(geofile);
0109 se->registerInputManager(ingeo);
0110
0111
0112
0113 G4TPC::ENABLE_MODULE_EDGE_CORRECTIONS = true;
0114
0115
0116 if(runnumber == 52077 || runnumber == 52078 || (runnumber >= 75103 && runnumber <= 75114) || (runnumber >= 75555 && runnumber <= 75574))
0117 {
0118
0119 G4TPC::ENABLE_STATIC_CORRECTIONS = false;
0120 }
0121 else
0122 {
0123 G4TPC::ENABLE_STATIC_CORRECTIONS = true;
0124 G4TPC::USE_PHI_AS_RAD_STATIC_CORRECTIONS=false;
0125 }
0126
0127 if (!distortionCorrection.empty())
0128 {
0129 G4TPC::ENABLE_AVERAGE_CORRECTIONS = true;
0130
0131 G4TPC::average_correction_filename = distortionCorrection;
0132 G4TPC::USE_PHI_AS_RAD_AVERAGE_CORRECTIONS=false;
0133 G4TPC::average_correction_interpolate = false;
0134 }
0135 else
0136 {
0137 G4TPC::ENABLE_AVERAGE_CORRECTIONS = false;
0138 }
0139
0140
0141
0142
0143
0144
0145 TrackingInit();
0146
0147
0148 auto *centralMembraneMatcher = new TpcCentralMembraneMatching;
0149 centralMembraneMatcher->setSavehistograms( true );
0150 centralMembraneMatcher->Verbosity( 1 );
0151 centralMembraneMatcher->set_fieldOn(true);
0152 centralMembraneMatcher->set_doFancy(false);
0153 centralMembraneMatcher->set_doHadd(true);
0154 centralMembraneMatcher->set_averageMode(true);
0155 centralMembraneMatcher->set_event_sequence(segment);
0156 centralMembraneMatcher->setHistogramOutputfile(
0157 std::format("{}/PHTpcCentralMembraneMatcher-{:08d}-all.root",
0158 outdir, runnumber));
0159
0160 centralMembraneMatcher->setOutputfile(
0161 std::format("{}/CMDistortionCorrections-{:08d}-all.root",
0162 outdir, runnumber));
0163
0164 centralMembraneMatcher->setDebugOutputFile(
0165 std::format("{}/CMMatching-{:08d}-all.root",
0166 outdir, runnumber));
0167 centralMembraneMatcher->set_grid_dimensions(500,500);
0168 se->registerSubsystem(centralMembraneMatcher);
0169
0170
0171
0172
0173
0174
0175
0176 se->run(nEvents);
0177
0178 se->End();
0179 se->PrintTimer();
0180
0181 delete se;
0182 std::cout << "Finished" << std::endl;
0183 gSystem->Exit(0);
0184 }