File indexing completed on 2025-08-05 08:19:41
0001
0002 #include <iostream>
0003 #include <memory>
0004 #include <string>
0005 #include <format>
0006
0007
0008 #include <TFile.h>
0009 #include <TSystem.h>
0010
0011 #include <calib_emc_pi0/pi0EtaByEta.h>
0012 R__LOAD_LIBRARY(libcalibCaloEmc_pi0.so)
0013
0014 void doFitAndCalibUpdate(const std::string &hist_fname = "base/combine_out/out2.root",
0015 const std::string &calib_fname = "base/local_calib_copy.root",
0016 int iter = 4,
0017 const std::string &fieldname = "CEMC_calib_ADC_to_ETower")
0018 {
0019 std::string m_fieldname = fieldname;
0020
0021 std::unique_ptr<pi0EtaByEta> caFit = std::make_unique<pi0EtaByEta>("calomodulename", "bla.root");
0022 caFit->set_massTargetHistFile("/sphenix/user/egm2153/calib_study/emcal_calib_year1/hijing_run14_fb_wupdatedsmear/hijing_run14_uncorr_cls_mass_towerThreshold070MeV.root");
0023
0024
0025
0026
0027 caFit->set_calib_fieldname(m_fieldname);
0028 caFit->fitEtaSlices(hist_fname, std::format("fitout_iter{}.root", iter), calib_fname);
0029
0030 size_t pos = calib_fname.find_last_of('.');
0031 std::string f_calib_save_name = calib_fname;
0032 f_calib_save_name.insert(pos, std::format("_iter{}", iter));
0033
0034 std::unique_ptr<TFile> f_calib_mod = std::make_unique<TFile>(calib_fname.c_str());
0035 f_calib_mod->Cp(f_calib_save_name.c_str());
0036
0037 gSystem->Exit(0);
0038 }
0039
0040 #ifndef __CINT__
0041 int main(int argc, const char *const argv[])
0042 {
0043 const std::vector<std::string> args(argv, argv + argc);
0044
0045 if (args.size() < 3 || args.size() > 5)
0046 {
0047 std::cout << "usage: " << args[0] << " hist_fname calib_fname [iter] [m_fieldname]" << std::endl;
0048 return 1;
0049 }
0050
0051 const std::string& hist_fname = args[1];
0052 const std::string& calib_fname = args[2];
0053 int iter = 4;
0054 std::string m_fieldname = "CEMC_calib_ADC_to_ETower";
0055
0056 if (args.size() >= 4)
0057 {
0058 iter = std::stoi(args[3]);
0059 }
0060 if (args.size() >= 5)
0061 {
0062 m_fieldname = args[4];
0063 }
0064
0065 doFitAndCalibUpdate(hist_fname, calib_fname, iter, m_fieldname);
0066
0067 std::cout << "======================================" << std::endl;
0068 std::cout << "done" << std::endl;
0069 return 0;
0070 }
0071 #endif