Commit e3272c28 authored by Simon Spannagel's avatar Simon Spannagel
Browse files

Merge branch 'master' into 'master'

Add MC Truth reading

See merge request !8
parents d2939b83 fca5b9b6
Pipeline #233939 passed with stage
in 1 minute and 43 seconds
......@@ -12,6 +12,7 @@ FileReader::FileReader(Configuration config, std::vector<Detector*> detectors)
m_readTracks = m_config.get<bool>("readTracks", false);
m_fileName = m_config.get<std::string>("fileName", "outputTuples.root");
m_timeWindow = m_config.get<double>("timeWindow", 1.);
m_readMCParticles = m_config.get<bool>("readMCParticles", false);
m_currentTime = 0.;
}
......@@ -40,6 +41,8 @@ void FileReader::initialise() {
m_objectList.push_back("clusters");
if(m_readTracks)
m_objectList.push_back("tracks");
if(m_readMCParticles)
m_objectList.push_back("mcparticles");
// Get input file
LOG(INFO) << "Opening file " << m_fileName;
......@@ -53,7 +56,7 @@ void FileReader::initialise() {
string objectType = m_objectList[itList];
// Section to set up object reading per detector (such as pixels, clusters)
if(objectType == "pixels" || objectType == "clusters") {
if(objectType == "pixels" || objectType == "clusters" || objectType == "mcparticles") {
// Loop over all detectors and search for data
for(auto& detector : get_detectors()) {
......@@ -112,7 +115,7 @@ StatusCode FileReader::run(Clipboard* clipboard) {
string objectType = m_objectList[itList];
// If this is written per device, loop over all devices
if(objectType == "pixels" || objectType == "clusters") {
if(objectType == "pixels" || objectType == "clusters" || objectType == "mcparticles") {
// Loop over all detectors
for(auto& detector : get_detectors()) {
......
......@@ -29,6 +29,7 @@ namespace corryvreckan {
bool m_readPixels;
bool m_readTracks;
bool m_onlyDUT;
bool m_readMCParticles;
// Map of trees which holds the output objects
std::map<std::string, TTree*> m_inputTrees;
......
......@@ -23,6 +23,7 @@ ROOT_GENERATE_DICTIONARY(CorryvreckanObjectsDictionary
${CMAKE_CURRENT_SOURCE_DIR}/SpidrSignal.h
${CMAKE_CURRENT_SOURCE_DIR}/TestBeamObject.h
${CMAKE_CURRENT_SOURCE_DIR}/Track.h
${CMAKE_CURRENT_SOURCE_DIR}/MCParticle.h
MODULE
CorryvreckanObjects
)
......
#ifndef MCPARTICLE_H
#define MCPARTICLE_H 1
#include "TestBeamObject.h"
#include <Math/Point3D.h>
namespace corryvreckan {
class MCParticle : public TestBeamObject {
public:
// Constructors and destructors
MCParticle() = default;
MCParticle(int particle_id, ROOT::Math::XYZPoint local_start_point, ROOT::Math::XYZPoint local_end_point){
m_particle_id = particle_id;
m_local_start_point = local_start_point;
m_local_end_point = local_end_point;
}
// Member variables
int m_particle_id;
ROOT::Math::XYZPoint m_local_start_point;
ROOT::Math::XYZPoint m_local_end_point;
// Member functions
int getID(){return m_particle_id;}
ROOT::Math::XYZPoint getLocalStart(){return m_local_start_point;}
ROOT::Math::XYZPoint getLocalEnd(){return m_local_end_point;}
// ROOT I/O class definition - update version number when you change this class!
ClassDef(MCParticle, 1)
};
// Vector type declaration
using MCParticles = std::vector<MCParticle*>;
} // namespace corryvreckan
#endif // MCPARTICLE_H
......@@ -2,6 +2,7 @@
#include "TestBeamObject.h"
#include "Cluster.h"
#include "Pixel.h"
#include "MCParticle.h"
#include "Track.h"
#include "core/utils/exceptions.h"
......@@ -31,6 +32,8 @@ TestBeamObject* TestBeamObject::Factory(std::string detectorType, std::string ob
return (object == NULL) ? new Pixel() : new Pixel(*static_cast<Pixel*>(object));
if(objectType == "clusters")
return (object == NULL) ? new Cluster() : new Cluster(*static_cast<Cluster*>(object));
if(objectType == "mcparticles")
return (object == NULL) ? new MCParticle() : new MCParticle(*static_cast<MCParticle*>(object));
}
return new TestBeamObject();
......
Supports Markdown
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