File indexing completed on 2025-08-05 08:15:14
0001 #include <GlobalVariables.C>
0002 #include <G4_Magnet.C>
0003 #include <G4_ActsGeom.C>
0004
0005 #include <Trkr_Reco_Cosmics.C>
0006
0007 #include <fun4all/Fun4AllRunNodeInputManager.h>
0008 #include <fun4all/Fun4AllDstOutputManager.h>
0009 #include <fun4all/Fun4AllInputManager.h>
0010 #include <fun4all/Fun4AllDstInputManager.h>
0011 #include <fun4all/Fun4AllOutputManager.h>
0012 #include <fun4all/Fun4AllServer.h>
0013 #include <ffamodules/CDBInterface.h>
0014
0015 #include <fun4allraw/Fun4AllStreamingInputManager.h>
0016
0017 #include <fun4allraw/SingleTpcPoolInput.h>
0018 #include <ffarawmodules/TpcCheck.h>
0019
0020 #include <phool/recoConsts.h>
0021 #include <ffamodules/FlagHandler.h>
0022 #include <ffamodules/HeadReco.h>
0023 #include <ffamodules/SyncReco.h>
0024
0025 #include <tpc/TpcCombinedRawDataUnpacker.h>
0026
0027 #include <trackingdiagnostics/TrkrNtuplizer.h>
0028
0029
0030 #include <tpcgaindebug/TPCGainDebug.h>
0031
0032
0033
0034
0035 #include <stdio.h>
0036
0037 R__LOAD_LIBRARY(libfun4all.so)
0038 R__LOAD_LIBRARY(libffamodules.so)
0039 R__LOAD_LIBRARY(libtpc.so)
0040 R__LOAD_LIBRARY(libphool.so)
0041 R__LOAD_LIBRARY(libTrackingDiagnostics.so)
0042 R__LOAD_LIBRARY(libtpcgaindebug.so)
0043 R__LOAD_LIBRARY(libfun4allraw.so)
0044 R__LOAD_LIBRARY(libffarawmodules.so)
0045
0046 void Fun4All_TPCGainDebug_mergedEBDC_useCombined(
0047 const std::string outdir = "/sphenix/tg/tg01/hf/yeonjugo/"
0048 , const int runnumber = 32420
0049 , bool saveAllhits = true
0050 , float AllHitADCThreshold = -9999
0051 , const std::string runType = "cosmics"
0052 , bool useListFiles = false
0053 , bool useCombinedFiles = true
0054
0055 , const string combinedFileName = "/sphenix/lustre01/sphnxpro/commissioning/aligned_streaming_tpc_3/cosmics-00032420-0002.root"
0056
0057 , const string prefix = "02"
0058 , bool doSharkFin = false
0059 , const int initevt = 172
0060 , const int endevt = 172
0061 )
0062 {
0063
0064
0065 const int nEvents = (initevt==0 && endevt==99999) ? -1 : endevt-initevt+1;
0066 string tempCap = (prefix == "") ? "" : "_" + prefix;
0067
0068 tempCap += (nEvents==-1) ? "_allEvents" : Form("_evt%dto%d", initevt, endevt);
0069 tempCap = tempCap + ( saveAllhits==1 ? "_allhit" : "");
0070
0071 if(doSharkFin)
0072 tempCap += "_sharkFin";
0073
0074 string outfilename = runType + "_run" + std::to_string(runnumber) + tempCap + ".root";
0075
0076
0077 vector<string> tpc_infile;
0078 for(int i=0; i<24;i++){
0079 if(useListFiles){
0080 std::string filePath = Form("/direct/sphenix+tg+tg01/hf/yeonjugo/TPCGainDebug/inputlist/TPC_ebdc%02d_%s-000%d.list", i, runType.data(), runnumber);
0081 tpc_infile.push_back(filePath);
0082 } else{
0083
0084 std::string filePath = "/sphenix/lustre01/sphnxpro/commissioning/tpc/" + runType + "/TPC_ebdc" + std::string(i < 10 ? "0" : "") + std::to_string(i) + "_" + runType + "-000" + std::to_string(runnumber) + "-000" + prefix + ".evt";
0085 tpc_infile.push_back(filePath);
0086
0087
0088
0089 }
0090 }
0091
0092 Fun4AllServer *se = Fun4AllServer::instance();
0093 se->Verbosity(1);
0094 recoConsts *rc = recoConsts::instance();
0095 rc->set_IntFlag("RUNNUMBER",runnumber);
0096
0097 HeadReco *head = new HeadReco();
0098 se->registerSubsystem(head);
0099
0100
0101
0102
0103 Fun4AllDstInputManager* hitsin;
0104 Fun4AllStreamingInputManager *in;
0105 Fun4AllOutputManager *out;
0106 if(useCombinedFiles){
0107 hitsin = new Fun4AllDstInputManager("InputManager");
0108 hitsin->fileopen(combinedFileName.c_str());
0109 se->registerInputManager(hitsin);
0110 } else{
0111 in = new Fun4AllStreamingInputManager("Comb");
0112 int i = 0;
0113 for (auto iter : tpc_infile)
0114 {
0115 cout << iter << endl;
0116 SingleTpcPoolInput *tpc_sngl = new SingleTpcPoolInput("TPC_" + to_string(i));
0117 tpc_sngl->SetBcoRange(130);
0118 if(useListFiles){
0119 tpc_sngl->AddListFile(iter);
0120 } else{
0121 tpc_sngl->AddFile(iter);
0122 }
0123 in->registerStreamingInput(tpc_sngl, InputManagerType::TPC);
0124 i++;
0125 }
0126 se->registerInputManager(in);
0127
0128 bool saveStreaming = false;
0129 if(saveStreaming){
0130 string streamingfilename = outdir + "/streaming_" + outfilename;
0131 out = new Fun4AllDstOutputManager("out", streamingfilename);
0132 se->registerOutputManager(out);
0133 }
0134 }
0135
0136 Enable::CDB = true;
0137 rc->set_StringFlag("CDB_GLOBALTAG","ProdA_2023");
0138 rc->set_uint64Flag("TIMESTAMP",6);
0139 auto cdb = CDBInterface::instance();
0140 cdb->Verbosity(2);
0141 std::string geofile = CDBInterface::instance()->getUrl("Tracking_Geometry");
0142
0143 Fun4AllRunNodeInputManager *ingeo = new Fun4AllRunNodeInputManager("GeoIn");
0144 ingeo->AddFile(geofile);
0145 se->registerInputManager(ingeo);
0146
0147 G4MAGNET::magfield = "0.01";
0148 G4MAGNET::magfield_rescale = 1;
0149 ACTSGEOM::ActsGeomInit();
0150
0151 string tpcunpackerfilename = outdir + "/tpcUnpacker_" + outfilename;
0152 auto tpcunpacker = new TpcCombinedRawDataUnpacker("TpcCombinedRawDataUnpacker", tpcunpackerfilename);
0153 tpcunpacker->do_zero_suppression(false);
0154
0155 tpcunpacker->Verbosity(0);
0156 tpcunpacker->event_range(initevt, endevt);
0157
0158 se->registerSubsystem(tpcunpacker);
0159
0160 string tpcgaindebugfilename = outdir + "/tpcGainDebug_" + outfilename;
0161 auto ntp = new TPCGainDebug("TPCGainDebug",tpcgaindebugfilename, runnumber);
0162 ntp->Verbosity(1);
0163 ntp->event_range(initevt, endevt);
0164 ntp->set_eventOffset(stoi(prefix)*1000);
0165 if(doSharkFin){
0166 ntp->save_ntuple(0);
0167 ntp->debugNtuple_adcThreshold(-9999);
0168 ntp->save_sharkFin(1);
0169
0170 ntp->do_gain(0);
0171 }
0172 else {
0173 ntp->save_ntuple(saveAllhits);
0174 ntp->debugNtuple_adcThreshold(AllHitADCThreshold);
0175 }
0176 se->registerSubsystem(ntp);
0177
0178
0179
0180 if(nEvents>0)
0181 se->run(endevt+1);
0182 else
0183 se->run();
0184 se->End();
0185 se->PrintTimer();
0186
0187 delete se;
0188 std::cout << "Finished" <<std::endl;
0189 gSystem->Exit(0);
0190
0191 }