4 Commits

Author SHA1 Message Date
Paolo Andreetto
b7c775ee35 Error handling 2023-02-22 11:20:56 +01:00
Paolo Andreetto
7bc4932d09 Missing component for VTK 2023-02-20 16:10:10 +01:00
Paolo Andreetto
8832f47e75 Fixed build for VTK on alma9 2023-02-20 16:08:30 +01:00
Paolo Andreetto
043a44150c New writer class for the skin detector 2023-02-17 14:35:31 +01:00
6 changed files with 112 additions and 5 deletions

View File

@@ -79,8 +79,25 @@ include(${EIGEN3_USE_FILE})
find_package(ROOT CONFIG REQUIRED) find_package(ROOT CONFIG REQUIRED)
include(${ROOT_USE_FILE}) include(${ROOT_USE_FILE})
find_package(VTK CONFIG REQUIRED) find_package(VTK REQUIRED
include(${VTK_USE_FILE}) 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_INCLUDES CMAKE_REQUIRED_INCLUDES math.h)
set(CMAKE_REQUIRED_LIBRARIES CMAKE_REQUIRED_LIBRARIES m) set(CMAKE_REQUIRED_LIBRARIES CMAKE_REQUIRED_LIBRARIES m)

View File

@@ -4,18 +4,21 @@ set(HEADERS RootMathDense.h
muCastorMCTrack.h muCastorMCTrack.h
muCastorHit.h muCastorHit.h
muCastorInfo.h muCastorInfo.h
muCastorSkinHit.h) muCastorSkinHit.h
SkinDetectorWriter.h)
set(SOURCES ${HEADERS} RootMuonScatter.cpp set(SOURCES ${HEADERS} RootMuonScatter.cpp
muCastorMCTrack.cpp muCastorMCTrack.cpp
muCastorHit.cpp muCastorHit.cpp
muCastorInfo.cpp muCastorInfo.cpp
muCastorSkinHit.cpp) muCastorSkinHit.cpp
SkinDetectorWriter.cpp)
set(DICTIONARY_HEADERS muCastorMCTrack.h set(DICTIONARY_HEADERS muCastorMCTrack.h
muCastorHit.h muCastorHit.h
muCastorInfo.h muCastorInfo.h
muCastorSkinHit.h) muCastorSkinHit.h
SkinDetectorWriter.h)
set(LIBRARIES ${ROOT_LIBRARIES} set(LIBRARIES ${ROOT_LIBRARIES}
${PACKAGE_LIBPREFIX}Math) ${PACKAGE_LIBPREFIX}Math)

View File

@@ -81,6 +81,8 @@ using namespace ROOT::Mutom;
#pragma link C++ class muCastorInfo+; #pragma link C++ class muCastorInfo+;
#pragma link C++ class muCastorSkinHit+; #pragma link C++ class muCastorSkinHit+;
#pragma link C++ class SkinDetectorWriter+;
#endif // __CINT__ #endif // __CINT__
#endif // LINKDEF_H #endif // LINKDEF_H

View 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();
}

View 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

View File

@@ -26,6 +26,12 @@ public:
void SetMotherID(Int_t mid) { fMotherID = mid; }; void SetMotherID(Int_t mid) { fMotherID = mid; };
void SetMom(TVector3 xyz) { fMomX = xyz.X(); fMomY = xyz.Y(); fMomZ = xyz.Z(); }; 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(); }; 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: private:
Int_t fDetID; // Detector module ID Int_t fDetID; // Detector module ID