mirror of
https://github.com/OpenCMT/uLib.git
synced 2025-12-06 07:21:31 +01:00
New writer class for the skin detector
This commit is contained in:
@@ -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)
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
43
src/Root/SkinDetectorWriter.cpp
Normal file
43
src/Root/SkinDetectorWriter.cpp
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
#include "SkinDetectorWriter.h"
|
||||||
|
#include "muCastorSkinHit.h"
|
||||||
|
#include "TVector3.h"
|
||||||
|
|
||||||
|
SkinDetectorWriter::SkinDetectorWriter(string filename) :
|
||||||
|
t_file(nullptr),
|
||||||
|
t_tree(nullptr),
|
||||||
|
t_buffer(nullptr)
|
||||||
|
{
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
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()
|
||||||
|
{
|
||||||
|
t_tree->Fill();
|
||||||
|
t_buffer->Delete(); // or t_buffer->Clear() ??
|
||||||
|
}
|
||||||
|
|
||||||
|
void SkinDetectorWriter::close()
|
||||||
|
{
|
||||||
|
t_tree->Write();
|
||||||
|
t_file->Close();
|
||||||
|
}
|
||||||
30
src/Root/SkinDetectorWriter.h
Normal file
30
src/Root/SkinDetectorWriter.h
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
#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);
|
||||||
|
void write();
|
||||||
|
void close();
|
||||||
|
|
||||||
|
private:
|
||||||
|
TFile* t_file;
|
||||||
|
TTree* t_tree;
|
||||||
|
TClonesArray* t_buffer;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif //SkinDetectorWriter_h
|
||||||
@@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user