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

Commit 740f26de authored by dino's avatar dino
Browse files

Selection of events in PreprocessingFilter, PostPSAFilter and AncillaryFilter...

Selection of events in PreprocessingFilter, PostPSAFilter and AncillaryFilter based on timestamp values taken from a file, define by means of the keywork "TstampFile  filename tolerance"

git-svn-id: svn://gal-serv.lnl.infn.it/agata/trunk/narval_emulator@1140 170316e4-aea8-4b27-aad4-0380ec0519c9
parent 01433940
......@@ -58,6 +58,7 @@ ${ACTORS}/common/cycleServer.cpp
${ACTORS}/common/misc.cpp
${ACTORS}/common/mwdlib.cpp
${ACTORS}/common/adetParams.cpp
${ACTORS}/common/TstampFilter.cpp
${ACTORS}/producers/Crystal/CrystalProducer.cpp
${ACTORS}/producers/Crystal/CrystalProducerATCA.cpp
${ACTORS}/producers/Crystal/includeATCA/mezzanine.cpp
......@@ -91,9 +92,7 @@ ${ACTORS}/filters/Tracking/includeMGT/mgt_vectorlib.c
${ACTORS}/builders/EventBuilder.cpp
${ACTORS}/builders/EventQueue.cpp
)
IF(NOT WIN32)
SET_SOURCE_FILES_PROPERTIES(${actors_SRCS} PROPERTIES LANGUAGE CXX)
ENDIF()
SET_SOURCE_FILES_PROPERTIES(${actors_SRCS} PROPERTIES LANGUAGE CXX)
SET(adf_SRCS
${ADFDIR}/ADFCentralLog.cpp
......@@ -162,11 +161,7 @@ SET(femul_SRCS ${FEMDIR}/femul.cpp ${FEMDIR}/ChainOfActors.cpp ${adf_SRCS} ${a
#MESSAGE("LINK_DIRECTORIES: ${LINK_DIRECTORIES}")
#LINK_DIRECTORIES( ${LINK_DIRECTORIES})
IF(WIN32)
SET(LINK_LIBRARIES libboost_thread-mt.a ${ROOT_LIBRARIES})
ELSE()
SET(LINK_LIBRARIES ${BOOST_LIBRARIES} ${ROOT_LIBRARIES})
ENDIF()
#MESSAGE("LINK_LIBRARIES: ${LINK_LIBRARIES}")
ADD_EXECUTABLE(femul ${femul_SRCS})
......
......@@ -136,7 +136,7 @@ int nSIGINT = 0; // count number of SIGINT (CTRL_C)
bool stopSig = false; // used to check StopFile
bool killSig = false; // used to check KillFile
bool listKeys = false; // rudimentary help
bool listKeys = false; // rudimentary help on the keywords accepted by the various actors
time_t ttstart;
time_t ttpresent;
......
......@@ -874,6 +874,14 @@
RelativePath="..\common\sAppend.h"
>
</File>
<File
RelativePath="..\common\TstampFilter.cpp"
>
</File>
<File
RelativePath="..\common\TstampFilter.h"
>
</File>
</Filter>
<Filter
Name="builders"
......
......@@ -616,15 +616,13 @@ void EventBuilder::ListParameters()
{
printInfo("\nKEYWORDS ACCEPTED BY EventBuilder");
UInt_t errcode = 0xFFFFFFFF;
UInt_t errcode = KSEE;
GetParameters(&errcode);
}
void EventBuilder::GetParameters(UInt_t *error_code)
{
#define KPAR(s1,s2,s3) if(doList) printInfo(s1, s2, s3); else if( !found && stringEq(keyw, s1) ) { found = true;
#define KEND }
bool doList = *error_code == 0xFFFFFFFF;
bool doList = (*error_code == KSEE);
*error_code = 0;
string configFileName = GetConfPath() + fActualClass + ".conf";
......
#include "TstampFilter.h"
#include <iostream>
using namespace std;
TstampFilter::TstampFilter()
{
Reset();
}
TstampFilter::TstampFilter(std::string tstampFile, int tolerance)
{
Reset();
Initialize(tstampFile, tolerance);
}
TstampFilter::~TstampFilter()
{
if(fFromFile)
fclose(fTstampFILE);
}
void TstampFilter::Reset()
{
fTstampFile.clear();
fFromFile = false;
fTstampFILE = NULL;
fTimestamp = 0;
fTolerance = 0;
fCount = 0;
}
bool TstampFilter::Initialize(std::string tstampFile, int tolerance)
{
if(fTstampFILE)
fclose(fTstampFILE);
Reset();
if(!tstampFile.size())
return false;
fTstampFile = tstampFile;
//fTstampFile = GetConfPath() + fTstampFile;
if( (fTstampFILE = fopen(fTstampFile.c_str(),"r")) == NULL) {
cout << "Error opening " << fTstampFile << endl;
//*error_code = 133;
//Log << dolog;
return false;
}
cout << "Opened timestamp file " << fTstampFile << endl;
fTimestamp = 0x0FFFFFFFFFFFFFFFULL;
int nn = fscanf(fTstampFILE, "%lld", &fTimestamp);
if(nn != 1) {
cout << "Error reading " << fTstampFile << endl;
//*error_code = 134;
//Log << dolog;
return false;
}
cout << "First timestamp " << fTimestamp << endl;
fCount = 1;
fFromFile = true;
return true;
}
void TstampFilter::NextTstamp()
{
int nn = fscanf(fTstampFILE, "%lld", &fTimestamp);
if(nn != 1) {
cout << "Error reading " << fTstampFile << endl;
fTimestamp = 0xFFFFFFFFFFFFFFFFULL;
}
fCount++;
}
bool TstampFilter::CheckTstamp(ULong64_t timestamp)
{
if(fTimestamp == 0xFFFFFFFFFFFFFFFFULL)
return false;
while(true) {
if(fTimestamp <= timestamp) {
// value from file is in the past re present timestamp
ULong64_t tdiff = timestamp - fTimestamp;
if(tdiff <= fTolerance) {
NextTstamp();
return true;
}
NextTstamp(); // try with next value from file
}
else {
// value from file is in the future re present timestamp
ULong64_t tdiff = fTimestamp-timestamp;
if(tdiff <= fTolerance) {
NextTstamp();
return true;
}
break; // too much in the future; see later
}
}
return false;
}
#ifndef TSTAMPFILTER_H_INCLUDED
#define TSTAMPFILTER_H_INCLUDED
#include <memory.h>
#include <string>
typedef unsigned long long ULong64_t;
typedef unsigned int UInt_t;
typedef bool Bool_t;
class TstampFilter
{
public:
Bool_t fFromFile;
std::string fTstampFile;
FILE *fTstampFILE;
ULong64_t fTolerance;
ULong64_t fTimestamp;
UInt_t fCount;
TstampFilter();
TstampFilter(std::string tstampFile, int tolerance);
virtual ~TstampFilter();
void Reset();
bool Initialize(std::string tstampFile, int tolerance);
bool IsReady() {return fFromFile;}
bool CheckTstamp(ULong64_t timestamp);
void TstampFilter::NextTstamp();
};
#endif //TSTAMPFILTER_H_INCLUDED
......@@ -6,6 +6,11 @@
//#include <ctime>
//#include "commonDefs.h"
// macros to define keywords in the GetParameters() method of the various actors
#define KPAR(s1,s2,s3) if(doList) printInfo(s1, s2, s3); else if( !found && stringEq(keyw, s1) ) { found = true;
#define KEND }
#define KSEE 0xABCDEF01
void stringTrim(std::string &str);
void stringTrim(std::string &str, const std::string& cmt);
bool stringFirst(std::string &line, std::string &keyw, const std::string sep = " \t");
......
......@@ -29,7 +29,6 @@ fTrigger("data:ranc0")
{
fOdirPrefix.clear();
fPRISMALUTFile.clear();
fTstampFile.clear();
fVerbose = false;
fEnergyGain = 1.f; // gain of energy spectra
......@@ -71,12 +70,9 @@ fTrigger("data:ranc0")
maxConvChan = 0;
#endif
fTstampFILE = NULL;
fFromFile = false;
fEvnumber = 0;
fTimestamp = 0;
fTolerance = 0;
fCount = 0;
fTstampFilterFile.clear();
fTstampFilterTolerance = 0;
fTstampFilter = NULL;
stop_called = false;
}
......@@ -169,32 +165,17 @@ void AncillaryFilter::process_initialise ( UInt_t *error_code )
// state set to kIdle so that the data can be treated
fFrameIO.SetStatus(BaseFrameIO::kIdle);
// version-specific initialization
*error_code = AlgoSpecificInitialise();
if(fTstampFile.size()) {
fTstampFile = GetConfPath() + fTstampFile;
if( (fTstampFILE = fopen(fTstampFile.c_str(),"r")) == NULL) {
cout << "Error opening " << fTstampFile << endl;
*error_code = 133;
Log << dolog;
if(fTstampFilterFile.size()) {
fTstampFilter = new TstampFilter(GetConfPath()+fTstampFilterFile, fTstampFilterTolerance);
if( !fTstampFilter->IsReady() ) {
*error_code = 200 + rerr;
return;
}
cout << "Opened timestamp file " << fTstampFile << endl;
fTimestamp = 0x0FFFFFFFFFFFFFFFULL;
int nn = fscanf(fTstampFILE, "%d %lld", &fEvnumber, &fTimestamp);
if(nn != 2) {
cout << "Error reading " << fTstampFile << endl;
*error_code = 134;
Log << dolog;
return;
}
cout << "First evnumber " << fEvnumber << endl;
cout << "First timestamp " << fTimestamp << endl;
fCount = 1;
fFromFile = true;
}
// version-specific initialization
*error_code = AlgoSpecificInitialise();
cServer.SetCommandFile(GetConfPath() + gMotherClass + ".live");
#ifdef ANF_MULTIHIST
cServer.SetHistGroup(&hGroup);
......@@ -216,16 +197,13 @@ void AncillaryFilter::ListParameters()
{
printInfo("\nKEYWORDS ACCEPTED BY AncillaryFilter");
UInt_t errcode = 0xFFFFFFFF;
UInt_t errcode = KSEE;
GetParameters(&errcode);
}
void AncillaryFilter::GetParameters(UInt_t *error_code)
{
#define KPAR(s1,s2,s3) if(doList) printInfo(s1, s2, s3); else if( !found && stringEq(keyw, s1) ) { found = true;
#define KEND }
bool doList = *error_code == 0xFFFFFFFF;
bool doList = (*error_code == KSEE);
*error_code = 0;
string configFileName = GetConfPath() + gMotherClass + ".conf";
......@@ -292,9 +270,9 @@ void AncillaryFilter::GetParameters(UInt_t *error_code)
ok = data.size() > 0;
string value1, value2;
stringSplit(data, value1, value2);
fTstampFile = value1;
fTstampFilterFile = value1;
if(value2.size())
fTolerance = atoi(value2.c_str());
fTstampFilterTolerance = atoi(value2.c_str());
KEND;
KPAR("DanteChan", "%d %d %d", "T X Y channels of DANTE data");
......@@ -588,9 +566,10 @@ UInt_t AncillaryFilter::ProcessBlock (ADF::FrameBlock &inBlock, ADF::FrameBlock
// cout << "# " << evnumber << " " << timestamp << endl;
//}
if(fFromFile) {
if(!CheckTstamp())
if(fTstampFilter) {
if(!fTstampFilter->CheckTstamp(timestamp)) {
continue;
}
}
if( (theStatus = Process()) ) { // process the input buffer
......@@ -769,45 +748,6 @@ Int_t AncillaryFilter::SetOutput()
}
bool AncillaryFilter::CheckTstamp()
{
if(fTimestamp == 0xFFFFFFFFFFFFFFFFULL)
return false;
bool again = true;
while(again) {
if(fTimestamp <= timestamp) {
// value from file is in the past re present timestamp
ULong64_t tdiff = timestamp - fTimestamp;
if(tdiff <= fTolerance) {
NextTstamp();
return true;
}
NextTstamp(); // try with next value from file
}
else {
// value from file is in the future re present timestamp
ULong64_t tdiff = fTimestamp-timestamp;
if(tdiff <= fTolerance) {
NextTstamp();
return true;
}
break; // too much in the future; see later
}
}
return false;
}
void AncillaryFilter::NextTstamp()
{
int nn = fscanf(fTstampFILE, "%d %lld", &fEvnumber, &fTimestamp);
if(nn != 2) {
cout << "Error reading " << fTstampFile << endl;
fTimestamp = 0xFFFFFFFFFFFFFFFFULL;
}
fCount++;
}
void AncillaryFilter::process_reset ( UInt_t *error_code )
{
*error_code = 0;
......
......@@ -18,6 +18,7 @@
# include "MultiHist.h"
#endif
#include "cycleServer.h"
#include "TstampFilter.h"
#include <ctime>
......@@ -72,13 +73,9 @@ protected:
bool fWriteRootTree; // enable writing the root tree
Bool_t fFromFile;
std::string fTstampFile;
FILE *fTstampFILE;
ULong64_t fTolerance;
ULong64_t fTimestamp;
UInt_t fEvnumber;
UInt_t fCount;
std::string fTstampFilterFile;
UInt_t fTstampFilterTolerance;
TstampFilter *fTstampFilter;
Bool_t stop_called;
......@@ -147,8 +144,6 @@ public:
protected:
bool Decodesetup(bool verbose=false);
bool CheckTstamp();
void NextTstamp();
protected:
void GetParameters(UInt_t *error_code);
......
......@@ -1010,16 +1010,13 @@ void GlobalFilter::ListParameters()
{
printInfo("\nKEYWORDS ACCEPTED BY GlobalFilter");
UInt_t errcode = 0xFFFFFFFF;
UInt_t errcode = KSEE;
GetParameters(&errcode);
}
void GlobalFilter::GetParameters(UInt_t *error_code)
{
#define KPAR(s1,s2,s3) if(doList) printInfo(s1, s2, s3); else if( !found && stringEq(keyw, s1) ) { found = true;
#define KEND }
bool doList = *error_code == 0xFFFFFFFF;
bool doList = (*error_code == KSEE);
*error_code = 0;
string configFileName = GetConfPath() + gMotherClass + ".conf";
......
......@@ -246,16 +246,13 @@ void PSAFilter::ListParameters()
{
printInfo("\nKEYWORDS ACCEPTED BY PSAFilter");
UInt_t errcode = 0xFFFFFFFF;
UInt_t errcode = KSEE;
GetParameters(&errcode);
}
void PSAFilter::GetParameters(UInt_t *error_code)
{
#define KPAR(s1,s2,s3) if(doList) printInfo(s1, s2, s3); else if( !found && stringEq(keyw, s1) ) { found = true;
#define KEND }
bool doList = *error_code == 0xFFFFFFFF;
bool doList = (*error_code == KSEE);
*error_code = 0;
string configFileName = GetConfPath() + gMotherClass + ".conf";
......
......@@ -76,6 +76,10 @@ PostPSAFilter::PostPSAFilter() :
sTstampDiff = NULL;
tStampOld = 0;
fTstampFilterFile.clear();
fTstampFilterTolerance = 0;
fTstampFilter = NULL;
fUseMultiHist = true;
#ifdef PSA_MULTIHIST
PostSpecEner = NULL; PostMatrXYZ = NULL; PostMatrRZE = NULL;
......@@ -213,6 +217,14 @@ void PostPSAFilter::process_initialise (UInt_t *error_code)
sTstampDiff = new sAppend<UInt_t>(fOdirPrefix+"PSA__0-2048-UI__tstdiff.bdat", 2048);
}
if(fTstampFilterFile.size()) {
fTstampFilter = new TstampFilter(GetConfPath()+fTstampFilterFile, fTstampFilterTolerance);
if( !fTstampFilter->IsReady() ) {
*error_code = 200 + rerr;
return;
}
}
#ifdef PPS_MULTIHIST
if(fUseMultiHist) {
PostSpecEner = new MultiHist<unsigned int>(4, 40, specLenE);
......@@ -245,16 +257,13 @@ void PostPSAFilter::ListParameters()
{
printInfo("\nKEYWORDS ACCEPTED BY PostPSAFilter");
UInt_t errcode = 0xFFFFFFFF;
UInt_t errcode = KSEE;
GetParameters(&errcode);
}
void PostPSAFilter::GetParameters(UInt_t *error_code)
{
#define KPAR(s1,s2,s3) if(doList) printInfo(s1, s2, s3); else if( !found && stringEq(keyw, s1) ) { found = true;
#define KEND }
bool doList = *error_code == 0xFFFFFFFF;
bool doList = (*error_code == KSEE);
*error_code = 0;
string configFileName = GetConfPath() + gMotherClass + ".conf";
......@@ -299,6 +308,15 @@ void PostPSAFilter::GetParameters(UInt_t *error_code)
ok = true;
KEND;
KPAR("TstampFile", "%s %d", "File_with_timestams_to_selct Width_of_selection");
ok = data.size() > 0;
string value1, value2;
stringSplit(data, value1, value2);
fTstampFilterFile = value1;
if(value2.size())
fTstampFilterTolerance = atoi(value2.c_str());
KEND;
KPAR("CoreEnergyGate", "%f %f", "acceptance window on core energy (keV)");
ok = 2 == sscanf(data.c_str(), "%f %f", &fCoreEnerMin, &fCoreEnerMax);
KEND;
......@@ -429,6 +447,13 @@ UInt_t PostPSAFilter::ProcessBlock(ADF::FrameBlock &inBlock, ADF::FrameBlock &ou
break;
}
if(fTstampFilter) {
if(!fTstampFilter->CheckTstamp(timestamp)) {
crystal_status = 1;
continue;
}
}
// process the input buffer
if( Process() ) {
error_code = 2;
......
......@@ -20,6 +20,7 @@
#include "cycleServer.h"
#include "sAppend.h"
#include "adetParams.h"
#include "TstampFilter.h"
#include <ctime>
......@@ -40,6 +41,10 @@ protected:
UInt_t evnumber;
ULong64_t timestamp;
std::string fTstampFilterFile;
UInt_t fTstampFilterTolerance;
TstampFilter *fTstampFilter;
UShort_t crystal_id;
UShort_t crystal_status;
Float_t CoreE[2];
......
......@@ -78,6 +78,10 @@ PreprocessingFilter::PreprocessingFilter() :
timestamp = timestampOld = 0;
fTstampFilterFile.clear();
fTstampFilterTolerance = 0;
fTstampFilter = NULL;
//fBlockIn.SetModeIO(ConfAgent::kRead);
//fBlockOut.SetModeIO(ConfAgent::kWrite);
}
......@@ -174,6 +178,14 @@ void PreprocessingFilter::process_initialise ( UInt_t *error_code )
fTracesCC[nn] = new Float_t [defTraceLengthRaw];
}
if(fTstampFilterFile.size()) {
fTstampFilter = new TstampFilter(GetConfPath()+fTstampFilterFile, fTstampFilterTolerance);
if( !fTstampFilter->IsReady() ) {
*error_code = 200 + rerr;
return;
}
}
// version-specific initialization
*error_code = AlgoSpecificInitialise();
......@@ -189,16 +201,13 @@ void PreprocessingFilter::ListParameters()
{
printInfo("\nKEYWORDS ACCEPTED BY PreprocessingFilter");
UInt_t errcode = 0xFFFFFFFF;
UInt_t errcode = KSEE;
GetParameters(&errcode);
}
void PreprocessingFilter::GetParameters(UInt_t *error_code)
{
#define KPAR(s1,s2,s3) if(doList) printInfo(s1, s2, s3); else if( !found && stringEq(keyw, s1) ) { found = true;
#define KEND }
bool doList = *error_code == 0xFFFFFFFF;
bool doList = (*error_code == KSEE);
*error_code = 0;
string configFileName = GetConfPath() + gMotherClass + ".conf";
......@@ -255,6 +264,15 @@ void PreprocessingFilter::GetParameters(UInt_t *error_code)
ok = 1 == sscanf(data.c_str(), "%d", &fWriteNumTraces);
KEND;
KPAR("TstampFile", "%s %d", "File_with_timestams_to_selct Width_of_selection");
ok = data.size() > 0;
string value1, value2;
stringSplit(data, value1, value2);
fTstampFilterFile = value1;
if(value2.size())
fTstampFilterTolerance = atoi(value2.c_str());
KEND;
KPAR("CoreEnergyGate", "%f %f", "acceptance window on core energy (keV)");
ok = 2 == sscanf(data.c_str(), "%f %f", &fCoreEnerMin, &fCoreEnerMax);
KEND;
......@@ -377,6 +395,13 @@ UInt_t PreprocessingFilter::ProcessBlock (ADF::FrameBlock &inBlock, ADF::FrameBl
break;
}
if(fTstampFilter) {
if(!fTstampFilter->CheckTstamp(timestamp)) {
crystal_status = 1;
continue;
}
}
if( Process() ) { // process the input buffer
error_code = 2;
LOCK_COUT;
......@@ -405,6 +430,7 @@ UInt_t PreprocessingFilter::ProcessBlock (ADF::FrameBlock &inBlock, ADF::FrameBl