File indexing completed on 2026-07-16 08:11:20
0001 #ifndef MACRO_FUN4ALLG4SPHENIX_C
0002 #define MACRO_FUN4ALLG4SPHENIX_C
0003
0004 #include "G4_Input.C"
0005 #include <G4_Global.C>
0006 #include <G4Setup_sPHENIX.C>
0007
0008 #include <Trkr_RecoInit.C>
0009 #include <Trkr_Clustering.C>
0010 #include <Trkr_TruthTables.C>
0011 #include <Trkr_Reco.C>
0012
0013 #include <phpythia8/PHPy8ParticleTrigger.h>
0014
0015 #include <decayfinder/DecayFinder.h>
0016 #include <hftrackefficiency/HFTrackEfficiency.h>
0017 #include <kfparticle_sphenix/KFParticle_sPHENIX.h>
0018
0019 #include <ffamodules/FlagHandler.h>
0020 #include <ffamodules/HeadReco.h>
0021 #include <ffamodules/SyncReco.h>
0022 #include <ffamodules/CDBInterface.h>
0023 #include <phool/PHRandomSeed.h>
0024 #include <phool/recoConsts.h>
0025
0026 #include <fun4all/Fun4AllRunNodeInputManager.h>
0027 #include <fun4all/Fun4AllDstOutputManager.h>
0028 #include <fun4all/Fun4AllOutputManager.h>
0029 #include <fun4all/Fun4AllServer.h>
0030
0031 #include <simqa_modules/QAG4SimulationTracking.h>
0032 #include <qautils/QAHistManagerDef.h>
0033
0034 #include "HF_selections.C"
0035
0036 #include <Trkr_Eval.C>
0037
0038
0039 R__LOAD_LIBRARY(libfun4all.so)
0040 R__LOAD_LIBRARY(libffamodules.so)
0041 R__LOAD_LIBRARY(libdecayfinder.so)
0042 R__LOAD_LIBRARY(libhftrackefficiency.so)
0043 R__LOAD_LIBRARY(libsimqa_modules.so)
0044
0045 int Fun4All_HFG(std::string processID = "0", std::string channel = "cascade")
0046 {
0047 int nEvents = 1e3;
0048
0049 string date = "20260513";
0050 std::string outDir = "./" + channel + "_" + date + "/";
0051
0052 string makeDirectory = "mkdir -p " + outDir + "hfEff";
0053 system(makeDirectory.c_str());
0054
0055
0056 Fun4AllServer *se = Fun4AllServer::instance();
0057 se->Verbosity(1);
0058
0059 PHRandomSeed::Verbosity(1);
0060 recoConsts *rc = recoConsts::instance();
0061
0062
0063
0064 Input::PYTHIA8 = true;
0065 int particleID = 421;
0066 PYTHIA8::config_file[0] = "steeringCards/pythia8_MB_Detroit_Tony.cfg";
0067 if (channel == "Kshort2pipi")
0068 {
0069 run_pipi_reco = false;
0070 particleID = 310;
0071 }
0072 else if (channel == "Lambda2ppi")
0073 {
0074 run_ppi_reco = false;
0075 particleID = 3122;
0076 }
0077 else if (channel == "Lambdabar2ppi")
0078 {
0079 run_anti_ppi_reco = false;
0080 particleID = -3122;
0081 }
0082 else if (channel == "cascade")
0083 {
0084 run_cascade_reco = false;
0085 particleID = 3312;
0086 }
0087 else if (channel == "minBias")
0088 {
0089 std::cout << "Min bias simulations" << std::endl;
0090 }
0091 else
0092 {
0093 std::cout << "Your decay channel " << channel << " is not known" << std::endl;
0094 exit(1);
0095 }
0096 Input::BEAM_CONFIGURATION = Input::pp_COLLISION;
0097
0098 InputInit();
0099
0100 float abs_eta = 10;
0101
0102 if (channel != "minBias")
0103 {
0104
0105 int pidtrig = particleID;
0106
0107 auto trigger = new PHPy8ParticleTrigger();
0108 trigger->Verbosity(0);
0109 trigger->AddParticles(pidtrig);
0110 trigger->AddParticles(-1 * pidtrig);
0111 trigger->SetYHighLow(1.2, -1.2);
0112 trigger->SetStableParticleOnly(false);
0113 trigger->PrintConfig();
0114
0115 INPUTGENERATOR::Pythia8[0]->register_trigger(trigger);
0116 INPUTGENERATOR::Pythia8[0]->set_trigger_OR();
0117 Input::ApplysPHENIXBeamParameter(INPUTGENERATOR::Pythia8[0]);
0118
0119
0120
0121
0122
0123
0124
0125
0126
0127
0128
0129
0130
0131
0132
0133
0134
0135
0136
0137
0138
0139
0140
0141
0142
0143
0144
0145
0146
0147
0148
0149
0150
0151
0152
0153
0154 }
0155
0156 Input::ApplysPHENIXBeamParameter(INPUTGENERATOR::Pythia8[0]);
0157
0158 InputRegister();
0159
0160
0161
0162 Enable::CDB = true;
0163 rc->set_StringFlag("CDB_GLOBALTAG","MDC2");
0164 rc->set_uint64Flag("TIMESTAMP",1);
0165 rc->set_IntFlag("RUNNUMBER",1);
0166
0167 Enable::MVTX_APPLYMISALIGNMENT = true;
0168 ACTSGEOM::mvtx_applymisalignment = Enable::MVTX_APPLYMISALIGNMENT;
0169
0170 SyncReco *sync = new SyncReco();
0171 se->registerSubsystem(sync);
0172
0173 HeadReco *head = new HeadReco();
0174 se->registerSubsystem(head);
0175
0176 FlagHandler *flag = new FlagHandler();
0177 se->registerSubsystem(flag);
0178
0179
0180 Enable::MBDFAKE = true;
0181 Enable::PIPE = true;
0182 Enable::PIPE_ABSORBER = true;
0183 Enable::MVTX = true;
0184 Enable::INTT = true;
0185 Enable::TPC = true;
0186 Enable::MICROMEGAS = true;
0187
0188
0189
0190 G4Init();
0191 MagnetInit();
0192 MagnetFieldInit();
0193
0194 G4Setup();
0195
0196
0197 DecayFinder *myFinder = new DecayFinder("myFinder");
0198 myFinder->Verbosity(INT_MAX);
0199 if (channel == "Kshort2pipi") myFinder->setDecayDescriptor(pipi_decay_descriptor);
0200 else if (channel == "Lambda2ppi") myFinder->setDecayDescriptor(ppi_decay_descriptor);
0201 else if (channel == "cascade") myFinder->setDecayDescriptor(cascade_decay_descriptor);
0202 else myFinder->setDecayDescriptor(anti_ppi_decay_descriptor);
0203 myFinder->saveDST(1);
0204 myFinder->allowPi0(1);
0205 myFinder->allowPhotons(1);
0206 myFinder->triggerOnDecay(0);
0207 myFinder->setPTmin(0.);
0208 myFinder->setEtaRange(-1*abs_eta, abs_eta);
0209 myFinder->useDecaySpecificEtaRange(false);
0210 if (channel != "minBias") se->registerSubsystem(myFinder);
0211
0212 Mbd_Reco();
0213 Mvtx_Cells();
0214 Intt_Cells();
0215 TPC_Cells();
0216 Micromegas_Cells();
0217
0218 TrackingInit();
0219
0220 Mvtx_Clustering();
0221 Intt_Clustering();
0222 TPC_Clustering();
0223 Micromegas_Clustering();
0224
0225 Tracking_Reco();
0226
0227 auto vtxfinder = new PHSimpleVertexFinder;
0228 vtxfinder->Verbosity(0);
0229 vtxfinder->setDcaCut(1);
0230 vtxfinder->setTrackPtCut(-99999.);
0231 vtxfinder->setBeamLineCut(1);
0232 vtxfinder->setTrackQualityCut(1000000000);
0233 vtxfinder->setRequireMVTX(false);
0234
0235 vtxfinder->setOutlierPairCut(1);
0236 se->registerSubsystem(vtxfinder);
0237
0238 Global_Reco();
0239
0240 build_truthreco_tables();
0241
0242
0243
0244
0245
0246
0247 string evalDir = outDir + "evaluatorFiles/" + channel + "/" + date + "/";
0248 makeDirectory = "mkdir -p " + evalDir;
0249 system(makeDirectory.c_str());
0250 string evalFile = evalDir + "evalFile_" + channel + "_" + processID + ".root";
0251
0252 SvtxEvaluator* eval;
0253 eval = new SvtxEvaluator("SVTXEVALUATOR", evalFile, "SvtxTrackMap",
0254 G4MVTX::n_maps_layer,
0255 G4INTT::n_intt_layer,
0256 G4TPC::n_gas_layer,
0257 G4MICROMEGAS::n_micromegas_layer);
0258 eval->do_cluster_eval(false);
0259 eval->do_g4hit_eval(false);
0260 eval->do_hit_eval(false);
0261 eval->do_gpoint_eval(false);
0262 eval->do_vtx_eval_light(false);
0263 eval->do_eval_light(false);
0264 eval->do_info_eval(false);
0265 eval->do_vertex_eval(false);
0266 eval->do_g4cluster_eval(false);
0267 eval->do_track_eval(false);
0268 eval->do_gtrack_eval(true);
0269 eval->do_track_match(true);
0270 eval->set_use_initial_vertex(G4TRACKING::g4eval_use_initial_vertex);
0271 bool embed_scan = false;
0272 if (TRACKING::pp_mode) embed_scan = false;
0273 eval->scan_for_embedded(embed_scan);
0274 eval->scan_for_primaries(embed_scan);
0275 eval->Verbosity(0);
0276 se->registerSubsystem(eval);
0277
0278 HFTrackEfficiency *myTrackEff = new HFTrackEfficiency("myTrackEff");
0279 myTrackEff->Verbosity(INT_MAX);
0280 myTrackEff->setDFNodeName("myFinder");
0281 myTrackEff->triggerOnDecay(0);
0282 myTrackEff->writeSelectedTrackMap(true);
0283 myTrackEff->writeOutputFile(true);
0284 std::string outputHFEffFile = outDir + "/hfEff/outputHFTrackEff_" + channel + "_" + processID + ".root";
0285 myTrackEff->setOutputFileName(outputHFEffFile);
0286 if (channel != "minBias" && false) se->registerSubsystem(myTrackEff);
0287
0288 output_dir = outDir;
0289
0290 if (run_pipi_reco) create_hf_directories(pipi_reconstruction_name, pipi_output_dir, pipi_output_reco_file, processID);
0291 if (run_ppi_reco) create_hf_directories(ppi_reconstruction_name, ppi_output_dir, ppi_output_reco_file, processID);
0292 if (run_anti_ppi_reco) create_hf_directories(anti_ppi_reconstruction_name, anti_ppi_output_dir, anti_ppi_output_reco_file, processID);
0293 if (run_cascade_reco) create_hf_directories(cascade_reconstruction_name, cascade_output_dir, cascade_output_reco_file, processID);
0294
0295 if (run_pipi_reco) reconstruct_pipi_mass();
0296 if (run_ppi_reco) reconstruct_ppi_mass();
0297 if (run_anti_ppi_reco) reconstruct_ppi_mass();
0298 if (run_cascade_reco) reconstruct_Lambdapi_mass();
0299
0300
0301
0302
0303
0304
0305
0306
0307
0308
0309
0310
0311
0312
0313
0314
0315
0316
0317
0318
0319
0320
0321
0322
0323
0324
0325
0326
0327
0328
0329
0330
0331
0332
0333
0334
0335
0336 se->run(nEvents);
0337
0338 se->End();
0339
0340 if (run_pipi_reco) end_kfparticle(pipi_output_reco_file, pipi_output_dir);
0341 if (run_ppi_reco) end_kfparticle(ppi_output_reco_file, ppi_output_dir);
0342 if (run_anti_ppi_reco) end_kfparticle(ppi_output_reco_file, ppi_output_dir);
0343 if (run_cascade_reco) end_kfparticle(cascade_output_reco_file, cascade_output_dir);
0344
0345 gSystem->Exit(0);
0346
0347 return 0;
0348 }
0349
0350 #endif