Back to home page

sPhenix code displayed by LXR

 
 

    


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

0001 /// ===========================================================================
0002 /*! \file    Fun4All_TestBeamBackgroundFilterAndQA.C
0003  *  \authors Hanpu Jiang, Derek Anderson
0004  *  \date    10.21.2024
0005  *
0006  *  A small F4A macro to test the 'BeamBackgroundFilterAndQA' module.
0007  */
0008 /// ===========================================================================
0009 
0010 #define FUN4ALL_TESTBEAMBACKGROUNDFILTERANDQA_C
0011 
0012 // c++ utilities
0013 #include <string>
0014 
0015 // f4a libraries
0016 #include <beambackgroundfilterandqa/BeamBackgroundFilterAndQA.h>
0017 #include <beambackgroundfilterandqa/NullFilter.h>
0018 #include <beambackgroundfilterandqa/StreakSidebandFilter.h>
0019 #include <beambackgroundfilterandqa/TestPHFlags.h>
0020 #include <ffamodules/CDBInterface.h>
0021 #include <FROG.h>
0022 #include <fun4all/Fun4AllDstInputManager.h>
0023 #include <fun4all/Fun4AllInputManager.h>
0024 #include <fun4all/Fun4AllServer.h>
0025 #include <fun4all/SubsysReco.h>
0026 #include <phool/recoConsts.h>
0027 #include <qautils/QAHistManagerDef.h>
0028 
0029 R__LOAD_LIBRARY(libbeambackgroundfilterandqa.so)
0030 R__LOAD_LIBRARY(libcalo_io.so)
0031 R__LOAD_LIBRARY(libfun4all.so)
0032 R__LOAD_LIBRARY(libfun4allraw.so)
0033 
0034 
0035 
0036 // macro body =================================================================
0037 
0038 void Fun4All_TestBeamBackgroundFilterAndQA(
0039   const int runnumber = 47152,
0040   const int nEvents = 10,
0041   const int verbosity = 0,
0042   const std::string inFile = "DST_CALO_run2pp_ana437_2024p007-00047152-00160.root",
0043   const std::string outFile = "test_bbfaq.root"
0044 ) {
0045 
0046   // options ------------------------------------------------------------------
0047 
0048   // options for null (template) algorithm
0049   NullFilter::Config cfg_null {
0050     .debug = true,
0051     .verbosity = verbosity
0052   };
0053 
0054   // options for streak sideband algorithm
0055   StreakSidebandFilter::Config cfg_sideband {
0056     .debug = true,
0057     .minStreakTwrEne = 0.6,
0058     .maxAdjacentTwrEne = 0.06,
0059     .minNumTwrsInStreak = 5,
0060     .verbosity = verbosity
0061   };
0062 
0063   // options for entire modle
0064   BeamBackgroundFilterAndQA::Config cfg_filter {
0065     .debug = true,
0066     .doQA = true,
0067     .doEvtAbort = false,
0068     .sideband = cfg_sideband
0069   };
0070 
0071   // initialize f4a -----------------------------------------------------------
0072 
0073   FROG*          frog = new FROG();
0074   Fun4AllServer* f4a  = Fun4AllServer::instance();
0075   CDBInterface*  cdb  = CDBInterface::instance();
0076   recoConsts*    rc   = recoConsts::instance();
0077   frog -> Verbosity(verbosity);
0078   f4a  -> Verbosity(verbosity);
0079   cdb  -> Verbosity(verbosity);
0080 
0081   // grab lookup tables
0082   rc -> set_StringFlag("CDB_GLOBALTAG", "ProdA_2024");
0083   rc -> set_uint64Flag("TIMESTAMP", runnumber);
0084 
0085   // register inputs/outputs --------------------------------------------------
0086 
0087   Fun4AllDstInputManager* input = new Fun4AllDstInputManager("InputDstManager");
0088   input -> fileopen(inFile);
0089   f4a   -> registerInputManager(input);
0090 
0091   // register subsystem reco modules ------------------------------------------
0092 
0093   // filter beam background events & QA them
0094   BeamBackgroundFilterAndQA* filter = new BeamBackgroundFilterAndQA("BeamBackgroundFilterAndQA");
0095   filter -> SetConfig(cfg_filter);
0096   filter -> Verbosity(verbosity);
0097   f4a    -> registerSubsystem(filter);
0098 
0099   // confirm that background flags exist
0100   TestPHFlags* flags = new TestPHFlags("TestPHFlags");
0101   f4a -> registerSubsystem(flags);
0102 
0103   // run modules and exit -----------------------------------------------------
0104 
0105   // run4all
0106   f4a -> run(nEvents);
0107   f4a -> End();
0108 
0109   // save qa output and exit
0110   if (cfg_filter.doQA) {
0111     QAHistManagerDef::saveQARootFile(outFile);
0112   }
0113   delete f4a;
0114 
0115   // close and  exit
0116   gSystem -> Exit(0);
0117   return;
0118 
0119 }
0120 
0121 // end ========================================================================