File indexing completed on 2026-05-23 08:12:16
0001 #include <string>
0002 #include <sstream>
0003 #include <iostream>
0004 #include <format>
0005
0006 #include <fun4all/Fun4AllBase.h>
0007 #include <fun4all/Fun4AllUtils.h>
0008 #include <fun4all/Fun4AllServer.h>
0009 #include <fun4all/Fun4AllInputManager.h>
0010 #include <fun4all/Fun4AllDstInputManager.h>
0011 #include <fun4all/SubsysReco.h>
0012 #include <ffamodules/CDBInterface.h>
0013 #include "Calo_CalibLocal.C"
0014
0015 #include <caloreco/RawClusterBuilderTopo.h>
0016
0017 #include <jetbase/JetReco.h>
0018 #include <jetbase/TowerJetInput.h>
0019 #include <jetbase/JetCalib.h>
0020 #include <jetbackground/FastJetAlgoSub.h>
0021
0022 #include <g4jets/TruthJetInput.h>
0023
0024
0025
0026
0027
0028 #include <jetbackground/TimingCut.h>
0029
0030 #include <dummy/dummy.h>
0031 #include <jetbackground/RetowerCEMC.h>
0032 #include <fstream>
0033
0034 R__LOAD_LIBRARY(libfun4all.so)
0035 R__LOAD_LIBRARY(libfun4allraw.so)
0036 R__LOAD_LIBRARY(libcalo_io.so)
0037 R__LOAD_LIBRARY(libffamodules.so)
0038 R__LOAD_LIBRARY(libjetbase.so)
0039 R__LOAD_LIBRARY(libjetbackground.so)
0040 R__LOAD_LIBRARY(libg4dst.so)
0041
0042 void Fun4All_VandySkimmerTruthCounter(const std::string caloDSTlist, const std::string jetDSTlist, const std::string g4HitsDSTlist, const std::string globalDSTlist, const std::string outDir = "/sphenix/tg/tg01/jets/bkimelman/wEEC/", const std::string nfiles="25", const bool P_or_H = true)
0043 {
0044
0045 bool doSim = true;
0046
0047 Fun4AllServer* se=Fun4AllServer::instance();
0048 se->Verbosity(0);
0049
0050
0051 int runnumber = 0;
0052 int seg = 0;
0053 int n=0;
0054 n = std::stoi(nfiles);
0055
0056 std::ifstream ifs(caloDSTlist);
0057 std::string filepath;
0058 std::getline(ifs,filepath);
0059 std::pair<int,int> runseg = Fun4AllUtils::GetRunSegment(filepath);
0060 runnumber = runseg.first;
0061 seg = runseg.second;
0062
0063 std::string sample_name {"Jet20"};
0064 std::stringstream fullfilename (caloDSTlist);
0065 std::string temp1, temp2;
0066 while(std::getline(fullfilename, temp1, '/'))
0067 {
0068 if(temp1.find("Jet") == std::string::npos) continue;
0069 std::stringstream filetag (temp1);
0070 while(std::getline(filetag, temp2, '_'))
0071 {
0072 if(temp2.find("data") == std::string::npos){
0073 sample_name = temp2;
0074 if(!P_or_H) sample_name = "Herwig"+sample_name;
0075 break;
0076 }
0077 }
0078 break;
0079 }
0080 Fun4AllInputManager *inCalo = new Fun4AllDstInputManager("InputManagerCalo");
0081 inCalo->AddListFile(caloDSTlist);
0082 se->registerInputManager(inCalo);
0083
0084 Fun4AllInputManager *inJet = new Fun4AllDstInputManager("InputManagerJet");
0085 inJet->AddListFile(jetDSTlist);
0086 se->registerInputManager(inJet);
0087
0088 Fun4AllInputManager *inTruth = new Fun4AllDstInputManager("InputManagerG4Hits");
0089 inTruth->AddListFile(g4HitsDSTlist);
0090 se->registerInputManager(inTruth);
0091
0092 Fun4AllInputManager *inGlobal = new Fun4AllDstInputManager("InputManagerGlobal");
0093 inGlobal->AddListFile(globalDSTlist);
0094 se->registerInputManager(inGlobal);
0095
0096 dummy* dm = new dummy();
0097 se->registerSubsystem(dm);
0098 se->run(0);
0099 se->End();
0100 int n_events=dm->n_evts;
0101 std::string end_text=sample_name+"_starting_seg_"+std::to_string(seg)+".txt";
0102 std::cout<<end_text<<std::endl;
0103 ofstream outfile (end_text.c_str());
0104 if(!outfile.is_open()) std::cout<<"Couldn't open the file" <<std::endl;
0105 outfile<<n_events<<std::endl;
0106 std::cout<<dm->n_evts<<std::endl;
0107 outfile.close();
0108
0109
0110
0111 }