Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:13:49

0001 #ifndef GeneratorInterface_LHEInterface_LH5Reader_h
0002 #define GeneratorInterface_LHEInterface_LH5Reader_h
0003 
0004 #include <string>
0005 #include <vector>
0006 #include <memory>
0007 
0008 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0009 #include "GeneratorInterface/LHEInterface/interface/lheh5.h"
0010 
0011 namespace lhef {
0012 
0013   class LHERunInfo;
0014   class LHEEvent;
0015 
0016   class H5Handler {
0017   public:
0018     H5Handler(const std::string &fileNameIn);
0019     virtual ~H5Handler() {}
0020     void readBlock();
0021     void counter(int, int);
0022     std::unique_ptr<HighFive::File> h5file;
0023     bool indexStatus;
0024     HighFive::Group _index, _particle, _event, _init, _procInfo;
0025     int npLO, npNLO;
0026     unsigned int long _eventsRead;
0027     lheh5::Events2 _events2;
0028     lheh5::Events _events1;
0029     std::vector<lheh5::Particle> getEvent();
0030     lheh5::EventHeader getHeader();
0031     std::pair<lheh5::EventHeader, std::vector<lheh5::Particle> > getEventProperties();
0032 
0033   private:
0034     unsigned int long _eventsTotal;
0035     int _eventsInBlock;
0036     int _formatType;
0037     int _blocksRead;
0038   };
0039 
0040   class LH5Reader {
0041   public:
0042     LH5Reader(const edm::ParameterSet &params);
0043     LH5Reader(const std::vector<std::string> &fileNames, unsigned int skip = 0, int maxEvents = -1);
0044     LH5Reader(const std::string &inputs, unsigned int skip = 0, int maxEvents = -1);
0045     ~LH5Reader();
0046 
0047     std::shared_ptr<LHEEvent> next(bool *newFileOpened = nullptr);
0048 
0049   private:
0050     class Source;
0051     class FileSource;
0052     class StringSource;
0053 
0054     const std::vector<std::string> fileURLs;
0055     const std::string strName;
0056     unsigned int firstEvent;
0057     int maxEvents;
0058     unsigned int curIndex;
0059     std::vector<std::string> weightsinconfig;
0060 
0061     std::unique_ptr<Source> curSource;
0062     bool curDoc;
0063     std::shared_ptr<LHERunInfo> curRunInfo;
0064   };
0065 
0066 }  // namespace lhef
0067 
0068 #endif  // GeneratorInterface_LHEInterface_LH5Reader_h