File indexing completed on 2025-08-06 08:13:24
0001 #pragma once
0002 #if ROOT_VERSION_CODE >= ROOT_VERSION(6,00,0)
0003 #include <string>
0004 #include <sstream>
0005 #include <vector>
0006 #include <utility>
0007 #include <map>
0008 #include <algorithm>
0009 #include <fun4all/Fun4AllBase.h>
0010 #include <fun4all/Fun4AllUtils.h>
0011 #include <fun4all/Fun4AllServer.h>
0012 #include <fun4all/Fun4AllInputManager.h>
0013 #include <fun4all/Fun4AllDstInputManager.h>
0014 #include <fun4all/SubsysReco.h>
0015 #include <ffamodules/CDBInterface.h>
0016 #include <Calo_Calib.C>
0017 #include <largerlenc/LargeRLENC.h>
0018 #include <jetbase/FastJetAlgo.h>
0019 #include <jetbase/JetReco.h>
0020 #include <jetbase/TowerJetInput.h>
0021 #include <jetbackground/RetowerCEMC.h>
0022 #include <phool/recoConsts.h>
0023 #include <TFile.h>
0024 #include <TTree.h>
0025 #include <fstream>
0026
0027 R__LOAD_LIBRARY(libfun4all.so)
0028 R__LOAD_LIBRARY(libcalo_io.so)
0029 R__LOAD_LIBRARY(libffamodules.so)
0030 R__LOAD_LIBRARY(libLargeRLENC.so)
0031 R__LOAD_LIBRARY(libjetbase.so)
0032 R__LOAD_LIBRARY(libjetbackground.so)
0033
0034 int RunLargeRLENC_test(std::string data_dst="none", std::string data_fitting_dst="none", std::string data_trigger="none", std::string truthjetfile="none", std::string calotowersfile="none", std::string truthrecofile="none", std::string globalrecofile="none", std::string n_evt="0", std::string minpt="1.0", const std::string& dbtag="ProdA_2024")
0035 {
0036 std::cout<<"actually processing this thing" <<std::endl;
0037 std::map<std::string, std::string> input_files {{data_dst, "data"}, {data_fitting_dst, "data_fitting"}, {data_trigger, "data_trigger"}, {truthjetfile, "truthjet"}, {calotowersfile, "calotowers"}, {truthrecofile, "truthreco"}, {globalrecofile, "globalreco"}};
0038 Fun4AllServer* se=Fun4AllServer::instance();
0039 std::cout<<"Initiated the fun for all server" <<std::endl;
0040 int run_number=0, segment=0, n_evts=std::stoi(n_evt);
0041
0042 bool data=true;
0043 if(data_dst.find("none") != std::string::npos) data=false;
0044 for(auto f:input_files)
0045 {
0046 std::cout<<"working on the file for: " <<f.second <<std::endl;
0047 if(f.first.find("none") != std::string::npos) continue;
0048 std::cout<<f.first<<std::endl;
0049 std::stringstream filename(f.first);
0050 if(run_number == 0){
0051 std::cout<<"trying to get the run number" <<f.first <<std::endl;
0052 std::pair<int, int> runseg=Fun4AllUtils::GetRunSegment(f.first);
0053 run_number=runseg.first;
0054 segment=runseg.second;
0055 std::cout<<"run " <<run_number <<" segement " <<segment <<std::endl;
0056 }
0057
0058
0059
0060
0061
0062
0063
0064
0065
0066
0067
0068
0069
0070
0071
0072
0073
0074
0075 try{
0076 Fun4AllInputManager* input_file = new Fun4AllDstInputManager(f.second);
0077 input_file->AddFile(f.first);
0078 se->registerInputManager(input_file);
0079 }
0080 catch(std::exception& e){std::cout<<"Unable to load file " <<f.first <<std::endl;}
0081 }
0082 if(data){
0083 recoConsts *rc = recoConsts::instance();
0084 rc->set_StringFlag("CDB_GLOBALTAG", dbtag);
0085 rc->set_uint64Flag("TIMESTAMP", run_number);
0086 CDBInterface::instance() -> Verbosity(0);
0087 Process_Calo_Calib();
0088 }
0089 else{
0090 recoConsts *rc = recoConsts::instance();
0091 rc->set_StringFlag("CDB_GLOBALTAG", "MDC2");
0092 rc->set_uint64Flag("TIMESTAMP", run_number);
0093 CDBInterface::instance() -> Verbosity(0);
0094 Process_Calo_Calib();
0095 }
0096
0097 bool nojets=true, retower_needed=true;
0098
0099
0100
0101
0102
0103
0104
0105
0106
0107
0108
0109
0110
0111
0112
0113
0114
0115
0116
0117
0118
0119
0120 if(data && nojets){
0121 JetReco* data_jets=new JetReco("JetReco");
0122 data_jets->add_input(new TowerJetInput(Jet::CEMC_TOWERINFO_RETOWER));
0123 data_jets->add_input(new TowerJetInput(Jet::HCALIN_TOWERINFO));
0124 data_jets->add_input(new TowerJetInput(Jet::HCALOUT_TOWERINFO));
0125 data_jets->add_algo(new FastJetAlgo(Jet::ANTIKT, 0.4), "AntiKt_TowerInfo_r04");
0126 data_jets->set_algo_node("ANTIKT");
0127 data_jets->set_input_node("TOWER");
0128 data_jets->Verbosity(0);
0129 se->registerSubsystem(data_jets);
0130
0131 }
0132 std::cout<<"Loaded all subparts in, now loading in the analysis code" <<std::endl;
0133
0134
0135 LargeRLENC* rlenc=new LargeRLENC(run_number, segment, std::stof(minpt), data);
0136 se->registerSubsystem(rlenc);
0137 std::cout<<"Runing for " <<n_evt <<" events" <<std::endl;
0138 se->run(n_evts);
0139 rlenc->Print();
0140 return 0;
0141 }
0142 #endif