Back to home page

sPhenix code displayed by LXR

 
 

    


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

0001 #ifndef MACRO_FUN4ALLG4EMBED_C
0002 #define MACRO_FUN4ALLG4EMBED_C
0003 
0004 #include <GlobalVariables.C>
0005 
0006 #include <G4Setup_sPHENIX.C>
0007 #include <G4_Input.C>
0008 // #include <G4_Mbd.C>
0009 #include <G4_Production.C>
0010 #include <globalvertex/GlobalVertexReco.h>
0011 
0012 #include <phpythia8/PHPy8JetTrigger.h>
0013 #include <caloembedding/HepMCCollisionVertex.h>
0014 #include <caloembedding/caloTowerEmbed.h>
0015 #include <caloembedding/CopyIODataNodes.h>
0016 
0017 /*
0018 #include <eventselection/EventSelector.h>
0019 #include <eventselection/MinBiasCut.h>
0020 #include <eventselection/TowerChi2Cut.h>
0021 #include <eventselection/ZVertexCut.h>
0022 */
0023 
0024 #include <jetbase/JetReco.h>
0025 #include <jetbase/TowerJetInput.h>
0026 #include <jetbase/FastJetAlgo.h>
0027 
0028 #include <jetbackground/FastJetAlgoSub.h>
0029 #include <jetbackground/RetowerCEMC.h>
0030 
0031 #include <g4jets/TruthJetInput.h>
0032 
0033 #include <centrality/CentralityInfov2.h>
0034 #include <calotrigger/MinimumBiasInfov1.h>
0035 
0036 #include <ffamodules/CDBInterface.h>
0037 #include <ffamodules/FlagHandler.h>
0038 #include <ffamodules/SyncReco.h>
0039 
0040 #include <fun4all/Fun4AllDstOutputManager.h>
0041 #include <fun4all/Fun4AllOutputManager.h>
0042 #include <fun4all/Fun4AllServer.h>
0043 #include <fun4all/Fun4AllSyncManager.h>
0044 #include <fun4all/Fun4AllRunNodeInputManager.h>
0045 #include <fun4all/Fun4AllUtils.h>
0046 
0047 #include <phool/PHRandomSeed.h>
0048 #include <phool/recoConsts.h>
0049 
0050 R__LOAD_LIBRARY(libfun4all.so)
0051 R__LOAD_LIBRARY(libffamodules.so)
0052 R__LOAD_LIBRARY(libCaloEmbedding.so)
0053 // R__LOAD_LIBRARY( libeventselection.so )
0054 R__LOAD_LIBRARY(libglobalvertex.so)
0055 R__LOAD_LIBRARY(libcentrality.so)
0056 R__LOAD_LIBRARY(libcalotrigger.so)
0057 R__LOAD_LIBRARY(libjetbase.so)
0058 R__LOAD_LIBRARY(libjetbackground.so)
0059 R__LOAD_LIBRARY(libg4jets.so)
0060 // R__LOAD_LIBRARY(libg4dst.so)
0061 //  For HepMC Hijing
0062 //  try inputFile = /sphenix/sim/sim01/sphnxpro/sHijing_HepMC/sHijing_0-12fm.dat
0063 
0064 // namespace OUTPUTMANAGER
0065 //{
0066 // set<string> outfiles;
0067 // }
0068 
0069 void AddCommonNodes(Fun4AllOutputManager *out);
0070 
0071 int Fun4All_G4_Embed_data(
0072     const int nEvents = 1000,
0073     const int segment = 00000,
0074     const string &embed_input_file0 = "/sphenix/u/bseidlitz/work/devMac/macros/CaloProduction/condor/test.root",
0075     const string &outdir = "./",
0076     const string &outnameEnd = "embed_test.root",
0077     const string &jettrigger = "Jet30",
0078     const string &cdbtag = "MDC2")
0079 {
0080 
0081   std::cout << "segment: " << segment << std::endl;
0082 
0083   gSystem->Load("libg4dst.so");
0084 
0085   Fun4AllServer *se = Fun4AllServer::instance();
0086   se->Verbosity(1);
0087 
0088   int verbosity = 0;
0089 
0090   // Opt to print all random seed used for debugging reproducibility. Comment out to reduce stdout prints.
0091   PHRandomSeed::Verbosity(1);
0092 
0093   // just if we set some flags somewhere in this macro
0094   recoConsts *rc = recoConsts::instance();
0095   // By default every random number generator uses
0096   // PHRandomSeed() which reads /dev/urandom to get its seed
0097   // if the RANDOMSEED flag is set its value is taken as seed
0098   // You can either set this to a random value using PHRandomSeed()
0099   // which will make all seeds identical (not sure what the point of
0100   // this would be:
0101   //  rc->set_IntFlag("RANDOMSEED",PHRandomSeed());
0102   // or set it to a fixed value so you can debug your code
0103   //  rc->set_IntFlag("RANDOMSEED", 12345);
0104 
0105   //===============
0106   // conditions DB flags
0107   //===============
0108   Enable::CDB = true;
0109   // tag
0110   rc->set_StringFlag("CDB_GLOBALTAG", cdbtag);
0111   // 64 bit timestamp
0112   rc->set_uint64Flag("TIMESTAMP", CDB::timestamp);
0113 
0114   //  pair<int, int> runseg = Fun4AllUtils::GetRunSegment(embed_input_file0);
0115   // int runnumber = runseg.first;
0116   // int segment = runseg.second;
0117   int runnumber = 54912;
0118   if (runnumber != 0)
0119   {
0120     rc->set_IntFlag("RUNNUMBER", runnumber);
0121     Fun4AllSyncManager *syncman = se->getSyncManager();
0122     syncman->SegmentNumber(segment);
0123   }
0124 
0125   // Sync Headers and Flags
0126   SyncReco *sync = new SyncReco();
0127   se->registerSubsystem(sync);
0128 
0129   //  G4CEMC::useTowerInfoV2 = false;
0130   //  G4HCALOUT::useTowerInfoV2 = false;
0131   //  G4HCALIN::useTowerInfoV2 = false;
0132 
0133   //  G4CEMC::useTowerInfoV4 = true;
0134   // G4HCALOUT::useTowerInfoV4 = true;
0135   // G4HCALIN::useTowerInfoV4 = true;
0136 
0137   //===============
0138   // Input options
0139   //===============
0140   // verbosity setting (applies to all input managers)
0141   Input::VERBOSITY = 0;
0142   // First enable the input generators
0143   // Either:
0144   // read previously generated g4-hits files, in this case it opens a DST and skips
0145   // the simulations step completely. The G4Setup macro is only loaded to get information
0146   // about the number of layers used for the cell reco code
0147   //  Input::READHITS = true;
0148   // INPUTREADHITS::filename[0] = inputFile;
0149   // if you use a filelist
0150   // INPUTREADHITS::listfile[0] = inputFile;
0151   // Or:
0152   // Use particle generator
0153   // And
0154   // Further choose to embed newly simulated events to a previous simulation. Not compatible with `readhits = true`
0155   // In case embedding into a production output, please double check your G4Setup_sPHENIX.C and G4_*.C consistent with those in the production macro folder
0156   // E.g. /sphenix/sim//sim01/production/2016-07-21/single_particle/spacal2d/
0157 
0158   Input::EMBED = true;
0159   INPUTEMBED::filename[0] = embed_input_file0;
0160   // no repeating of embedding background, stop processing when end of file reached
0161   INPUTEMBED::REPEAT = false;
0162 
0163   // if you use a filelist
0164   // INPUTEMBED::listfile[0] = embed_input_file;
0165 
0166   // Input::SIMPLE = true;
0167   // Input::SIMPLE_NUMBER = 2; // if you need 2 of them
0168   // Input::SIMPLE_VERBOSITY = 1;
0169 
0170   //  Input::PYTHIA6 = true;
0171   // Enable this is emulating the nominal pp/pA/AA collision vertex distribution
0172   Input::BEAM_CONFIGURATION = Input::AA_COLLISION; // for 2023 sims we want the AA geometry for no pileup sims
0173 
0174   Input::PYTHIA8 = true;
0175   if (Input::PYTHIA8)
0176   {
0177     std::string pythia8_config_file = string(getenv("CALIBRATIONROOT")) + "/Generators/JetStructure_TG/";
0178     std::cout << "pythia config path: " << pythia8_config_file << std::endl;
0179     if (jettrigger == "Jet10")
0180     {
0181       pythia8_config_file += "phpythia8_15GeV_JS_MDC2.cfg";
0182     }
0183     else if (jettrigger == "Jet30")
0184     {
0185       pythia8_config_file += "phpythia8_30GeV_JS_MDC2.cfg";
0186     }
0187     else if (jettrigger == "Jet40")
0188     {
0189       pythia8_config_file += "phpythia8_40GeV_JS_MDC2.cfg";
0190     }
0191     else if (jettrigger == "PhotonJet")
0192     {
0193       pythia8_config_file += "phpythia8_JS_GJ_MDC2.cfg";
0194     }
0195     else
0196     {
0197       cout << "invalid jettrigger: " << jettrigger << endl;
0198       gSystem->Exit(1);
0199     }
0200     PYTHIA8::config_file = pythia8_config_file;
0201   }
0202 
0203   //-----------------
0204   // Initialize the selected Input/Event generation
0205   //-----------------
0206   InputInit();
0207 
0208   //--------------
0209   // Set generator specific options
0210   //--------------
0211   // can only be set after InputInit() is called
0212 
0213   if (Input::PYTHIA8)
0214   {
0215     //! apply sPHENIX nominal beam parameter with 2mrad crossing as defined in sPH-TRG-2020-001
0216     PHPy8JetTrigger *p8_js_signal_trigger = new PHPy8JetTrigger();
0217     p8_js_signal_trigger->SetEtaHighLow(1.5, -1.5); // Set eta acceptance for particles into the jet between +/- 1.5
0218     p8_js_signal_trigger->SetJetR(0.4);             // Set the radius for the trigger jet
0219     if (jettrigger == "Jet10")
0220     {
0221       p8_js_signal_trigger->SetMinJetPt(10); // require a 10 GeV minimum pT jet in the event
0222     }
0223     else if (jettrigger == "Jet30")
0224     {
0225       p8_js_signal_trigger->SetMinJetPt(30); // require a 30 GeV minimum pT jet in the event
0226     }
0227     else if (jettrigger == "Jet40")
0228     {
0229       p8_js_signal_trigger->SetMinJetPt(30); // require a 30 GeV minimum pT jet in the event
0230     }
0231     else if (jettrigger == "PhotonJet")
0232     {
0233       delete p8_js_signal_trigger;
0234       p8_js_signal_trigger = nullptr;
0235       cout << "no cut for PhotonJet" << endl;
0236     }
0237     else
0238     {
0239       cout << "invalid jettrigger: " << jettrigger << endl;
0240       gSystem->Exit(1);
0241     }
0242     if (p8_js_signal_trigger)
0243     {
0244       INPUTGENERATOR::Pythia8->register_trigger(p8_js_signal_trigger);
0245       INPUTGENERATOR::Pythia8->set_trigger_AND();
0246     }
0247     Input::ApplysPHENIXBeamParameter(INPUTGENERATOR::Pythia8);
0248   }
0249 
0250   //--------------
0251   // Set Input Manager specific options
0252   //--------------
0253   // can only be set after InputInit() is called
0254 
0255   // register all input generators with Fun4All
0256 
0257   std::string DataTopNode = "TOPData";
0258   /*
0259   EventSelector *EventSelectorHandler = new EventSelector();
0260   EventSelectorHandler->Verbosity( 1 );
0261   auto mbc = new MinBiasCut( );
0262   mbc->SetNodeName("MinimumBiasInfo");
0263   EventSelectorHandler->AddCut(mbc);
0264 
0265   auto tcc = new TowerChi2Cut( );
0266   std::vector<std::string> TowerChi2Nodes = {
0267     "TOWERINFO_CALIB_CEMC",
0268     "TOWERINFO_CALIB_HCALIN",
0269     "TOWERINFO_CALIB_HCALOUT"
0270   };
0271   tcc->SetNodeNames(TowerChi2Nodes);
0272   EventSelectorHandler->AddCut( tcc );
0273 
0274   auto zvc =  new ZVertexCut( 20, -20 );
0275   zvc->SetNodeName( "GlobalVertexMap" );
0276   EventSelectorHandler->AddCut( zvc );
0277 
0278   EventSelectorHandler->PrintCuts();
0279   se->registerSubsystem( EventSelectorHandler, DataTopNode);
0280 
0281   */
0282 
0283   HepMCCollisionVertex *collvtx = new HepMCCollisionVertex();
0284   collvtx->Verbosity(0);
0285   se->registerSubsystem(collvtx);
0286 
0287   InputRegister();
0288 
0289   FlagHandler *flag = new FlagHandler();
0290   se->registerSubsystem(flag);
0291 
0292   // set up production relatedstuff
0293   Enable::PRODUCTION = true;
0294 
0295   //======================
0296   // Write the DST
0297   //======================
0298 
0299   Enable::DSTOUT = true;
0300   Enable::DSTOUT_COMPRESS = false;
0301   DstOut::OutputDir = outdir;
0302 
0303   if (Enable::PRODUCTION)
0304   {
0305     PRODUCTION::SaveOutputDir = DstOut::OutputDir;
0306     //    Production_CreateOutputDir();
0307   }
0308 
0309 
0310   //-----------------
0311   // Copy over RunHeader, EventHeader, centrality, globalvertex, and MinimumBiasInfo nodes
0312   //-----------------
0313   CopyIODataNodes *cp = new CopyIODataNodes();
0314   cp->Verbosity(0);
0315   se->registerSubsystem(cp, DataTopNode);
0316 
0317   //======================
0318   // What to run
0319   //======================
0320 
0321   // Global options (enabled for all enables subsystems - if implemented)
0322   //  Enable::ABSORBER = true;
0323   //  Enable::OVERLAPCHECK = true;
0324   //  Enable::VERBOSITY = 1;
0325 
0326   Enable::MBD = true;
0327 
0328   // Enable::PIPE = true;
0329 
0330   // central tracking
0331   // Enable::MVTX = true;
0332 
0333   // Enable::INTT = true;
0334 
0335   // Enable::TPC = true;
0336 
0337   // Enable::MICROMEGAS = true;
0338 
0339   Enable::CEMC = true;
0340   // Enable::CEMC_ABSORBER = true;
0341   // Enable::CEMC_CELL = Enable::CEMC && true;
0342   // Enable::CEMC_TOWER = Enable::CEMC_CELL && true;
0343 
0344   Enable::HCALIN = true;
0345   // Enable::HCALIN_ABSORBER = true;
0346   // Enable::HCALIN_CELL = Enable::HCALIN && true;
0347   // Enable::HCALIN_TOWER = Enable::HCALIN_CELL && true;
0348 
0349   Enable::MAGNET = true;
0350   // Enable::MAGNET_ABSORBER = true;
0351 
0352   Enable::HCALOUT = true;
0353   // Enable::HCALOUT_ABSORBER = true;
0354   // Enable::HCALOUT_CELL = Enable::HCALOUT && true;
0355   // Enable::HCALOUT_TOWER = Enable::HCALOUT_CELL && true;
0356 
0357   Enable::EPD = true;
0358 
0359   // new settings using Enable namespace in GlobalVariables.C
0360   Enable::BLACKHOLE = true;
0361   Enable::BLACKHOLE_FORWARD_SAVEHITS = false; // disable forward/backward hits
0362   // Enable::BLACKHOLE_SAVEHITS = false; // turn off saving of bh hits
0363   // BlackHoleGeometry::visible = true;
0364 
0365   G4MAGNET::magfield = "FIELDMAP_GAP";
0366   G4MAGNET::magfield_OHCAL_steel = "FIELDMAP_STEEL";
0367   G4MAGNET::magfield_tracking = "FIELDMAP_TRACKING";
0368 
0369   // G4MAGNET::magfield = "/cvmfs/sphenix.sdcc.bnl.gov/calibrations/sphnxpro/cdb/FIELDMAP_GAP/65/a9/65a930ed6de9c0e049cd0f3ef226e6b4_sphenix3dbigmapxyz_gap_rebuild_v2.root";
0370   // G4MAGNET::magfield_OHCAL_steel = "/cvmfs/sphenix.sdcc.bnl.gov/calibrations/sphnxpro/cdb/FIELDMAP_STEEL/ea/f0/eaf07c2a2def280428b9aeea99d14fd1_sphenix3dbigmapxyz_steel_rebuild_v2.root";
0371   // G4MAGNET::magfield_tracking = "/cvmfs/sphenix.sdcc.bnl.gov/calibrations/sphnxpro/cdb/FIELDMAP_TRACKING/8e/4d/8e4d6c3b1660540a658da3a275af2bde_sphenix3dtrackingmapxyz.root";
0372 
0373   // Initialize the selected subsystems
0374   G4Init();
0375 
0376   //---------------------
0377   // GEANT4 Detector description
0378   //---------------------
0379   if (!Input::READHITS)
0380   {
0381     G4Setup();
0382   }
0383 
0384   //--------------------
0385   // GEANT4 Calorimeters
0386   //--------------------
0387 
0388   if (Enable::CEMC_CELL)
0389     CEMC_Cells();
0390 
0391   if (Enable::HCALIN_CELL)
0392     HCALInner_Cells();
0393 
0394   if (Enable::HCALOUT_CELL)
0395     HCALOuter_Cells();
0396 
0397   if (Enable::CEMC_TOWER)
0398     CEMC_Towers();
0399 
0400   if (Enable::HCALIN_TOWER)
0401     HCALInner_Towers();
0402 
0403   if (Enable::HCALOUT_TOWER)
0404     HCALOuter_Towers();
0405 
0406   //truth jets
0407   JetReco *truthjets2 = new JetReco("TRUTHJETRECO2");
0408   truthjets2->add_input(new TruthJetInput(Jet::PARTICLE));
0409   truthjets2->add_algo(new FastJetAlgo(Jet::ANTIKT, 0.2), "AntiKt_Truth_r02");
0410   truthjets2->set_algo_node("ANTIKT");
0411   truthjets2->set_input_node("TRUTH");
0412   truthjets2->Verbosity(verbosity);
0413   se->registerSubsystem(truthjets2);
0414 
0415   JetReco *truthjets3 = new JetReco("TRUTHJETRECO3");
0416   truthjets3->add_input(new TruthJetInput(Jet::PARTICLE));
0417   truthjets3->add_algo(new FastJetAlgo(Jet::ANTIKT, 0.3), "AntiKt_Truth_r03");
0418   truthjets3->set_algo_node("ANTIKT");
0419   truthjets3->set_input_node("TRUTH");
0420   truthjets3->Verbosity(verbosity);
0421   se->registerSubsystem(truthjets3);
0422 
0423   JetReco *truthjets4 = new JetReco("TRUTHJETRECO4");
0424   truthjets4->add_input(new TruthJetInput(Jet::PARTICLE));
0425   truthjets4->add_algo(new FastJetAlgo(Jet::ANTIKT, 0.4), "AntiKt_Truth_r04");
0426   truthjets4->set_algo_node("ANTIKT");
0427   truthjets4->set_input_node("TRUTH");
0428   truthjets4->Verbosity(verbosity);
0429   se->registerSubsystem(truthjets4);
0430 
0431   JetReco *truthjets5 = new JetReco("TRUTHJETRECO5");
0432   truthjets5->add_input(new TruthJetInput(Jet::PARTICLE));
0433   truthjets5->add_algo(new FastJetAlgo(Jet::ANTIKT, 0.5), "AntiKt_Truth_r05");
0434   truthjets5->set_algo_node("ANTIKT");
0435   truthjets5->set_input_node("TRUTH");
0436   truthjets5->Verbosity(verbosity);
0437   se->registerSubsystem(truthjets5);
0438 
0439   JetReco *truthjets6 = new JetReco("TRUTHJETRECO6");
0440   truthjets6->add_input(new TruthJetInput(Jet::PARTICLE));
0441   truthjets6->add_algo(new FastJetAlgo(Jet::ANTIKT, 0.6), "AntiKt_Truth_r06");
0442   truthjets6->set_algo_node("ANTIKT");
0443   truthjets6->set_input_node("TRUTH");
0444   truthjets6->Verbosity(verbosity);
0445   se->registerSubsystem(truthjets6);
0446 
0447   JetReco *truthjets7 = new JetReco("TRUTHJETRECO7");
0448   truthjets7->add_input(new TruthJetInput(Jet::PARTICLE));
0449   truthjets7->add_algo(new FastJetAlgo(Jet::ANTIKT, 0.7), "AntiKt_Truth_r07");
0450   truthjets7->set_algo_node("ANTIKT");
0451   truthjets7->set_input_node("TRUTH");
0452   truthjets7->Verbosity(verbosity);
0453   se->registerSubsystem(truthjets7);
0454 
0455   JetReco *truthjets8 = new JetReco("TRUTHJETRECO8");
0456   truthjets8->add_input(new TruthJetInput(Jet::PARTICLE));
0457   truthjets8->add_algo(new FastJetAlgo(Jet::ANTIKT, 0.8), "AntiKt_Truth_r08");
0458   truthjets8->set_algo_node("ANTIKT");
0459   truthjets8->set_input_node("TRUTH");
0460   truthjets8->Verbosity(verbosity);
0461   se->registerSubsystem(truthjets8);
0462 
0463   // waveform sim
0464   CaloWaveformSim *caloWaveformSim = new CaloWaveformSim();
0465   caloWaveformSim->set_detector_type(CaloTowerDefs::CEMC);
0466   caloWaveformSim->set_detector("CEMC");
0467   caloWaveformSim->set_nsamples(12);
0468   caloWaveformSim->set_pedestalsamples(12);
0469   caloWaveformSim->set_timewidth(0.2);
0470   caloWaveformSim->set_peakpos(6);
0471   caloWaveformSim->set_noise_type(CaloWaveformSim::NOISE_NONE);
0472   se->registerSubsystem(caloWaveformSim);
0473 
0474   caloWaveformSim = new CaloWaveformSim();
0475   caloWaveformSim->set_detector_type(CaloTowerDefs::HCALIN);
0476   caloWaveformSim->set_detector("HCALIN");
0477   caloWaveformSim->set_nsamples(12);
0478   caloWaveformSim->set_pedestalsamples(12);
0479   caloWaveformSim->set_timewidth(0.2);
0480   caloWaveformSim->set_peakpos(6);
0481   caloWaveformSim->set_noise_type(CaloWaveformSim::NOISE_NONE);
0482   se->registerSubsystem(caloWaveformSim);
0483 
0484   caloWaveformSim = new CaloWaveformSim();
0485   caloWaveformSim->set_detector_type(CaloTowerDefs::HCALOUT);
0486   caloWaveformSim->set_detector("HCALOUT");
0487   caloWaveformSim->set_nsamples(12);
0488   caloWaveformSim->set_pedestalsamples(12);
0489   caloWaveformSim->set_timewidth(0.2);
0490   caloWaveformSim->set_peakpos(6);
0491   caloWaveformSim->set_noise_type(CaloWaveformSim::NOISE_NONE);
0492   se->registerSubsystem(caloWaveformSim);
0493 
0494   se->Print("NODETREE");
0495 
0496   //-----------------
0497   // Calorimeter embedding
0498   //-----------------
0499 
0500   caloTowerEmbed *embedder_CEMC = new caloTowerEmbed("embedder_CEMC");
0501   embedder_CEMC->set_detector_type(CaloTowerDefs::CEMC);
0502   embedder_CEMC->set_removeBadTowers(false);
0503   embedder_CEMC->set_embedwaveform(true);
0504   embedder_CEMC->set_inputNodePrefix("TOWERS_");
0505   embedder_CEMC->Verbosity(verbosity);
0506   se->registerSubsystem(embedder_CEMC);
0507 
0508   caloTowerEmbed *embedder_IHCAL = new caloTowerEmbed("embedder_IHCAL");
0509   embedder_IHCAL->set_detector_type(CaloTowerDefs::HCALIN);
0510   embedder_IHCAL->set_removeBadTowers(false);
0511   embedder_IHCAL->set_embedwaveform(true);
0512   embedder_IHCAL->set_inputNodePrefix("TOWERS_");
0513   embedder_IHCAL->Verbosity(verbosity);
0514   se->registerSubsystem(embedder_IHCAL);
0515 
0516   caloTowerEmbed *embedder_OHCAL = new caloTowerEmbed("embedder_OHCal");
0517   embedder_OHCAL->set_detector_type(CaloTowerDefs::HCALOUT);
0518   embedder_OHCAL->set_removeBadTowers(false);
0519   embedder_OHCAL->set_embedwaveform(true);
0520   embedder_OHCAL->set_inputNodePrefix("TOWERS_");
0521   embedder_OHCAL->Verbosity(verbosity);
0522   se->registerSubsystem(embedder_OHCAL);
0523 
0524   // waveform fitting
0525 
0526   CaloTowerBuilder *ca2 = new CaloTowerBuilder();
0527   ca2->set_detector_type(CaloTowerDefs::CEMC);
0528   ca2->set_nsamples(12);
0529   ca2->set_dataflag(false);
0530   ca2->set_processing_type(CaloWaveformProcessing::TEMPLATE);
0531   ca2->set_builder_type(CaloTowerDefs::kWaveformTowerSimv1);
0532   // match our current ZS threshold ~60ADC for emcal
0533   ca2->set_softwarezerosuppression(true, 60);
0534   se->registerSubsystem(ca2);
0535 
0536   ca2 = new CaloTowerBuilder();
0537   ca2->set_detector_type(CaloTowerDefs::HCALIN);
0538   ca2->set_nsamples(12);
0539   ca2->set_dataflag(false);
0540   ca2->set_processing_type(CaloWaveformProcessing::TEMPLATE);
0541   ca2->set_builder_type(CaloTowerDefs::kWaveformTowerSimv1);
0542   ca2->set_softwarezerosuppression(true, 30);
0543   se->registerSubsystem(ca2);
0544 
0545   ca2 = new CaloTowerBuilder();
0546   ca2->set_detector_type(CaloTowerDefs::HCALOUT);
0547   ca2->set_nsamples(12);
0548   ca2->set_dataflag(false);
0549   ca2->set_processing_type(CaloWaveformProcessing::TEMPLATE);
0550   ca2->set_builder_type(CaloTowerDefs::kWaveformTowerSimv1);
0551   ca2->set_softwarezerosuppression(true, 30);
0552   se->registerSubsystem(ca2);
0553 
0554   //--------------
0555   // Set up Input Managers
0556   //--------------
0557 
0558   for (auto iter = INPUTEMBED::filename.begin(); iter != INPUTEMBED::filename.end(); ++iter)
0559   {
0560     string mgrname = "DSTin" + to_string(iter->first);
0561     Fun4AllInputManager *hitsin = new Fun4AllDstInputManager(mgrname, "DST", DataTopNode);
0562     hitsin->fileopen(iter->second);
0563     hitsin->Verbosity(Input::VERBOSITY);
0564     if (INPUTEMBED::REPEAT)
0565     {
0566       hitsin->Repeat();
0567     }
0568     se->registerInputManager(hitsin);
0569   }
0570   // input for pedestals
0571   {
0572     TRandom3 randGen;
0573     // get seed
0574     unsigned int seed = PHRandomSeed();
0575     randGen.SetSeed(seed);
0576     // a int from 0 to 3259
0577     int sequence = randGen.Integer(3260);
0578     // pad the name
0579     std::ostringstream opedname;
0580     opedname << "pedestal-54256-0" << std::setw(4) << std::setfill('0') << sequence << ".root";
0581 
0582     std::string pedestalname = opedname.str();
0583 
0584     Fun4AllInputManager *hitsin = new Fun4AllNoSyncDstInputManager("DST2");
0585     hitsin->AddFile(pedestalname);
0586     hitsin->Repeat();
0587     se->registerInputManager(hitsin);
0588   }
0589   // input geom files
0590   {
0591     Fun4AllInputManager *ingeo = new Fun4AllRunNodeInputManager("DST_GEO");
0592     std::string geoLocation = CDBInterface::instance()->getUrl("calo_geo");
0593     ingeo->AddFile(geoLocation);
0594     se->registerInputManager(ingeo);
0595   }
0596 
0597   //  InputManagers();
0598 
0599   string FullOutFile = outdir + "DST_TRUTH_G4HIT_" + outnameEnd;
0600   Fun4AllOutputManager *out = new Fun4AllDstOutputManager("TRUTHOUT", FullOutFile);
0601   AddCommonNodes(out);
0602   out->AddNode("G4TruthInfo");
0603   out->AddNode("G4HIT_BH_1");
0604   out->AddNode("PHHepMCGenEventMap");
0605   out->Verbosity(0);
0606   se->registerOutputManager(out);
0607   // OUTPUTMANAGER::outfiles.insert(FullOutFile);
0608   se->registerOutputManager(out);
0609 
0610   FullOutFile = outdir + "DST_TRUTH_JET_" + outnameEnd;
0611   out = new Fun4AllDstOutputManager("JETOUT", FullOutFile);
0612   AddCommonNodes(out);
0613   out->AddNode("AntiKt_Truth_r02");
0614   out->AddNode("AntiKt_Truth_r03");
0615   out->AddNode("AntiKt_Truth_r04");
0616   out->AddNode("AntiKt_Truth_r05");
0617   out->AddNode("AntiKt_Truth_r06");
0618   out->AddNode("AntiKt_Truth_r07");
0619   out->AddNode("AntiKt_Truth_r08");
0620   out->AddNode("AntiKt_Sim_r02");
0621   out->AddNode("AntiKt_Sim_r03");
0622   out->AddNode("AntiKt_Sim_r04");
0623   out->AddNode("AntiKt_Sim_r05");
0624   out->AddNode("AntiKt_Sim_r06");
0625   out->AddNode("AntiKt_Sim_r07");
0626   out->AddNode("AntiKt_Sim_r08");
0627   out->AddNode("AntiKt_Sim_Retower_r02");
0628   out->AddNode("AntiKt_Sim_Retower_r03");
0629   out->AddNode("AntiKt_Sim_Retower_r04");
0630   out->AddNode("AntiKt_Sim_Retower_r05");
0631   out->AddNode("AntiKt_Sim_Retower_r06");
0632   out->AddNode("AntiKt_Sim_Retower_r07");
0633   out->AddNode("AntiKt_Sim_Retower_r08");
0634   out->Verbosity(0);
0635   se->registerOutputManager(out);
0636   // OUTPUTMANAGER::outfiles.insert(FullOutFile);
0637 
0638   FullOutFile = outdir + "DST_CALO_" + outnameEnd;
0639   out = new Fun4AllDstOutputManager("CALOPROCESSED", FullOutFile);
0640   AddCommonNodes(out);
0641   out->AddNode("TOWERS_CEMC");
0642   out->AddNode("TOWERS_HCALIN");
0643   out->AddNode("TOWERS_HCALOUT");
0644   out->Verbosity(0);
0645   se->registerOutputManager(out);
0646   // OUTPUTMANAGER::outfiles.insert(FullOutFile);
0647 
0648   FullOutFile = outdir + "DST_GLOBAL_" + outnameEnd;
0649   out = new Fun4AllDstOutputManager("GLOBALOUT", FullOutFile);
0650   AddCommonNodes(out);
0651   out->AddNode("GlobalVertexMap");
0652   out->AddNode("MinimumBiasInfo");
0653   out->AddNode("CentralityInfo");
0654   out->AddNode("MbdOut");
0655   out->Verbosity(0);
0656   se->registerOutputManager(out);
0657   // OUTPUTMANAGER::outfiles.insert(FullOutFile);
0658 
0659   //-----------------
0660   // Event processing
0661   //-----------------
0662   // if we use a negative number of events we go back to the command line here
0663   if (nEvents < 0)
0664   {
0665     return 0;
0666   }
0667   // if we run the particle generator and use 0 it'll run forever
0668   if (nEvents == 0 && !Input::HEPMC && !Input::READHITS && INPUTEMBED::REPEAT)
0669   {
0670     cout << "using 0 for number of events is a bad idea when using particle generators" << endl;
0671     cout << "it will run forever, so I just return without running anything" << endl;
0672     return 0;
0673   }
0674 
0675   se->run(nEvents);
0676 
0677   //-----
0678   // Exit
0679   //-----
0680 
0681   CDBInterface::instance()->Print(); // print used DB files
0682   se->End();
0683   std::cout << "All done" << std::endl;
0684   delete se;
0685   gSystem->Exit(0);
0686   return 0;
0687 }
0688 
0689 void AddCommonNodes(Fun4AllOutputManager *out)
0690 {
0691   out->AddNode("Sync");
0692   out->AddNode("EventHeader");
0693   return;
0694 }
0695 
0696 #endif