29 using namespace lheh5;
61 throw cms::Exception(
"StreamOpenError") <<
"Empty LHE file string name \"" << std::endl;
71 : h5file(new HighFive::
File(fileNameIn)),
72 indexStatus(h5file->exist(
"/index")),
73 _index(h5file->getGroup(indexStatus ?
"index" :
"event")),
74 _particle(h5file->getGroup(
"particle")),
75 _event(h5file->getGroup(
"event")),
76 _init(h5file->getGroup(
"init")),
77 _procInfo(h5file->getGroup(
"procInfo")) {
82 dspace = H5Dget_space(
h5file->getDataSet(
"index/start").getId());
86 dspace = H5Dget_space(
h5file->getDataSet(
"event/start").getId());
94 throw cms::Exception(
"ReadError") <<
"block size does not match HDF5 file" << std::endl;
100 HighFive::DataSet _npLO =
_procInfo.getDataSet(
"npLO");
102 HighFive::DataSet _npNLO =
_procInfo.getDataSet(
"npNLO");
111 if (maxEventsIn > 0 && firstEventIn > maxEventsIn)
112 throw cms::Exception(
"ConfigurationError") <<
"\" firstEvent > maxEvents \"" << std::endl;
127 if ((
unsigned long int)(iStart + nEvents) >
_eventsTotal)
134 std::vector<lheh5::Particle> _vE;
136 return std::vector<lheh5::Particle>();
140 if (checkEvents >= 0 &&
_eventsRead > (
unsigned long int)checkEvents)
151 std::vector<lheh5::Particle> _vE;
155 return std::make_pair(_h, _vE);
160 if (checkEvents >= 0 &&
_eventsRead > (
unsigned long int)checkEvents)
162 return std::make_pair(_h, _vE);
166 : fileURLs(params.getUntrackedParameter<std::
vector<std::
string> >(
"fileNames")),
168 firstEvent(params.getUntrackedParameter<unsigned int>(
"skipEvents", 0)),
169 maxEvents(params.getUntrackedParameter<int>(
"limitEvents", -1)) {}
172 : fileURLs(fileNames), strName(
""), firstEvent(firstEvent), maxEvents(maxEvents), curIndex(0), curDoc(
false) {}
175 : strName(inputs), firstEvent(firstEvent), maxEvents(maxEvents), curIndex(0) {}
186 if (newFileOpened !=
nullptr)
187 *newFileOpened =
true;
201 curSource->handler->_init.getDataSet(
"beamA").read(beamA);
202 curSource->handler->_init.getDataSet(
"beamB").read(beamB);
203 tmprup.
IDBMUP = std::make_pair(beamA, beamB);
204 double energyA, energyB;
205 curSource->handler->_init.getDataSet(
"energyA").read(energyA);
206 curSource->handler->_init.getDataSet(
"energyB").read(energyB);
207 tmprup.
EBMUP = std::make_pair(energyA, energyB);
208 int PDFsetA, PDFsetB;
209 curSource->handler->_init.getDataSet(
"PDFsetA").read(PDFsetA);
210 curSource->handler->_init.getDataSet(
"PDFsetB").read(PDFsetB);
211 tmprup.
PDFSUP = std::make_pair(PDFsetA, PDFsetB);
212 int PDFgroupA, PDFgroupB;
213 curSource->handler->_init.getDataSet(
"PDFgroupA").read(PDFgroupA);
214 curSource->handler->_init.getDataSet(
"PDFgroupB").read(PDFgroupB);
215 tmprup.
PDFGUP = std::make_pair(PDFgroupA, PDFgroupB);
216 std::vector<int> procId;
217 std::vector<double> xSection;
218 std::vector<double>
error;
219 std::vector<double> unitWeight;
221 curSource->handler->_procInfo.getDataSet(
"procId").read(procId);
222 curSource->handler->_procInfo.getDataSet(
"xSection").read(xSection);
223 curSource->handler->_procInfo.getDataSet(
"error").read(error);
224 curSource->handler->_procInfo.getDataSet(
"unitWeight").read(unitWeight);
226 tmprup.
LPRUP = procId;
229 tmprup.
XMAXUP = unitWeight;
231 size_t numProcesses = procId.size();
232 tmprup.
NPRUP = numProcesses;
234 const HEPRUP heprup(tmprup);
245 std::pair<EventHeader, std::vector<Particle> > evp =
curSource->handler->getEventProperties();
250 return std::shared_ptr<LHEEvent>();
257 for (
auto part : evp.second) {
276 std::shared_ptr<LHEEvent> lheevent;
290 lheevent->setNpLO(npLO);
291 lheevent->setNpNLO(npNLO);
298 return std::shared_ptr<LHEEvent>();
unsigned int long _eventsTotal
LH5Reader(const edm::ParameterSet ¶ms)
EventHeader mkEventHeader(int ievent) const
static void logFileAction(char const *msg, std::string const &fileName)
HighFive::Group _particle
std::unique_ptr< Source > curSource
FileSource(const std::string &fileURL)
std::vector< std::pair< int, int > > ICOLUP
std::vector< Particle > mkEvent(size_t ievent) const
std::pair< double, double > EBMUP
Events readEvents(HighFive::Group &g_index, HighFive::Group &g_particle, HighFive::Group &g_event, size_t first_event, size_t n_events)
std::vector< lheh5::Particle > getEvent()
std::vector< double > VTIMUP
std::pair< int, int > IDBMUP
std::unique_ptr< H5Handler > handler
std::shared_ptr< LHEEvent > next(bool *newFileOpened=nullptr)
std::pair< int, int > PDFGUP
lheh5::EventHeader getHeader()
std::vector< FiveVector > PUP
std::pair< lheh5::EventHeader, std::vector< lheh5::Particle > > getEventProperties()
std::vector< double > SPINUP
HighFive::Group _procInfo
const std::string strName
std::vector< std::pair< int, int > > MOTHUP
StringSource(const std::string &inputs)
std::vector< double > XERRUP
std::unique_ptr< HighFive::File > h5file
std::vector< double > XMAXUP
unsigned int long _eventsRead
std::pair< int, int > PDFSUP
H5Handler(const std::string &fileNameIn)
std::shared_ptr< LHERunInfo > curRunInfo
Log< level::System, true > LogAbsolute
std::vector< double > XSECUP
const std::vector< std::string > fileURLs