Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-05 08:13:08

0001 // c++ includes --
0002 #include <string>
0003 #include <iostream>
0004 
0005 // root includes --
0006 #include <TSystem.h>
0007 #include <TROOT.h>
0008 #include <TF1.h>
0009 
0010 #include <fun4all/Fun4AllDstInputManager.h>
0011 #include <fun4all/Fun4AllInputManager.h>
0012 #include <fun4all/Fun4AllRunNodeInputManager.h>
0013 #include <fun4all/Fun4AllServer.h>
0014 #include <fun4all/SubsysReco.h>
0015 #include <fun4all/Fun4AllUtils.h>
0016 
0017 #include <caloreco/CaloTowerStatus.h>
0018 
0019 #include <phool/recoConsts.h>
0020 
0021 #include <jetvalidation/JetValidation.h>
0022 
0023 #include <ffamodules/CDBInterface.h>
0024 
0025 #include <globalvertex/GlobalVertexReco.h>
0026 
0027 #include <mbd/MbdReco.h>
0028 
0029 using std::cout;
0030 using std::endl;
0031 using std::string;
0032 using std::pair;
0033 using std::istringstream;
0034 
0035 #include "Calo_Calib.C"
0036 #include "HIJetReco.C"
0037 
0038 R__LOAD_LIBRARY(libJetValidation.so)
0039 
0040 void Fun4All_JetVal(const string &inputFile,
0041                     const string &outputTreeFile = "tree.root",
0042                     const string &outputQAFile   = "qa.root",
0043                     UInt_t nEvents = 0)
0044 {
0045   cout << "#############################" << endl;
0046   cout << "Run Parameters" << endl;
0047   cout << "inputFile: "    << inputFile << endl;
0048   cout << "output tree: "  << outputTreeFile << endl;
0049   cout << "output QA: "    << outputQAFile << endl;
0050   cout << "Events: "       << nEvents << endl;
0051   cout << "#############################" << endl;
0052 
0053   Fun4AllServer *se = Fun4AllServer::instance();
0054 
0055   recoConsts *rc = recoConsts::instance();
0056 
0057   rc->set_StringFlag("CDB_GLOBALTAG", "ProdA_2024");
0058 
0059   pair<Int_t, Int_t> runseg = Fun4AllUtils::GetRunSegment(inputFile);
0060   Int_t runnumber = runseg.first;
0061   rc->set_uint64Flag("TIMESTAMP", runnumber);
0062 
0063   // Geometry
0064   cout << "Adding Geometry file" << endl;
0065   Fun4AllInputManager* intrue2 = new Fun4AllRunNodeInputManager("DST_GEO");
0066   string geoLocation = CDBInterface::instance()->getUrl("calo_geo");
0067   intrue2->AddFile(geoLocation);
0068   se->registerInputManager(intrue2);
0069 
0070   // MBD/BBC Reconstruction
0071   MbdReco* mbdreco = new MbdReco();
0072   se->registerSubsystem(mbdreco);
0073 
0074   // Official vertex storage
0075   GlobalVertexReco* gvertex = new GlobalVertexReco();
0076   se->registerSubsystem(gvertex);
0077 
0078   Process_Calo_Calib();
0079 
0080   HIJetReco();
0081 
0082   JetValidation *myJetVal = new JetValidation();
0083   myJetVal->set_outputTreeFileName(outputTreeFile);
0084   myJetVal->set_outputQAFileName(outputQAFile);
0085   myJetVal->set_bkg_tower_neighbor_energy(0.3); /*GeV*/
0086   myJetVal->set_saveTree(false);
0087   se->registerSubsystem(myJetVal);
0088 
0089   Fun4AllInputManager *in = new Fun4AllDstInputManager("DSTcalo");
0090   in->AddFile(inputFile.c_str());
0091   se->registerInputManager(in);
0092 
0093   se->run(nEvents);
0094   se->End();
0095   // se->PrintTimer();
0096 
0097   gSystem->Exit(0);
0098 }
0099 
0100 # ifndef __CINT__
0101 int main(int argc, char* argv[]) {
0102     if(argc < 2 || argc > 5){
0103         cout << "usage: ./bin/Fun4All_JetVal inputFile [outputTreeFile] [outputQAFile] [events]" << endl;
0104         cout << "inputFile: Location of fileList containing dst." << endl;
0105         cout << "outputTreeFile: name of output Tree file. Default: tree.root" << endl;
0106         cout << "outputQAFile: name of output QA file. Default: qa.root" << endl;
0107         cout << "events: Number of events to analyze. Default: all" << endl;
0108         return 1;
0109     }
0110 
0111     string outputTreeFile = "tree.root";
0112     string outputQAFile   = "qa.root";
0113     UInt_t events         = 0;
0114 
0115     if(argc >= 3) {
0116         outputTreeFile = argv[2];
0117     }
0118     if(argc >= 4) {
0119         outputQAFile = argv[3];
0120     }
0121     if(argc >= 5) {
0122         events = atoi(argv[4]);
0123     }
0124 
0125     Fun4All_JetVal(argv[1], outputTreeFile, outputQAFile, events);
0126 
0127     cout << "done" << endl;
0128     return 0;
0129 }
0130 # endif