Back to home page

sPhenix code displayed by LXR

 
 

    


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

0001 /// ===========================================================================
0002 /*! \file Fun4All_TestCaloStatusMapper.C
0003  *  Derek Anderson
0004  *  05.16.2024
0005  *
0006  *  A small Fun4All macro to test the 'CaloStatusMapper' module.
0007  */
0008 /// ===========================================================================
0009 
0010 #define FUN4ALL_TESTCALOSTATUSMAPPER_C
0011 
0012 // c++ utilities
0013 #include <string>
0014 #include <utility>
0015 // ffa modules
0016 #include <ffamodules/CDBInterface.h>
0017 #include <ffamodules/FlagHandler.h>
0018 // fun4all libraries
0019 #include <fun4all/Fun4AllDstInputManager.h>
0020 #include <fun4all/Fun4AllInputManager.h>
0021 #include <fun4all/Fun4AllServer.h>
0022 #include <fun4all/Fun4AllUtils.h>
0023 #include <fun4all/SubsysReco.h>
0024 // jet qa utilities
0025 #include <jetqa/JetQADefs.h>
0026 // phool utilities
0027 #include <phool/recoConsts.h>
0028 // qa utils
0029 #include <qautils/QAHistManagerDef.h>
0030 // module definitions
0031 #include <calostatusmapper/CaloStatusMapper.h>
0032 #include <calostatusmapper/CaloStatusMapperDefs.h>
0033 
0034 R__LOAD_LIBRARY(libcalo_io.so)
0035 R__LOAD_LIBRARY(libcalostatusmapper.so)
0036 R__LOAD_LIBRARY(libfun4all.so)
0037 R__LOAD_LIBRARY(libfun4allraw.so)
0038 R__LOAD_LIBRARY(libjetqa.so)
0039 
0040 
0041 
0042 // macro body =================================================================
0043 
0044 void Fun4All_TestCaloStatusMapper(
0045   const int nEvents = 100,
0046   const std::string& inlist = "input/dst_calo_run2pp-00047289.list",
0047   const std::string& outfile = "test.root",
0048   const std::string& outfile_hist = "test_hists.root",
0049   const std::string& dbtag = "ProdA_2024",
0050   const int verbosity = 1
0051 ) {
0052 
0053   // options ------------------------------------------------------------------
0054 
0055   // trigger cluster maker options
0056   CaloStatusMapper::Config cfg_mapper {
0057     .debug       = true,
0058     .histTag     = "Test",
0059     .doTrgSelect = false,
0060     .trgToSelect = JetQADefs::GL1::MBDNSJet1
0061   };
0062 
0063   // for example, we'll only look at the EMCal and OHCal
0064   cfg_mapper.inNodeNames = {
0065     {"TOWERINFO_CALIB_CEMC",    CaloStatusMapperDefs::Calo::EMCal},
0066     {"TOWERINFO_CALIB_HCALOUT", CaloStatusMapperDefs::Calo::HCal}
0067   };
0068 
0069   // initialize f4a -----------------------------------------------------------
0070 
0071   // initialize F4A server
0072   Fun4AllServer* se = Fun4AllServer::instance();
0073   se -> Verbosity(verbosity);
0074 
0075   // grab 1st file from input list
0076   ifstream    files(inlist);
0077   std::string first("");
0078   std::getline(files, first);
0079 
0080   // grab run and segment no.s
0081   std::pair<int, int> runseg = Fun4AllUtils::GetRunSegment(first);
0082   int runnumber = runseg.first;
0083 
0084   Fun4AllServer* f4a = Fun4AllServer::instance();
0085   CDBInterface*  cdb = CDBInterface::instance();
0086   recoConsts*    rc  = recoConsts::instance();
0087   f4a -> Verbosity(verbosity);
0088   cdb -> Verbosity(verbosity);
0089 
0090   // grab lookup tables
0091   rc -> set_StringFlag("CDB_GLOBALTAG", dbtag);
0092   rc -> set_uint64Flag("TIMESTAMP", runnumber);
0093 
0094   // connect to conditions database
0095   CDBInterface::instance()->Verbosity(verbosity);
0096 
0097   // set up flag handler
0098   FlagHandler* flag = new FlagHandler();
0099   se -> registerSubsystem(flag);
0100 
0101   // register inputs/outputs --------------------------------------------------
0102 
0103   Fun4AllDstInputManager* input = new Fun4AllDstInputManager("InputDstManager");
0104   input -> AddListFile(inlist);
0105   f4a   -> registerInputManager(input);
0106 
0107   // register subsystem reco modules ------------------------------------------
0108 
0109   // map out status of calo towers
0110   CaloStatusMapper* mapper = new CaloStatusMapper("CaloStatusMapper");
0111   mapper -> SetConfig(cfg_mapper);
0112   mapper -> Verbosity(verbosity);
0113   f4a    -> registerSubsystem(mapper);
0114 
0115   // run modules and exit -----------------------------------------------------
0116 
0117   // run4all
0118   f4a -> run(nEvents);
0119   f4a -> End();
0120 
0121   // save qa output and exit
0122   QAHistManagerDef::saveQARootFile(outfile_hist);
0123   delete f4a;
0124 
0125   // close and  exit
0126   gSystem -> Exit(0);
0127   return;
0128 
0129 }
0130 
0131 // end ========================================================================