Belle II Software development
HerwigHepMCFragmentationModule.h
1/**************************************************************************
2 * basf2 (Belle II Analysis Software Framework) *
3 * Author: The Belle II Collaboration *
4 * *
5 * See git log for contributors and copyright holders. *
6 * This file is licensed under LGPL-3.0, see LICENSE.md. *
7 **************************************************************************/
8
9#pragma once
10
11#include <framework/core/Module.h>
12#include <mdst/dataobjects/MCParticle.h>
13#include <mdst/dataobjects/MCParticleGraph.h>
14#include <generators/evtgen/EvtGenInterface.h>
15
16#include <string>
17#include <map>
18#include <memory>
19
20namespace HepMC { class GenEvent; }
21
22namespace Belle2 {
27
28 class HerwigFragHelper;
29
41 class HerwigHepMCFragmentationModule : public Module {
42
43 public:
44 HerwigHepMCFragmentationModule();
45 virtual ~HerwigHepMCFragmentationModule();
46
48 virtual void initialize() override;
50 virtual void terminate() override;
52 virtual void event() override;
53
54 private:
55 // Steerable module parameters
56 std::string m_workDir{};
57 std::string m_decFile{};
58 std::string m_userDecFile{};
59 bool m_useEvtGen{true};
60 bool m_coherentMixing{true};
61 bool m_keepTempFiles{false};
62
63 // Non-steerable internal state: read-only after initialize()
64 std::string m_hepmcPath{};
65
67 std::map<int, HepMC::GenEvent*> m_hepmcEvents;
68
70 std::map<int, std::string> m_sidecarMap;
71
72 std::unique_ptr<HerwigFragHelper> m_helper;
75
78
80 bool loadManifest();
81
88 bool loadHepMCEvents();
89
95 bool loadKKMCSidecar(int globalEvtNum, std::vector<int>& quarkIndices);
96
98 bool applyEvtGenDecays();
99 };
100
102} // namespace Belle2
Class to interface EvtGen.
Helper class for Herwig fragmentation modules.
std::string m_userDecFile
EvtGen user decay file.
int m_successCounter
Counts successfully processed events.
bool m_coherentMixing
Coherent B0/B0bar mixing in EvtGen.
std::map< int, std::string > m_sidecarMap
Mapping from global event number to sidecar filename (basename only).
virtual void initialize() override
Open and validate HepMC file; load all events and manifest; initialize EvtGen.
virtual void event() override
Load one HepMC event, reconstruct MCParticle truth tree, apply EvtGen decays.
virtual void terminate() override
Log success rate; warn if below 97% threshold.
bool applyEvtGenDecays()
Apply EvtGen filter and write decayed particles to StoreArray.
std::string m_hepmcPath
Resolved path to all_events.hepmc.
std::map< int, HepMC::GenEvent * > m_hepmcEvents
Mapping from global basf2 event number to HepMC event stored in memory.
bool m_useEvtGen
Use EvtGen for particle decays (default true).
std::string m_workDir
Working directory written by HerwigLHEWriterModule (Stage 1).
bool m_keepTempFiles
If false, delete WorkDir and all pipeline files in terminate().
bool loadManifest()
Load the manifest.txt written by HerwigLHEWriterModule::terminate().
bool loadKKMCSidecar(int globalEvtNum, std::vector< int > &quarkIndices)
Add KKMC particles from sidecar file to m_mcParticleGraph.
MCParticleGraph m_mcParticleGraph
Particle graph rebuilt per event.
std::unique_ptr< HerwigFragHelper > m_helper
Two-pass HepMC-to-graph helper.
bool loadHepMCEvents()
Load all HepMC events from all_events.hepmc into m_hepmcEvents map.
EvtGenInterface m_evtGenInterface
Persistent EvtGen interface; setup() called once in initialize().
Class to build, validate and sort a particle decay chain.
Module()
Constructor.
Definition Module.cc:30
Abstract base class for different kinds of events.