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

Commit e894a5a0 authored by dino's avatar dino
Browse files

Changes in Misc.cpp and ConfReader to manage "" or '' delimited strings with...

Changes in Misc.cpp and ConfReader to manage "" or '' delimited strings with embedded spaces. Removed keyword BuilderType in EventBuilder; added keyword TstampWindow

git-svn-id: svn://gal-serv.lnl.infn.it/agata/trunk/narval_emulator@1193 170316e4-aea8-4b27-aad4-0380ec0519c9
parent bf286de5
......@@ -128,7 +128,7 @@ unsigned int library_timeout = 0;
#include "CentralLog.h"
#include "LogCollector.h"
int adfVerbose = 1; // 0=LogMessage::kError 1=LogMessage::kWarning 3=LogMessage::kInfo
int adfVerbose = 0; // 0=LogMessage::kError 1=LogMessage::kWarning 3=LogMessage::kInfo
std::string topologyFile;
std::string confPrefix("Conf/");
......@@ -770,7 +770,7 @@ void topologyPrint(int nchains)
// Call GetParameters(doList=true) for the relevant classes to get the list of accepted keys.
void listKeysAndExit()
{
// get rid of the adf messages
// get rid of adf messages
CentralLog::theCentralLog()->GetCurrentLogCollector()->SetLevelFiltering(LogMessage::kError, (unsigned short)(0));
// The first object is not deleted because, when this function is called at the very start of the program,
......@@ -778,43 +778,43 @@ void listKeysAndExit()
// Apparently AgataConfAgent::gTheGlobalAgent is not reset to NULL by the destructor
AncillaryProducerTCP *pa1 = new AncillaryProducerTCP;
pa1->GetParameters(true);
pa1->GetParameters("", true);
//delete pa1;
AncillaryFilter *pa2 = new AncillaryFilter;
pa2->GetParameters(true);
pa2->GetParameters("", true);
delete pa2;
CrystalProducer *pp1 = new CrystalProducer;
pp1->GetParameters(true);
pp1->GetParameters("", true);
delete pp1;
PreprocessingFilter *pf1 = new PreprocessingFilterPSA;
pf1->GetParameters(true);
pf1->GetParameters("", true);
delete pf1;
PSAFilter *pf2 = new PSAFilterGridSearch;
pf2->GetParameters(true);
pf2->GetParameters("", true);
delete pf2;
// pf2 = new PSAFilterFips;
//pf2->GetParameters(true);
//pf2->GetParameters("", true);
//delete pf2;
PostPSAFilter *pf3 = new PostPSAFilter;
pf3->GetParameters(true);
pf3->GetParameters("", true);
delete pf3;
EventBuilder *pe1 = new EventBuilder("EventBuilder");
pe1->GetParameters(true);
pe1->GetParameters("", true);
delete pe1;
GlobalFilter *pf4 = new GlobalFilter;
pf4->GetParameters(true);
pf4->GetParameters("", true);
delete pf4;
TrackingFilter *pf5 = new TrackingFilter;
pf5->GetParameters(true);
pf5->GetParameters("", true);
delete pf5;
exit(EXIT_SUCCESS);
......
......@@ -570,7 +570,9 @@ void EventBuilder::process_initialise (UInt_t *error_code)
{
*error_code = 0;
*error_code = GetParameters();
useEventNumber = false; // to use the TimeStamp variant
*error_code = GetParameters(GetConfPath() + fActualClass + ".conf"); // fActual to distinguish Builder/Merger/...
if(*error_code)
return;
......@@ -662,60 +664,65 @@ bool EventBuilder::InitBuilder()
return true;
}
UInt_t EventBuilder::GetParameters(Bool_t doList)
UInt_t EventBuilder::GetParameters(const std::string& confFile, Bool_t doList)
{
string bType; int btV1(0), btV2(0);
//string bType; int btV1(0), btV2(0);
string inpKey;
UInt_t ind1(0); int val1(0);
UInt_t ind2(0);
//UInt_t ind2(0);
ConfReader conf;
conf.Add("ActualClass", "name of daughter class", &gActualClass);
conf.Add("SaveDataDir", "where to write data and spectra", &fOdirPrefix);
conf.Add("BuilderType", "builder type(TimeStamp | EventNumber) coincidence_window start_from(default = 0)", &bType, &btV1, &btV2);
//conf.Add("BuilderType", "builder type(TimeStamp | EventNumber) coincidence_window start_from(default = 0)", &bType, &btV1, &btV2);
conf.Add("TstampWindow", "coincidence window 'width' or 'from to' (timestamp units)", &sumbusL, &sumbusR);
conf.Add("KeyIn", "symbolic_name (e.g. data:psa)", &inpKey);
conf.Add("KeyOut", "symbolic_name (e.g. event:data:psa). 'None' to not have the surrounding frame", &sKeyOut);
conf.Add("MinFold", "minimum number of detectors for valid events", &minFold);
conf.Add("TimestampCorrect", "Queue Value", &ind1, &val1);
conf.Add("TimestampFixBug24", "Queue", &ind2);
conf.Add("TstampCorrect", "Queue Value", &ind1, &val1);
//conf.Add("TstampFixBug24", "Queue", &ind2);
conf.Add("Details", "bit1=tstamp_snapshot bit2=tstamp_diff for all input queues, bit3=TAC for all pairs", &fDetails);
conf.Add("NoMultiHist", "exclude flat binary spectra", &fUseMultiHist);
conf.Add("Verbose", "verbosity of printouts", &fVerbose);
conf.Info("Keyword 'BuilderType' has been removed because the 'EventNumber' variant has never been fully");
conf.Info("implemented (due to the complications of managing the 24-bit value provided by the hardware).");
conf.Info("The coincidence window is now defined by the new keyword");
conf.Info("'TstampWindow width' for EventBuilder behaviour or");
conf.Info("'TstampWindow from to' for EventMerger behaviour");
// refine behaviour
//conf.SetCall("SaveDataDir", 0, forceTailSlash);
conf.Require("BuilderType", 2);
conf.Default("Details", 0, "1");
conf.Default("TstampWindow", 1, "0");
conf.Default("Details", 0, "1");
if(doList) {conf.Show(gMotherClass); return 0;}
// decode the command file
string className = "EventBuilder";
if(doList) {conf.Show(className); return 0;}
string confFile = GetConfPath() + fActualClass + ".conf";
int rv = conf.Read(className, confFile);
int rv = conf.Read(gMotherClass, confFile);
if(rv)
return rv; // Read() error
// check parameters
if(conf.Seen("BuilderType")) {
if( stringEq(bType, "TimeStamp") ) {
useEventNumber = false;
if(conf.Count("BuilderType") == 2) {
sumbusL = 0;
sumbusR = btV1;
}
if(conf.Count("BuilderType") == 3) {
sumbusL = btV1;
sumbusR = btV2;
}
}
else if( stringEq(bType, "EventNumber") ) {
useEventNumber = true;
}
else {
cout << "BuilderType unknown " << bType << endl;
rv = 200;;
}
}
//if(conf.Seen("BuilderType")) {
// if( stringEq(bType, "TimeStamp") ) {
// useEventNumber = false;
// if(conf.Count("BuilderType") == 2) {
// sumbusL = 0;
// sumbusR = btV1;
// }
// if(conf.Count("BuilderType") == 3) {
// sumbusL = btV1;
// sumbusR = btV2;
// }
// }
// else if( stringEq(bType, "EventNumber") ) {
// useEventNumber = true;
// }
// else {
// cout << "BuilderType unknown " << bType << endl;
// rv = 200;;
// }
//}
if(conf.Seen("KeyIn")) {
int which = conf.Find("KeyIn");
int times = conf.Times(which);
......@@ -724,7 +731,7 @@ UInt_t EventBuilder::GetParameters(Bool_t doList)
sKeyIn.push_back(inpKey);
}
}
if(conf.Seen("TimestampCorrect")) {
if(conf.Seen("TstampCorrect")) {
int which = conf.Find("TimestampCorrect");
int times = conf.Times(which);
for(int nn = 0; nn < times; nn++) {
......@@ -733,25 +740,25 @@ UInt_t EventBuilder::GetParameters(Bool_t doList)
vCorrection[ind1] = val1;
}
else {
cout << "TimestampCorrect wrong queue " << val1 << endl;
rv = 200;
}
}
}
if(conf.Seen("TimestampFixBug24")) {
int which = conf.Find("TimestampFixBug24");
int times = conf.Times(which);
for(int nn = 0; nn < times; nn++) {
conf.Restore(which, nn);
if(ind2 >=0 && ind2< nQueues) {
vCorrection[ind1] = 0x7FFFFFFF;
}
else {
cout << "TimestampFixBug24 wrong queue " << val1 << endl;
cout << "TstampCorrect wrong queue " << val1 << endl;
rv = 200;
}
}
}
//if(conf.Seen("TstampFixBug24")) {
// int which = conf.Find("TimestampFixBug24");
// int times = conf.Times(which);
// for(int nn = 0; nn < times; nn++) {
// conf.Restore(which, nn);
// if(ind2 >=0 && ind2< nQueues) {
// vCorrection[ind1] = 0x7FFFFFFF;
// }
// else {
// cout << "TstampFixBug24 wrong queue " << val1 << endl;
// rv = 200;
// }
// }
//}
return rv;
}
......
......@@ -46,7 +46,7 @@ public:
static std::string gMotherClass; // Static string containing the name of the base class
static std::string gActualClass; // Static string to choose daughter class at run time
static std::string gConfPath; // set by the static method process_config
static std::string gConfPath; // set by the static method process_config; used to distinguish EventBuilder from EventMerger
std::string fActualClass;
std::string fConfPath;
......@@ -181,7 +181,7 @@ private:
bool InitKeys(unsigned int nv);
public:
UInt_t GetParameters(Bool_t doList=false);
UInt_t GetParameters(const std::string& confFile, Bool_t doList=false);
protected:
virtual Int_t AlgoInitialise() {return 0;}
......
......@@ -52,6 +52,12 @@ void ConfReader::Show(const std::string& className) {
cout << left << setw(ltype) << stype << right << " ";
cout << vcom[nn]->Help << endl;
}
if(infoLines.size()) {
cout << "##"<< endl;
for(size_t nn = 0; nn < infoLines.size(); nn++)
cout << "# " << infoLines[nn] << endl;
cout << "##"<< endl;
}
}
int ConfReader::Read(const std::string& className, const std::string& confFile, bool verbose)
......@@ -74,8 +80,8 @@ int ConfReader::Read(const std::string& className, const std::string& confFile,
int which = Find(keyw);
if(which < 0) {
cout << " ==========> UNKNOWN KEYWORD <==========" << endl;
Show(className);
cout << " --> unknown keyword" << endl;
return 110;
}
......@@ -87,7 +93,7 @@ int ConfReader::Read(const std::string& className, const std::string& confFile,
Com* pcom = vcom[which];
if(pcom->keyCount > 0) {
if(!pcom->Backup()) {
cout << " --> backup error" << endl;
cout << " ====> ConfReader:: internal error in Backup()" << endl;
return 140;
}
pcom->Rewind();
......@@ -107,7 +113,7 @@ int ConfReader::Read(const std::string& className, const std::string& confFile,
for(size_t nn = 0; nn < vcom.size(); nn++) {
if(vcom[nn]->keyCount > 1) {
if( !vcom[nn]->Backup() ) {
cout << " --> backup error" << endl;
cout << " ====> ConfReader:: internal error in Backup()" << endl;
return 140;
}
}
......
......@@ -99,6 +99,7 @@ class ConfReader
};
std::vector<Com*> vcom;
std::vector<std::string> infoLines;
int defaultRequired;
bool smartDefaults; // set defaults for single-bool and single-string parameters la femul
//int GetData( std::string data, Com* pcom, bool verbose);
......@@ -108,6 +109,10 @@ public:
// ConfReader::Add defined with up to 8 parameters ==> should be done with variadic templates in C++11
void Info(const std::string & info) {
infoLines.push_back(info);
}
int Add(std::string keyw, std::string help) {
Com* cc = new Com(keyw, help);
cc->Required = defaultRequired;
......
......@@ -95,7 +95,7 @@ unsigned int cycleServer::Prompt(int id, unsigned int nevs, unsigned int bsize,
unsigned int irate = GetRate();
cout << left << setw(24) << myName << right
<< " " << setw(5) << nevs
<< " " << setw(6) << nevs
<< " evts (" << setw(8) << bsize << ")"
<< " Tot = " << setw(8) << GetCounts()
<< " " << setw(5) << irate << "/s";
......
......@@ -107,6 +107,25 @@ bool stringSplit(std::string &line, std::string &keyw, std::string &data, const
stringTrim(line, "#");
if(line.size() == 0)
return false;
const char cc[2] = {'\'', '"'}; // if grouped as '' or ""
for(int nn = 0; nn < 2; nn++) {
if(line[0] == cc[nn]) {
size_t npos2 = line.find_first_of(cc[nn], 1);
if(npos2 != string::npos) {
keyw = line.substr(1, npos2-1);
data = line.substr(npos2+1);
}
else {
keyw = line.substr(1); // grab all ??
data = "";
}
stringTrim(keyw);
stringTrim(data);
return true;
}
}
size_t npos1 = line.find_first_not_of(sep, 0);
size_t npos2 = line.find_first_of(sep, npos1);
keyw = line.substr(npos1, npos2);
......
......@@ -138,7 +138,7 @@ void AncillaryFilter::process_initialise ( UInt_t *error_code )
Log.SetProcessMethod("process_initialise");
Log.SetPID ( GetPID() );
*error_code = GetParameters();
*error_code = GetParameters(GetConfPath() + gMotherClass + ".conf");
if(*error_code) {
Log << dolog;
return;
......@@ -197,7 +197,7 @@ void AncillaryFilter::process_initialise ( UInt_t *error_code )
Log << dolog;
}
UInt_t AncillaryFilter::GetParameters(Bool_t doList)
UInt_t AncillaryFilter::GetParameters(const std::string& confFile, Bool_t doList)
{
ConfReader conf;
conf.Add("ActualClass", "name of daughter class", &gActualClass);
......@@ -224,11 +224,9 @@ UInt_t AncillaryFilter::GetParameters(Bool_t doList)
//conf.Default("NoMultiHist", 0, "0");
//conf.Default("Verbose", 0, "1");
// read parameters
string className = "AncillaryFilter";
if(doList) {conf.Show(className); return 0;}
string confFile = GetConfPath() + gMotherClass + ".conf";
int rv = conf.Read(className, confFile);
if(doList) {conf.Show(gMotherClass); return 0;}
int rv = conf.Read(gMotherClass, confFile);
if(rv)
return rv; // Read() error
......
......@@ -144,7 +144,7 @@ protected:
bool Decodesetup(bool verbose=false);
public:
UInt_t GetParameters(Bool_t doList=false);
UInt_t GetParameters(const std::string& confFile, Bool_t doList=false);
protected:
virtual Int_t AlgoInitialise() {return 0;}
......
......@@ -77,7 +77,7 @@ void AncillaryFilterATCA::process_initialise ( UInt_t *error_code )
Log.SetProcessMethod("process_initialise");
Log.SetPID ( GetPID() );
*error_code = GetParameters();
*error_code = GetParameters(GetConfPath() + gMotherClass + ".conf"); // ??? or gActualClass
if(*error_code) {
Log << dolog;
return;
......
......@@ -320,7 +320,7 @@ void GlobalFilter::process_initialise (UInt_t *error_code)
Log.SetProcessMethod("process_initialise");
Log.SetPID(GetPID());
*error_code = GetParameters();
*error_code = GetParameters(GetConfPath() + gMotherClass + ".conf");
if(*error_code) {
Log << dolog;
return;
......@@ -1149,7 +1149,7 @@ int GlobalFilter::RemoveInvalidCrystals()
return 0;
}
UInt_t GlobalFilter::GetParameters(Bool_t doList)
UInt_t GlobalFilter::GetParameters(const std::string& confFile, Bool_t doList)
{
int rGeID(0), rAxis(0); float rAngle(0);
int sGeID(0); float sMove[3] = {0};
......@@ -1210,12 +1210,9 @@ UInt_t GlobalFilter::GetParameters(Bool_t doList)
//conf.Require("WriteMgtData", 0); // these two guys do exactly the same job,
//conf.Require("WriteRootTree", 0);
if(doList) {conf.Show(gMotherClass); return 0;}
// read parameters
string className = "GlobalFilter";
if(doList) {conf.Show(className); return 0;}
string confFile = GetConfPath() + gMotherClass + ".conf";
int rv = conf.Read(className, confFile);
int rv = conf.Read(gMotherClass, confFile);
if(rv)
return rv; // Read() error
......
......@@ -463,7 +463,7 @@ private:
}
public:
UInt_t GetParameters(Bool_t doList=false);
UInt_t GetParameters(const std::string& confFile, Bool_t doList=false);
protected:
virtual Int_t AlgoInitialise() {return 0;}
......
......@@ -132,7 +132,7 @@ void PSAFilter::process_initialise (UInt_t *error_code)
Log.SetProcessMethod("process_initialise");
Log.SetPID(GetPID());
*error_code = GetParameters();
*error_code = GetParameters(GetConfPath() + gMotherClass + ".conf");
if(*error_code) {
Log << dolog;
return;
......@@ -227,7 +227,7 @@ void PSAFilter::process_initialise (UInt_t *error_code)
Log << dolog;
}
UInt_t PSAFilter::GetParameters(Bool_t doList)
UInt_t PSAFilter::GetParameters(const std::string& confFile, Bool_t doList)
{
int tauSeg(-1); float tauVal(0);
......@@ -251,17 +251,12 @@ UInt_t PSAFilter::GetParameters(Bool_t doList)
// refine behaviour
//conf.SetCall("SaveDataDir", 0, forceTailSlash);
//conf.Default("SkipPSA", 0, "1");
//conf.Default("NoMultiHist", 0, "0");
//conf.Default("Verbose", 0, "1");
AlgoParameters(conf);
AlgoParameters(conf); // daughter class can add further commands
// read parameters
string className = "PSAFilter";
if(doList) {conf.Show(className); return 0;}
string confFile = GetConfPath() + gMotherClass + ".conf";
int rv = conf.Read(className, confFile);
if(doList) {conf.Show(gMotherClass); return 0;}
int rv = conf.Read(gMotherClass, confFile);
if(rv)
return rv; // Read() error
......
......@@ -314,7 +314,7 @@ public:
#endif // PSA_FromGRU
public:
UInt_t GetParameters(Bool_t doList=false);
UInt_t GetParameters(const std::string& confFile, Bool_t doList=false);
protected:
virtual bool AlgoParameters(ConfReader &conf, bool check = false) { return true;}
virtual Int_t AlgoInitialise() {return 0;} //!In here you open your data file etc
......
......@@ -136,7 +136,7 @@ void PostPSAFilter::process_initialise (UInt_t *error_code)
Log.SetProcessMethod("process_initialise");
Log.SetPID(GetPID());
*error_code = GetParameters();
*error_code = GetParameters(GetConfPath() + gMotherClass + ".conf");
if(*error_code) {
Log << dolog;
return;
......@@ -300,10 +300,12 @@ void PostPSAFilter::process_initialise (UInt_t *error_code)
PostSpecEner->setComment("Energy spectra before and after Trapping correction");
hGroup.add(PostSpecEner);
PostMatrXYZ = new MultiHist<unsigned short>(4, matLen, matLen, matLen);
PostMatrXYZ->setFileName(fOdirPrefix+"Post?XYZ.matr");
PostMatrXYZ->setComment("zXY, yXZ, xYZ rPhiZ distributions of hits");
hGroup.add(PostMatrXYZ);
if(fSmearPosHit > 0) {
PostMatrXYZ = new MultiHist<unsigned short>(4, matLen, matLen, matLen);
PostMatrXYZ->setFileName(fOdirPrefix+"Post?XYZ.matr");
PostMatrXYZ->setComment("zXY, yXZ, xYZ rPhiZ distributions of hits");
hGroup.add(PostMatrXYZ);
}
//PostMatrRZE = new MultiHist<unsigned short>(4, 50, 50, 2000);
//PostMatrRZE->setFileName(fOdirPrefix+"Psa?RZE.matr");
......@@ -319,7 +321,7 @@ void PostPSAFilter::process_initialise (UInt_t *error_code)
Log << dolog;
}
UInt_t PostPSAFilter::GetParameters(Bool_t doList)
UInt_t PostPSAFilter::GetParameters(const std::string& confFile, Bool_t doList)
{
ConfReader conf;
conf.Add("ActualClass", "name of daughter class", &gActualClass);
......@@ -350,11 +352,9 @@ UInt_t PostPSAFilter::GetParameters(Bool_t doList)
// refine behaviour
//conf.SetCall("SaveDataDir", 0, forceTailSlash);
// read parameters
string className = "PostPSAFilter";
if(doList) {conf.Show(className); return 0;}
string confFile = GetConfPath() + gMotherClass + ".conf";
int rv = conf.Read(className, confFile);
if(doList) {conf.Show(gMotherClass); return 0;}
int rv = conf.Read(gMotherClass, confFile);
if(rv)
return rv; // Read() error
......
......@@ -183,7 +183,7 @@ public:
virtual void process_stop (UInt_t *error_code);
public:
UInt_t GetParameters(Bool_t doList=false);
UInt_t GetParameters(const std::string& confFile, Bool_t doList=false);
protected:
virtual Int_t AlgoInitialise() {return 0;}
......
......@@ -147,7 +147,7 @@ void PreprocessingFilter::process_initialise ( UInt_t *error_code )
Log.SetProcessMethod("process_initialise");
Log.SetPID ( GetPID() );
*error_code = GetParameters();
*error_code = GetParameters(GetConfPath() + gMotherClass + ".conf");
if(*error_code) {
Log << dolog;
return;
......@@ -223,7 +223,7 @@ void PreprocessingFilter::process_initialise ( UInt_t *error_code )
cServer.Start(gMotherClass);
}
UInt_t PreprocessingFilter::GetParameters(Bool_t doList)
UInt_t PreprocessingFilter::GetParameters(const std::string& confFile, Bool_t doList)
{
ConfReader conf;
conf.Add("ActualClass", "name of daughter class", &gActualClass);
......@@ -256,11 +256,9 @@ UInt_t PreprocessingFilter::GetParameters(Bool_t doList)
// refine behaviour
//conf.SetCall("SaveDataDir", 0, forceTailSlash);
// read parameters
string className = "PreprocessingFilter";
if(doList) {conf.Show(className); return 0;}
string confFile = GetConfPath() + gMotherClass + ".conf";
int rv = conf.Read(className, confFile);
if(doList) {conf.Show(gMotherClass); return 0;}
int rv = conf.Read(gMotherClass, confFile);
if(rv)
return rv; // Read() error
......
......@@ -163,7 +163,7 @@ public:
virtual void process_stop (UInt_t *error_code);
public:
UInt_t GetParameters(Bool_t doList=false);
UInt_t GetParameters(const std::string& confFile, Bool_t doList=false);
protected:
virtual Int_t AlgoInitialise() {return 0;}
......
......@@ -322,19 +322,24 @@ TrackingFilter::~TrackingFilter()
if(hitSg) delete [] hitSg;
#endif // #ifdef TRF_ROOTTREE
if(GeGroups.size() > 0) {
cout << " #################################### " << endl;
cout << " Number of events before group gating " << fGroupEvents[0] << endl;
cout << " Number of events after group gating " << fGroupEvents[1] << endl;