File indexing completed on 2025-08-05 08:11:58
0001 #ifndef MACRO_FUN4ALLG4SPHENIX_C
0002 #define MACRO_FUN4ALLG4SPHENIX_C
0003
0004 #include <ffamodules/CDBInterface.h>
0005 #include <ffamodules/FlagHandler.h>
0006 #include <ffamodules/HeadReco.h>
0007 #include <ffamodules/SyncReco.h>
0008 #include <filesystem>
0009 #include <string>
0010
0011 #include <GlobalVariables.C>
0012
0013 #include <G4Setup_sPHENIX.C>
0014 #include <G4_Centrality.C>
0015 #include <G4_Input.C>
0016 #include <Trkr_Clustering.C>
0017 #include <Trkr_RecoInit.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/Fun4AllServer.h>
0024
0025 #include <calotrigger/MinimumBiasClassifier.h>
0026 #include <centrality/CentralityReco.h>
0027 #include <g4centrality/PHG4CentralityReco.h>
0028 #include <trackreco/PHTruthVertexing.h>
0029
0030 #include <caloreco/CaloTowerBuilder.h>
0031 #include <caloreco/CaloTowerCalib.h>
0032 #include <calotrigger/MinimumBiasClassifier.h>
0033 #include <centrality/CentralityReco.h>
0034 #include <globalvertex/GlobalVertexReco.h>
0035 #include <mbd/MbdReco.h>
0036 #include <zdcinfo/ZdcReco.h>
0037
0038 #include <dndetaintt/dNdEtaINTT.h>
0039
0040 #include <phool/recoConsts.h>
0041
0042 R__LOAD_LIBRARY(libfun4allraw.so)
0043 R__LOAD_LIBRARY(libffarawmodules.so)
0044 R__LOAD_LIBRARY(libfun4all.so)
0045 R__LOAD_LIBRARY(libffamodules.so)
0046 R__LOAD_LIBRARY(libdNdEtaINTT.so)
0047 R__LOAD_LIBRARY(libcentrality_io.so)
0048 R__LOAD_LIBRARY(libcentrality.so)
0049 R__LOAD_LIBRARY(libg4centrality.so)
0050 R__LOAD_LIBRARY(libcalotrigger.so)
0051 R__LOAD_LIBRARY(libmbd.so)
0052 R__LOAD_LIBRARY(libglobalvertex.so)
0053
0054 R__LOAD_LIBRARY(libzdcinfo.so)
0055
0056 int Fun4All_G4_sPHENIX(
0057 const bool rundata = false,
0058 const bool getINTTData = true,
0059 const int runnumber = 54280,
0060 const string productionTag = "ProdA_2024",
0061 const string generator = "HIJING",
0062 const int nEvents = 10,
0063 const string &outputFile = "testNtuple.root",
0064 const int process = 0
0065 )
0066 {
0067
0068 bool getCentralityData = (rundata) ? !getINTTData : true;
0069 if (rundata && getINTTData && getCentralityData)
0070 {
0071 std::cout << "We currently can't get INTT and Centrality info from the same file for real data, exiting!" << std::endl;
0072 exit(1);
0073 }
0074
0075 int skip;
0076 if (rundata)
0077 {
0078 skip = nEvents * process;
0079 }
0080 else
0081 {
0082 skip = 0;
0083 }
0084
0085 Fun4AllServer *se = Fun4AllServer::instance();
0086 se->Verbosity(1);
0087
0088 Input::VERBOSITY = 10;
0089 Input::READHITS = true;
0090
0091 string infile;
0092 if (rundata)
0093 {
0094 if (getINTTData)
0095 {
0096
0097 std::filesystem::path productiondir = std::filesystem::current_path().parent_path() / "production/";
0098 infile = productiondir.string() + "intt-" + std::string(TString::Format("%08d", runnumber).Data()) + ".root";
0099 FILE *file;
0100 file = fopen(infile.c_str(), "r");
0101 if (file == NULL)
0102 {
0103 std::cout << "File: " << infile << " does not exist. Use the pre-generated file" << std::endl;
0104 infile = "/sphenix/user/hjheng/sPHENIXRepo/analysis/dNdEta_Run2023/production/ProdDST-HotDead-BCO-ADC-Survey/intt-" + std::string(TString::Format("%08d", runnumber).Data()) + ".root";
0105 }
0106 else
0107 {
0108 fclose(file);
0109 }
0110
0111 INPUTREADHITS::filename[0] = infile;
0112 }
0113 else if (getCentralityData)
0114 {
0115 INPUTREADHITS::listfile[0] = "dst_calo_run1auau-000" + std::to_string(runnumber) + "-ana410_2023p014.list";
0116
0117 }
0118 }
0119 else
0120 {
0121 if (generator == "HIJING")
0122 {
0123
0124
0125
0126
0127
0128
0129
0130
0131
0132
0133
0134 INPUTREADHITS::filename[0] = "/sphenix/lustre01/sphnxpro/mdc2/shijing_hepmc/fm_0_20/nopileup/trkrhit/run0027/DST_TRUTH_sHijing_0_20fm-0000000027-" + std::string(TString::Format("%06d", process).Data()) + ".root";
0135 INPUTREADHITS::filename[1] = "/sphenix/lustre01/sphnxpro/mdc2/shijing_hepmc/fm_0_20/nopileup/trkrhit/run0027/DST_TRKR_HIT_sHijing_0_20fm-0000000027-" + std::string(TString::Format("%06d", process).Data()) + ".root";
0136 INPUTREADHITS::filename[2] = "/sphenix/lustre01/sphnxpro/mdc2/shijing_hepmc/fm_0_20/nopileup/trkrcluster/run0027/DST_TRKR_CLUSTER_sHijing_0_20fm-0000000027-" + std::string(TString::Format("%06d", process).Data()) + ".root";
0137 INPUTREADHITS::filename[3] = "/sphenix/lustre01/sphnxpro/mdc2/shijing_hepmc/fm_0_20/nopileup/mbdepd/run0027/DST_MBD_EPD_sHijing_0_20fm-0000000027-" + std::string(TString::Format("%06d", process).Data()) + ".root";
0138 }
0139 else if (generator == "EPOS")
0140 {
0141
0142
0143 INPUTREADHITS::filename[0] = "/sphenix/lustre01/sphnxpro/mdc2/epos/nopileup/trkrhit/run0026/DST_TRUTH_epos_0_153fm-0000000026-" + std::string(TString::Format("%06d", process).Data()) + ".root";
0144 INPUTREADHITS::filename[1] = "/sphenix/lustre01/sphnxpro/mdc2/epos/nopileup/trkrhit/run0026/DST_TRKR_HIT_epos_0_153fm-0000000026-" + std::string(TString::Format("%06d", process).Data()) + ".root";
0145 INPUTREADHITS::filename[2] = "/sphenix/lustre01/sphnxpro/mdc2/epos/nopileup/trkrcluster/run0026/DST_TRKR_CLUSTER_epos_0_153fm-0000000026-" + std::string(TString::Format("%06d", process).Data()) + ".root";
0146 INPUTREADHITS::filename[3] = "/sphenix/lustre01/sphnxpro/mdc2/epos/nopileup/mbdepd/run0026/DST_MBD_EPD_epos_0_153fm-0000000026-" + std::string(TString::Format("%06d", process).Data()) + ".root";
0147 }
0148 else if (generator == "AMPT")
0149 {
0150
0151
0152 INPUTREADHITS::filename[0] = "/sphenix/lustre01/sphnxpro/mdc2/ampt/nopileup/trkrhit/run0026/DST_TRUTH_ampt_0_20fm-0000000026-" + std::string(TString::Format("%06d", process).Data()) + ".root";
0153 INPUTREADHITS::filename[1] = "/sphenix/lustre01/sphnxpro/mdc2/ampt/nopileup/trkrhit/run0026/DST_TRKR_HIT_ampt_0_20fm-0000000026-" + std::string(TString::Format("%06d", process).Data()) + ".root";
0154 INPUTREADHITS::filename[2] = "/sphenix/lustre01/sphnxpro/mdc2/ampt/nopileup/trkrcluster/run0026/DST_TRKR_CLUSTER_ampt_0_20fm-0000000026-" + std::string(TString::Format("%06d", process).Data()) + ".root";
0155 INPUTREADHITS::filename[3] = "/sphenix/lustre01/sphnxpro/mdc2/ampt/nopileup/mbdepd/run0026/DST_MBD_EPD_ampt_0_20fm-0000000026-" + std::string(TString::Format("%06d", process).Data()) + ".root";
0156 }
0157 else if (generator == "SIMPLE")
0158 {
0159 infile = "/sphenix/tg/tg01/bulk/dNdeta_INTT_run2023/data/simulation/ana.474/SIMPLE/e-/fullSim/magOff/detectorAligned/dstSet_00001/dNdeta-sim-SIMPLE-e--000-" + std::string(TString::Format("%05d", process).Data()) + ".root";
0160 INPUTREADHITS::filename[0] = infile;
0161 }
0162 else
0163 {
0164 std::cout << "Generator " << generator << " is not [HIJING, EPOS, AMPT, SIMPLE]. Exit" << std::endl;
0165 return 0;
0166 }
0167 }
0168
0169
0170
0171
0172 Enable::MBD = getINTTData;
0173 Enable::MBDRECO = getCentralityData || !rundata;
0174 Enable::PIPE = getINTTData;
0175 Enable::MVTX = getINTTData;
0176 Enable::INTT = getINTTData;
0177 Enable::INTT_VERBOSITY = 0;
0178 Enable::TPC = getINTTData;
0179 Enable::MICROMEGAS = getINTTData;
0180
0181
0182
0183
0184 recoConsts *rc = recoConsts::instance();
0185 Enable::CDB = true;
0186 Enable::VERBOSITY = 0;
0187 rc->set_StringFlag("CDB_GLOBALTAG", productionTag);
0188 rc->set_uint64Flag("TIMESTAMP", runnumber);
0189 rc->set_IntFlag("RUNNUMBER", runnumber);
0190
0191 if (getINTTData)
0192 {
0193 G4Init();
0194 G4Setup();
0195
0196
0197 TrackingInit();
0198
0199
0200
0201 }
0202
0203 if (getCentralityData)
0204 {
0205
0206
0207
0208 MbdReco *mbdreco = new MbdReco();
0209 mbdreco->Verbosity(0);
0210 se->registerSubsystem(mbdreco);
0211
0212 GlobalVertexReco *gblvertex = new GlobalVertexReco();
0213 gblvertex->Verbosity(INT_MAX - 1);
0214 se->registerSubsystem(gblvertex);
0215
0216
0217
0218
0219
0220
0221
0222
0223
0224
0225
0226
0227
0228
0229
0230
0231
0232
0233
0234
0235
0236 MinimumBiasClassifier *mb = new MinimumBiasClassifier();
0237 mb->Verbosity(INT_MAX - 1);
0238 mb->setIsSim(!rundata);
0239 mb->setOverwriteScale("/sphenix/user/dlis/Projects/centrality/cdb/calibrations/scales/cdb_centrality_scale_1.root");
0240 mb->setOverwriteVtx("/sphenix/user/dlis/Projects/centrality/cdb/calibrations/vertexscales/cdb_centrality_vertex_scale_1.root");
0241 se->registerSubsystem(mb);
0242
0243 CentralityReco *cr = new CentralityReco();
0244 cr->Verbosity(INT_MAX - 1);
0245 if (generator == "HIJING")
0246 {
0247 cr->setOverwriteScale("/sphenix/user/dlis/Projects/centrality/cdb/calibrations/scales/cdb_centrality_scale_1.root");
0248 cr->setOverwriteVtx("/sphenix/user/dlis/Projects/centrality/cdb/calibrations/vertexscales/cdb_centrality_vertex_scale_1.root");
0249 cr->setOverwriteDivs("/sphenix/user/dlis/Projects/centrality/cdb/calibrations/divs/cdb_centrality_1.root");
0250 }
0251 else if (generator == "EPOS")
0252 {
0253 cr->setOverwriteScale("/sphenix/user/dlis/Projects/centrality/cdb/calibrations/divs/cdb_centrality_scale_epos_magoff.root");
0254 cr->setOverwriteVtx("/sphenix/user/dlis/Projects/centrality/cdb/calibrations/vertexscales/cdb_centrality_vertex_scale_epos_magoff.root");
0255 cr->setOverwriteDivs("/sphenix/user/dlis/Projects/centrality/cdb/calibrations/divs/cdb_centrality_epos_magoff.root");
0256 }
0257 else if (generator == "AMPT")
0258 {
0259 cr->setOverwriteScale("/sphenix/user/dlis/Projects/centrality/cdb/calibrations/divs/cdb_centrality_scale_ampt_magoff.root");
0260 cr->setOverwriteVtx("/sphenix/user/dlis/Projects/centrality/cdb/calibrations/vertexscales/cdb_centrality_vertex_scale_ampt_magoff.root");
0261 cr->setOverwriteDivs("/sphenix/user/dlis/Projects/centrality/cdb/calibrations/divs/cdb_centrality_ampt_magoff.root");
0262 }
0263 else
0264 {
0265 std::cout << "Generator " << generator << " is not [HIJING, EPOS, AMPT]. Use HIJING as default" << std::endl;
0266 cr->setOverwriteScale("/sphenix/user/dlis/Projects/centrality/cdb/calibrations/scales/cdb_centrality_scale_1.root");
0267 cr->setOverwriteVtx("/sphenix/user/dlis/Projects/centrality/cdb/calibrations/vertexscales/cdb_centrality_vertex_scale_1.root");
0268 cr->setOverwriteDivs("/sphenix/user/dlis/Projects/centrality/cdb/calibrations/divs/cdb_centrality_1.root");
0269 }
0270 se->registerSubsystem(cr);
0271 }
0272
0273 if (!rundata)
0274 {
0275 auto vtxing = new PHTruthVertexing;
0276 vtxing->associate_tracks(false);
0277 se->registerSubsystem(vtxing);
0278 }
0279
0280 if (rundata && getCentralityData)
0281 {
0282 MinimumBiasClassifier *mb = new MinimumBiasClassifier();
0283 mb->Verbosity(0);
0284 se->registerSubsystem(mb);
0285 }
0286
0287 dNdEtaINTT *myAnalyzer = new dNdEtaINTT("dNdEtaAnalyzer", outputFile, rundata);
0288 myAnalyzer->GetINTTdata(getINTTData || !rundata);
0289 myAnalyzer->GetRecoCluster(getINTTData || !rundata);
0290 myAnalyzer->GetTruthCluster(getINTTData || !rundata);
0291 myAnalyzer->GetInttRawHit(false);
0292 myAnalyzer->GetTrkrHit(getINTTData || !rundata);
0293 myAnalyzer->GetCentrality(getCentralityData);
0294
0295 myAnalyzer->GetPMTInfo(getCentralityData);
0296 myAnalyzer->GetPHG4(!rundata);
0297 myAnalyzer->GetAllPHG4(!rundata);
0298 if (!rundata)
0299 {
0300 if (generator == "SIMPLE")
0301 myAnalyzer->GetHEPMC(false);
0302 else
0303 myAnalyzer->GetHEPMC(true);
0304 }
0305 myAnalyzer->GetTrigger(rundata);
0306
0307 se->registerSubsystem(myAnalyzer);
0308
0309
0310
0311
0312 InputManagers();
0313
0314
0315
0316
0317 se->skip(skip);
0318 se->run(nEvents);
0319
0320
0321
0322
0323 se->End();
0324 std::cout << "All done" << std::endl;
0325 delete se;
0326
0327 gSystem->Exit(0);
0328 return 0;
0329 }
0330 #endif