Commit 0ca57e77 authored by Jérémie Dudouet's avatar Jérémie Dudouet
Browse files

Change the way the file incremntation is done. fTree never deleted to be...

Change the way the file incremntation is done. fTree never deleted to be compatible with vamoslib. It is reseted and associated to the new file each file incrementation
Add also a new autosave of the TTree, using a SafeSave mode to be avle to read the file while being written
parent 4c42e277
......@@ -177,14 +177,14 @@ Int_t TreeBuilder::SetInput()
timestamp = ((AgataKey*)fAgataComposite->GetKey())->GetTimeStamp();
}
// cout<<AgataKeyFactory::theFactory()->GetMessage(((AgataKey*)fAgataComposite->GetKey())->GetMessage())<<endl;
// cout<<AgataKeyFactory::theFactory()->GetMessage(((AgataKey*)fAgataComposite->GetKey())->GetMessage())<<endl;
// for(int i=0 ; i<fAgataComposite->GetNbSubFrame() ; i++)
// {
// cout<<AgataKeyFactory::theFactory()->GetMessage( ((AgataKey*)fAgataComposite->GetSubKey(i))->GetMessage() )<<" ";
// }
// for(int i=0 ; i<fAgataComposite->GetNbSubFrame() ; i++)
// {
// cout<<AgataKeyFactory::theFactory()->GetMessage( ((AgataKey*)fAgataComposite->GetSubKey(i))->GetMessage() )<<" ";
// }
// cout<<endl;
// cout<<endl;
for(int idet=0 ; idet<fListOfDets.size() ; idet ++) {
TB_Detector *det = fListOfDets[idet];
......@@ -238,6 +238,10 @@ UInt_t TreeBuilder::ProcessBlock(ADF::FrameBlock &inBlock)
nevs++;
fReadEvts++;
if(fReadEvts%fAutoSave == 0) {
fTree->AutoSave("SaveSelf");
}
}
fFrameIO.Detach(&inBlock, 0x0);
......@@ -256,24 +260,29 @@ void TreeBuilder::NewTree()
if(fFile) {
fFile->cd();
fTree->Write();
fTree->SetDirectory(nullptr);
fFile->Close();
}
TString Name = Form("%s/%s%.4d.root",fSaveDir.data(),fNamePatern.data(),fCurrentFileNumber);
fFile = new TFile(Name,"recreate");
// default compression level, good compression and processing time
fFile->SetCompressionLevel();
fTree = new TTree(fTreeName.data(),fTreeName.data());
fTree->SetAutoSave(-50000000); // Auto save all 50MBytes
fCurrentFileNumber++;
if(fTree == nullptr) {
fTree = new TTree(fTreeName.data(),fTreeName.data());
for(int idet=0 ; idet < fListOfDets.size() ; idet++) {
fListOfDets[idet]->SetTree(fTree);
fListOfDets[idet]->InitTree();
for(int idet=0 ; idet < fListOfDets.size() ; idet++) {
fListOfDets[idet]->SetTree(fTree);
fListOfDets[idet]->InitTree();
}
}
else {
fTree->Reset();
fTree->SetDirectory(fFile);
}
fCurrentFileNumber++;
}
UInt_t TreeBuilder::GetParameters(const std::string& confFile, Bool_t doList)
......
......@@ -57,7 +57,8 @@ protected:
protected:
static const Long64_t fMaxFileSize = 2*1024*1024*1024LL;
static const Long64_t fMaxFileSize = 2*1024*1024*1024LL; //! the output file number is incremented all fMaxFileSize (Here 2GB)
static const Long64_t fAutoSave = 1*100*1000; //! the tree is saved all fAutoSave events (Here, 1e5 evts)
string fSaveDir = "";
string fNamePatern = "";
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment