Commit 7960fbad authored by Stezowski Olivier's avatar Stezowski Olivier
Browse files

almost last step before full synchronization of ADF with ADPP

git-svn-id: svn+ssh://anonsvn.in2p3.fr/agata/gammaware/trunk@1745 c3abf467-7ff2-0310-b516-c5fb849bdde0
parent 5c464dad
......@@ -105,12 +105,14 @@ void LoadWatchers()
gROOT->ProcessLine(tmp.Data());
tmp = Form(".L DefaultWatchers/DanteWatchers.C+%s",CompOpt);
gROOT->ProcessLine(tmp.Data());
tmp = Form(".L DefaultWatchers/LLaBr3Watchers.C+%s",CompOpt);
gROOT->ProcessLine(tmp.Data());
// ---> ANCILLARY_PART /////////////////////////
// ---> Additional libraries if required
// PRISMA lib ... setup properly if PRISMA_PREPROC is set
TString tmp = gSystem->Getenv("PRISMA_PREPROC");
if ( tmp != "" ) {
TString isprisma = gSystem->Getenv("PRISMA_PREPROC");
if ( isprisma != "" ) {
// Directory where are the includes of the ancillary part for compilation
tmp = "$PRISMA_PREPROC/src/lib_prisma/include/"; printf("- Add %s to the include path \n",tmp.Data());
tmp.Prepend(" .include ");
......@@ -131,8 +133,8 @@ void LoadWatchers()
// ---> END ANCILLARY_PART /////////////////////////
// do it after in case an ancillary part is added in the tree
// tmp = Form(".L MyWatchers/MyTree.C+%s",CompOpt);
tmp = Form(".L Macros/MyTree.C+%s",CompOpt);
tmp = Form(".L MyWatchers/MyTree.C+%s",CompOpt);
// tmp = Form(".L Macros/MyTree.C+%s",CompOpt);
gROOT->ProcessLine(tmp.Data());
......
......@@ -54,7 +54,7 @@ void DoTSRateCollector(TTask *top_task, TSRateCollector *collector)
*/
Bool_t SetupWatchers(const char *df_type, FrameDispatcher *fd, const char *ext = "")
{
Bool_t ok = false; TString DFtype = df_type;
Bool_t ok = false; TString DFtype = df_type; TString isprisma = gSystem->Getenv("PRISMA_PREPROC");
// ANY KIND OF DATA FLOW
// ADF ----------------------------------------------------------------
......@@ -64,7 +64,7 @@ Bool_t SetupWatchers(const char *df_type, FrameDispatcher *fd, const char *ext =
AgataFrameTrigger *trig =
new AgataFrameTrigger("ADF");
trig->Add(FactoryItem("Agata","agata",Version(1,0)),
FactoryItem("Agata","agata",Version(0,0)));
FactoryItem("Agata","agata",Version(0,0)));
trig->Universal(true);
fd->SetTrigger(trig);
......@@ -106,7 +106,7 @@ Bool_t SetupWatchers(const char *df_type, FrameDispatcher *fd, const char *ext =
// It defines triggers on crystal frames
AgataFrameTrigger *trig2 =
AgataFrameTrigger::Build("CCrystal", "data:ccrystal");
AgataFrameTrigger::Build("CCrystal", "data:ccrystal");
// main trigger for the Dispatcher, delete by fd
fd->SetTrigger(trig2);
......@@ -143,7 +143,7 @@ Bool_t SetupWatchers(const char *df_type, FrameDispatcher *fd, const char *ext =
// define WatcherClient for a specific trigger
// it defines a trigger on an ancilary frame
AgataFrameTrigger *trig =
AgataFrameTrigger::Build("RANC0", "data:ranc0");
AgataFrameTrigger::Build("RANC0", "data:ranc0");
fd->SetTrigger(trig);
// to get all the raw spectra for ancillaries
......@@ -232,11 +232,23 @@ Bool_t SetupWatchers(const char *df_type, FrameDispatcher *fd, const char *ext =
// set the main trigger to coincidences between ancillary et gammas
fd->SetTrigger(trig);
// specific to tracked frame
// apply doppler correction from PRISMA if configuand check it
if ( isprsma != "" ) {
DoPrismaDoppler *prisma_dop = fd->Add<DoPrismaDoppler>("DoDoppler","Set Doppler event by event");
prisma_dop->Configure("Conf/PRISMA/manager.conf","Conf/PRISMA/lutPRISMA_WEEK49.txt");
fd->Add<GlobalDC>(GetWN("CheckDoppler",ext),"Doppler as delivered by Prisma");
// add a wacther on raw data
DisplayPrisma *prisma_2 = fd->Add<DisplayPrisma>("DisplayPrima","Some usefull calibrated spectra for PRISMA ");
prisma_2->Configure("Conf/PRISMA/manager.conf","Conf/PRISMA/lutPRISMA_WEEK49.txt");
}
// specific to tracked frame
// gamma-gamma matrix
fd->Add<Coinc2D>(GetWN("GxG",ext),"Gamma Gamma coincidence");
// Any kind of Watcher on event:data:psa, data:ranc1 or
// Any kind of Watcher on event:data:psa, data:ranc1 or
fd->Add<TSCoinc>(GetWN("TSCoinc",ext),"TS distribution in events");
// watcher to keep rates
fd->Add<TSRate>(GetWN("TSRate",ext),"To get rate form consecutive TS value");
......@@ -252,6 +264,10 @@ Bool_t SetupWatchers(const char *df_type, FrameDispatcher *fd, const char *ext =
// rootmaster->Add<DoMyRawAncillaryTree>("RawAncTree","Branch on ancillary");
// rootmaster->Add<DoMyHitTree>("HitTree","Branch on hits");
// rootmaster->Add<DoMyTrackTree>("TrackTree","Branch on track");
if ( isprsma != "" ) {
MyPrismaTree *prisma_tree = rootmaster->Add<MyPrismaTree>("Prisma","Branch on track");
prisma_tree->Configure("Conf/PRISMA/manager.conf","Conf/PRISMA/lutPRISMA_WEEK49.txt");
}
ok = true;
}
......
......@@ -24,25 +24,20 @@
#include "AgataKeyFactory.h"
#endif
#include <sstream>
#include <iomanip>
// common to all agata keys
void ADF::AgataKey::Print(std::ostream &out) const
{
out << "[AgataKey"
<< " (" << GetVersion().GetMajor() << "," << GetVersion().GetMinor() << ")] "
<< std::dec
<< GetFrameLength()
<< " 0x"
<< std::hex
<< GetMessage()
<< " "
<< std::dec
<< GetEventNumber()
<< " "
<< GetTimeStamp()
<< " "
<< std::endl;
out << "[AgataKey"
<< " (" << GetVersion().GetMajor() << "," << GetVersion().GetMinor() << ")] "
<< std::dec << std::setw(4) << GetFrameLength()
<< " 0x" << std::hex << GetMessage()
<< " " << std::dec << std::setw(15) << GetEventNumber()
<< " " << std::setw(16) << GetTimeStamp();
//<< std::endl; // user should decide, like in Key::Print()
}
Bool_t ADF::AgataKey::Convert(const Key *akey)
{
......
......@@ -17,7 +17,7 @@
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
/** \file BasicAFC.cpp compiled in libADF.so */
#ifndef ADF_BasicAFC
......@@ -33,15 +33,16 @@
using namespace ADF;
BasicAFC::BasicAFC() :
NarvalConsumer(),
fEndOfFrames(aMByte,ConfAgent::kWrite),
fPath("./"),
fBaseForName("AFC_"),
fCurrentFile(0x0),
fCurrentFileNumber(0u),
fMaxSize(kMaxInt_t),
fVertex(0x0)
BasicAFC::BasicAFC(Int_t id) :
NarvalConsumer(),
fEndOfFrames(aMByte,ConfAgent::kWrite),
fPath("./"),
fBaseForName("AFC_"),
fCurrentFile(0x0),
fCurrentFileNumber(0u),
fMaxSize(kMaxInt_t),
fMyID(id),
fVertex(0x0)
{
// log system
Log.GetProcessName() = "BasicAFC";
......@@ -67,21 +68,25 @@ void BasicAFC::process_config (const Char_t *directory_path, UInt_t *error_code)
{
// first init narval stuff
NarvalInterface::process_config(directory_path,error_code);
if ( (*error_code) == 0u ) { // now init your stuff if required
if ( (*error_code) == 0u ) {
// now init your stuff if required
}
}
Bool_t BasicAFC::NewFile()
{
Log.SetProcessMethod("NewFile");
Bool_t ok = false;
// close if already open
if ( fCurrentFile )
if ( fCurrentFile ) {
::fclose(fCurrentFile);
fCurrentFile = 0x0;
std::cout << " -BasicAFP: the input file has just been closed " << fCurrentFileName << std::endl;
}
// open the file
std::string tmp = fPath;
if ( tmp.size() > 0 && !(tmp.at(tmp.size()-1) == '/') )
......@@ -89,31 +94,35 @@ Bool_t BasicAFC::NewFile()
std::ostringstream filename;
filename << tmp << fBaseForName
<< std::setfill('0') << std::setw(4) << fCurrentFileNumber++ << std::setfill(' ')
<< ".adf";
fCurrentFile = ::fopen(filename.str().data(),"wb");
<< std::setfill('0') << std::setw(4) << fCurrentFileNumber++ << std::setfill(' ')
<< ".adf";
fCurrentFileName = filename.str();
fCurrentFile = ::fopen(fCurrentFileName.c_str(),"wb");
if ( fCurrentFile != 0x0 ) {
Log << info << "A new output file has just been open "
<< fCurrentFileName << nline;
Log << info << "A new output file has just been open " << filename.str() << nline;
fEndOfFrames.SetFile(fCurrentFile,fMaxSize);
GetFrameIO().SetStatus(BaseFrameIO::kIdle);
size_t len = fCurrentFileName.length();
size_t lpt = fCurrentFileName.find_last_of('/');
fCurrentName = fCurrentFileName.substr(lpt+1, len-lpt-1);
fEndOfFrames.SetFile
(fCurrentFile,fMaxSize);
GetFrameIO().SetStatus
(BaseFrameIO::kIdle);
// add conf frame at the beginning of the file and a vertex frame.
GetFrameIO().RecordGlobalConfiguration();
ok = true;
}
else {
Log << warning << "Cannot open file "
<< filename.str() << nline;
Log << warning << "Cannot open file " << fCurrentFileName << nline;
GetFrameIO().SetStatus(BaseFrameIO::kFinished);
ok = false;
}
Log << dolog; return ok;
Log << dolog;
return ok;
}
UInt_t BasicAFC::ProcessBlock (ADF::FrameBlock &in)
......@@ -123,6 +132,7 @@ UInt_t BasicAFC::ProcessBlock (ADF::FrameBlock &in)
// attach the FrameBlocks
GetFrameIO().Attach(&in,0x0);
UInt_t nevtsIn = GetFrameIO().GetFramesWritten();
while ( 1 ) {
// fill the output block with the frames from the input block
while ( GetFrameIO().Notify() ) {
......@@ -135,13 +145,21 @@ UInt_t BasicAFC::ProcessBlock (ADF::FrameBlock &in)
if ( GetFrameIO().GetCurrentBlockIN()->IsEoB() ) // the input block is treated
break;
}
UInt_t nevtsOut = GetFrameIO().GetFramesWritten();
//
GetFrameIO().Detach(&in,0x0);
// send messages to the log if any
Log << dolog; return 0u;
if(fMyID >= 0) {
std::cout << std::setw(2) << fMyID;
std::cout << std::left << std::setw(24) << "-BasicAFC:" << std::right
<< " " << std::setw(5) << nevtsOut-nevtsIn
<< " evts (" << std::setw(8) << in.GetSize() << ")"
<< " Tot = " << std::setw(8) << nevtsOut
<< " " << fCurrentName << std::endl;
}
return 0u;
}
void BasicAFC::process_initialise (UInt_t *error_code)
{
......@@ -155,15 +173,11 @@ void BasicAFC::process_initialise (UInt_t *error_code)
GetFrameIO().Register(fVertex);
// read an input file to get the base filename and the path
std::string conffile =
// GetConfPath();
GetGlobalConfPath();
conffile += "BasicAFC.conf";
std::string conffile = GetConfPath() + "BasicAFC.conf";
std::ifstream filein(conffile.data());
if ( filein.is_open() == true ) {
std::string pathforfiles, basename;
UInt_t starting_number;
filein >> pathforfiles >> basename >> starting_number;
......@@ -172,7 +186,7 @@ void BasicAFC::process_initialise (UInt_t *error_code)
fPath = pathforfiles;
fBaseForName = basename;
fCurrentFileNumber = starting_number;
// GetFrameIO().GetConfAgent()->GetRunAgent()->SetSubRun(starting_number);
// GetFrameIO().GetConfAgent()->GetRunAgent()->SetSubRun(starting_number);
}
filein.close();
}
......@@ -180,11 +194,10 @@ void BasicAFC::process_initialise (UInt_t *error_code)
// open the first file
if ( !NewFile() )
*error_code = 1;
Log << dolog;
}
void BasicAFC::process_reset (UInt_t *error_code)
{
*error_code = 0;
......@@ -192,18 +205,18 @@ void BasicAFC::process_reset (UInt_t *error_code)
if ( fCurrentFile )
::fclose(fCurrentFile);
GetFrameIO().Print( Log() );
Log << dolog;
}
/*
void BasicAFC::process_unload (UInt_terror_code)
{
std::cout << "process_unload called with GetPID()" << GetPID() << std::endl;
*error_code = 0;
} */
void BasicAFC::process_unload (UInt_terror_code)
{
std::cout << "process_unload called with GetPID()" << GetPID() << std::endl;
*error_code = 0;
} */
......
......@@ -17,7 +17,7 @@
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
/** @file BasicAFC.h header file for BasicAFC.cpp */
#ifndef _BasicAFC
......@@ -34,7 +34,7 @@
//! basic consumer, it counts and dumps Frame in files
/*!
*/
*/
class BasicAFC : public ADF::NarvalConsumer
{
private:
......@@ -52,18 +52,25 @@ private:
UInt_t fCurrentFileNumber;
//! max size for a file (in bytes)
UInt_t fMaxSize;
//! id of the instance, used for printouts
Int_t fMyID;
// current file name
std::string fCurrentFileName;
std::string fCurrentName;
private:
ADF::AgataFrameTrigger *fVertex;
protected:
//! open a new file
Bool_t NewFile();
public:
BasicAFC();
BasicAFC(Int_t id = -1);
virtual ~BasicAFC();
void SetID(Int_t id) {fMyID = id;}
//! to init globals (static) from a directory
static void process_config (const Char_t *, UInt_t *) ;
......@@ -74,7 +81,7 @@ public:
virtual void process_reset (UInt_t *error_code);
virtual UInt_t ProcessBlock (ADF::FrameBlock &) ;
};
#endif
......@@ -17,7 +17,7 @@
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
/** \file BasicAFP.cpp compiled in libADF.so */
#ifndef ADF_BasicAFP
......@@ -30,24 +30,26 @@
using namespace ADF;
BasicAFP::BasicAFP():
NarvalProducer(),
fSourceOfFrames(aMByte,ConfAgent::kRead),
fPath("./"),
fBaseForName("AFP_"),
fCurrentFile(0x0),
fCurrentFileNumber(0u),
fMaxSize(kMaxInt_t),
fEndOfFrame("EndOfFrame")
{
Log.GetProcessName() = "BasicAFP"; GetFrameIO().SetName("BasicAFP");
BasicAFP::BasicAFP(Int_t id):
NarvalProducer(),
fSourceOfFrames(aMByte,ConfAgent::kRead),
fPath("./"),
fBaseForName("AFP_"),
fCurrentFile(0x0),
fCurrentFileNumber(0u),
fMaxSize(kMaxInt_t),
fMyID(id),
fEndOfFrame("EndOfFrame")
{
Log.GetProcessName() = "BasicAFP";
GetFrameIO().SetName("BasicAFP");
// to be sure unknown frames are written in the ouput
GetFrameIO().SetModel(ConfAgent::kSafe);
// to protect writings in the source of frames
fSourceOfFrames.SetModeIO(ConfAgent::kRead);
// the input datablock is owned by BasicAFP
GetFrameIO().Attach(&fSourceOfFrames,0x0);
GetFrameIO().Attach(&fSourceOfFrames,0x0);
}
BasicAFP::~BasicAFP()
......@@ -60,34 +62,40 @@ Bool_t BasicAFP::NewFile()
{
Bool_t ok = false;
if ( fCurrentFile )
if ( fCurrentFile ) {
::fclose(fCurrentFile);
fCurrentFile = 0x0;
std::cout << " -BasicAFP: the input file has just been closed " << fCurrentFileName << std::endl;
}
// open the first file to be ready to be run
std::string tmp = fPath;
if ( tmp.size() > 0 && !(tmp.at(tmp.size()-1) == '/') )
tmp += '/';
std::ostringstream filename;
filename << tmp << fBaseForName
<< std::setfill('0') << std::setw(4) << fCurrentFileNumber++ << std::setfill(' ')
<< ".adf";
fCurrentFile = ::fopen(filename.str().data(),"rb");
filename << tmp << fBaseForName
<< std::setfill('0') << std::setw(4) << fCurrentFileNumber++ << std::setfill(' ')
<< ".adf";
fCurrentFileName = filename.str();
fCurrentFile = ::fopen(fCurrentFileName.c_str(),"rb");
if ( fCurrentFile != 0x0 ) {
Log << "A new input file has just been open "
<< filename.str();
fSourceOfFrames.SetFile
(fCurrentFile,fMaxSize);
GetFrameIO().SetStatus
(BaseFrameIO::kIdle);
Log << " -BasicAFP: the input file has just been opened "
<< fCurrentFileName << nline;
fSourceOfFrames.SetFile(fCurrentFile,fMaxSize);
GetFrameIO().SetStatus(BaseFrameIO::kIdle);
size_t len = fCurrentFileName.length();
size_t lpt = fCurrentFileName.find_last_of('/');
fCurrentName = fCurrentFileName.substr(lpt+1, len-lpt-1);
ok = true;
}
else {
Log << "Cannot open file "
<< filename.str();
Log << "Could not open input file " << fCurrentFileName << nline;
GetFrameIO().SetStatus(BaseFrameIO::kFinished);
ok = false;
}
return ok;
......@@ -96,16 +104,20 @@ Bool_t BasicAFP::NewFile()
void BasicAFP::process_config (const Char_t *directory_path, UInt_t *error_code)
{
// first init narval and ADF stuff (if required)
NarvalInterface::process_config(directory_path,error_code);
if ( (*error_code) == 0u ) { // now init your stuff
NarvalInterface::process_config(directory_path, error_code);
if ( (*error_code) == 0u ) {
// now init your stuff
}
}
UInt_t BasicAFP::ProcessBlock(ADF::FrameBlock &out)
{
Log.ClearMessage(); Log.SetProcessMethod("process_block");
if( !fCurrentFile )
return 1u;
Log.ClearMessage(); Log.SetProcessMethod("process_block");
if ( GetFrameIO().GetStatus() == BaseFrameIO::kFinished ) {
// set a trigger to send end of frames (single shot) in case the producer is in finish mode and the user ask for an new frame
if ( fEndOfFrame.GetOutputFrame() == 0x0 ) {
......@@ -127,25 +139,35 @@ UInt_t BasicAFP::ProcessBlock(ADF::FrameBlock &out)
return 1u;
}
//std::cout << std::left << std::setw(74) << " -BasicAFP:" << std::right
// << fCurrentName << std::endl;
// attach the FrameBlock
GetFrameIO().Attach(0x0,&out);
// fill the output with successive frames read from the file until out is filled
while ( GetFrameIO().Notify() ) {
UInt_t nevtsIn = GetFrameIO().GetFramesRead();
while ( GetFrameIO().Notify() ) {
}
UInt_t nevtsOut = GetFrameIO().GetFramesRead();
if(fMyID >= 0) {
std::cout << std::setw(2) << fMyID;
std::cout << std::left << std::setw(24) << "-BasicAFP:" << std::right
<< " " << std::setw(5) << nevtsOut-nevtsIn
<< " evts (" << std::setw(8) << out.GetSize() << ")"
<< " Tot = " << std::setw(8) << nevtsOut
<< " " << fCurrentName << std::endl;
}
// interruption: means end of file or out is full
if ( GetFrameIO().GetCurrentBlockIN()->IsEoB() ) { // the file has been read, try to open the next one
if ( NewFile() == false )
GetFrameIO().SetStatus(BaseFrameIO::kFinished);
GetFrameIO().Detach(0x0,&out);
Log << dolog;
return 100;
}
// detach the output block
GetFrameIO().Detach(0x0,&out);
//
Log << dolog;
return 0u;
}
return 0;
}
void BasicAFP::process_initialise (UInt_t *error_code)
{
......@@ -153,15 +175,11 @@ void BasicAFP::process_initialise (UInt_t *error_code)
Log.ClearMessage(); Log.SetProcessMethod("process_initialise");
// read an input file to get the base filename and the path
std::string conffile
// = GetConfPath();
= GetGlobalConfPath();
conffile += "BasicAFP.conf";
std::string conffile = GetConfPath() + "BasicAFP.conf";
std::ifstream filein(conffile.data());
if ( filein.is_open() == true ) {
std::string pathforfiles, basename;
UInt_t starting_number;
......@@ -170,6 +188,7 @@ void BasicAFP::process_initialise (UInt_t *error_code)
fPath = pathforfiles;
fBaseForName = basename;
fCurrentFileNumber = starting_number;
std::cout << "BasicAFP::process_initialise " << pathforfiles << " " << basename << " " << starting_number << std::endl;
}
}
filein.close();
......@@ -186,20 +205,20 @@ void BasicAFP::process_reset (UInt_t *error_code)
{
*error_code = 0u;
Log.ClearMessage(); Log.SetProcessMethod("process_reset");
if ( fCurrentFile )
::fclose(fCurrentFile);
GetFrameIO().Print( Log() );
Log << dolog;
}
/*
void BasicAFP::process_unload (UInt_terror_code)
{
std::cout << "process_unload called with GetPID()" << GetPID() << std::endl;
*error_code = 0;
} */
void BasicAFP::process_unload (UInt_terror_code)