123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213 |
- #include <iostream>
- #include <vector>
- #include <TString.h>
- #include <TH1D.h>
- #include <TH1I.h>
- #include <TH2D.h>
- #include <TProfile.h>
- #include <TProfile2D.h>
- #include <TFile.h>
- #include <TStopwatch.h>
- #include <qaParticle.h>
- #include <qaParticleLight.h>
- #include <qaEvent.h>
- #include <qaReader_manager.h>
- #include <qaReader_smash_root.h>
- #include <qaReader_mcpico.h>
- #include <Utility.h>
- #include <qaWriter_manager.h>
- #include <qaWriter_analysistree2.h>
- #ifdef _MCINI_
- #include <qaReader_mcini.h>
- #endif
- #ifdef _PHQMD_
- #include <qaReader_phqmd.h>
- #endif
- #ifdef _HSD_ROOT_
- #include <qaReader_hsd_root.h>
- #endif
- // AnalysisTree headers
- #include <AnalysisTree/Configuration.hpp>
- #include <AnalysisTree/DataHeader.hpp>
- #include <AnalysisTree/EventHeader.hpp>
- #include <AnalysisTree/Detector.hpp>
- #include <AnalysisTree/Matching.hpp>
- 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;
- }
|