Commit 538671e6 authored by Sylvester Joosten's avatar Sylvester Joosten
Browse files

Refactored output plugin and added proper MC truth info to hits

parent 9a5fce9b
Pipeline #18973 passed with stages
in 33 seconds
......@@ -33,10 +33,8 @@ components:
"
dd4pod::MonteCarloContrib:
#Description: "Podio implementation of dd4hep's dd4hep::sim::MonteCarloContrib class"
#Author : "W.Armstrong"
Members:
- int32_t trackID // track id, -1 if none/invalid
- int32_t trackID // track id, -1 if none/invalid. Maps to Geant4Particle::ID.
- int32_t pdgID // PDG Particle ID code
- double deposit // energy deposit [GeV]
- double time // time [ns]
......@@ -61,11 +59,11 @@ components:
bool empty() const {return trackID < 0;}\n
"
datatypes :
datatypes:
dd4pod::Geant4Particle:
Description: "Podio implementation of dd4hep's dd4hep::sim::Geant4Particle class"
Author : "W.Armstrong"
Author : "W. Armstrong, S. Joosten"
Members:
- int32_t ID // unique identifier for this particle
- int32_t g4Parent // g4 parent particle
......@@ -100,7 +98,7 @@ datatypes :
dd4pod::PhotoMultiplierHit:
Description: "Podio implementation of a pmt hit "
Author : "W.Armstrong"
Author : "W. Armstrong, S. Joosten"
Members:
- int64_t cellID // cellID
- int32_t flag // User flag to classify hits
......@@ -113,7 +111,7 @@ datatypes :
dd4pod::TrackerHit:
Description: "Podio implementation of dd4hep's dd4hep::sim::Geant4Tracker::Hit class"
Author : "W.Armstrong"
Author : "W. Armstrong, S. Joosten"
Members:
- int64_t cellID // cellID
- int32_t flag // User flag to classify hits
......@@ -126,12 +124,14 @@ datatypes :
dd4pod::CalorimeterHit:
Description: "Podio implementation of dd4hep's dd4hep::sim::Geant4Calorimeter::Hit class"
Author : "W.Armstrong"
Author : "W. Armstrong, S. Joosten"
Members:
- int64_t cellID // cellID
- int32_t flag // User flag to classify hits
- int32_t g4ID // Original Geant4 track identifier of the creating track (debugging)
- dd4pod::VectorXYZ position // position [mm]
- dd4pod::MonteCarloContrib truth // truth-info
- dd4pod::MonteCarloContrib truth // truth-info of one of the contributing hits
- double energyDeposit // energy deposit [GeV]
VectorMembers:
- dd4pod::MonteCarloContrib contributions // All contributing hits. Not filled by default.
This diff is collapsed.
......@@ -9,6 +9,9 @@
#include "podio/EventStore.h"
#include "podio/ROOTWriter.h"
#include <set>
#include <memory>
namespace dd4pod {
class Geant4Particle;
class Geant4ParticleCollection;
......@@ -37,19 +40,22 @@ namespace dd4hep {
dd4hep::sim::Geant4Particle* part);
/// Flag if Monte-Carlo truth should be followed and checked
bool m_handleMCTruth;
bool m_handleMCTruth = true;
/// Property: vector with disabled collections
std::vector<std::string> m_disabledCollections;
/// Property: vector with disabled collections
std::vector<std::string> m_enabledCollections;
// map collection names to a boolean for quick enable/disable check
std::set<std::string> m_disableList;
/// Property: vector with disabled collections
bool m_disableParticles = false;
/// Store all calorimeter contributions. Will dramatically increase output data size
bool m_storeCalorimeterContributions = false;
podio::EventStore store;
podio::ROOTWriter* writer = nullptr;
std::unique_ptr<podio::EventStore> m_store;
std::unique_ptr<podio::ROOTWriter> m_writer;
std::map<std::string, podio::CollectionBase*> m_col_map;
std::vector<std::pair<std::string, podio::CollectionBase*>> m_collections;
......@@ -57,6 +63,17 @@ namespace dd4hep {
m_readCollections;
podio::CollectionIDTable* m_collectionIDs;
// Create a podio collection on the event store
template <class CollectionType>
void createCollection(const std::string& name) {
m_store->create<CollectionType>(name);
m_writer->registerForWrite(name);
printout(DEBUG, "Geant4Output2Podio", "Created collection %s", name.c_str());
}
void initEventStore(OutputContext<G4Event>& ctxt);
void saveParticles(const Geant4ParticleMap* parts);
public:
Geant4Output2Podio(Geant4Context* context, const std::string& nam);
virtual ~Geant4Output2Podio();
......@@ -81,6 +98,7 @@ namespace dd4hep {
/// Commit data at end of filling procedure
virtual void commit(OutputContext<G4Event>& ctxt);
};
} // End namespace sim
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment