Back to home page

sPhenix code displayed by LXR

 
 

    


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

0001 // c++ includes --
0002 #include <iostream>
0003 #include <string>
0004 
0005 // root includes --
0006 #include <TROOT.h>
0007 #include <TSystem.h>
0008 
0009 // fun4all includes --
0010 #include <fun4all/Fun4AllDstInputManager.h>
0011 #include <fun4all/Fun4AllInputManager.h>
0012 #include <fun4all/Fun4AllServer.h>
0013 #include <fun4all/Fun4AllUtils.h>
0014 #include <fun4all/SubsysReco.h>
0015 
0016 #include <phool/recoConsts.h>
0017 
0018 // My Analysis includes --
0019 #include <jetvalidation/EventValidation.h>
0020 #include <jetvalidation/EventCheck.h>
0021 
0022 using std::cout;
0023 using std::endl;
0024 using std::istringstream;
0025 using std::pair;
0026 using std::string;
0027 
0028 #include "Calo_Calib-EventVal.C"
0029 
0030 R__LOAD_LIBRARY(libJetValidation.so)
0031 
0032 void Fun4All_EventVal(const string &input_JET,
0033                       const string &input_JETCALO,
0034                       const string &eventList,
0035                       const string &outputFile = "test.root",
0036                       UInt_t nEvents = 0)
0037 {
0038   cout << "#############################" << endl;
0039   cout << "Run Parameters" << endl;
0040   cout << "input file: " << input_JET << endl;
0041   cout << "input file: " << input_JETCALO << endl;
0042   cout << "Event List: " << eventList << endl;
0043   cout << "output file: " << outputFile << endl;
0044   cout << "Events: " << nEvents << endl;
0045   cout << "#############################" << endl;
0046 
0047   Fun4AllServer *se = Fun4AllServer::instance();
0048 
0049   recoConsts *rc = recoConsts::instance();
0050 
0051   rc->set_StringFlag("CDB_GLOBALTAG", "ProdA_2024");
0052 
0053   Int_t runnumber = (input_JET.find(".root") != string::npos) ? Fun4AllUtils::GetRunSegment(input_JET).first
0054                                                               : stoi(input_JET.substr(input_JET.rfind("-")+1,input_JET.rfind(".")-input_JET.rfind("-")-1));
0055   rc->set_uint64Flag("TIMESTAMP", runnumber);
0056 
0057   Fun4AllInputManager *in = new Fun4AllDstInputManager("DST_JET");
0058   if(input_JET.find(".root") != string::npos) in->AddFile(input_JET.c_str());
0059   else                                        in->AddListFile(input_JET.c_str());
0060   se->registerInputManager(in);
0061 
0062   Fun4AllInputManager *in2 = new Fun4AllDstInputManager("DST_JETCALO");
0063   if(input_JETCALO.find(".root") != string::npos) in2->AddFile(input_JETCALO.c_str());
0064   else                                            in2->AddListFile(input_JETCALO.c_str());
0065   se->registerInputManager(in2);
0066 
0067   EventCheck *myEventCheck = new EventCheck();
0068   myEventCheck->set_eventList(eventList);
0069   se->registerSubsystem(myEventCheck);
0070 
0071   Process_Calo_Calib();
0072 
0073   EventValidation *myEventVal = new EventValidation();
0074   myEventVal->set_outputFile(outputFile);
0075   se->registerSubsystem(myEventVal);
0076 
0077   se->run();
0078   se->End();
0079   se->PrintTimer();
0080   cout << "All done!" << endl;
0081 
0082   gSystem->Exit(0);
0083   std::quick_exit(0);
0084 }
0085 
0086 #ifndef __CINT__
0087 int main(int argc, char *argv[])
0088 {
0089   if (argc < 4 || argc > 6)
0090   {
0091     cout << "usage: ./bin/Fun4All_EventVal input_JET input_JETCALO eventList [outputFile] [events]" << endl;
0092     cout << "input_JET: Location of fileList containing dst JET." << endl;
0093     cout << "input_JETCALO: Location of fileList containing dst JETCALO." << endl;
0094     cout << "eventList: List of events of interest to save." << endl;
0095     cout << "outputFile: name of output QA file. Default: test.root" << endl;
0096     cout << "events: Number of events to analyze. Default: all" << endl;
0097     return 1;
0098   }
0099 
0100   string outputFile = "test.root";
0101   UInt_t events = 0;
0102 
0103   if (argc >= 5)
0104   {
0105     outputFile = argv[4];
0106   }
0107   if (argc >= 6)
0108   {
0109     events = atoi(argv[5]);
0110   }
0111 
0112   Fun4All_EventVal(argv[1], argv[2], argv[3], outputFile, events);
0113 
0114   cout << "done" << endl;
0115   return 0;
0116 }
0117 #endif