#include #include #include #include #include #include #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 // AnalysisTree headers #include #include #include #include #include int main(int argc, char **argv) { TString iFileName, oFileName; TString outputFormat = "analysistree_v2"; if (argc < 7) { std::cerr << "./matc -i input.list -o output.root -input_format [INPUT_FORMAT] [OPTIONAL: -output_format [OUTPUT_FORMAT]]" << 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" << 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 << "\tanalysistree_v2 - AnalysisTree ver. 2 data format" << 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::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) { qaUtility::GetInstance()->format = argv[++i]; continue; } if (std::string(argv[i]) == "-input_format" && i == argc - 1) { std::cerr << "\n[ERROR]: Input file format was not specified " << std::endl; return 1; } if (std::string(argv[i]) == "-output_format" && i != argc - 1) { outputFormat = argv[++i]; continue; } if (std::string(argv[i]) == "-output_format" && i == argc - 1) { std::cerr << "\n[ERROR]: Output file format was not specified " << std::endl; return 1; } } } TStopwatch timer; timer.Start(); qaReader_manager *readerManager; if (qaUtility::GetInstance()->format == "mcpico") { readerManager = new qaReader_mcpico(); } #ifdef _MCINI_ if (qaUtility::GetInstance()->format == "mcini") { readerManager = new qaReader_mcini(); } #endif #ifdef _PHQMD_ if (qaUtility::GetInstance()->format == "phqmd") { readerManager = new qaReader_phqmd(); } #endif #ifdef _HSD_ROOT_ if (qaUtility::GetInstance()->format == "hsd") { readerManager = new qaReader_hsd_root(); } #endif if (qaUtility::GetInstance()->format == "particles") { readerManager = new qaReader_smash_root(); } if (!readerManager) { std::cerr << "This input format is not found!" << std::endl; return 20; } qaWriter_manager *writerManager; if (outputFormat == "analysistree_v2") { writerManager = new qaWriter_analysistree2(); } if (!writerManager) { std::cerr << "This output format is not found!" << std::endl; return 30; } readerManager->SetChain(iFileName.Data()); Long64_t Nentries = readerManager->GetEntries(); Int_t Nparticles; qaEvent *event = nullptr; qaParticle *particle = nullptr; writerManager->Init(oFileName.Data(), "modelTree"); for (Long64_t iev = 0; iev < Nentries; iev++) { if (iev % 1000 == 0) std::cout << "Event [" << Minbias_counter << "/" << Nentries << "]" << std::endl; event = (qaEvent *)readerManager->ReadEvent(iev); if (!event) continue; writerManager->WriteEvent(event); Nparticles = event->GetNparticles(); for (int iparticle = 0; iparticle < Nparticles; iparticle++) { particle = readerManager->ReadParticle(iparticle); if (!particle) continue; writerManager->WriteParticle(particle); delete particle; } writerManager->FillTree(); delete event; } writerManager->WriteTree(); timer.Stop(); timer.Print(); return 0; }