File indexing completed on 2025-08-03 08:20:29
0001 #include <QA.C>
0002
0003 #include <fun4all/Fun4AllDstOutputManager.h>
0004 #include <fun4all/Fun4AllInputManager.h>
0005 #include <fun4all/Fun4AllOutputManager.h>
0006 #include <fun4all/Fun4AllServer.h>
0007 #include <fun4allraw/Fun4AllStreamingInputManager.h>
0008 #include <fun4allraw/InputManagerType.h>
0009 #include <fun4allraw/SingleGl1PoolInput.h>
0010 #include <fun4allraw/SingleInttPoolInput.h>
0011 #include <fun4allraw/SingleMicromegasPoolInput.h>
0012 #include <fun4allraw/SingleMvtxPoolInput.h>
0013 #include <fun4allraw/SingleTpcPoolInput.h>
0014
0015 #include <intt/InttOdbcQuery.h>
0016
0017 #include <phool/recoConsts.h>
0018
0019 #include <ffarawmodules/InttCheck.h>
0020 #include <ffarawmodules/StreamingCheck.h>
0021 #include <ffarawmodules/TpcCheck.h>
0022
0023 #include <ffamodules/HeadReco.h>
0024 #include <ffamodules/FlagHandler.h>
0025 #include <ffamodules/SyncReco.h>
0026
0027 R__LOAD_LIBRARY(libfun4all.so)
0028 R__LOAD_LIBRARY(libffamodules.so)
0029 R__LOAD_LIBRARY(libfun4allraw.so)
0030 R__LOAD_LIBRARY(libffarawmodules.so)
0031 R__LOAD_LIBRARY(libintt.so)
0032 bool isGood(const string &infile);
0033
0034 void Fun4All_SingleStream_Combiner(int nEvents = 0,
0035 const int runnumber = 30117,
0036 const string &outdir = "/sphenix/lustre01/sphnxpro/commissioning/slurp/tpccosmics/",
0037 const string &type = "streaming",
0038 const string &input_gl1file = "gl1daq.list",
0039 const string &input_tpcfile00 = "tpc00.list",
0040 const string &input_inttfile00 = "intt0.list",
0041 const string &input_mvtxfile00 = "mvtx0.list",
0042 const string &input_tpotfile = "tpot.list")
0043 {
0044
0045 vector<string> gl1_infile;
0046 gl1_infile.push_back(input_gl1file);
0047
0048
0049 vector<string> mvtx_infile;
0050 mvtx_infile.push_back(input_mvtxfile00);
0051
0052
0053 vector<string> intt_infile;
0054 intt_infile.push_back(input_inttfile00);
0055
0056 vector<string> tpc_infile;
0057 tpc_infile.push_back(input_tpcfile00);
0058
0059
0060 vector<string> tpot_infile;
0061 tpot_infile.push_back(input_tpotfile);
0062
0063 Fun4AllServer *se = Fun4AllServer::instance();
0064 se->Verbosity(1);
0065 recoConsts *rc = recoConsts::instance();
0066 Fun4AllStreamingInputManager *in = new Fun4AllStreamingInputManager("Comb");
0067
0068
0069
0070 int i = 0;
0071
0072 std::string readoutNumber = "";
0073
0074 for (auto iter : gl1_infile)
0075 {
0076 if (isGood(iter))
0077 {
0078 SingleGl1PoolInput *gl1_sngl = new SingleGl1PoolInput("GL1_" + to_string(i));
0079
0080 gl1_sngl->AddListFile(iter);
0081 in->registerStreamingInput(gl1_sngl, InputManagerType::GL1);
0082 i++;
0083 }
0084 }
0085 i = 0;
0086
0087
0088 for (auto iter : intt_infile)
0089 {
0090 if (isGood(iter))
0091 {
0092 SingleInttPoolInput *intt_sngl = new SingleInttPoolInput("INTT_" + to_string(i));
0093
0094 InttOdbcQuery query;
0095 bool isStreaming = false;
0096 if(RunNumber != 0)
0097 {
0098 query.Query(RunNumber);
0099 isStreaming = query.IsStreaming();
0100 }
0101 intt_sngl->streamingMode(isStreaming);
0102 auto pos = iter.find("intt");
0103 std::string num = iter.substr(pos+4, 1);
0104 readoutNumber = "INTT"+num;
0105 intt_sngl->setHitContainerName("INTTRAWHIT_" + num);
0106
0107 intt_sngl->AddListFile(iter);
0108 in->registerStreamingInput(intt_sngl, InputManagerType::INTT);
0109 i++;
0110 }
0111 }
0112 i = 0;
0113 for (auto iter : mvtx_infile)
0114 {
0115 if (isGood(iter))
0116 {
0117
0118
0119 std::string filepath, felix;
0120 std::ifstream ifs(iter);
0121 while(std::getline(ifs, filepath))
0122 {
0123 auto pos = filepath.find("mvtx");
0124 felix = filepath.substr(pos+4, 1);
0125 break;
0126 }
0127 readoutNumber = "MVTX"+felix;
0128 SingleMvtxPoolInput *mvtx_sngl = new SingleMvtxPoolInput("MVTX_" + to_string(i));
0129
0130
0131 mvtx_sngl->setHitContainerName("MVTXRAWHIT_" + felix);
0132 mvtx_sngl->setRawEventHeaderName("MVTXRAWEVTHEADER_" + felix);
0133 mvtx_sngl->AddListFile(iter);
0134 in->registerStreamingInput(mvtx_sngl, InputManagerType::MVTX);
0135 i++;
0136 }
0137 }
0138 i = 0;
0139 for (auto iter : tpc_infile)
0140 {
0141 if (isGood(iter))
0142 {
0143
0144
0145 std::string filepath, ebdc;
0146 std::ifstream ifs(iter);
0147 while(std::getline(ifs, filepath))
0148 {
0149 auto pos = filepath.find("ebdc");
0150 ebdc = filepath.substr(pos+4, 2);
0151 break;
0152 }
0153
0154 SingleTpcPoolInput *tpc_sngl = new SingleTpcPoolInput("TPC_" + to_string(i));
0155
0156
0157 readoutNumber = "TPC"+ebdc;
0158 tpc_sngl->SetBcoRange(5);
0159 tpc_sngl->setHitContainerName("TPCRAWHIT_" + ebdc);
0160 tpc_sngl->AddListFile(iter);
0161 in->registerStreamingInput(tpc_sngl, InputManagerType::TPC);
0162 i++;
0163 }
0164 }
0165 i = 0;
0166
0167 for (auto iter : tpot_infile)
0168 {
0169 if (isGood(iter))
0170 {
0171 SingleMicromegasPoolInput *mm_sngl = new SingleMicromegasPoolInput("MICROMEGAS_" + to_string(i));
0172
0173 mm_sngl->SetBcoRange(10);
0174 mm_sngl->SetNegativeBco(2);
0175 mm_sngl->SetBcoRange(10);
0176 mm_sngl->SetBcoPoolSize(50);
0177 mm_sngl->AddListFile(iter);
0178 in->registerStreamingInput(mm_sngl, InputManagerType::MICROMEGAS);
0179 readoutNumber = "TPOT";
0180 i++;
0181 }
0182 }
0183
0184 se->registerInputManager(in);
0185
0186
0187
0188
0189
0190
0191
0192 SyncReco *sync = new SyncReco();
0193 se->registerSubsystem(sync);
0194
0195 HeadReco *head = new HeadReco();
0196 se->registerSubsystem(head);
0197
0198 FlagHandler *flag = new FlagHandler();
0199 se->registerSubsystem(flag);
0200
0201
0202 char outfile[500];
0203 sprintf(outfile,"./%s-%s.root",type.c_str(),readoutNumber.c_str());
0204
0205 Fun4AllOutputManager *out = new Fun4AllDstOutputManager("out",outfile);
0206 se->registerOutputManager(out);
0207
0208 if (nEvents < 0)
0209 {
0210 return;
0211 }
0212 se->run(nEvents);
0213
0214 se->End();
0215
0216 char histoutfile[500];
0217 sprintf(histoutfile,"./HIST_%s-%s-%08i-%05i.root",type.c_str(),readoutNumber.c_str(),runnumber,0);
0218 QAHistManagerDef::saveQARootFile(histoutfile);
0219
0220 delete se;
0221 cout << "all done" << endl;
0222 gSystem->Exit(0);
0223 }
0224
0225 bool isGood(const string &infile)
0226 {
0227 ifstream intest;
0228 intest.open(infile);
0229 bool goodfile = false;
0230 if (intest.is_open())
0231 {
0232 if (intest.peek() != std::ifstream::traits_type::eof())
0233 {
0234 goodfile = true;
0235 }
0236 intest.close();
0237 }
0238 return goodfile;
0239 }