File indexing completed on 2025-08-03 08:20:28
0001 #include <fun4all/Fun4AllDstOutputManager.h>
0002 #include <fun4all/Fun4AllInputManager.h>
0003 #include <fun4all/Fun4AllOutputManager.h>
0004 #include <fun4all/Fun4AllServer.h>
0005 #include <fun4allraw/Fun4AllStreamingInputManager.h>
0006 #include <fun4allraw/InputManagerType.h>
0007 #include <fun4allraw/SingleInttPoolInput.h>
0008
0009 #include <phool/recoConsts.h>
0010
0011 #include <ffarawmodules/InttCheck.h>
0012
0013 #include <intt/InttCombinedRawDataDecoder.h>
0014
0015 #include <G4Setup_sPHENIX.C>
0016 #include <G4_TrkrVariables.C>
0017 #include <G4_ActsGeom.C>
0018 #include <Trkr_Clustering.C>
0019
0020 R__LOAD_LIBRARY(libfun4all.so)
0021 R__LOAD_LIBRARY(libfun4allraw.so)
0022 R__LOAD_LIBRARY(libffarawmodules.so)
0023 R__LOAD_LIBRARY(libintt.so)
0024
0025 bool isGood(const string &infile)
0026 {
0027 ifstream intest;
0028 intest.open(infile);
0029 bool goodfile = false;
0030 if (intest.is_open())
0031 {
0032 if (intest.peek() != std::ifstream::traits_type::eof())
0033 {
0034 goodfile = true;
0035 }
0036 intest.close();
0037 }
0038 return goodfile;
0039 }
0040
0041 void Fun4All_Intt_Combiner(int nEvents = 0,
0042 const int runnumber = 20869,
0043 const string cdbglobaltag = "ProdA_2023",
0044 const bool runTrkrHits = true,
0045 const bool applyHotChannel = true,
0046 const bool applyBCOCut = true,
0047 const bool applyADCConversion = true,
0048 const bool runTkrkClus = true,
0049 const bool usesurveygeom = true,
0050 const bool stripRawHit = true)
0051 {
0052
0053 vector<string> infile = {"intt0.list", "intt1.list", "intt2.list", "intt3.list", "intt4.list", "intt5.list", "intt6.list", "intt7.list"};
0054
0055 TString outfilename = Form("intt-%08d.root", runnumber);
0056 TString outdirinitial = "ProdDST";
0057 if (applyHotChannel)
0058 {
0059 outdirinitial += "-HotDead";
0060 }
0061 if (applyBCOCut)
0062 {
0063 outdirinitial += "-BCO";
0064 }
0065 if (applyADCConversion)
0066 {
0067 outdirinitial += "-ADC";
0068 }
0069 if (usesurveygeom)
0070 {
0071 outdirinitial += "-Survey";
0072 }
0073
0074 system(Form("mkdir -p %s", outdirinitial.Data()));
0075
0076 Fun4AllServer *se = Fun4AllServer::instance();
0077 se->Verbosity(1);
0078 recoConsts *rc = recoConsts::instance();
0079
0080 Enable::CDB = true;
0081 rc->set_StringFlag("CDB_GLOBALTAG", cdbglobaltag);
0082 rc->set_uint64Flag("TIMESTAMP", runnumber);
0083
0084 Fun4AllStreamingInputManager *in = new Fun4AllStreamingInputManager("Comb");
0085
0086 int i = 0;
0087 for (auto iter : infile)
0088 {
0089 if (isGood(iter))
0090 {
0091 SingleInttPoolInput *sngl = new SingleInttPoolInput("INTT_" + to_string(i));
0092
0093 sngl->AddListFile(iter);
0094 int nBcoVal = runTrkrHits ? 0 : 2;
0095 sngl->SetNegativeBco(nBcoVal);
0096 sngl->SetBcoRange(2);
0097 in->registerStreamingInput(sngl, InputManagerType::INTT);
0098 i++;
0099 }
0100 }
0101
0102 se->registerInputManager(in);
0103
0104
0105
0106
0107
0108 if (runTrkrHits)
0109 {
0110 InttCombinedRawDataDecoder *myDecoder = new InttCombinedRawDataDecoder("myUnpacker");
0111 myDecoder->runInttStandalone(true);
0112 myDecoder->writeInttEventHeader(true);
0113 if (applyHotChannel) myDecoder->LoadHotChannelMapRemote("INTT_HotMap");
0114 string DACmap = (applyADCConversion) ? "INTT_DACMAP" : "";
0115 string BCOmap = (applyBCOCut) ? "INTT_BCOMAP" : "";
0116 myDecoder->SetCalibDAC(DACmap);
0117 myDecoder->SetCalibBCO(BCOmap);
0118 se->registerSubsystem(myDecoder);
0119 }
0120
0121 if (runTkrkClus)
0122 {
0123 Enable::MVTX = true;
0124 Enable::INTT = true;
0125 Enable::TPC = true;
0126 Enable::MICROMEGAS = true;
0127
0128 Enable::INTT_USEG4SURVEYGEOM = usesurveygeom;
0129 ACTSGEOM::inttsurvey = usesurveygeom;
0130 G4Init();
0131 G4Setup();
0132 ClusteringInit();
0133 Intt_Clustering();
0134 }
0135
0136 Fun4AllOutputManager *out = new Fun4AllDstOutputManager("out", Form("%s/%s", outdirinitial.Data(), outfilename.Data()));
0137 if (stripRawHit)
0138 {
0139 out->StripNode("INTTRAWHIT");
0140 }
0141 se->registerOutputManager(out);
0142
0143 se->run(nEvents);
0144
0145 se->End();
0146 delete se;
0147 gSystem->Exit(0);
0148 }