Docker-in-Docker (DinD) capabilities of public runners deactivated. More info

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

Add the Vamos part in the TreeBuilder

Add the possibility to build trees after the builder
parent d0891780
......@@ -104,6 +104,7 @@ find_package(ADF REQUIRED)
find_package(ROOT)
find_package(MFM)
find_package(DCOD)
find_package(VAMOS)
# Find module using simple test
include(AGAPROMacroUtilities)
......@@ -140,6 +141,10 @@ endif()
if (MFM_FOUND)
list (APPEND AGAPRO_INCLUDE_DIRS ${MFM_INCLUDE_DIRS})
endif()
# VAMOS
if (VAMOS_FOUND)
list (APPEND AGAPRO_INCLUDE_DIRS ${VAMOS_INCLUDE_DIRS})
endif()
# Boost
if (HAS_BOOST)
list(APPEND AGAPRO_INCLUDE_DIRS ${Boost_INCLUDE_DIRS})
......
......@@ -868,7 +868,7 @@ void listKeysAndExit()
pf6->GetParameters("", true);
delete pf6;
#if defined(HAS_MFM) && defined(HAS_ROOT)
#ifdef HAS_ROOT
AGAPRO::TreeBuilder *pf7 = new AGAPRO::TreeBuilder;
pf7->GetParameters("", true);
delete pf7;
......@@ -1117,7 +1117,7 @@ bool topologyConfNew()
pActor->libItem = 400;
}
// 42
#if defined(HAS_MFM) && defined(HAS_ROOT)
#ifdef HAS_ROOT
else if(pActor->libName == "TreeBuilder") { // no mother-daughter model
cout << "TreeBuilder ..." << endl;
AGAPRO::TreeBuilder::process_config(pActor->libConf.c_str(), &error_config);
......@@ -1390,7 +1390,7 @@ bool topologyConfNew()
pActor->nrvPointer = new BasicAFC(nc);
pActor->libItem = 1;
}
#if defined(HAS_MFM) && defined(HAS_ROOT)
#ifdef HAS_ROOT
else if(pActor->libName == "TreeBuilder") {
cout << "TreeBuilder ..." << endl;
BasicAFC::process_config(pActor->libConf.c_str(), &error_config);
......
......@@ -7,8 +7,13 @@
#cmakedefine HAS_C11
#cmakedefine HAS_ROOT
#cmakedefine HAS_MFM
#cmakedefine HAS_VAMOS
#cmakedefine HAS_DCOD
// For Vamos lib
#cmakedefine WITH_MFM
#cmakedefine WITH_ROOT
//////////////////////////////
////// Define OS_TYPE ////////
......
......@@ -45,6 +45,7 @@ endif()
if (ROOT_FOUND)
SET(HAS_ROOT ON)
SET(WITH_ROOT ON) # For Vamos lib
message("[AGAPRO] + Configured with ROOT enabled")
else()
message("[AGAPRO] + Configured with ROOT disabled")
......@@ -52,11 +53,19 @@ endif()
if (MFM_FOUND)
SET(HAS_MFM ON)
SET(WITH_MFM ON) # For Vamos lib
message("[AGAPRO] + Configured with MFM enabled")
else()
message("[AGAPRO] + Configured with MFM disabled")
endif()
if (VAMOS_FOUND)
SET(HAS_VAMOS ON)
message("[AGAPRO] + Configured with VAMOS enabled")
else()
message("[AGAPRO] + Configured with VAMOS disabled")
endif()
if (DCOD_FOUND)
SET(HAS_DCOD ON)
message("[AGAPRO] + Configured with DCOD enabled")
......
......@@ -168,7 +168,11 @@ void TB_AGATA_Builder::Process(Int_t idet)
Log.GetProcessName() = "TB_AGATA_Builder";
Log.SetProcessMethod("Process()");
fCompFrame = (AgataCompositeFrame*) fTrigger->GetInputSharedFP(idet+1)->GetFrame();
if(fNoMergerMode)
fCompFrame = (AgataCompositeFrame*) fTrigger->GetInputSharedFP()->GetFrame();
else
fCompFrame = (AgataCompositeFrame*) fTrigger->GetInputSharedFP(idet+1)->GetFrame();
fCompFrame->Scan();
TSHit = ((AgataKey *)fCompFrame->GetKey())->GetTimeStamp();
......@@ -177,6 +181,8 @@ void TB_AGATA_Builder::Process(Int_t idet)
nbCores = fCompFrame->GetNbSubFrame();
// cout<<"builder "<<TSHit<<" "<<nbCores<<endl;
Float_t MaxE[nbCores];
Float_t coreX[nbCores];
Float_t coreY[nbCores];
......@@ -479,12 +485,21 @@ void TB_AGATA_Tracking::Process(Int_t idet)
Log.GetProcessName() = gActualClass;
Log.SetProcessMethod("Process()");
fFrame = fTrigger->GetInputSharedFP(idet+1);
if(fNoMergerMode)
{
fFrame = fTrigger->GetInputSharedFP();
}
else
fFrame = fTrigger->GetInputSharedFP(idet+1);
fFrame->GetFrame()->Read();
// to get the data part of the frame
const GammaTrackedInterface *data = GetCstDataPointer<GammaTrackedInterface>(fFrame);
if(data == nullptr)
return;
nbTrack = data->GetNbGamma();
if(nbTrack>MaxTrackedGamma)
......@@ -497,6 +512,8 @@ void TB_AGATA_Tracking::Process(Int_t idet)
//! get time stamp
TSTrack = ((AgataKey *)fFrame->GetFrame()->GetKey())->GetTimeStamp();
// cout<<"tracking "<< TSTrack << " " << nbTrack << endl;
for (UShort_t i = 0u; i < nbTrack; i++)
{
const TrackedHit *gamma1 = data->GetGamma(i);
......
......@@ -51,6 +51,7 @@ protected:
protected:
TString fName = "";
TString fConfPath = "";
TString fOutputPath = "";
TString fTriggerName = "";
Bool_t fIsTriggered = false;
......@@ -62,6 +63,8 @@ protected:
TTree *fTree = nullptr;
bool fNoMergerMode = false;
public:
TB_Detector(TString name="", TString ADFKey="");
virtual ~TB_Detector();
......@@ -80,6 +83,9 @@ public:
void SetConfPath(TString confpath){fConfPath = confpath;}
TString GetConfPath(){return fConfPath;}
void SetOutputPath(TString path){fOutputPath = path;}
TString GetOutputPath(){return fOutputPath;}
void SetTriggerName(TString trig){fTriggerName = trig;}
TString GetTriggerName(){return fTriggerName;}
......@@ -88,6 +94,9 @@ public:
void SetTriggered(Bool_t ok){fIsTriggered = ok;}
Bool_t IsTriggered(){return fIsTriggered;}
void SetNoMergerMode(Bool_t mode){fNoMergerMode = mode;}
Bool_t GetNoMergerMode(){return fNoMergerMode;}
};
}
......
......@@ -22,6 +22,16 @@
#include "AGAPRO_TB_VAMOS.h"
#endif
#include "AGAPROConfig.h"
#include "ConfReader.h"
#include "AgataKeyFactory.h"
#include "MFMMergeFrame.h"
#include "TSystem.h"
#include "Analysis.hh"
using namespace AGAPRO;
TB_VAMOS::TB_VAMOS(TString name, TString ADFKey) : TB_Detector(name,ADFKey)
......@@ -31,12 +41,23 @@ TB_VAMOS::TB_VAMOS(TString name, TString ADFKey) : TB_Detector(name,ADFKey)
TB_VAMOS::~TB_VAMOS()
{
if(fAnalysis)
delete fAnalysis;
}
void TB_VAMOS::Init()
{
fFrame = fTrigger->AddUtility("data:ranc0",ConfAgent::theGlobalAgent());
fMFMMergeFrame = new MFMMergeFrame();
fMFMCommonFrame = new MFMCommonFrame();
fMFMEBYFrame = new MFMEbyedatFrame();
Int_t err = GetParameters(fConfPath.Data() + gActualClass + ".conf");
if(err)
{
Log << dolog;
return;
}
}
void TB_VAMOS::InitValues()
......@@ -53,8 +74,53 @@ void TB_VAMOS::InitTree()
Log.GetProcessName() = gActualClass;
Log.SetProcessMethod("InitfTree()");
if(fTree == nullptr)
if ( fTree == nullptr ){
std::cout << " Warning empty tree ! " << std::endl;
return;
}
TString ActionFile = fConfPath + fActionFileName;
if(gSystem->IsFileInIncludePath(ActionFile) == false){
Log << error << "ActionFile: "<< ActionFile << " not found" << dolog;
return;
}
// set managers
fLogManager = LogManager::getInstance();
fLogManager->SetLogFile(Form("%s/VamosAnalysis.log",fOutputPath.Data()));
//
fMOFile = fLogManager->GetFilePtr();
fParameters = new Parameters(16387);
fHistoManager = new HistoManager();
fAnalysis = new Analysis(fTree,fParameters,fHistoManager);
fAnalysis->SetOutTFile( new TFile(Form("%s/VAMOS_Spectra.root",fOutputPath.Data()),"recreate") );
fParameters->GetParametersFromActionFile((char *)ActionFile.Data());
if ( fBrhoRef > 0. && fBrhoRef < 2.4)
fAnalysis->SetBrhoWatcher(fBrhoRef);
else{
Log << error <<"WRONG Brho !! (Broh="<<fBrhoRef<<") " << dolog;
}
Int_t NumberOfParameters = fParameters->GetNParameters();
#ifdef TRIG_PAT
fParameters->Add(16384,"DAQ_PATTERN",13);
NumberOfParameters++;
#endif
fParameters->Add(16385,"MFM_TS",13);
NumberOfParameters++;
fParameters->Add(16386,"MFM_EVTNUM",13);
NumberOfParameters++;
fParameters->SetNParameters(NumberOfParameters);
// Data operation
fAnalysis->GetMap()->DataOp(fParameters);
fAnalysis->SetUpDetectors(fMode);
}
void TB_VAMOS::Process(Int_t idet)
......@@ -63,4 +129,99 @@ void TB_VAMOS::Process(Int_t idet)
Log.GetProcessName() = gActualClass;
Log.SetProcessMethod("Process()");
if(fAnalysis == nullptr)
return;
fAnalysis->Clear();
fFrame = fTrigger->GetInputSharedFP(idet+1);
fFrame->GetFrame()->Read();
// fMFMMergeFrame->SetAttributs(((ADF::RawFrame *)fFrame->GetFrame())->RawBuffer().Address());
fMFMCommonFrame->SetAttributs(((ADF::RawFrame *)fFrame->GetFrame())->RawBuffer().Address());
// cout<<fFrame->GetFrame()->GetLength()<<endl;
// cout<<((AgataKey*)fFrame->GetFrame()->GetKey())->GetTimeStamp()<<endl;
if(fMFMCommonFrame->GetFrameTypeAttribut() == MFM_EBY_EN_TS_FRAME_TYPE)
{
fMFMEBYFrame->SetAttributs(fMFMCommonFrame->GetPointHeader());
// extract new one from MFM
Int_t size = fMFMEBYFrame->GetNbItemsAttribut();
for (Int_t i = 0; i < size; i++) {
fMFMEBYFrame->EbyedatGetParameters(i, &fData[0], &fData[1]);
if(fData[0] == 0) {
Log << error << Form("LABEL Error : Label 0 found in the data LABEL: %d DATA : %d !",fData[0],fData[1]) << dolog ;
continue;
}
fAnalysis->Add(fData);
}
ULong64_t MFM_TS = 0;
MFM_TS = fMFMEBYFrame->GetTimeStamp();
// Store Time Stamp as parameter
fData[0] = 16385;
fData[1] = (UShort_t) (MFM_TS*1.e-5) ; // in mSec
fAnalysis->Add(fData);
fData[0] = 16386;
fData[1] = (UShort_t) (fMFMEBYFrame->GetEventNumber()) ;
fAnalysis->Add(fData);
fAnalysis->Treat();
fAnalysis->FillHistograms();
}
// fAnalysis->Clear();
// fAnalysis->Unpack(fMFMCommonFrame);
// fAnalysis->Treat();
}
UInt_t TB_VAMOS::GetParameters(const std::string& confFile, Bool_t doList)
{
Log.ClearMessage();
Log.GetProcessName() = gActualClass;
Log.SetProcessMethod(Form("GetParameters(confFile=%s,doList=%d)",confFile.data(),doList));
ConfReader conf;
conf.Add("BRho", "BRho", &fBrhoRef);
conf.Add("ActionFile", "Action file name", &fActionFileName);
conf.Add("VamosConfPath", "Vamos configuration files path", &fVamosConfPath);
if(doList) {conf.Show(gActualClass); return 0;}
int rv = conf.Read(gActualClass, confFile);
if(rv)
return rv; // Read() error
if(!conf.Seen("Brho")) {
Log << error << "Brho has not been defined" << dolog;
rv = 200;
}
if(!conf.Seen("ActionFile")) {
Log << error << "ActionFile has not been defined" << dolog;
rv = 201;
}
if(!conf.Seen("VamosConfPath")) {
Log << error << "VamosConfPath has not been defined" << dolog;
rv = 201;
}
setenv("ANALYSIS_AGATA",fVamosConfPath.data(),1);
TString ExpName = fActionFileName;
ExpName.ReplaceAll("ACTIONS_","");
ExpName.ReplaceAll(".CHC_PAR","");
setenv("EXPNAME",ExpName.Data(),1);
return rv;
}
......@@ -23,11 +23,47 @@
#include "AGAPRO_TB_Detector.h"
class Parameters;
class Map;
class HistoManager;
class Analysis;
class LogManager;
class MOFile;
class MFMMergeFrame;
class MFMCommonFrame;
class MFMEbyedatFrame;
namespace AGAPRO {
class TB_VAMOS : public TB_Detector
{
protected:
string fActionFileName="";
string fVamosConfPath="";
Parameters *fParameters = nullptr;
Map *M = nullptr;
//! Manage spectra built by the VAMOS LIB
HistoManager *fHistoManager = nullptr;
//! Do effectively the analysis
Analysis *fAnalysis = nullptr;
//! VAMOS Log system
LogManager *fLogManager = nullptr;
//!
MOFile *fMOFile = nullptr;
MFMMergeFrame *fMFMMergeFrame = nullptr;
MFMCommonFrame *fMFMCommonFrame = nullptr;
MFMEbyedatFrame *fMFMEBYFrame = nullptr;
//! Reference value for Brho
Float_t fBrhoRef = 1.0;
Int_t fMode = 2;
UShort_t fData[2];
public:
TB_VAMOS(TString name="", TString ADFKey="");
virtual ~TB_VAMOS();
......@@ -36,6 +72,8 @@ public:
void InitValues();
void InitTree();
void Process(Int_t idet);
virtual UInt_t GetParameters(const std::string& confFile, Bool_t doList=false);
};
}
......
......@@ -19,15 +19,22 @@
***************************************************************************/
/** \file TreeBuilder.cpp compiled in libADF.so */
#include "AGAPROConfig.h"
#ifndef AGAPRO_TreeBuilder
#include "AGAPRO_TreeBuilder.h"
#endif
#include "AGAPRO_TB_AGATA.h"
#ifdef HAS_MFM
#include "AGAPRO_TB_NEDA.h"
#include "AGAPRO_TB_DIAMANT.h"
#endif
#if defined(HAS_MFM) && defined(HAS_VAMOS)
#include "AGAPRO_TB_VAMOS.h"
#endif
#include "ConfReader.h"
......@@ -160,17 +167,22 @@ void TreeBuilder::process_stop (UInt_t *error_code)
Int_t TreeBuilder::SetInput()
{
fAgataComposite = dynamic_cast< AgataCompositeFrame *> ( fTrigger->GetInputFrame() );
fAgataComposite->Scan();
if(fNoMergerMode == false)
{
fAgataComposite = dynamic_cast< AgataCompositeFrame *> ( fTrigger->GetInputFrame() );
fAgataComposite->Scan();
timestamp = ((AgataKey*)fAgataComposite->GetKey())->GetTimeStamp();
}
timestamp = ((AgataKey*)fAgataComposite->GetKey())->GetTimeStamp();
// 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 ++)
{
......@@ -178,7 +190,10 @@ Int_t TreeBuilder::SetInput()
det->InitValues();
det->SetTriggered(fTrigger->IsIndividualFired(idet+1)); // +1 because the first value is for the global trigger
if(fNoMergerMode)
det->SetTriggered(fTrigger->IsIndividualFired(0));
else
det->SetTriggered(fTrigger->IsIndividualFired(idet+1)); // +1 because the first value is for the global trigger
}
return 0;
......@@ -210,14 +225,19 @@ UInt_t TreeBuilder::ProcessBlock(ADF::FrameBlock &inBlock)
}
else
{
bool has_triggered = false;
for(int idet=0 ; idet<fListOfDets.size() ; idet ++)
{
TB_Detector *det = fListOfDets[idet];
if(det->IsTriggered())
{
has_triggered = true;
det->Process(idet);
}
}
fTree->Fill();
if(has_triggered)
fTree->Fill();
}
nevs++;
......@@ -274,6 +294,8 @@ UInt_t TreeBuilder::GetParameters(const std::string& confFile, Bool_t doList)
&gActualClass);
conf.Add("SaveDataDir", "Save root file dir (SaveDir, NamePatern, TreeName)",
&fSaveDir, &fNamePatern, &fTreeName);
conf.Add("NoMergerMode", "If the EventMerger is not used (Tracked and Builder data will not be in coincidencd)",
&fNoMergerMode);
conf.Add("AddDetector", "Add a detector in the Tree (DetName, ADF key, Mode [-1: Must NOT be present, 0: Can be present, 1: Must be present]), accepted detectors: AGATA_BUILDER, AGATA_TRACKING, NEDA, DIAMANT, VAMOS",
&Detector, &ADFKey, &MandatoryMode);
......@@ -294,6 +316,11 @@ UInt_t TreeBuilder::GetParameters(const std::string& confFile, Bool_t doList)
for(int nn = 0; nn < times; nn++) {
conf.Restore(which, nn);
AddDetector(Detector,ADFKey,MandatoryMode);
if(fNoMergerMode && ((TString)ADFKey).Contains("anc"))
{
Log << error << " Ancillary detector set, but NoMergerMode is on..." << dolog;
}
}
}
......@@ -302,6 +329,12 @@ UInt_t TreeBuilder::GetParameters(const std::string& confFile, Bool_t doList)
rv = 201;
}
if(fNoMergerMode && fListOfDets.size()>1)
{
Log << error << " Only one detector type can be defined when NoMergerMode is on" << dolog;
rv = 202;
}
return rv;
}
......@@ -362,11 +395,11 @@ void TreeBuilder::AddDetector(TString Name, TString ADFKey, Int_t MandatoryMode)
#endif
}
else if(NameTest == "vamos")
{
#ifdef HAS_MFM
{
#if defined(HAS_MFM) && defined(HAS_VAMOS)
det = new TB_VAMOS(NameTest,ADFKey);
#else
Log << error << " MFM not found, VAMOS TreeBuilder ignored" << dolog;
Log << error << " Vamos lib and/or MFM lib not found, VAMOS TreeBuilder ignored" << dolog;
return;
#endif
}
......@@ -374,6 +407,8 @@ void TreeBuilder::AddDetector(TString Name, TString ADFKey, Int_t MandatoryMode)
if(det)
{
det->SetConfPath(GetConfPath());
det->SetOutputPath(fSaveDir);
det->SetNoMergerMode(fNoMergerMode);
fListOfDets.push_back(det);
}
else{
......@@ -384,10 +419,15 @@ void TreeBuilder::AddDetector(TString Name, TString ADFKey, Int_t MandatoryMode)
Int_t TreeBuilder::BuildTrigger()
{
fTriggerName = "event:data";
if(fNoMergerMode)
fTriggerName="";
else
fTriggerName = "event:data ";
for(int idet=0 ; idet<fListOfDets.size() ; idet++)
fTriggerName += " " + fListOfDets[idet]->GetTriggerName();
fTriggerName += fListOfDets[idet]->GetTriggerName() + " ";
fTriggerName.Remove(fTriggerName.Length()-1); // remove the last empty space
fTrigger = AgataFrameTrigger::Build("Event", fTriggerName.Data());
......
......@@ -63,7 +63,7 @@ protected:
string fNamePatern = "";
string fTreeName = "";
Int_t fCurrentFileNumber = 0;
bool fNoMergerMode = false;
TFile *fFile = nullptr;
TTree *fTree = nullptr;
......
......@@ -16,23 +16,30 @@ if (ROOT_FOUND)
endif()
if (MFM_FOUND)
INCLUDE_DIRECTORIES(${MFM_INCLUDE_DIR})
link_directories(${MFM_LIBRARY_DIR})
set(EXTRA_EXTERNAL_LIBRARIES ${EXTRA_EXTERNAL_LIBRARIES} ${MFM_LIBRARY})
endif()
if (VAMOS_FOUND)
INCLUDE_DIRECTORIES(${VAMOS_INCLUDE_DIR})
link_directories(${VAMOS_LIBRARY_DIR})
set(EXTRA_EXTERNAL_LIBRARIES ${EXTRA_EXTERNAL_LIBRARIES} Vamos GWVamos)
endif()
# headers / sources