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 <dummy/dummy.h>
0018 #include <largerlenc/LargeRLENC.h>
0019 #include <jetbase/FastJetAlgo.h>
0020 #include <jetbase/JetReco.h>
0021 #include <jetbase/TowerJetInput.h>
0022 #include <jetbackground/RetowerCEMC.h>
0023 #include <largerlenc/LargeRLENC_LEDPedestalScan.h>
0024 #include <phool/recoConsts.h>
0025 #include <TFile.h>
0026 #include <TTree.h>
0027 #include <fstream>
0028
0029 R__LOAD_LIBRARY(libfun4all.so)
0030 R__LOAD_LIBRARY(libcalo_io.so)
0031 R__LOAD_LIBRARY(libffamodules.so)
0032 R__LOAD_LIBRARY(libLargeRLENC.so)
0033 R__LOAD_LIBRARY(libdummy.so)
0034 R__LOAD_LIBRARY(libjetbase.so)
0035 R__LOAD_LIBRARY(libjetbackground.so)
0036 std::pair<std::string, std::string> fix_calo_fitting_dst_names(int dst_numb, std::string data_fitting_dst_name){
0037 int first_file_num=dst_numb*2;
0038 int snd_file_num = first_file_num+1;
0039 std::string file_name_stem=data_fitting_dst_name.substr(0, data_fitting_dst_name.find(".root")-5);
0040 std::stringstream file1 (file_name_stem), file2(file_name_stem);
0041 std::stringstream file11, file22;
0042 file11 <<std::setw(5) <<std::setfill('0') <<first_file_num <<".root";
0043 file22 <<std::setw(5) <<std::setfill('0') <<snd_file_num <<".root";
0044 std::string s (file1.str());
0045 std::string s2 (file2.str());
0046 s+=file11.str();
0047 s2+=file22.str();
0048 return std::make_pair(s, s2);
0049
0050 }
0051 int RunLargeRLENC(std::string data_dst="none", std::string data_fitting_dst="none", std::string data_trigger="none", std::string data_jet="none", std::string truthfile="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")
0052 {
0053 std::cout<<"actually processing this thing" <<std::endl;
0054 std::map<std::string, std::string> input_files {{data_dst, "data_calo_dst"}, {data_fitting_dst, "data_fitting"}, {data_trigger,"data_trigger"}, {data_jet, "data_jet"}, {truthjetfile, "truthjet"}, {calotowersfile, "calotowers"}, {truthrecofile, "truthreco"}, {globalrecofile, "globalreco"}, {truthfile, "truth"}};
0055
0056 Fun4AllServer* se=Fun4AllServer::instance();
0057 std::cout<<"Initiated the fun for all server" <<std::endl;
0058 int run_number=0, segment=0, n_evts=std::stoi(n_evt);
0059
0060 bool data=true;
0061
0062 se->Verbosity(0);
0063 if(data_dst.find("none") != std::string::npos) data=false;
0064 if(data){
0065 segment=Fun4AllUtils::GetRunSegment(data_dst).second;
0066 }
0067
0068 for(auto f:input_files)
0069 {
0070 std::cout<<"working on the file for: " <<f.second <<std::endl;
0071 if(f.first.find("none") != std::string::npos) continue;
0072
0073
0074
0075
0076
0077
0078
0079
0080
0081
0082
0083
0084
0085
0086
0087
0088 std::cout<<f.first<<std::endl;
0089 std::stringstream filename(f.first);
0090 if(run_number == 0){
0091 std::cout<<"trying to get the run number" <<f.first <<std::endl;
0092
0093 std::pair<int, int> runseg=Fun4AllUtils::GetRunSegment(f.first);
0094 run_number=runseg.first;
0095 segment=runseg.second;
0096 std::cout<<"run " <<run_number <<" segement " <<segment <<std::endl;
0097 }
0098
0099
0100
0101
0102
0103
0104
0105
0106
0107
0108
0109
0110
0111
0112
0113
0114
0115
0116 try{
0117 Fun4AllInputManager* input_file = new Fun4AllDstInputManager(f.second);
0118 input_file->AddFile(f.first);
0119 se->registerInputManager(input_file);
0120 }
0121 catch(std::exception& e){std::cout<<"Unable to load file " <<f.first <<std::endl;}
0122 }
0123
0124 if(data){
0125 recoConsts *rc = recoConsts::instance();
0126 rc->set_StringFlag("CDB_GLOBALTAG", dbtag);
0127 rc->set_uint64Flag("TIMESTAMP", run_number);
0128 CDBInterface::instance() -> Verbosity(0);
0129 Process_Calo_Calib();
0130 }
0131 else{
0132 recoConsts *rc = recoConsts::instance();
0133 rc->set_StringFlag("CDB_GLOBALTAG", "MDC2");
0134 rc->set_uint64Flag("TIMESTAMP", run_number);
0135 CDBInterface::instance() -> Verbosity(0);
0136 Process_Calo_Calib();
0137 }
0138
0139 bool nojets=true, retower_needed=true;
0140
0141
0142
0143
0144
0145
0146
0147
0148
0149
0150
0151
0152
0153
0154
0155
0156
0157
0158
0159
0160
0161
0162
0163
0164
0165
0166
0167
0168
0169
0170
0171
0172
0173
0174
0175
0176
0177
0178 std::cout<<"Loaded all subparts in, now loading in the analysis code" <<std::endl;
0179
0180
0181 LargeRLENC* rlenc=new LargeRLENC(run_number, segment, std::stof(minpt), data);
0182
0183
0184 se->registerSubsystem(rlenc);
0185
0186
0187
0188 std::cout<<"Runing for " <<n_evt <<" events" <<std::endl;
0189 se->run(n_evts);
0190
0191
0192 rlenc->Print();
0193 return 0;
0194 }
0195 #endif