Commit 4c42e277 authored by Jérémie Dudouet's avatar Jérémie Dudouet
Browse files

Correct the bug of exiting femul with TreeBuilder and Vamos

Take into account the new dev in the vamos lib to get counters
parent 57982463
......@@ -41,6 +41,7 @@ TB_VAMOS::TB_VAMOS(TString name, TString ADFKey) : TB_Detector(name,ADFKey)
TB_VAMOS::~TB_VAMOS()
{
fVamosSpectraFile->Close();
if(fAnalysis)
delete fAnalysis;
}
......@@ -98,7 +99,8 @@ void TB_VAMOS::InitTree()
fAnalysis = new Analysis(fTree,fParameters,fHistoManager);
fAnalysis->SetOutTFile( new TFile(Form("%s/VAMOS_Spectra.root",fOutputPath.Data()),"recreate") );
fVamosSpectraFile = new TFile(Form("%s/VAMOS_Spectra.root",fOutputPath.Data()),"recreate");
fAnalysis->SetOutTFile( fVamosSpectraFile );
fParameters->GetParametersFromActionFile((char *)ActionFile.Data());
......@@ -123,6 +125,7 @@ void TB_VAMOS::InitTree()
// Data operation
fAnalysis->GetMap()->DataOp(fParameters);
fAnalysis->SetUpDetectors(fMode);
fAnalysis->EndInit();
}
void TB_VAMOS::Process(Int_t idet)
......@@ -141,6 +144,7 @@ void TB_VAMOS::Process(Int_t idet)
fAnalysis->UnPack(fMFMCommonFrame);
fAnalysis->Treat();
fAnalysis->UpdateCounters();
}
UInt_t TB_VAMOS::GetParameters(const std::string& confFile, Bool_t doList)
......
......@@ -53,7 +53,7 @@ protected:
LogManager *fLogManager = nullptr;
//!
MOFile *fMOFile = nullptr;
TFile *fVamosSpectraFile = nullptr;
MFMMergeFrame *fMFMMergeFrame = nullptr;
MFMCommonFrame *fMFMCommonFrame = nullptr;
MFMEbyedatFrame *fMFMEBYFrame = nullptr;
......
......@@ -40,6 +40,7 @@
#include "TTree.h"
#include "TFile.h"
#include "TROOT.h"
using namespace AGAPRO;
......@@ -56,18 +57,23 @@ TreeBuilder::~TreeBuilder()
{
cServer.Finish();
if(fFile != nullptr)
{
if(fFile != nullptr) {
cout << " #################################### " << endl;
cout << " Number of read events " << fReadEvts << endl;
cout << " #################################### " << endl;
fFile->cd();
fTree->Write();
fFile->Close();
// in principle not needed ... just in case reset it has not been called by narval
UInt_t error = 0u; process_reset(&error) ;
}
for(int idet=0 ; idet<fListOfDets.size() ; idet++){
TB_Detector *det = fListOfDets[idet];
delete det;
}
}
void TreeBuilder::process_config(const Char_t *directory_path, UInt_t *error_code)
......@@ -95,8 +101,7 @@ void TreeBuilder::process_initialise (UInt_t *error_code)
Log.SetPID(GetPID());
*error_code = GetParameters(GetConfPath() + gMotherClass + ".conf");
if(*error_code)
{
if(*error_code) {
Log << dolog;
return;
}
......@@ -110,8 +115,7 @@ void TreeBuilder::process_initialise (UInt_t *error_code)
if( !fFrameIO.Register(fTrigger) )
rerr |= 2;
if(rerr)
{
if(rerr) {
std::cout << "Trigger definition error " << rerr << " in TreeBuilder::process_initialise()" << std::endl;
*error_code = 100 + rerr;
Log << dolog;
......@@ -125,8 +129,7 @@ void TreeBuilder::process_initialise (UInt_t *error_code)
cServer.Start(gActualClass);
for(int idet=0 ; idet<fListOfDets.size() ; idet++)
{
for(int idet=0 ; idet<fListOfDets.size() ; idet++) {
TB_Detector *det = fListOfDets[idet];
det->Init();
......@@ -167,8 +170,7 @@ void TreeBuilder::process_stop (UInt_t *error_code)
Int_t TreeBuilder::SetInput()
{
if(fNoMergerMode == false)
{
if(fNoMergerMode == false) {
fAgataComposite = dynamic_cast< AgataCompositeFrame *> ( fTrigger->GetInputFrame() );
fAgataComposite->Scan();
......@@ -184,8 +186,7 @@ Int_t TreeBuilder::SetInput()
// cout<<endl;
for(int idet=0 ; idet<fListOfDets.size() ; idet ++)
{
for(int idet=0 ; idet<fListOfDets.size() ; idet ++) {
TB_Detector *det = fListOfDets[idet];
det->InitValues();
......@@ -211,26 +212,21 @@ UInt_t TreeBuilder::ProcessBlock(ADF::FrameBlock &inBlock)
if(fFile->GetEND()>fMaxFileSize)
NewTree();
while ( fFrameIO.Notify() )
{
while ( fFrameIO.Notify() ) {
// fill local variables with data from the input
error_code = SetInput();
if( error_code == 1)
{
if( error_code == 1) {
LOCK_COUT;
Log.SetProcessMethod("ProcessBlock");
Log << error << " During : SetInput()" << dolog;
break;
}
else
{
else {
bool has_triggered = false;
for(int idet=0 ; idet<fListOfDets.size() ; idet ++)
{
for(int idet=0 ; idet<fListOfDets.size() ; idet ++) {
TB_Detector *det = fListOfDets[idet];
if(det->IsTriggered())
{
if(det->IsTriggered()) {
has_triggered = true;
det->Process(idet);
}
......@@ -257,22 +253,24 @@ UInt_t TreeBuilder::ProcessBlock(ADF::FrameBlock &inBlock)
void TreeBuilder::NewTree()
{
if(fFile)
{
if(fFile) {
fFile->cd();
fTree->Write();
fFile->Close();
}
TString Name = Form("%s/%s%.4d.root",fSaveDir.data(),fNamePatern.data(),fCurrentFileNumber);
fFile = new TFile(Name,"recreate");
// fFile->SetCompressionLevel(0);
// 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++;
for(int idet=0 ; idet < fListOfDets.size() ; idet++)
{
for(int idet=0 ; idet < fListOfDets.size() ; idet++) {
fListOfDets[idet]->SetTree(fTree);
fListOfDets[idet]->InitTree();
}
......@@ -317,20 +315,18 @@ UInt_t TreeBuilder::GetParameters(const std::string& confFile, Bool_t doList)
conf.Restore(which, nn);
AddDetector(Detector,ADFKey,MandatoryMode);
if(fNoMergerMode && ((TString)ADFKey).Contains("anc"))
{
if(fNoMergerMode && ((TString)ADFKey).Contains("anc")) {
Log << error << " Ancillary detector set, but NoMergerMode is on..." << dolog;
}
}
}
if(fListOfDets.size()==0){
if(fListOfDets.size()==0) {
Log << error << " No detector added in the Tree" << dolog;
rv = 201;
}
if(fNoMergerMode && fListOfDets.size()>1)
{
if(fNoMergerMode && fListOfDets.size()>1) {
Log << error << " Only one detector type can be defined when NoMergerMode is on" << dolog;
rv = 202;
}
......@@ -346,14 +342,12 @@ void TreeBuilder::AddDetector(TString Name, TString ADFKey, Int_t MandatoryMode)
Log.SetPID(GetPID());
UInt_t mess;
if( ! AgataKeyFactory::theFactory()->GetMessage(ADFKey.Data(),mess))
{
if( ! AgataKeyFactory::theFactory()->GetMessage(ADFKey.Data(),mess)) {
Log << error << ADFKey << " Unkown adf key" << dolog;
return;
}
if(MandatoryMode<-1 || MandatoryMode>1)
{
if(MandatoryMode<-1 || MandatoryMode>1) {
Log << error << " MandatoryMode must be either -1 (must not be present) , 0 (can be present) or 1 (must be present)" << dolog;
return;
}
......@@ -368,12 +362,10 @@ void TreeBuilder::AddDetector(TString Name, TString ADFKey, Int_t MandatoryMode)
TB_Detector *det = nullptr;
if(NameTest == "agata_builder")
{
if(NameTest == "agata_builder") {
det = new TB_AGATA_Builder(NameTest,ADFKey);
}
if(NameTest == "agata_tracking")
{
if(NameTest == "agata_tracking") {
det = new TB_AGATA_Tracking(NameTest,ADFKey);
}
else if(NameTest == "neda")
......@@ -394,8 +386,7 @@ void TreeBuilder::AddDetector(TString Name, TString ADFKey, Int_t MandatoryMode)
return;
#endif
}
else if(NameTest == "vamos")
{
else if(NameTest == "vamos") {
#if defined(HAS_MFM) && defined(HAS_VAMOS)
det = new TB_VAMOS(NameTest,ADFKey);
#else
......@@ -404,14 +395,13 @@ void TreeBuilder::AddDetector(TString Name, TString ADFKey, Int_t MandatoryMode)
#endif
}
if(det)
{
if(det) {
det->SetConfPath(GetConfPath());
det->SetOutputPath(fSaveDir);
det->SetNoMergerMode(fNoMergerMode);
fListOfDets.push_back(det);
}
else{
else {
Log << error << Name << " ==> Unkonwn detector " << dolog;
return;
}
......@@ -431,10 +421,8 @@ Int_t TreeBuilder::BuildTrigger()
fTrigger = AgataFrameTrigger::Build("Event", fTriggerName.Data());
if ( fTrigger)
{
for(int idet=0 ; idet<fListOfDets.size() ; idet++)
{
if ( fTrigger) {
for(int idet=0 ; idet<fListOfDets.size() ; idet++) {
TB_Detector *det = fListOfDets[idet];
det->SetTrigger(fTrigger);
}
......
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