mirror of
https://github.com/OpenCMT/uLib.git
synced 2025-12-06 07:21:31 +01:00
Error handling
This commit is contained in:
@@ -5,13 +5,16 @@
|
||||
SkinDetectorWriter::SkinDetectorWriter(string filename) :
|
||||
t_file(nullptr),
|
||||
t_tree(nullptr),
|
||||
t_buffer(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()
|
||||
@@ -30,14 +33,15 @@ void SkinDetectorWriter::add(int detID, float p_x, float p_y, float p_z,
|
||||
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();
|
||||
if (t_tree->Fill() < 0) i_status = 2;
|
||||
t_buffer->Delete(); // or t_buffer->Clear() ??
|
||||
}
|
||||
|
||||
void SkinDetectorWriter::close()
|
||||
{
|
||||
t_tree->Write();
|
||||
if (t_tree->Write() == 0) i_status = 3;
|
||||
t_file->Close();
|
||||
}
|
||||
@@ -16,6 +16,7 @@ public:
|
||||
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();
|
||||
|
||||
@@ -23,6 +24,7 @@ private:
|
||||
TFile* t_file;
|
||||
TTree* t_tree;
|
||||
TClonesArray* t_buffer;
|
||||
int i_status;
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user