1 #include "otsdaq-core/EventBuilder/EventDataSaver.h"
2 #include "otsdaq-core/MessageFacility/MessageFacility.h"
3 #include "otsdaq-core/Macros/CoutMacros.h"
4 #include "otsdaq-core/EventBuilder/Event.h"
11 #include <TBufferFile.h>
16 EventDataSaver::EventDataSaver(std::string supervisorApplicationUID, std::string bufferUID, std::string processorUID, ConsumerPriority priority)
18 ,
DataConsumer (supervisorApplicationUID, bufferUID, processorUID, HighConsumerPriority)
20 , anEvent_ (new
Event())
25 EventDataSaver::~EventDataSaver(
void)
27 std::cout << __COUT_HDR_FL__ << __PRETTY_FUNCTION__ <<
"Destructor" << std::endl;
33 void EventDataSaver::openFile(std::string fileName)
36 outFile_ = TFile::Open((fileName +
"_Event.root").c_str(),
"NEW");
37 if(!outFile_->IsOpen())
39 std::cout << __COUT_HDR_FL__ <<
"Can't open file " << fileName +
"_Event.root" << std::endl;
43 outTree_ =
new TTree(
"EventTree",
"Event Tree");
44 outTree_-> SetAutoSave(10000);
45 outTree_->Branch(
"EventBranch", anEvent_->GetName(), &anEvent_, 16000, 0);
50 void EventDataSaver::closeFile(
void)
52 std::cout << __COUT_HDR_FL__ << __PRETTY_FUNCTION__ <<
"Saving file!" << std::endl;
53 if(outFile_ != 0 && outFile_->IsOpen())
66 void EventDataSaver::save(std::string& data)
74 if(outTree_ != 0) outTree_->Fill();
78 void EventDataSaver::writeHeader(
void)
88 bool EventDataSaver::workLoopThread(toolbox::task::WorkLoop* workLoop)
93 if(read<
ots::Event, std::map<std::string,std::string>>(*anEvent_) < 0)