Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-10-16 08:23:48

0001 #ifndef FUN4ALL_YEAR2_FITTING_C
0002 #define FUN4ALL_YEAR2_FITTING_C
0003 
0004 #include "/sphenix/u/bseidlitz/work/devMac/macros/CaloProduction/condor/Calo_Fitting.C"
0005 #include <QA.C>
0006 
0007 #include <calotrigger/TriggerRunInfoReco.h>
0008 
0009 #include <calovalid/CaloFittingQA.h>
0010 
0011 #include <ffamodules/CDBInterface.h>
0012 #include <ffamodules/FlagHandler.h>
0013 #include <ffamodules/HeadReco.h>
0014 #include <ffamodules/SyncReco.h>
0015 
0016 #include <fun4all/Fun4AllDstInputManager.h>
0017 #include <fun4all/Fun4AllDstOutputManager.h>
0018 #include <fun4all/Fun4AllInputManager.h>
0019 #include <fun4all/Fun4AllRunNodeInputManager.h>
0020 #include <fun4all/Fun4AllServer.h>
0021 #include <fun4all/Fun4AllUtils.h>
0022 #include <fun4all/SubsysReco.h>
0023 
0024 #include <mbd/MbdReco.h>
0025 #include <globalvertex/GlobalVertexReco.h>
0026 
0027 #include <phool/recoConsts.h>
0028 
0029 R__LOAD_LIBRARY(libfun4allraw.so)
0030 R__LOAD_LIBRARY(libcalovalid.so)
0031 R__LOAD_LIBRARY(libcalotrigger.so)
0032 
0033 // this pass containis the reco process that's stable wrt time stamps(raw tower building)
0034 void Fun4All_PrepDataFitting(int nEvents = 1e4,
0035                const std::string inlist = "test.list",
0036                            const std::string &outfile = "DST_CALOFITTING",
0037                            const std::string &outfile_hist = "HIST_CALOFITTINGQA",
0038                            const std::string &dbtag = "ProdA_2024")
0039 {
0040   gSystem->Load("libg4dst.so");
0041 
0042   Fun4AllServer *se = Fun4AllServer::instance();
0043   se->Verbosity(0);
0044   se->VerbosityDownscale(1000);
0045 
0046   recoConsts *rc = recoConsts::instance();
0047 
0048   // conditions DB global tag
0049   rc->set_StringFlag("CDB_GLOBALTAG", dbtag);
0050   CDBInterface::instance()->Verbosity(1);
0051 
0052   FlagHandler *flag = new FlagHandler();
0053   se->registerSubsystem(flag);
0054 
0055   // Get info from DB and store in DSTs
0056   TriggerRunInfoReco *triggerinfo = new TriggerRunInfoReco();
0057   se->registerSubsystem(triggerinfo);
0058 
0059   // MBD/BBC Reconstruction
0060   MbdReco *mbdreco = new MbdReco();
0061   se->registerSubsystem(mbdreco);
0062 
0063   // Official vertex storage
0064   GlobalVertexReco *gvertex = new GlobalVertexReco();
0065   se->registerSubsystem(gvertex);
0066 
0067   Process_Calo_Fitting();
0068 
0069   ///////////////////////////////////
0070   // Validation
0071   CaloFittingQA *ca = new CaloFittingQA("CaloFittingQA");
0072   se->registerSubsystem(ca);
0073 
0074 // loop over all files in file list and create an input manager for each one  
0075   Fun4AllInputManager *In = nullptr;
0076   ifstream infile;
0077   infile.open(inlist);
0078   int iman = 0;
0079   std::string line;
0080   bool first {true};
0081   int runnumber = 0;
0082   int segment = 99999;
0083   if (infile.is_open())
0084   {
0085     while (std::getline(infile, line))
0086     {
0087       if (line[0] == '#')
0088       {
0089     std::cout << "found commented out line " << line << std::endl;
0090     continue;
0091       }
0092       // extract run number from first not commented out file in list
0093       if (first)
0094       {
0095     pair<int, int> runseg = Fun4AllUtils::GetRunSegment(line);
0096     runnumber = runseg.first;
0097     segment = runseg.second;
0098     rc->set_uint64Flag("TIMESTAMP", runnumber);
0099     first = false;
0100       }
0101       std::string magname = "DSTin_" + std::to_string(iman);
0102       In = new Fun4AllDstInputManager(magname);
0103       In->Verbosity(1);
0104       In->AddFile(line);
0105       se->registerInputManager(In);
0106       iman++;
0107     }
0108     infile.close();
0109   }
0110   
0111 // this strips all nodes under the Packets PHCompositeNode
0112 // (means removes all offline packets)
0113   char dstoutfile[500];
0114   sprintf(dstoutfile,"%s-%08d-%05d.root",outfile.c_str(), runnumber,segment);
0115   Fun4AllDstOutputManager *out = new Fun4AllDstOutputManager("DSTOUT", dstoutfile);
0116   out->StripCompositeNode("Packets");
0117   se->registerOutputManager(out);
0118   // se->Print();
0119   if (nEvents < 0)
0120   {
0121     return;
0122   }
0123   se->run(nEvents);
0124   se->End();
0125   sprintf(dstoutfile,"%s-%08d-%05d.root",outfile_hist.c_str(), runnumber,segment);
0126   QAHistManagerDef::saveQARootFile(dstoutfile);
0127 
0128   CDBInterface::instance()->Print();  // print used DB files
0129   se->PrintTimer();
0130   delete se;
0131   std::cout << "All done!" << std::endl;
0132   gSystem->Exit(0);
0133 }
0134 #endif