Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-05 08:15:41

0001 //
0002 // Inspired by code from ATLAS.  Thanks!
0003 //
0004 
0005 #include "flowAfterburner.h"
0006 
0007 #include <HepMC/GenEvent.h>
0008 #include <HepMC/IO_BaseClass.h>
0009 #include <HepMC/IO_GenEvent.h>
0010 
0011 #include <CLHEP/Random/MTwistEngine.h>
0012 
0013 #include <boost/property_tree/ptree.hpp>
0014 #include <boost/version.hpp>  // to get BOOST_VERSION
0015 
0016 #include <boost/operators.hpp>
0017 #include <boost/property_tree/xml_parser.hpp>
0018 
0019 #include <algorithm>
0020 #include <sstream>
0021 #include <string>
0022 
0023 namespace CLHEP
0024 {
0025   class HepRandomEngine;
0026 }
0027 
0028 namespace
0029 {
0030   CLHEP::HepRandomEngine *engine;
0031 }
0032 
0033 int main()  // NOLINT(bugprone-exception-escape)
0034 {
0035   boost::property_tree::iptree pt;
0036   // These values (coded here or in the xml file are used only in the
0037   // flowAfterburner executable. If you want to adjust them in the flow
0038   // module of our simulations you need to change
0039   // generators/phhepmc/HepMCFlowAfterBurner.cc
0040   // for the default and/or the values set in the macro
0041 
0042   std::ifstream config_file("flowAfterburner.xml");
0043 
0044   if (config_file)
0045   {
0046     // Read XML configuration file.
0047     read_xml(config_file, pt);
0048   }
0049   long randomSeed = pt.get("FLOWAFTERBURNER.RANDOM.SEED", 11793);
0050   engine = new CLHEP::MTwistEngine(randomSeed);
0051 
0052   std::string input = pt.get("FLOWAFTERBURNER.INPUT", "sHijing.dat");
0053   std::string output = pt.get("FLOWAFTERBURNER.OUTPUT", "flowAfterburner.dat");
0054 
0055   float mineta = pt.get("FLOWAFTERBURNER.CUTS.MINETA", -5.0);
0056   float maxeta = pt.get("FLOWAFTERBURNER.CUTS.MAXETA", 5.0);
0057 
0058   float minpt = pt.get("FLOWAFTERBURNER.CUTS.MINPT", 0.0);
0059   float maxpt = pt.get("FLOWAFTERBURNER.CUTS.MAXPT", 100.0);
0060 
0061   std::string algorithmName = pt.get("FLOWAFTERBURNER.ALGORITHM", "MINBIAS");
0062 
0063   // Open input file.
0064   HepMC::IO_GenEvent ascii_in(input, std::ios::in);
0065   HepMC::IO_GenEvent ascii_out(output, std::ios::out);
0066   HepMC::GenEvent *evt;
0067 
0068   while (ascii_in >> evt)
0069   {
0070     flowAfterburner(evt, engine, algorithmName, mineta, maxeta, minpt, maxpt);
0071 
0072     ascii_out << evt;
0073     delete evt;
0074   }
0075 }