Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:06:39

0001 // The LHEH5 code below has been modified from the original
0002 // https://bitbucket.org/iamholger/lheh5/src/master/ authored by
0003 // Holger Schulz, and developed under the Scientific Discovery
0004 // through Advanced Computing (SciDAC) program funded by
0005 // the U.S. Department of Energy, Office of Science, Advanced Scientific
0006 // Computing Research.
0007 //
0008 // Note, this header can be used in conjuction with LHAHF5.h.
0009 //
0010 // Fermilab Software Legal Information (BSD License)
0011 // Copyright (c) 2009, FERMI NATIONAL ACCELERATOR LABORATORY
0012 // All rights reserved.
0013 //
0014 // Redistribution and use in source and binary forms, with or without
0015 // modification, are permitted provided that the following conditions
0016 // are met:
0017 //
0018 // Redistributions of source code must retain the above copyright
0019 // notice, this list of conditions and the following disclaimer.
0020 //
0021 // Redistributions in binary form must reproduce the above copyright
0022 // notice, this list of conditions and the following disclaimer in the
0023 // documentation and/or other materials provided with the
0024 // distribution.
0025 //
0026 // Neither the name of the FERMI NATIONAL ACCELERATOR LABORATORY, nor
0027 // the names of its contributors may be used to endorse or promote
0028 // products derived from this software without specific prior written
0029 // permission.
0030 //
0031 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
0032 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
0033 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
0034 // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
0035 // COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
0036 // INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
0037 // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
0038 // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
0039 // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
0040 // STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
0041 // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
0042 // OF THE POSSIBILITY OF SUCH DAMAGE.
0043 
0044 #ifndef Pythia8_LHEH5_H
0045 #define Pythia8_LHEH5_H
0046 
0047 // Standard includes.
0048 #include <iostream>
0049 #include <string>
0050 #include <vector>
0051 #include <unistd.h>
0052 
0053 // HighFive includes.
0054 #include "highfive/H5File.hpp"
0055 #include "highfive/H5DataSet.hpp"
0056 
0057 using namespace HighFive;
0058 
0059 namespace LHEH5 {
0060 
0061 //==========================================================================
0062 
0063 // Particle struct.
0064 
0065 struct Particle {
0066   int id, status, mother1, mother2, color1, color2;
0067   double px, py, pz, e, m, lifetime, spin;
0068   // id        .. IDUP
0069   // color1/2  .. ICOLUP firt/second
0070   // mother1/2 .. MOTHUP first/second
0071   // status    .. ISTUP
0072   // px ... m  .. PUP[..]
0073   // lifetime  .. VTIMUP
0074   // spin      .. SPINUP
0075   // (UP ... user process)
0076 };
0077 
0078 //--------------------------------------------------------------------------
0079 
0080 // Print a particle.
0081 
0082 std::ostream& operator << (std::ostream& os, Particle const & p) {
0083   os << "\tpx: " << p.px  << " py: " << p.py  << " pz: " << p.pz
0084      << " e: " << p.e <<  "\n";
0085   return os;
0086 }
0087 
0088 //==========================================================================
0089 
0090 // Event header struct.
0091 
0092 struct EventHeader {
0093   // Event info
0094   int    nparticles; // corr to NUP
0095   int    pid;        // this is all LHAu-::setProcess
0096   std::vector<double> weights;
0097   //double weight;
0098   size_t trials;
0099   double scale;
0100   double rscale;
0101   double fscale;
0102   double aqed;
0103   double aqcd;
0104   int    npLO;
0105   int    npNLO;
0106 };
0107 
0108 //--------------------------------------------------------------------------
0109 
0110 // Print an event header.
0111 
0112 std::ostream& operator << (std::ostream& os, EventHeader const & eh) {
0113   os << "\tnparticles: " << eh.nparticles  << " procid: " << eh.pid
0114      << " weights: { ";
0115   for (const auto& w : eh.weights) os << w << " ";
0116   os << "} trials: " << eh.trials <<  "\n";
0117   os << "\tscale: " << eh.scale  << " rscale: " << eh.rscale << " fscale: "
0118      << eh.fscale  << " aqed: " << eh.aqed << " aqcd: " << eh.aqcd <<  "\n";
0119   os << "\tnpLO: " << eh.npLO  << " npNLO: " << eh.npNLO <<  "\n";
0120   return os;
0121 }
0122 
0123 //==========================================================================
0124 
0125 // Old event struct.
0126 
0127 struct Events {
0128   // Lookup.
0129   std::vector<size_t> _vstart;
0130   std::vector<size_t> _vend;
0131   // Particles.
0132   std::vector<int>    _vid;
0133   std::vector<int>    _vstatus;
0134   std::vector<int>    _vmother1;
0135   std::vector<int>    _vmother2;
0136   std::vector<int>    _vcolor1;
0137   std::vector<int>    _vcolor2;
0138   std::vector<double> _vpx;
0139   std::vector<double> _vpy;
0140   std::vector<double> _vpz;
0141   std::vector<double> _ve;
0142   std::vector<double> _vm;
0143   std::vector<double> _vlifetime;
0144   std::vector<double> _vspin;
0145   // Event info.
0146   std::vector<int>    _vnparticles;
0147   std::vector<int>    _vpid;
0148   std::vector<double> _vweight;
0149   std::vector<size_t> _vtrials;
0150   std::vector<double> _vscale;
0151   std::vector<double> _vrscale;
0152   std::vector<double> _vfscale;
0153   std::vector<double> _vaqed;
0154   std::vector<double> _vaqcd;
0155   std::vector<int>    _vnpLO;
0156   std::vector<int>    _vnpNLO;
0157   size_t _particle_offset;
0158   Particle mkParticle(size_t idx) const;
0159   std::vector<Particle> mkEvent(size_t ievent) const;
0160   EventHeader mkEventHeader(int ievent) const;
0161 };
0162 
0163 //--------------------------------------------------------------------------
0164 
0165 // Make a particle, given an index.
0166 
0167 Particle Events::mkParticle(size_t idx) const {
0168   return {std::move(_vid[idx]), std::move(_vstatus[idx]),
0169       std::move(_vmother1[idx]), std::move(_vmother2[idx]),
0170       std::move(_vcolor1[idx]), std::move(_vcolor2[idx]),
0171       std::move(_vpx[idx]), std::move(_vpy[idx]), std::move(_vpz[idx]),
0172       std::move(_ve[idx]), std::move(_vm[idx]),
0173       std::move(_vlifetime[idx]),std::move(_vspin[idx])};
0174 }
0175 
0176 //--------------------------------------------------------------------------
0177 
0178 // Make an event, given an index.
0179 
0180 std::vector<Particle> Events::mkEvent(size_t ievent) const {
0181   std::vector<Particle> _E;
0182   // NOTE we need to subtract the particle offset here as the
0183   // particle properties run from 0 and not the global index
0184   // when using batches.
0185   size_t id = _vstart[ievent] - _particle_offset;
0186   for ( ; id <(_vend[ievent] - _particle_offset); ++id)
0187     _E.push_back(mkParticle( id));
0188 
0189   // Make sure beam particles are ordered according to convention
0190   // i.e. first particle has positive z-momentum
0191   if (_E[0].pz <0) std::swap<Particle>(_E[0], _E[1]);
0192 
0193   return _E;
0194 }
0195 
0196 //--------------------------------------------------------------------------
0197 
0198 // Make an event header, given an index.
0199 
0200 EventHeader Events::mkEventHeader(int iev) const {
0201   return {std::move(_vnparticles[iev]), std::move(_vpid[iev]),
0202       std::vector<double>(1,_vweight[iev]), std::move(_vtrials[iev]),
0203       std::move(_vscale[iev]), std::move(_vrscale[iev]),
0204       std::move(_vfscale[iev]),
0205       std::move(_vaqed[iev]), std::move(_vaqcd[iev]),
0206       std::move(_vnpLO[iev]), std::move(_vnpNLO[iev])};
0207 }
0208 
0209 //--------------------------------------------------------------------------
0210 
0211 // Read function, returns an Events struct.
0212 
0213 Events readEvents(Group& g_index, Group& g_particle, Group& g_event,
0214   size_t first_event, size_t n_events) {
0215   // Lookup
0216   std::vector<size_t> _vstart, _vend;
0217   // Particles
0218   std::vector<int>    _vid, _vstatus, _vmother1, _vmother2, _vcolor1, _vcolor2;
0219   std::vector<double> _vpx, _vpy, _vpz, _ve, _vm, _vlifetime, _vspin;
0220   // Event info
0221   std::vector<int>    _vnparticles, _vpid, _vnpLO, _vnpNLO;
0222   std::vector<size_t> _vtrials      ;
0223   std::vector<double> _vweight, _vscale, _vrscale, _vfscale, _vaqed, _vaqcd;
0224 
0225   // Lookup.
0226   DataSet _start = g_index.getDataSet("start");
0227   DataSet _end   = g_index.getDataSet("end");
0228   // Particles.
0229   DataSet _id       =  g_particle.getDataSet("id");
0230   DataSet _status   =  g_particle.getDataSet("status");
0231   DataSet _mother1  =  g_particle.getDataSet("mother1");
0232   DataSet _mother2  =  g_particle.getDataSet("mother2");
0233   DataSet _color1   =  g_particle.getDataSet("color1");
0234   DataSet _color2   =  g_particle.getDataSet("color2");
0235   DataSet _px       =  g_particle.getDataSet("px");
0236   DataSet _py       =  g_particle.getDataSet("py");
0237   DataSet _pz       =  g_particle.getDataSet("pz");
0238   DataSet _e        =  g_particle.getDataSet("e");
0239   DataSet _m        =  g_particle.getDataSet("m");
0240   DataSet _lifetime =  g_particle.getDataSet("lifetime");
0241   DataSet _spin     =  g_particle.getDataSet("spin");
0242   // Event info.
0243   DataSet _nparticles =  g_event.getDataSet("nparticles");
0244   DataSet _pid        =  g_event.getDataSet("pid");
0245   DataSet _weight     =  g_event.getDataSet("weight");
0246   DataSet _trials     =  g_event.getDataSet("trials");
0247   DataSet _scale      =  g_event.getDataSet("scale");
0248   DataSet _rscale     =  g_event.getDataSet("rscale");
0249   DataSet _fscale     =  g_event.getDataSet("fscale");
0250   DataSet _aqed       =  g_event.getDataSet("aqed");
0251   DataSet _aqcd       =  g_event.getDataSet("aqcd");
0252   DataSet _npLO       =  g_event.getDataSet("npLO");
0253   DataSet _npNLO       =  g_event.getDataSet("npNLO");
0254 
0255   std::vector<size_t> offset_e = {first_event};
0256   std::vector<size_t> readsize_e = {n_events};
0257 
0258   _start.select(offset_e, readsize_e).read(_vstart);
0259   _end.select(  offset_e, readsize_e).read(_vend  );
0260   std::vector<size_t> offset_p   = {_vstart.front()};
0261   std::vector<size_t> readsize_p = {_vend.back()-_vstart.front()};
0262 
0263   int RESP = _vend.back()-_vstart.front();
0264   _vid.reserve(RESP);
0265   _vstatus  .reserve(RESP);
0266   _vmother1 .reserve(RESP);
0267   _vmother2 .reserve(RESP);
0268   _vcolor1  .reserve(RESP);
0269   _vcolor2  .reserve(RESP);
0270   _vpx      .reserve(RESP);
0271   _vpy      .reserve(RESP);
0272   _vpz      .reserve(RESP);
0273   _ve       .reserve(RESP);
0274   _vm       .reserve(RESP);
0275   _vlifetime.reserve(RESP);
0276   _vspin    .reserve(RESP);
0277 
0278   _vnparticles.reserve(n_events);
0279   _vpid       .reserve(n_events);
0280   _vweight    .reserve(n_events);
0281   _vtrials    .reserve(n_events);
0282   _vscale     .reserve(n_events);
0283   _vrscale    .reserve(n_events);
0284   _vfscale    .reserve(n_events);
0285   _vaqed      .reserve(n_events);
0286   _vaqcd      .reserve(n_events);
0287   _vnpLO      .reserve(n_events);
0288   _vnpNLO     .reserve(n_events);
0289 
0290   // This is using HighFive's read.
0291   _id      .select(offset_p, readsize_p).read(_vid      );
0292   _status  .select(offset_p, readsize_p).read(_vstatus  );
0293   _mother1 .select(offset_p, readsize_p).read(_vmother1 );
0294   _mother2 .select(offset_p, readsize_p).read(_vmother2 );
0295   _color1  .select(offset_p, readsize_p).read(_vcolor1  );
0296   _color2  .select(offset_p, readsize_p).read(_vcolor2  );
0297   _px      .select(offset_p, readsize_p).read(_vpx      );
0298   _py      .select(offset_p, readsize_p).read(_vpy      );
0299   _pz      .select(offset_p, readsize_p).read(_vpz      );
0300   _e       .select(offset_p, readsize_p).read(_ve       );
0301   _m       .select(offset_p, readsize_p).read(_vm       );
0302   _lifetime.select(offset_p, readsize_p).read(_vlifetime);
0303   _spin    .select(offset_p, readsize_p).read(_vspin    );
0304 
0305   _nparticles.select(offset_e, readsize_e).read(_vnparticles);
0306   _pid       .select(offset_e, readsize_e).read(_vpid       );
0307   _weight    .select(offset_e, readsize_e).read(_vweight    );
0308   _trials    .select(offset_e, readsize_e).read(_vtrials    );
0309   _scale     .select(offset_e, readsize_e).read(_vscale     );
0310   _rscale    .select(offset_e, readsize_e).read(_vrscale    );
0311   _fscale    .select(offset_e, readsize_e).read(_vfscale    );
0312   _aqed      .select(offset_e, readsize_e).read(_vaqed      );
0313   _aqcd      .select(offset_e, readsize_e).read(_vaqcd      );
0314   _npLO      .select(offset_e, readsize_e).read(_vnpLO      );
0315   _npNLO     .select(offset_e, readsize_e).read(_vnpNLO     );
0316 
0317   return {
0318     std::move(_vstart),
0319       std::move(_vend),
0320       std::move(_vid),
0321       std::move(_vstatus),
0322       std::move(_vmother1),
0323       std::move(_vmother2),
0324       std::move(_vcolor1),
0325       std::move(_vcolor2),
0326       std::move(_vpx),
0327       std::move(_vpy),
0328       std::move(_vpz),
0329       std::move(_ve),
0330       std::move(_vm),
0331       std::move(_vlifetime),
0332       std::move(_vspin),
0333       std::move(_vnparticles),
0334       std::move(_vpid),
0335       std::move(_vweight),
0336       std::move(_vtrials),
0337       std::move(_vscale),
0338       std::move(_vrscale),
0339       std::move(_vfscale),
0340       std::move(_vaqed),
0341       std::move(_vaqcd),
0342       std::move(_vnpLO),
0343       std::move(_vnpNLO),
0344       offset_p[0]};
0345 }
0346 
0347 //==========================================================================
0348 
0349 // New events struct.
0350 
0351 struct Events2 {
0352   // Lookup.
0353   std::vector<size_t> _vstart;
0354   // Particles.
0355   std::vector<int> _vid;
0356   std::vector<int> _vstatus;
0357   std::vector<int> _vmother1;
0358   std::vector<int> _vmother2;
0359   std::vector<int> _vcolor1;
0360   std::vector<int> _vcolor2;
0361   std::vector<double> _vpx;
0362   std::vector<double> _vpy;
0363   std::vector<double> _vpz;
0364   std::vector<double> _ve;
0365   std::vector<double> _vm;
0366   std::vector<double> _vlifetime;
0367   std::vector<double> _vspin;
0368   // Event info.
0369   std::vector<int>                 _vnparticles;
0370   std::vector<int>                 _vpid;
0371   std::vector<std::vector<double>> _vweightvec;
0372   std::vector<size_t>              _vtrials;
0373   std::vector<double>              _vscale;
0374   std::vector<double>              _vrscale;
0375   std::vector<double>              _vfscale;
0376   std::vector<double>              _vaqed;
0377   std::vector<double>              _vaqcd;
0378   int npLO;
0379   int npNLO;
0380   size_t _particle_offset;
0381 
0382   Particle mkParticle(size_t idx) const;
0383   std::vector<Particle> mkEvent(size_t ievent) const;
0384   EventHeader mkEventHeader(int ievent) const;
0385 };
0386 
0387 //--------------------------------------------------------------------------
0388 
0389 // Make a particle, given an index.
0390 
0391 Particle Events2::mkParticle(size_t idx) const {
0392   return {std::move(_vid[idx]), std::move(_vstatus[idx]),
0393       std::move(_vmother1[idx]), std::move(_vmother2[idx]),
0394       std::move(_vcolor1[idx]), std::move(_vcolor2[idx]),
0395       std::move(_vpx[idx]), std::move(_vpy[idx]), std::move(_vpz[idx]),
0396       std::move(_ve[idx]), std::move(_vm[idx]),
0397       std::move(_vlifetime[idx]),std::move(_vspin[idx])};
0398 }
0399 
0400 //--------------------------------------------------------------------------
0401 
0402 // Make an event, given an index.
0403 
0404 std::vector<Particle> Events2::mkEvent(size_t ievent) const {
0405   std::vector<Particle> _E;
0406   // NOTE we need to subtract the particle offset here as the particle
0407   // properties run from 0 and not the global index when using batches.
0408   size_t partno = _vstart[ievent] - _particle_offset;
0409   for (int id=0; id <_vnparticles[ievent];++id){
0410     _E.push_back(mkParticle(partno));
0411     partno++;
0412   }
0413   // Make sure beam particles are ordered according to convention
0414   // i.e. first particle has positive z-momentum
0415   if (_E[0].pz < 0.) std::swap<Particle>(_E[0], _E[1]);
0416   return _E;
0417 }
0418 
0419 //--------------------------------------------------------------------------
0420 
0421 // Make an event header, given an index.
0422 
0423 EventHeader Events2::mkEventHeader(int iev) const {
0424   return {std::move(_vnparticles[iev]), std::move(_vpid[iev]),
0425       std::move(_vweightvec[iev]), std::move(_vtrials[iev]),
0426       std::move(_vscale[iev]), std::move(_vrscale[iev]),
0427       std::move(_vfscale[iev]),
0428       std::move(_vaqed[iev]), std::move(_vaqcd[iev]),
0429       npLO, npNLO,
0430       };
0431 }
0432 
0433 //--------------------------------------------------------------------------
0434 
0435 // Read function, returns an Events struct --- this is for the new structure.
0436 
0437 Events2 readEvents2(Group& g_particle, Group& g_event, size_t first_event,
0438   size_t n_events, int npLO, int npNLO, bool hasMultiWts) {
0439   // Lookup.
0440   std::vector<size_t> _vstart;
0441   // Particles.
0442   std::vector<int>    _vid, _vstatus, _vmother1, _vmother2, _vcolor1, _vcolor2;
0443   std::vector<double> _vpx, _vpy, _vpz, _ve, _vm, _vlifetime, _vspin;
0444   // Event info.
0445   std::vector<int>    _vnparticles, _vpid;
0446   std::vector<size_t> _vtrials      ;
0447   std::vector<double> _vscale, _vrscale, _vfscale, _vaqed, _vaqcd;
0448 
0449   // Lookup.
0450   DataSet _start = g_event.getDataSet("start");
0451   // Particles.
0452   DataSet _id       =  g_particle.getDataSet("id");
0453   DataSet _status   =  g_particle.getDataSet("status");
0454   DataSet _mother1  =  g_particle.getDataSet("mother1");
0455   DataSet _mother2  =  g_particle.getDataSet("mother2");
0456   DataSet _color1   =  g_particle.getDataSet("color1");
0457   DataSet _color2   =  g_particle.getDataSet("color2");
0458   DataSet _px       =  g_particle.getDataSet("px");
0459   DataSet _py       =  g_particle.getDataSet("py");
0460   DataSet _pz       =  g_particle.getDataSet("pz");
0461   DataSet _e        =  g_particle.getDataSet("e");
0462   DataSet _m        =  g_particle.getDataSet("m");
0463   DataSet _lifetime =  g_particle.getDataSet("lifetime");
0464   DataSet _spin     =  g_particle.getDataSet("spin");
0465   // Event info.
0466   DataSet _nparticles =  g_event.getDataSet("nparticles");
0467   DataSet _pid        =  g_event.getDataSet("pid");
0468   DataSet _weight     =  g_event.getDataSet("weight");
0469   DataSet _trials     =  g_event.getDataSet("trials");
0470   DataSet _scale      =  g_event.getDataSet("scale");
0471   DataSet _rscale     =  g_event.getDataSet("rscale");
0472   DataSet _fscale     =  g_event.getDataSet("fscale");
0473   DataSet _aqed       =  g_event.getDataSet("aqed");
0474   DataSet _aqcd       =  g_event.getDataSet("aqcd");
0475 
0476   std::vector<size_t> offset_e = {first_event};
0477   std::vector<size_t> readsize_e = {n_events};
0478 
0479   // We now know the first event to read.
0480   _start.select(offset_e, readsize_e).read(_vstart);
0481 
0482   // That's the first particle.
0483   std::vector<size_t> offset_p   = {_vstart.front()};
0484   // The last particle is last entry in start + nparticles of that event.
0485   _vnparticles.reserve(n_events);
0486   _nparticles.select(offset_e, readsize_e).read(_vnparticles);
0487 
0488   size_t RESP = _vstart.back() -   _vstart.front() + _vnparticles.back();
0489   std::vector<size_t> readsize_p = {RESP};
0490   _vid.reserve(RESP);
0491   _vstatus  .reserve(RESP);
0492   _vmother1 .reserve(RESP);
0493   _vmother2 .reserve(RESP);
0494   _vcolor1  .reserve(RESP);
0495   _vcolor2  .reserve(RESP);
0496   _vpx      .reserve(RESP);
0497   _vpy      .reserve(RESP);
0498   _vpz      .reserve(RESP);
0499   _ve       .reserve(RESP);
0500   _vm       .reserve(RESP);
0501   _vlifetime.reserve(RESP);
0502   _vspin    .reserve(RESP);
0503   _vpid     .reserve(n_events);
0504   _vtrials  .reserve(n_events);
0505   _vscale   .reserve(n_events);
0506   _vrscale  .reserve(n_events);
0507   _vfscale  .reserve(n_events);
0508   _vaqed    .reserve(n_events);
0509   _vaqcd    .reserve(n_events);
0510 
0511   // This is using HighFive's read.
0512   _id      .select(offset_p, readsize_p).read(_vid      );
0513   _status  .select(offset_p, readsize_p).read(_vstatus  );
0514   _mother1 .select(offset_p, readsize_p).read(_vmother1 );
0515   _mother2 .select(offset_p, readsize_p).read(_vmother2 );
0516   _color1  .select(offset_p, readsize_p).read(_vcolor1  );
0517   _color2  .select(offset_p, readsize_p).read(_vcolor2  );
0518   _px      .select(offset_p, readsize_p).read(_vpx      );
0519   _py      .select(offset_p, readsize_p).read(_vpy      );
0520   _pz      .select(offset_p, readsize_p).read(_vpz      );
0521   _e       .select(offset_p, readsize_p).read(_ve       );
0522   _m       .select(offset_p, readsize_p).read(_vm       );
0523   _lifetime.select(offset_p, readsize_p).read(_vlifetime);
0524   _spin    .select(offset_p, readsize_p).read(_vspin    );
0525   _pid       .select(offset_e, readsize_e).read(_vpid   );
0526   // Read event weights depending on format.
0527   std::vector<size_t> wtdim = _weight.getSpace().getDimensions();
0528   size_t n_weights = wtdim.size() > 1 ? wtdim[1] : 1;
0529   std::vector< std::vector<double> > _vweightvec(n_events,
0530     std::vector<double>(n_weights));
0531   if (hasMultiWts) {
0532     // The weights are stored in a (possibly one-dimensional) vector.
0533     std::vector<size_t> offsets = {first_event,first_event};
0534     std::vector<size_t> counts  = {n_events, n_weights};
0535     _weight  .select(offsets, counts).read(_vweightvec  );
0536   } else {
0537     // The weights are stored as a single floating point value.
0538     std::vector<double> _vweight;
0539     _weight  .select(offset_e, readsize_e).read(_vweight);
0540     _vweightvec.resize(1);
0541     _vweightvec[0] = _vweight;
0542   }
0543   _trials    .select(offset_e, readsize_e).read(_vtrials);
0544   _scale     .select(offset_e, readsize_e).read(_vscale );
0545   _rscale    .select(offset_e, readsize_e).read(_vrscale);
0546   _fscale    .select(offset_e, readsize_e).read(_vfscale);
0547   _aqed      .select(offset_e, readsize_e).read(_vaqed  );
0548   _aqcd      .select(offset_e, readsize_e).read(_vaqcd  );
0549 
0550   return {
0551       std::move(_vstart     ),
0552       std::move(_vid        ),
0553       std::move(_vstatus    ),
0554       std::move(_vmother1   ),
0555       std::move(_vmother2   ),
0556       std::move(_vcolor1    ),
0557       std::move(_vcolor2    ),
0558       std::move(_vpx        ),
0559       std::move(_vpy        ),
0560       std::move(_vpz        ),
0561       std::move(_ve         ),
0562       std::move(_vm         ),
0563       std::move(_vlifetime  ),
0564       std::move(_vspin      ),
0565       std::move(_vnparticles),
0566       std::move(_vpid       ),
0567       std::move(_vweightvec ),
0568       std::move(_vtrials    ),
0569       std::move(_vscale     ),
0570       std::move(_vrscale    ),
0571       std::move(_vfscale    ),
0572       std::move(_vaqed      ),
0573       std::move(_vaqcd      ),
0574       npLO,
0575       npNLO,
0576       offset_p[0],
0577       };
0578 }
0579 
0580 //==========================================================================
0581 
0582 } // end namespace LHEH5
0583 
0584 #endif // Pythia8_LHEH5_H