Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-12-16 09:24:01

0001 #include <caloreco/CaloTowerBuilder.h>
0002 #include <caloreco/CaloWaveformProcessing.h>
0003 
0004 #include <ffamodules/CDBInterface.h>
0005 #include <ffamodules/FlagHandler.h>
0006 #include <ffamodules/HeadReco.h>
0007 #include <ffamodules/SyncReco.h>
0008 
0009 #include <fun4allraw/Fun4AllPrdfInputManager.h>
0010 
0011 #include <fun4all/Fun4AllDstInputManager.h>
0012 #include <fun4all/Fun4AllDstOutputManager.h>
0013 #include <fun4all/Fun4AllInputManager.h>
0014 #include <fun4all/Fun4AllRunNodeInputManager.h>
0015 #include <fun4all/Fun4AllServer.h>
0016 #include <fun4all/Fun4AllUtils.h>
0017 #include <fun4all/SubsysReco.h>
0018 
0019 #include <phool/recoConsts.h>
0020 
0021 #include <Rtypes.h> // for R__LOAD_LIBRARY
0022 #include <TSystem.h>
0023 
0024 #include <format>
0025 
0026 R__LOAD_LIBRARY(libfun4all.so)
0027 R__LOAD_LIBRARY(libfun4allraw.so)
0028 R__LOAD_LIBRARY(libcalo_reco.so)
0029 R__LOAD_LIBRARY(libffamodules.so)
0030 
0031 void Fun4All_WaveformFit(const std::string &fname = "/sphenix/lustre01/sphnxpro/commissioning/slurp/calobeam/run_00040700_00040800/DST_TRIGGERED_RAW_beam_new_2023p015-00040797-0001.root", int nEvents = 10)
0032 {
0033   // v1 uncomment:
0034   // CaloTowerDefs::BuilderType buildertype = CaloTowerDefs::kPRDFTowerv1;
0035   // v2 uncomment:
0036    CaloTowerDefs::BuilderType buildertype = CaloTowerDefs::kWaveformTowerv2;
0037   // v3 uncomment:
0038   // CaloTowerDefs::BuilderType buildertype = CaloTowerDefs::kPRDFWaveform;
0039 
0040   Fun4AllServer *se = Fun4AllServer::instance();
0041   se->Verbosity(0);
0042 
0043   recoConsts *rc = recoConsts::instance();
0044 
0045   std::pair<int, int> runseg = Fun4AllUtils::GetRunSegment(fname);
0046   int runnumber = runseg.first;
0047   int segment = runseg.second;
0048   std::string outfile = std::format("DST_CALOR-{:08}-{:04}.root", runnumber, segment);
0049 //  std::string outfile_hist = std::format("HIST_CALOR-{:08}-{:04}.root", runnumber, segment);
0050   std::string fulloutfile = "./" + outfile;
0051 //  std::string fulloutfile_hist = "./" + outfile_hist;
0052   //===============
0053   // conditions DB flags
0054   //===============
0055   // ENABLE::CDB = true;
0056   // global tag
0057   rc->set_StringFlag("CDB_GLOBALTAG", "ProdA_2024");
0058   // // 64 bit timestamp
0059   rc->set_uint64Flag("TIMESTAMP", runnumber);
0060   CDBInterface::instance()->Verbosity(1);
0061 
0062   FlagHandler *flag = new FlagHandler();
0063   se->registerSubsystem(flag);
0064 
0065 
0066 
0067   /////////////////
0068   // build towers
0069   CaloTowerBuilder *ctbEMCal = new CaloTowerBuilder("EMCalBUILDER");
0070   ctbEMCal->set_detector_type(CaloTowerDefs::CEMC);
0071   ctbEMCal->set_processing_type(CaloWaveformProcessing::TEMPLATE);
0072   ctbEMCal->set_builder_type(buildertype);
0073   ctbEMCal->set_offlineflag(true);
0074   ctbEMCal->set_nsamples(12);
0075   se->registerSubsystem(ctbEMCal);
0076 
0077   CaloTowerBuilder *ctbIHCal = new CaloTowerBuilder("HCALINBUILDER");
0078   ctbIHCal->set_detector_type(CaloTowerDefs::HCALIN);
0079   ctbIHCal->set_processing_type(CaloWaveformProcessing::TEMPLATE);
0080   ctbIHCal->set_builder_type(buildertype);
0081   ctbIHCal->set_offlineflag();
0082   ctbIHCal->set_nsamples(12);
0083   se->registerSubsystem(ctbIHCal);
0084 
0085   CaloTowerBuilder *ctbOHCal = new CaloTowerBuilder("HCALOUTBUILDER");
0086   ctbOHCal->set_detector_type(CaloTowerDefs::HCALOUT);
0087   ctbOHCal->set_processing_type(CaloWaveformProcessing::TEMPLATE);
0088   ctbOHCal->set_builder_type(buildertype);
0089   ctbOHCal->set_offlineflag();
0090   ctbOHCal->set_nsamples(12);
0091   se->registerSubsystem(ctbOHCal);
0092 
0093   CaloTowerBuilder *caZDC = new CaloTowerBuilder("ZDCBUILDER");
0094   caZDC->set_detector_type(CaloTowerDefs::ZDC);
0095   caZDC->set_builder_type(buildertype);
0096   caZDC->set_processing_type(CaloWaveformProcessing::FAST);
0097   caZDC->set_nsamples(16);
0098   caZDC->set_offlineflag();
0099   se->registerSubsystem(caZDC);
0100 
0101   CaloTowerBuilder *caEPD = new CaloTowerBuilder("SEPDBUILDER");
0102   caEPD->set_detector_type(CaloTowerDefs::SEPD);
0103   caEPD->set_builder_type(buildertype);
0104   caEPD->set_processing_type(CaloWaveformProcessing::FAST);
0105   caEPD->set_nsamples(12);
0106   caEPD->set_offlineflag();
0107   se->registerSubsystem(caEPD);
0108 
0109   Fun4AllInputManager *In = new Fun4AllDstInputManager("in");
0110   In->AddFile(fname);
0111   se->registerInputManager(In);
0112 
0113   Fun4AllDstOutputManager *out = new Fun4AllDstOutputManager("DSTOUT", fulloutfile);
0114   out->StripNode("CEMCPackets");
0115   out->StripNode("HCALPackets");
0116   out->StripNode("ZDCPackets");
0117   out->StripNode("SEPDPackets");
0118   se->registerOutputManager(out);
0119 
0120   se->run(nEvents);
0121   se->End();
0122 
0123   CDBInterface::instance()->Print();  // print used DB files
0124   se->PrintTimer();
0125   delete se;
0126   std::cout << "All done!" << std::endl;
0127   gSystem->Exit(0);
0128 }
0129