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 // jet background cut includes --
0017 #include <jetbackgroundcut/jetBackgroundCut.h>
0018 
0019 #include <phool/recoConsts.h>
0020 
0021 // My Analysis includes --
0022 #include <jetvalidation/JetValidationv2.h>
0023 #include <jetvalidation/EventCheck.h>
0024 
0025 using std::cout;
0026 using std::endl;
0027 using std::istringstream;
0028 using std::pair;
0029 using std::string;
0030 
0031 #include "Calo_Calib.C"
0032 
0033 R__LOAD_LIBRARY(libJetValidation.so)
0034 
0035 void Fun4All_JetValv2(const string &input_JET,
0036                       const string &input_JETCALO,
0037                       const string &outputFile = "test.root",
0038                       UInt_t nEvents = 0)
0039 {
0040   cout << "#############################" << endl;
0041   cout << "Run Parameters" << endl;
0042   cout << "input file: " << input_JET << endl;
0043   cout << "input file: " << input_JETCALO << endl;
0044   cout << "output file: " << outputFile << endl;
0045   cout << "Events: " << nEvents << endl;
0046   cout << "#############################" << endl;
0047 
0048   Fun4AllServer *se = Fun4AllServer::instance();
0049 
0050   recoConsts *rc = recoConsts::instance();
0051 
0052   rc->set_StringFlag("CDB_GLOBALTAG", "ProdA_2024");
0053 
0054   Int_t runnumber = (input_JET.find(".root") != string::npos) ? Fun4AllUtils::GetRunSegment(input_JET).first
0055                                                               : stoi(input_JET.substr(input_JET.rfind("-")+1,input_JET.rfind(".")-input_JET.rfind("-")-1));
0056   rc->set_uint64Flag("TIMESTAMP", runnumber);
0057 
0058   Fun4AllInputManager *in = new Fun4AllDstInputManager("DST_JET");
0059   if(input_JET.find(".root") != string::npos) in->AddFile(input_JET.c_str());
0060   else                                        in->AddListFile(input_JET.c_str());
0061   se->registerInputManager(in);
0062 
0063   Fun4AllInputManager *in2 = new Fun4AllDstInputManager("DST_JETCALO");
0064   if(input_JETCALO.find(".root") != string::npos) in2->AddFile(input_JETCALO.c_str());
0065   else                                            in2->AddListFile(input_JETCALO.c_str());
0066   se->registerInputManager(in2);
0067 
0068   EventCheck *myEventCheck = new EventCheck();
0069   myEventCheck->set_zvtx_max(30); /*cm*/
0070   myEventCheck->set_trigger(17); /*Jet 8 GeV + MBD NS >= 1*/
0071   se->registerSubsystem(myEventCheck);
0072 
0073   Process_Calo_Calib();
0074 
0075   jetBackgroundCut *jocl = new jetBackgroundCut("AntiKt_unsubtracted_r04","JOCL", 0, false);
0076   se->registerSubsystem(jocl);
0077 
0078   JetValidationv2 *myJetVal = new JetValidationv2();
0079   myJetVal->set_outputFile(outputFile);
0080   se->registerSubsystem(myJetVal);
0081 
0082   se->run(nEvents);
0083   se->End();
0084   se->PrintTimer();
0085   cout << "All done!" << endl;
0086 
0087   gSystem->Exit(0);
0088   std::quick_exit(0);
0089 }
0090 
0091 #ifndef __CINT__
0092 int main(int argc, char *argv[])
0093 {
0094   if (argc < 3 || argc > 5)
0095   {
0096     cout << "usage: ./bin/Fun4All_JetValv2 input_JET input_JETCALO [outputFile] [events]" << endl;
0097     cout << "input_JET: Location of fileList containing dst JET." << endl;
0098     cout << "input_JETCALO: Location of fileList containing dst JETCALO." << endl;
0099     cout << "outputFile: name of output QA file. Default: test.root" << endl;
0100     cout << "events: Number of events to analyze. Default: all" << endl;
0101     return 1;
0102   }
0103 
0104   string outputFile = "test.root";
0105   UInt_t events = 0;
0106 
0107   if (argc >= 4)
0108   {
0109     outputFile = argv[3];
0110   }
0111   if (argc >= 5)
0112   {
0113     events = atoi(argv[4]);
0114   }
0115 
0116   Fun4All_JetValv2(argv[1], argv[2], outputFile, events);
0117 
0118   cout << "done" << endl;
0119   return 0;
0120 }
0121 #endif