mirror of
https://github.com/OpenCMT/uLib.git
synced 2025-12-06 07:21:31 +01:00
Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b7c775ee35 | ||
|
|
7bc4932d09 | ||
|
|
8832f47e75 | ||
|
|
043a44150c |
@@ -79,8 +79,25 @@ include(${EIGEN3_USE_FILE})
|
||||
find_package(ROOT CONFIG REQUIRED)
|
||||
include(${ROOT_USE_FILE})
|
||||
|
||||
find_package(VTK CONFIG REQUIRED)
|
||||
include(${VTK_USE_FILE})
|
||||
find_package(VTK REQUIRED
|
||||
COMPONENTS CommonColor
|
||||
CommonCore
|
||||
FiltersCore
|
||||
FiltersModeling
|
||||
FiltersSources
|
||||
IOLegacy
|
||||
IOXML
|
||||
IOXMLParser
|
||||
ImagingCore
|
||||
InteractionStyle
|
||||
InteractionWidgets
|
||||
RenderingAnnotation
|
||||
RenderingContextOpenGL2
|
||||
RenderingCore
|
||||
RenderingFreeType
|
||||
RenderingGL2PSOpenGL2
|
||||
RenderingOpenGL2
|
||||
RenderingVolumeOpenGL2)
|
||||
|
||||
set(CMAKE_REQUIRED_INCLUDES CMAKE_REQUIRED_INCLUDES math.h)
|
||||
set(CMAKE_REQUIRED_LIBRARIES CMAKE_REQUIRED_LIBRARIES m)
|
||||
|
||||
@@ -4,18 +4,21 @@ set(HEADERS RootMathDense.h
|
||||
muCastorMCTrack.h
|
||||
muCastorHit.h
|
||||
muCastorInfo.h
|
||||
muCastorSkinHit.h)
|
||||
muCastorSkinHit.h
|
||||
SkinDetectorWriter.h)
|
||||
|
||||
set(SOURCES ${HEADERS} RootMuonScatter.cpp
|
||||
muCastorMCTrack.cpp
|
||||
muCastorHit.cpp
|
||||
muCastorInfo.cpp
|
||||
muCastorSkinHit.cpp)
|
||||
muCastorSkinHit.cpp
|
||||
SkinDetectorWriter.cpp)
|
||||
|
||||
set(DICTIONARY_HEADERS muCastorMCTrack.h
|
||||
muCastorHit.h
|
||||
muCastorInfo.h
|
||||
muCastorSkinHit.h)
|
||||
muCastorSkinHit.h
|
||||
SkinDetectorWriter.h)
|
||||
|
||||
set(LIBRARIES ${ROOT_LIBRARIES}
|
||||
${PACKAGE_LIBPREFIX}Math)
|
||||
|
||||
@@ -81,6 +81,8 @@ using namespace ROOT::Mutom;
|
||||
#pragma link C++ class muCastorInfo+;
|
||||
#pragma link C++ class muCastorSkinHit+;
|
||||
|
||||
#pragma link C++ class SkinDetectorWriter+;
|
||||
|
||||
#endif // __CINT__
|
||||
|
||||
#endif // LINKDEF_H
|
||||
|
||||
47
src/Root/SkinDetectorWriter.cpp
Normal file
47
src/Root/SkinDetectorWriter.cpp
Normal file
@@ -0,0 +1,47 @@
|
||||
#include "SkinDetectorWriter.h"
|
||||
#include "muCastorSkinHit.h"
|
||||
#include "TVector3.h"
|
||||
|
||||
SkinDetectorWriter::SkinDetectorWriter(string filename) :
|
||||
t_file(nullptr),
|
||||
t_tree(nullptr),
|
||||
t_buffer(nullptr),
|
||||
i_status(0)
|
||||
{
|
||||
t_file = new TFile(filename.c_str(), "RECREATE");
|
||||
t_tree = new TTree("muCastorMC", "muCastorMC");
|
||||
t_buffer = new TClonesArray("muCastorSkinHit");
|
||||
|
||||
t_tree->Branch("CastorSkinHits", "TClonesArray", t_buffer, 32000, 99);
|
||||
|
||||
if (t_file->IsZombie()) i_status = 1;
|
||||
}
|
||||
|
||||
SkinDetectorWriter::~SkinDetectorWriter()
|
||||
{}
|
||||
|
||||
void SkinDetectorWriter::add(int detID, float p_x, float p_y, float p_z,
|
||||
float m_x, float m_y, float m_z)
|
||||
{
|
||||
TClonesArray& ref = *t_buffer;
|
||||
int size = ref.GetEntriesFast();
|
||||
|
||||
muCastorSkinHit* new_hit = new(ref[size]) muCastorSkinHit();
|
||||
new_hit->SetDetID(detID);
|
||||
new_hit->SetPdgCode(13);
|
||||
new_hit->SetMotherID(-1);
|
||||
new_hit->SetPos (TVector3(p_x, p_y, p_z));
|
||||
new_hit->SetMom (TVector3(m_x, m_y, m_z));
|
||||
}
|
||||
|
||||
void SkinDetectorWriter::write()
|
||||
{
|
||||
if (t_tree->Fill() < 0) i_status = 2;
|
||||
t_buffer->Delete(); // or t_buffer->Clear() ??
|
||||
}
|
||||
|
||||
void SkinDetectorWriter::close()
|
||||
{
|
||||
if (t_tree->Write() == 0) i_status = 3;
|
||||
t_file->Close();
|
||||
}
|
||||
32
src/Root/SkinDetectorWriter.h
Normal file
32
src/Root/SkinDetectorWriter.h
Normal file
@@ -0,0 +1,32 @@
|
||||
#ifndef SkinDetectorWriter_h
|
||||
#define SkinDetectorWriter_h
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "TFile.h"
|
||||
#include "TTree.h"
|
||||
#include "TClonesArray.h"
|
||||
|
||||
using std::string;
|
||||
|
||||
class SkinDetectorWriter
|
||||
{
|
||||
public:
|
||||
SkinDetectorWriter(string filename);
|
||||
virtual ~SkinDetectorWriter();
|
||||
|
||||
void add(int detID, float p_x, float p_y, float p_z, float m_x, float m_y, float m_z);
|
||||
int status() { return i_status; }
|
||||
void write();
|
||||
void close();
|
||||
|
||||
private:
|
||||
TFile* t_file;
|
||||
TTree* t_tree;
|
||||
TClonesArray* t_buffer;
|
||||
int i_status;
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif //SkinDetectorWriter_h
|
||||
@@ -27,6 +27,12 @@ public:
|
||||
void SetMom(TVector3 xyz) { fMomX = xyz.X(); fMomY = xyz.Y(); fMomZ = xyz.Z(); };
|
||||
void SetPos(TVector3 xyz) { fPosX = xyz.X(); fPosY = xyz.Y(); fPosZ = xyz.Z(); };
|
||||
|
||||
Int_t GetDetID() { return fDetID; }
|
||||
Int_t GetPdgCode() { return fPdgCode; }
|
||||
Int_t GetMotherID() { return fMotherID; }
|
||||
TVector3 GetMom() { return TVector3(fMomX, fMomY, fMomZ); }
|
||||
TVector3 GetPos() { return TVector3(fPosX, fPosY, fPosZ); }
|
||||
|
||||
private:
|
||||
Int_t fDetID; // Detector module ID
|
||||
Int_t fPdgCode; // Particle PDG Code
|
||||
|
||||
Reference in New Issue
Block a user