#include #include #include #include #include #include #include #include #include #include #include #include #include #ifdef _MCINI_ #include #endif #ifdef _PHQMD_ #include #endif #ifdef _HSD_ROOT_ #include #endif int main(int argc, char **argv) { TString iFileName, oFileName; if (argc < 9) { std::cerr << "./ModelConverter -i input.list -o output.root -input-format [FORMAT] -output-format [FORMAT] [OPTIONAL: -debug]" << std::endl; std::cerr << "Available input formats:" << std::endl; std::cerr << "\tmcpico - simple custom ROOT format to store model data." << std::endl; std::cerr << "\tparticle - ROOT format that is used by the SMASH model." << std::endl; #ifdef _MCINI_ std::cerr << "\tmcini - custom ROOT format to store both initial state and final state (UniGen data format) model data. Fully compatible with UniGen format." << std::endl; #endif #ifdef _PHQMD_ std::cerr << "\tphqmd - custom ROOT format to store PHQMD (with MST) model data." << std::endl; #endif #ifdef _HSD_ROOT_ std::cerr << "\thsd - custom ROOT format to store HSD model data." << std::endl; #endif std::cerr << "Available output formats:" << std::endl; std::cerr << "\tmcpico - simple custom ROOT format to store model data." << std::endl; return 1; } for (int i = 1; i < argc; i++) { if (std::string(argv[i]) != "-i" && std::string(argv[i]) != "-o" && std::string(argv[i]) != "-input-format" && std::string(argv[i]) != "-output-format" && std::string(argv[i]) != "-debug") { std::cerr << "\n[ERROR]: Unknown parameter " << i << ": " << argv[i] << std::endl; return 2; } else { if (std::string(argv[i]) == "-i" && i != argc - 1) { iFileName = argv[++i]; continue; } if (std::string(argv[i]) == "-i" && i == argc - 1) { std::cerr << "\n[ERROR]: Input file name was not specified " << std::endl; return 1; } if (std::string(argv[i]) == "-o" && i != argc - 1) { oFileName = argv[++i]; continue; } if (std::string(argv[i]) == "-o" && i == argc - 1) { std::cerr << "\n[ERROR]: Output file name was not specified " << std::endl; return 1; } if (std::string(argv[i]) == "-input-format" && i != argc - 1) { mciUtility::GetInstance()->input_format = argv[++i]; continue; } if (std::string(argv[i]) == "-input-format" && i == argc - 1) { std::cerr << "\n[ERROR]: Output file name was not specified " << std::endl; return 1; } if (std::string(argv[i]) == "-output-format" && i != argc - 1) { mciUtility::GetInstance()->output_format = argv[++i]; continue; } if (std::string(argv[i]) == "-output-format" && i == argc - 1) { std::cerr << "\n[ERROR]: Output file name was not specified " << std::endl; return 1; } if (std::string(argv[i]) == "-debug" && i != argc - 1) { mciUtility::GetInstance()->debug = 1; continue; } } } TStopwatch timer; timer.Start(); if (mciUtility::GetInstance()->debug) { std::cout << "Input format = " << mciUtility::GetInstance()->input_format << std::endl; std::cout << "Output format = " << mciUtility::GetInstance()->output_format << std::endl; std::cout << "debug = " << mciUtility::GetInstance()->debug << std::endl; std::cout << "Nevents = " << mciUtility::GetInstance()->Nevents << std::endl; std::cout << std::endl; } mciReader_manager *readerManager = nullptr; if (mciUtility::GetInstance()->input_format == "mcpico") { readerManager = new mciReader_mcpico(); } #ifdef _MCINI_ if (mciUtility::GetInstance()->input_format == "mcini") { readerManager = new mciReader_mcini(); } #endif #ifdef _PHQMD_ if (mciUtility::GetInstance()->input_format == "phqmd") { readerManager = new mciReader_phqmd(); } #endif #ifdef _HSD_ROOT_ if (mciUtility::GetInstance()->input_format == "hsd") { readerManager = new mciReader_hsd_root(); } #endif if (mciUtility::GetInstance()->input_format == "particles") { readerManager = new mciReader_smash_root(); } if (!readerManager) { std::cerr << "This input format is not found!" << std::endl; return 20; } readerManager->SetChain(iFileName.Data()); Long64_t Nentries_chain = readerManager->GetEntries(); Long64_t Nentries = (mciUtility::GetInstance()->Nevents > Nentries_chain) ? Nentries_chain : mciUtility::GetInstance()->Nevents; if (mciUtility::GetInstance()->Nevents == -1) Nentries = Nentries_chain; Int_t Nparticles; mciWriter_manager *writerManager = nullptr; if (mciUtility::GetInstance()->output_format == "mcpico") { writerManager = new mciWriter_mcpico(); } if (!writerManager) { std::cerr << "This output format is not found!" << std::endl; return 30; } writerManager->SetFile(oFileName.Data()); mciEvent *event = nullptr; mciParticle *particle = nullptr; for (Long64_t ievent=0; ieventReadEvent(ievent); if (!event) continue; writerManager->SetEvent(event); Nparticles = event->GetNparticles(); for (int iparticle = 0; iparticle < Nparticles; iparticle++) { particle = readerManager->ReadParticle(iparticle); if (!particle) continue; writerManager->SetParticle(particle, iparticle); } writerManager->Fill(); } writerManager->Write(); writerManager->Close(); timer.Stop(); timer.Print(); return 0; }