Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2026-07-16 08:16:47

0001 #ifndef FUN4ALL_VERNIER_C
0002 #define FUN4ALL_VERNIER_C
0003 
0004 #include <mbd/MbdReco.h>
0005 
0006 #include <caloreco/CaloTowerBuilder.h>
0007 
0008 #include <calotrigger/TriggerRunInfoReco.h>
0009 
0010 #include <ffamodules/CDBInterface.h>
0011 #include <ffamodules/FlagHandler.h>
0012 #include <ffamodules/HeadReco.h>
0013 #include <ffamodules/SyncReco.h>
0014 
0015 #include <fun4all/Fun4AllDstInputManager.h>
0016 #include <fun4all/Fun4AllDstOutputManager.h>
0017 #include <fun4all/Fun4AllInputManager.h>
0018 #include <fun4all/Fun4AllServer.h>
0019 #include <fun4all/Fun4AllUtils.h>
0020 #include <fun4all/SubsysReco.h>
0021 
0022 #include <phool/recoConsts.h>
0023 
0024 #include <TSystem.h>
0025 
0026 #include <fstream>
0027 
0028 R__LOAD_LIBRARY(libfun4all.so)
0029 R__LOAD_LIBRARY(libcalotrigger.so)
0030 
0031 // this pass containis the reco process that's stable wrt time stamps(raw tower building)
0032 void Fun4All_Vernier(int nEvents = 100,
0033                      const std::string &inlist = "files.list",
0034                      const std::string &outfile1 = "DST_Vernier_run3auau_pro001_pcdb001_v001-00054733-00000.root",
0035                      const std::string &dbtag = "newcdbtag")
0036 {
0037   gSystem->Load("libg4dst.so");
0038 
0039   Fun4AllServer *se = Fun4AllServer::instance();
0040   se->Verbosity(1);
0041   se->VerbosityDownscale(10000);
0042 
0043   recoConsts *rc = recoConsts::instance();
0044 
0045   // conditions DB flags and timestamp
0046   rc->set_StringFlag("CDB_GLOBALTAG", dbtag);
0047 
0048   CDBInterface::instance()->Verbosity(1);
0049 
0050   FlagHandler *flag = new FlagHandler();
0051   se->registerSubsystem(flag);
0052 
0053   // Get info from DB and store in DSTs
0054   TriggerRunInfoReco *triggerinfo = new TriggerRunInfoReco();
0055   se->registerSubsystem(triggerinfo);
0056 
0057   MbdReco *mbd = new MbdReco();
0058   mbd->DoOnlyFits();
0059   se->registerSubsystem(mbd);
0060 
0061   CaloTowerDefs::BuilderType buildertype = CaloTowerDefs::kPRDFTowerv4;
0062 
0063   // build ZDC towers
0064   CaloTowerBuilder *caZDC = new CaloTowerBuilder("ZDCBUILDER");
0065   caZDC->set_detector_type(CaloTowerDefs::ZDC);
0066   caZDC->set_builder_type(buildertype);
0067   caZDC->set_processing_type(CaloWaveformProcessing::FUNCFIT);
0068   caZDC->set_funcfit_type(2);
0069   caZDC->set_nsamples(16);
0070   caZDC->set_offlineflag();
0071   se->registerSubsystem(caZDC);
0072 
0073   Fun4AllInputManager *In{nullptr};
0074   std::ifstream infile;
0075   infile.open(inlist);
0076   int iman = 0;
0077   std::string line;
0078   if (infile.is_open())
0079   {
0080     bool first{true};
0081     while (std::getline(infile, line))
0082     {
0083       if (line[0] == '#')
0084       {
0085         std::cout << "found commented out line " << line << std::endl;
0086         continue;
0087       }
0088       if (first)
0089       {
0090         std::pair<int, int> runseg = Fun4AllUtils::GetRunSegment(line);
0091         int runnumber = runseg.first;
0092         rc->set_uint64Flag("TIMESTAMP", runnumber);
0093         first = false;
0094       }
0095 
0096       std::cout << line << std::endl;
0097       std::string magname = "DSTin_" + std::to_string(iman);
0098       In = new Fun4AllDstInputManager(magname);
0099       In->Verbosity(1);
0100       In->AddFile(line);
0101       se->registerInputManager(In);
0102       iman++;
0103     }
0104     infile.close();
0105   }
0106   if (iman == 0)
0107   {
0108     std::cout << "No files in filelist" << std::endl;
0109     gSystem->Exit(1);
0110   }
0111   Fun4AllDstOutputManager *out = new Fun4AllDstOutputManager("DSTOUT", outfile1);
0112   out->AddNode("EventHeader");
0113   out->AddNode("Sync");
0114   out->AddNode("14001");
0115   out->AddNode("MbdRawContainer");
0116   out->AddNode("TOWERS_ZDC");
0117   se->registerOutputManager(out);
0118 
0119   // se->Print();
0120   if (nEvents < 0)
0121   {
0122     return;
0123   }
0124   se->run(nEvents);
0125   se->End();
0126 
0127   CDBInterface::instance()->Print();  // print used DB files
0128   se->PrintTimer();
0129   delete se;
0130   std::cout << "All done!" << std::endl;
0131   gSystem->Exit(0);
0132 }
0133 #endif