Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-05 08:12:36

0001 
0002 #pragma once
0003 #if ROOT_VERSION_CODE >= ROOT_VERSION(6,00,0)
0004 #include <fun4all/SubsysReco.h>
0005 #include <fun4all/Fun4AllServer.h>
0006 #include <fun4all/Fun4AllInputManager.h>
0007 #include <fun4all/Fun4AllDstInputManager.h>
0008 #include <fun4all/Fun4AllDstOutputManager.h>
0009 
0010 #include <filterevents/FilterEvents.h>
0011 
0012 R__LOAD_LIBRARY(libfun4all.so)
0013 R__LOAD_LIBRARY(libfilterevents.so)
0014 #endif
0015 
0016 void Fun4All_FilterEvents(vector<string> myInputLists = {"condorJob/fileLists/productionFiles-HIJING_0-20-tracks-00000.list"}, const int nEvents = 10)
0017 {
0018 
0019 //  gSystem->Load("libg4dst");
0020 //  gSystem->Load("libfiltereventsupsilon");
0021   string outDir = "/sphenix/u/rosstom/analysis/FilterEvents/macro/";
0022 
0023   string fileNumber = myInputLists[0];
0024   size_t findLastDash = fileNumber.find_last_of("-");
0025   if (findLastDash != string::npos) fileNumber.erase(0, findLastDash + 1);
0026   string remove_this = ".list";
0027   size_t pos = fileNumber.find(remove_this);
0028   if (pos != string::npos) fileNumber.erase(pos, remove_this.length());
0029   string outputFileName = "outputFilteredTrackSeeds_" + fileNumber + ".root";
0030 
0031   string outputRecoDir = outDir + "inReconstruction/";
0032   string makeDirectory = "mkdir -p " + outputRecoDir;
0033   system(makeDirectory.c_str());
0034   const string outputRecoFile = outputRecoDir + outputFileName;
0035 
0036   cout << "output file name: " << outputRecoFile << endl;
0037 
0038   bool upsilonFilter = false; // true for Upsilon, false for D0 (will make more general soon)
0039 
0040   Fun4AllServer *se = Fun4AllServer::instance();
0041   se->Verbosity(1);
0042 
0043   //Add all required input files
0044   for (unsigned int i = 0; i < myInputLists.size(); ++i)
0045   {
0046     Fun4AllInputManager *infile = new Fun4AllDstInputManager("DSTin_" + to_string(i));
0047     infile->AddListFile(myInputLists[i]);
0048     se->registerInputManager(infile);
0049   } 
0050   //Needs TRACKS, TRACKSEEDS, TRKR_CLUSTER, CALO_CLUSTER, and VERTEX DSTs
0051 
0052   //in1->AddFile("DST_TRACKS_sHijing_0_20fm_50kHz_bkg_0_20fm-0000000060-00000.root");
0053   //in2->AddFile("DST_TRACKSEEDS_sHijing_0_20fm_50kHz_bkg_0_20fm-0000000060-00000.root");
0054   //in3->AddFile("DST_TRKR_CLUSTER_sHijing_0_20fm_50kHz_bkg_0_20fm-0000000060-00000.root");
0055   //in4->AddFile("DST_CALO_CLUSTER_sHijing_0_20fm_50kHz_bkg_0_20fm-0000000060-00000.root");
0056   //in5->AddFile("DST_VERTEX_sHijing_0_20fm_50kHz_bkg_0_20fm-0000000060-00000.root");
0057 
0058   FilterEvents *filter = new FilterEvents("FilterEvents");
0059   if (!upsilonFilter) filter->setCuts(1.0, 0.01, 20, false);
0060   se->registerSubsystem(filter);
0061 
0062   Fun4AllOutputManager *out = new Fun4AllDstOutputManager("out",outputRecoFile);
0063   out->Verbosity(1);
0064   //out->AddNode("SvtxTrackMap_ee");
0065   out->AddNode("TRKR_CLUSTER");
0066   out->AddNode("SiliconTrackSeedContainer");
0067   out->AddNode("TpcTrackSeedContainer");
0068   out->AddNode("SvtxTrackSeedContainer");
0069   if (upsilonFilter) out->AddNode("CLUSTER_CEMC");
0070   out->AddNode("SvtxVertexMap");
0071   out->AddNode("GlobalVertexMap");
0072   se->registerOutputManager(out);
0073   out->Print();
0074 
0075   se->run(nEvents);
0076   se->End();
0077 
0078   ifstream file(outputRecoFile.c_str());
0079   if (file.good())
0080   {
0081     string moveOutput = "mv " + outputRecoFile + " " + outDir;
0082     system(moveOutput.c_str());
0083   }
0084 
0085 cout << "all done." << endl;
0086 }
0087 
0088 
0089