diff --git a/src/Root/SkinDetectorWriter.cpp b/src/Root/SkinDetectorWriter.cpp index 726b762..0d92e3e 100644 --- a/src/Root/SkinDetectorWriter.cpp +++ b/src/Root/SkinDetectorWriter.cpp @@ -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(); } \ No newline at end of file diff --git a/src/Root/SkinDetectorWriter.h b/src/Root/SkinDetectorWriter.h index 8025c63..714c7da 100644 --- a/src/Root/SkinDetectorWriter.h +++ b/src/Root/SkinDetectorWriter.h @@ -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; };