44 #ifndef Pythia8_LHEH5_H 45 #define Pythia8_LHEH5_H 54 #include "highfive/H5File.hpp" 55 #include "highfive/H5DataSet.hpp" 66 int id, status, mother1, mother2, color1, color2;
67 double px, py, pz, e, m, lifetime, spin;
82 std::ostream& operator << (std::ostream& os,
Particle const & p) {
83 os <<
"\tpx: " << p.px <<
" py: " << p.py <<
" pz: " << p.pz
84 <<
" e: " << p.e <<
"\n";
112 std::ostream& operator << (std::ostream& os,
EventHeader const & eh) {
113 os <<
"\tnparticles: " << eh.
nparticles <<
" procid: " << eh.
pid 115 for (
const auto& w : eh.
weights) os << w <<
" ";
116 os <<
"} trials: " << eh.
trials <<
"\n";
117 os <<
"\tscale: " << eh.scale <<
" rscale: " << eh.rscale <<
" fscale: " 118 << eh.fscale <<
" aqed: " << eh.aqed <<
" aqcd: " << eh.aqcd <<
"\n";
119 os <<
"\tnpLO: " << eh.npLO <<
" npNLO: " << eh.npNLO <<
"\n";
130 std::vector<size_t> _vend;
133 std::vector<int> _vstatus;
134 std::vector<int> _vmother1;
135 std::vector<int> _vmother2;
136 std::vector<int> _vcolor1;
137 std::vector<int> _vcolor2;
138 std::vector<double> _vpx;
139 std::vector<double> _vpy;
140 std::vector<double> _vpz;
141 std::vector<double> _ve;
142 std::vector<double> _vm;
143 std::vector<double> _vlifetime;
144 std::vector<double> _vspin;
147 std::vector<int> _vpid;
148 std::vector<double> _vweight;
149 std::vector<size_t> _vtrials;
150 std::vector<double> _vscale;
151 std::vector<double> _vrscale;
152 std::vector<double> _vfscale;
153 std::vector<double> _vaqed;
154 std::vector<double> _vaqcd;
155 std::vector<int> _vnpLO;
156 std::vector<int> _vnpNLO;
157 size_t _particle_offset;
158 Particle mkParticle(
size_t idx)
const;
159 std::vector<Particle> mkEvent(
size_t ievent)
const;
168 return {std::move(_vid[idx]), std::move(_vstatus[idx]),
169 std::move(_vmother1[idx]), std::move(_vmother2[idx]),
170 std::move(_vcolor1[idx]), std::move(_vcolor2[idx]),
171 std::move(_vpx[idx]), std::move(_vpy[idx]), std::move(_vpz[idx]),
172 std::move(_ve[idx]), std::move(_vm[idx]),
173 std::move(_vlifetime[idx]),std::move(_vspin[idx])};
180 std::vector<Particle> Events::mkEvent(
size_t ievent)
const {
181 std::vector<Particle> _E;
185 size_t id = _vstart[ievent] - _particle_offset;
186 for ( ;
id <(_vend[ievent] - _particle_offset); ++id)
187 _E.push_back(mkParticle(
id));
191 if (_E[0].pz <0) std::swap<Particle>(_E[0], _E[1]);
201 return {std::move(_vnparticles[iev]), std::move(_vpid[iev]),
202 std::vector<double>(1,_vweight[iev]), std::move(_vtrials[iev]),
203 std::move(_vscale[iev]), std::move(_vrscale[iev]),
204 std::move(_vfscale[iev]),
205 std::move(_vaqed[iev]), std::move(_vaqcd[iev]),
206 std::move(_vnpLO[iev]), std::move(_vnpNLO[iev])};
213 Events readEvents(Group& g_index, Group& g_particle, Group& g_event,
214 size_t first_event,
size_t n_events) {
216 std::vector<size_t> _vstart, _vend;
218 std::vector<int> _vid, _vstatus, _vmother1, _vmother2, _vcolor1, _vcolor2;
219 std::vector<double> _vpx, _vpy, _vpz, _ve, _vm, _vlifetime, _vspin;
221 std::vector<int> _vnparticles, _vpid, _vnpLO, _vnpNLO;
222 std::vector<size_t> _vtrials ;
223 std::vector<double> _vweight, _vscale, _vrscale, _vfscale, _vaqed, _vaqcd;
226 DataSet _start = g_index.getDataSet(
"start");
227 DataSet _end = g_index.getDataSet(
"end");
229 DataSet _id = g_particle.getDataSet(
"id");
230 DataSet _status = g_particle.getDataSet(
"status");
231 DataSet _mother1 = g_particle.getDataSet(
"mother1");
232 DataSet _mother2 = g_particle.getDataSet(
"mother2");
233 DataSet _color1 = g_particle.getDataSet(
"color1");
234 DataSet _color2 = g_particle.getDataSet(
"color2");
235 DataSet _px = g_particle.getDataSet(
"px");
236 DataSet _py = g_particle.getDataSet(
"py");
237 DataSet _pz = g_particle.getDataSet(
"pz");
238 DataSet _e = g_particle.getDataSet(
"e");
239 DataSet _m = g_particle.getDataSet(
"m");
240 DataSet _lifetime = g_particle.getDataSet(
"lifetime");
241 DataSet _spin = g_particle.getDataSet(
"spin");
243 DataSet _nparticles = g_event.getDataSet(
"nparticles");
244 DataSet _pid = g_event.getDataSet(
"pid");
245 DataSet _weight = g_event.getDataSet(
"weight");
246 DataSet _trials = g_event.getDataSet(
"trials");
247 DataSet _scale = g_event.getDataSet(
"scale");
248 DataSet _rscale = g_event.getDataSet(
"rscale");
249 DataSet _fscale = g_event.getDataSet(
"fscale");
250 DataSet _aqed = g_event.getDataSet(
"aqed");
251 DataSet _aqcd = g_event.getDataSet(
"aqcd");
252 DataSet _npLO = g_event.getDataSet(
"npLO");
253 DataSet _npNLO = g_event.getDataSet(
"npNLO");
255 std::vector<size_t> offset_e = {first_event};
256 std::vector<size_t> readsize_e = {n_events};
258 _start.select(offset_e, readsize_e).read(_vstart);
259 _end.select( offset_e, readsize_e).read(_vend );
260 std::vector<size_t> offset_p = {_vstart.front()};
261 std::vector<size_t> readsize_p = {_vend.back()-_vstart.front()};
263 int RESP = _vend.back()-_vstart.front();
265 _vstatus .reserve(RESP);
266 _vmother1 .reserve(RESP);
267 _vmother2 .reserve(RESP);
268 _vcolor1 .reserve(RESP);
269 _vcolor2 .reserve(RESP);
275 _vlifetime.reserve(RESP);
276 _vspin .reserve(RESP);
278 _vnparticles.reserve(n_events);
279 _vpid .reserve(n_events);
280 _vweight .reserve(n_events);
281 _vtrials .reserve(n_events);
282 _vscale .reserve(n_events);
283 _vrscale .reserve(n_events);
284 _vfscale .reserve(n_events);
285 _vaqed .reserve(n_events);
286 _vaqcd .reserve(n_events);
287 _vnpLO .reserve(n_events);
288 _vnpNLO .reserve(n_events);
291 _id .select(offset_p, readsize_p).read(_vid );
292 _status .select(offset_p, readsize_p).read(_vstatus );
293 _mother1 .select(offset_p, readsize_p).read(_vmother1 );
294 _mother2 .select(offset_p, readsize_p).read(_vmother2 );
295 _color1 .select(offset_p, readsize_p).read(_vcolor1 );
296 _color2 .select(offset_p, readsize_p).read(_vcolor2 );
297 _px .select(offset_p, readsize_p).read(_vpx );
298 _py .select(offset_p, readsize_p).read(_vpy );
299 _pz .select(offset_p, readsize_p).read(_vpz );
300 _e .select(offset_p, readsize_p).read(_ve );
301 _m .select(offset_p, readsize_p).read(_vm );
302 _lifetime.select(offset_p, readsize_p).read(_vlifetime);
303 _spin .select(offset_p, readsize_p).read(_vspin );
305 _nparticles.select(offset_e, readsize_e).read(_vnparticles);
306 _pid .select(offset_e, readsize_e).read(_vpid );
307 _weight .select(offset_e, readsize_e).read(_vweight );
308 _trials .select(offset_e, readsize_e).read(_vtrials );
309 _scale .select(offset_e, readsize_e).read(_vscale );
310 _rscale .select(offset_e, readsize_e).read(_vrscale );
311 _fscale .select(offset_e, readsize_e).read(_vfscale );
312 _aqed .select(offset_e, readsize_e).read(_vaqed );
313 _aqcd .select(offset_e, readsize_e).read(_vaqcd );
314 _npLO .select(offset_e, readsize_e).read(_vnpLO );
315 _npNLO .select(offset_e, readsize_e).read(_vnpNLO );
322 std::move(_vmother1),
323 std::move(_vmother2),
331 std::move(_vlifetime),
333 std::move(_vnparticles),
356 std::vector<int> _vstatus;
357 std::vector<int> _vmother1;
358 std::vector<int> _vmother2;
359 std::vector<int> _vcolor1;
360 std::vector<int> _vcolor2;
361 std::vector<double> _vpx;
362 std::vector<double> _vpy;
363 std::vector<double> _vpz;
364 std::vector<double> _ve;
365 std::vector<double> _vm;
366 std::vector<double> _vlifetime;
367 std::vector<double> _vspin;
370 std::vector<int> _vpid;
371 std::vector<std::vector<double>> _vweightvec;
372 std::vector<size_t> _vtrials;
373 std::vector<double> _vscale;
374 std::vector<double> _vrscale;
375 std::vector<double> _vfscale;
376 std::vector<double> _vaqed;
377 std::vector<double> _vaqcd;
380 size_t _particle_offset;
382 Particle mkParticle(
size_t idx)
const;
383 std::vector<Particle> mkEvent(
size_t ievent)
const;
392 return {std::move(_vid[idx]), std::move(_vstatus[idx]),
393 std::move(_vmother1[idx]), std::move(_vmother2[idx]),
394 std::move(_vcolor1[idx]), std::move(_vcolor2[idx]),
395 std::move(_vpx[idx]), std::move(_vpy[idx]), std::move(_vpz[idx]),
396 std::move(_ve[idx]), std::move(_vm[idx]),
397 std::move(_vlifetime[idx]),std::move(_vspin[idx])};
404 std::vector<Particle> Events2::mkEvent(
size_t ievent)
const {
405 std::vector<Particle> _E;
408 size_t partno = _vstart[ievent] - _particle_offset;
409 for (
int id=0;
id <_vnparticles[ievent];++id){
410 _E.push_back(mkParticle(partno));
415 if (_E[0].pz < 0.) std::swap<Particle>(_E[0], _E[1]);
424 return {std::move(_vnparticles[iev]), std::move(_vpid[iev]),
425 std::move(_vweightvec[iev]), std::move(_vtrials[iev]),
426 std::move(_vscale[iev]), std::move(_vrscale[iev]),
427 std::move(_vfscale[iev]),
428 std::move(_vaqed[iev]), std::move(_vaqcd[iev]),
437 Events2 readEvents2(Group& g_particle, Group& g_event,
size_t first_event,
438 size_t n_events,
int npLO,
int npNLO,
bool hasMultiWts) {
440 std::vector<size_t> _vstart;
442 std::vector<int> _vid, _vstatus, _vmother1, _vmother2, _vcolor1, _vcolor2;
443 std::vector<double> _vpx, _vpy, _vpz, _ve, _vm, _vlifetime, _vspin;
445 std::vector<int> _vnparticles, _vpid;
446 std::vector<size_t> _vtrials ;
447 std::vector<double> _vscale, _vrscale, _vfscale, _vaqed, _vaqcd;
450 DataSet _start = g_event.getDataSet(
"start");
452 DataSet _id = g_particle.getDataSet(
"id");
453 DataSet _status = g_particle.getDataSet(
"status");
454 DataSet _mother1 = g_particle.getDataSet(
"mother1");
455 DataSet _mother2 = g_particle.getDataSet(
"mother2");
456 DataSet _color1 = g_particle.getDataSet(
"color1");
457 DataSet _color2 = g_particle.getDataSet(
"color2");
458 DataSet _px = g_particle.getDataSet(
"px");
459 DataSet _py = g_particle.getDataSet(
"py");
460 DataSet _pz = g_particle.getDataSet(
"pz");
461 DataSet _e = g_particle.getDataSet(
"e");
462 DataSet _m = g_particle.getDataSet(
"m");
463 DataSet _lifetime = g_particle.getDataSet(
"lifetime");
464 DataSet _spin = g_particle.getDataSet(
"spin");
466 DataSet _nparticles = g_event.getDataSet(
"nparticles");
467 DataSet _pid = g_event.getDataSet(
"pid");
468 DataSet _weight = g_event.getDataSet(
"weight");
469 DataSet _trials = g_event.getDataSet(
"trials");
470 DataSet _scale = g_event.getDataSet(
"scale");
471 DataSet _rscale = g_event.getDataSet(
"rscale");
472 DataSet _fscale = g_event.getDataSet(
"fscale");
473 DataSet _aqed = g_event.getDataSet(
"aqed");
474 DataSet _aqcd = g_event.getDataSet(
"aqcd");
476 std::vector<size_t> offset_e = {first_event};
477 std::vector<size_t> readsize_e = {n_events};
480 _start.select(offset_e, readsize_e).read(_vstart);
483 std::vector<size_t> offset_p = {_vstart.front()};
485 _vnparticles.reserve(n_events);
486 _nparticles.select(offset_e, readsize_e).read(_vnparticles);
488 size_t RESP = _vstart.back() - _vstart.front() + _vnparticles.back();
489 std::vector<size_t> readsize_p = {RESP};
491 _vstatus .reserve(RESP);
492 _vmother1 .reserve(RESP);
493 _vmother2 .reserve(RESP);
494 _vcolor1 .reserve(RESP);
495 _vcolor2 .reserve(RESP);
501 _vlifetime.reserve(RESP);
502 _vspin .reserve(RESP);
503 _vpid .reserve(n_events);
504 _vtrials .reserve(n_events);
505 _vscale .reserve(n_events);
506 _vrscale .reserve(n_events);
507 _vfscale .reserve(n_events);
508 _vaqed .reserve(n_events);
509 _vaqcd .reserve(n_events);
512 _id .select(offset_p, readsize_p).read(_vid );
513 _status .select(offset_p, readsize_p).read(_vstatus );
514 _mother1 .select(offset_p, readsize_p).read(_vmother1 );
515 _mother2 .select(offset_p, readsize_p).read(_vmother2 );
516 _color1 .select(offset_p, readsize_p).read(_vcolor1 );
517 _color2 .select(offset_p, readsize_p).read(_vcolor2 );
518 _px .select(offset_p, readsize_p).read(_vpx );
519 _py .select(offset_p, readsize_p).read(_vpy );
520 _pz .select(offset_p, readsize_p).read(_vpz );
521 _e .select(offset_p, readsize_p).read(_ve );
522 _m .select(offset_p, readsize_p).read(_vm );
523 _lifetime.select(offset_p, readsize_p).read(_vlifetime);
524 _spin .select(offset_p, readsize_p).read(_vspin );
525 _pid .select(offset_e, readsize_e).read(_vpid );
527 std::vector<size_t> wtdim = _weight.getSpace().getDimensions();
528 size_t n_weights = wtdim.size() > 1 ? wtdim[1] : 1;
529 std::vector< std::vector<double> > _vweightvec(n_events,
530 std::vector<double>(n_weights));
533 std::vector<size_t> offsets = {first_event,first_event};
534 std::vector<size_t> counts = {n_events, n_weights};
535 _weight .select(offsets, counts).read(_vweightvec );
538 std::vector<double> _vweight;
539 _weight .select(offset_e, readsize_e).read(_vweight);
540 _vweightvec.resize(1);
541 _vweightvec[0] = _vweight;
543 _trials .select(offset_e, readsize_e).read(_vtrials);
544 _scale .select(offset_e, readsize_e).read(_vscale );
545 _rscale .select(offset_e, readsize_e).read(_vrscale);
546 _fscale .select(offset_e, readsize_e).read(_vfscale);
547 _aqed .select(offset_e, readsize_e).read(_vaqed );
548 _aqcd .select(offset_e, readsize_e).read(_vaqcd );
553 std::move(_vstatus ),
554 std::move(_vmother1 ),
555 std::move(_vmother2 ),
556 std::move(_vcolor1 ),
557 std::move(_vcolor2 ),
563 std::move(_vlifetime ),
565 std::move(_vnparticles),
567 std::move(_vweightvec ),
568 std::move(_vtrials ),
570 std::move(_vrscale ),
571 std::move(_vfscale ),
Old event struct.
Definition: LHEH5.h:127
std::vector< int > _vnparticles
Event info.
Definition: LHEH5.h:369
std::vector< int > _vid
Particles.
Definition: LHEH5.h:132
New events struct.
Definition: LHEH5.h:351
std::vector< int > _vid
Particles.
Definition: LHEH5.h:355
std::vector< size_t > _vstart
Lookup.
Definition: LHEH5.h:353
std::vector< int > _vnparticles
Event info.
Definition: LHEH5.h:146
std::vector< size_t > _vstart
Lookup.
Definition: LHEH5.h:129
Particle struct.
Definition: LHEH5.h:65