Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-04-19 09:06:57

0001 // -*- C++ -*-
0002 #ifndef RIVET_Run_HH
0003 #define RIVET_Run_HH
0004 
0005 #include "Rivet/Tools/RivetSTL.hh"
0006 #include "Rivet/Tools/RivetHepMC.hh"
0007 #include "Rivet/Tools/Logging.hh"
0008 
0009 namespace Rivet {
0010 
0011 
0012   // Forward declaration
0013   class AnalysisHandler;
0014 
0015 
0016   /// @brief Interface to handle a run of events read from a HepMC stream or file.
0017   class Run {
0018   public:
0019 
0020     /// Standard constructor.
0021     Run(AnalysisHandler& ah);
0022 
0023     /// Destructor
0024     ~Run();
0025 
0026 
0027     /// @name Set run properties
0028     /// @{
0029 
0030     /// Get the cross-section for this run.
0031     Run& setCrossSection(double xs);
0032 
0033     /// Declare whether to list available analyses
0034     Run& setListAnalyses(bool dolist);
0035 
0036     /// @}
0037 
0038 
0039     /// @name File processing stages
0040     /// @{
0041 
0042     /// Set up HepMC file readers (using the appropriate file weight for the first file)
0043     bool init(const std::string& evtfile, double weight=1.0);
0044 
0045     /// Open a HepMC GenEvent file (using the appropriate file weight for the first file)
0046     bool openFile(const std::string& evtfile, double weight=1.0);
0047 
0048     /// Read the next HepMC event
0049     bool readEvent();
0050 
0051     /// Read the next HepMC event only to skip it
0052     //bool skipEvent();
0053 
0054     /// Return the number of (collapsed) events read in from HepMC,
0055     /// including current partial event in case of sub-events
0056     size_t numEvents() const { return _evtcount; }
0057 
0058     /// Handle next event
0059     bool processEvent();
0060 
0061     /// Close up HepMC I/O
0062     bool finalize();
0063 
0064     /// @}
0065 
0066 
0067   private:
0068 
0069     /// Get a Log object
0070     Log& getLog() const;
0071 
0072     /// AnalysisHandler object
0073     AnalysisHandler& _ah;
0074 
0075     /// @name Run variables obtained from events or command line
0076     /// @{
0077 
0078     /// @brief An extra event weight scaling per event file.
0079     /// Useful for e.g. AlpGen n-parton event file combination.
0080     double _fileweight = 1.0;
0081 
0082     /// Cross-section from command line.
0083     double _xs = NAN;
0084 
0085     /// Number of (collapsed) events read from file so far
0086     size_t _evtcount = 0;
0087 
0088     /// Current event number to keep track of sub-events
0089     int _evtnumber = -1;
0090 
0091     /// @}
0092 
0093 
0094     /// Flag to show list of analyses
0095     bool _listAnalyses = false;
0096 
0097 
0098     /// @name HepMC I/O members
0099     /// @{
0100 
0101     /// Current event
0102     std::shared_ptr<GenEvent> _evt;
0103 
0104     /// Output stream for HepMC writer
0105     std::shared_ptr<std::istream> _istr;
0106 
0107     /// HepMC reader
0108     std::shared_ptr<HepMC_IO_type> _hepmcReader;
0109 
0110     /// @}
0111 
0112   };
0113 
0114 
0115 }
0116 
0117 #endif