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

Commit 725ff88c authored by dino's avatar dino
Browse files

Some more work on PreprocessingFilterPSA and on GetParameters

git-svn-id: svn://gal-serv.lnl.infn.it/agata/trunk/narval_emulator@1128 170316e4-aea8-4b27-aad4-0380ec0519c9
parent 61bd0452
......@@ -478,25 +478,25 @@ bool topologyRead(string topo)
break;
}
if(!stringSplit(line, " \t", keyw, data))
if(!stringSplit(line, keyw, data))
continue; // empty or comment lines
if( stringEq(keyw, "Loop") ) {
cout << line << endl;
string values, value1, value2;
if(!stringSplit(data, " \t", loopSymbol, values)) {
if(!stringSplit(data, loopSymbol, values)) {
cout << "Format is: Loop Name Value1 Value2 ..." << endl;
return false;
}
// tokenize values
while(stringSplit(values, " \t", value1, value2)) {
while(stringSplit(values, value1, value2)) {
loopValues.push_back(value1);
values = value2;
}
// read and store until EndLoop
bool hasEndLoop = false;
while(getline(ifs, line)) {
if(!stringSplit(line, " \t", keyw, data))
if(!stringSplit(line, keyw, data))
continue; // empty or comment lines
cout << line << endl;
if( stringEq(keyw, "EndLoop") || stringEq(keyw, "End_Loop") ) {
......@@ -519,7 +519,7 @@ bool topologyRead(string topo)
if( stringEq(keyw, "Chain") ) {
cout << line;
string count, conf;
if(!stringSplit(data, " \t", count, conf)) {
if(!stringSplit(data, count, conf)) {
cout << "\nFormat is: Chain numActors confDir" << endl;
return false;
}
......@@ -537,7 +537,7 @@ bool topologyRead(string topo)
ChainOfActors * pChain = new ChainOfActors( (int)theChains.size() );
string lconf, lsize;
stringSplit(conf, " \t", lconf, lsize);
stringSplit(conf, lconf, lsize);
pChain->confDir = confPrefix+lconf;
for(int nn = 0; nn < nacts; ) {
......@@ -556,12 +556,12 @@ bool topologyRead(string topo)
return false;
}
}
if(!stringSplit(line, " \t", keyw, data))
if(!stringSplit(line, keyw, data))
continue; // empty or comment lines
cout << line << endl;
string lname, lmore;
stringSplit(data, " \t", lname, lmore); // isolate the extra parts after the name of the library
stringSplit(data, lname, lmore); // isolate the extra parts after the name of the library
theActor.libName = lname;
theActor.libMore = lmore;
theActor.libConf = pChain->confDir;
......
......@@ -602,7 +602,7 @@ void EventBuilder::GetParameters(UInt_t *error_code)
while(doList || getline(configfile, line)) {
if(!doList) {
if(!stringSplit(line, " \t", keyw, data))
if(!stringSplit(line, keyw, data))
continue; // empty or comment lines
cout << line;
ok = false;
......@@ -622,7 +622,7 @@ void EventBuilder::GetParameters(UInt_t *error_code)
KEND;
KPAR("BuilderType", "%s", "builder type (TimeStamp | EventNumber)");
stringSplit(data, " \t", keyw, value);
stringSplit(data, keyw, value);
if( stringEq(keyw, "TimeStamp") ) {
useEventNumber = false;
if(value.size() > 0) {
......
......@@ -58,7 +58,7 @@ bool adetParams::ReadCalibCoeffs(std::string setupFile, bool verbose)
// count number of triggers(==1), cores and segments
while(getline(cfg, line)) {
if(!stringSplit(line, " \t", name, data))
if(!stringSplit(line, name, data))
continue;
if (name == keys[0])
nn_core++;
......@@ -151,7 +151,7 @@ bool adetParams::ReadCalibV01(std::ifstream &cfg, std::string *keys, bool verbos
cout << "\nFile decoded following the 1st format" << endl;
while(getline(cfg, line)) {
if(!stringSplit(line, " \t", name, data))
if(!stringSplit(line, name, data))
continue;
if(verbose)
cout << line << endl;
......@@ -248,7 +248,7 @@ bool adetParams::ReadCalibV02(std::ifstream &cfg, std::string *keys, bool verbos
itrig = 0;
//vtrig = fCoreEnerMin; // use SetTriggerLevel()
while(getline(cfg, line)) {
if(!stringSplit(line, " \t", name, data))
if(!stringSplit(line, name, data))
continue;
if(verbose)
cout << line << endl;
......@@ -475,13 +475,9 @@ bool adetParams::ReadTrappingCal(std::string setupFile, bool verbose)
const int nPars = 7;
while(getline(cfg, line)) {
//cout << line << endl;
stringTrim(line);
stringTrim(line, "#");
if(line.size() == 0)
continue;
if(line[0] == '#' ) {
cout << line << endl;
continue;
}
int np = sscanf(line.c_str(), "%d %f %f %f %f %f %f", &ns, &oSG, &oCC, &lE, &lH, &cSG, &cCC);
if(np != nPars) {
printf("\nWrong number of parameters (%d instead of %d) in line \n %s \n", np, nPars, line.c_str());
......
......@@ -48,6 +48,24 @@ void stringTrim(std::string &str)
str = str.substr(0, ii+1);
}
void stringTrim(std::string &str, const std::string& cmt)
{
stringTrim(str);
size_t ll = str.length();
if(ll <= 0)
return;
// check for comment substring
size_t nn = str.find_first_of(cmt);
if(nn == string::npos)
return;
// and remove it to the end of line
str = str.substr(0, nn);
return;
}
void stringRemove(std::string &str, const std::string rem, bool by_char) {
if(by_char) {
size_t nn = str.find_first_of(rem);
......@@ -65,13 +83,11 @@ void stringRemove(std::string &str, const std::string rem, bool by_char) {
}
}
bool stringSplit(std::string &line, const std::string sep, std::string &keyw)
bool stringFirst(std::string &line, std::string &keyw, const std::string sep)
{
stringTrim(line);
stringTrim(line, "#");
if(line.size() == 0)
return false;
if(line[0] == '#' )
return false;
size_t npos1 = line.find_first_not_of(sep, 0);
size_t npos2 = line.find_first_of(sep, npos1);
keyw = line.substr(npos1, npos2);
......@@ -81,13 +97,11 @@ bool stringSplit(std::string &line, const std::string sep, std::string &keyw)
return true;
}
bool stringSplit(std::string &line, const std::string sep, std::string &keyw, std::string &data)
bool stringSplit(std::string &line, std::string &keyw, std::string &data, const std::string sep)
{
stringTrim(line);
stringTrim(line, "#");
if(line.size() == 0)
return false;
if(line[0] == '#' )
return false;
size_t npos1 = line.find_first_not_of(sep, 0);
size_t npos2 = line.find_first_of(sep, npos1);
keyw = line.substr(npos1, npos2);
......@@ -100,6 +114,26 @@ bool stringSplit(std::string &line, const std::string sep, std::string &keyw, st
return true;
}
int stringCount(std::string &line, const std::string sep)
{
stringTrim(line, "#");
if(line.size() == 0)
return 0;
int count = 1;
size_t pos1 = 0;
while(true) {
size_t pos2 = line.find_first_of(sep, pos1);
if(pos2 == string::npos)
break;
count++;
pos1 = line.find_first_not_of(sep, pos2);
}
return count;
}
bool stringIncrement(std::string &str, int count)
{
if(count == 0)
......@@ -226,7 +260,7 @@ int getKeyFromFile(const std::string filename, const std::string theKey, std::st
string line, keyw, data;
while(getline(configfile, line)) {
if(!stringSplit(line, " \t", keyw, data))
if(!stringSplit(line, keyw, data))
continue; // empty or comment lines
if(verbose)
cout << line << endl;
......
......@@ -7,8 +7,10 @@
//#include "commonDefs.h"
void stringTrim(std::string &str);
bool stringSplit(std::string &line, const std::string sep, std::string &keyw);
bool stringSplit(std::string &line, const std::string sep, std::string &keyw, std::string &data);
void stringTrim(std::string &str, const std::string& cmt);
bool stringFirst(std::string &line, std::string &keyw, const std::string sep = " \t");
bool stringSplit(std::string &line, std::string &keyw, std::string &data, const std::string sep = " \t");
int stringCount(std::string &line, const std::string sep = " \t");
bool stringIncrement(std::string &str, int count = 1);
bool stringIncrement(std::string &str, const std::string sep, int count = 1);
bool stringEq (const std::string &s1, const std::string &s2, bool ignorecase = true);
......
......@@ -246,7 +246,7 @@ void AncillaryFilter::GetParameters(UInt_t *error_code)
while(doList || getline(configfile, line)) {
if(!doList) {
if(!stringSplit(line, " \t", keyw, data))
if(!stringSplit(line, keyw, data))
continue; // empty or comment lines
cout << line;
ok = false;
......@@ -256,7 +256,7 @@ void AncillaryFilter::GetParameters(UInt_t *error_code)
KPAR("ActualClass", "%s", "name of daughter class");
ok = data.size() > 0;
gActualClass = data;
}
KEND;
KPAR("SaveDataDir", "%s", "where to write data and spectra");
ok = data.size() > 0;
......@@ -291,7 +291,7 @@ void AncillaryFilter::GetParameters(UInt_t *error_code)
KPAR("TstampFile", "%s %d", "File_with_timestams_to_selct Width_of_selection");
ok = data.size() > 0;
string value1, value2;
stringSplit(data, " \t", value1, value2);
stringSplit(data, value1, value2);
fTstampFile = value1;
if(value2.size())
fTolerance = atoi(value2.c_str());
......@@ -403,7 +403,7 @@ bool AncillaryFilter::Decodesetup(bool verbose)
// count number of modules
while(getline(cfg, line)) {
if(!stringSplit(line, " \t", name, data))
if(!stringSplit(line, name, data))
continue;
if (name == keys[0])
nn_ADC++;
......@@ -440,7 +440,7 @@ bool AncillaryFilter::Decodesetup(bool verbose)
unsigned int nbConv = 0; // total number of converter
while(getline(cfg, line)) {
if(!stringSplit(line, " \t", name, data))
if(!stringSplit(line, name, data))
continue;
if(verbose)
......
......@@ -1040,7 +1040,7 @@ void GlobalFilter::GetParameters(UInt_t *error_code)
while(doList || getline(configfile, line)) {
if(!doList) {
if(!stringSplit(line, " \t", keyw, data))
if(!stringSplit(line, keyw, data))
continue; // empty or comment lines
cout << line;
ok = false;
......
......@@ -273,7 +273,7 @@ void PSAFilter::GetParameters(UInt_t *error_code)
while(doList || getline(configfile, line)) {
if(!doList) {
if(!stringSplit(line, " \t", keyw, data))
if(!stringSplit(line, keyw, data))
continue; // empty or comment lines
cout << line;
ok = false;
......
......@@ -265,7 +265,7 @@ void PostPSAFilter::GetParameters(UInt_t *error_code)
while(doList || getline(configfile, line)) {
if(!doList) {
if(!stringSplit(line, " \t", keyw, data))
if(!stringSplit(line, keyw, data))
continue; // empty or comment lines
cout << line;
ok = false;
......
......@@ -74,6 +74,7 @@ PreprocessingFilter::PreprocessingFilter() :
fPrepXtalkMatGain1 = 1/10.f; // gain of 1st set of [eCore - eCoreFromXtalk] matrices
fPrepXtalkMatGain2 = 1/1000.f; // gain of 2nd set of [eCore - eCoreFromXtalk] matrices
fPrepXtalkEnerHigh = 4000.f; // energy threshold count hit segments for the 2nd set of matrices
fPrepXtalkWrEmin = fPrepXtalkWrEmax = 0; // window on derived energy to call PreprocessingFilterPSA::WriteTraces()
timestamp = timestampOld = 0;
......@@ -212,13 +213,13 @@ void PreprocessingFilter::GetParameters(UInt_t *error_code)
cout << endl << gMotherClass + "::GetParameters() reading from --> " << configFileName << endl;
}
string line, keyw, data;
string line, keyw, data, value;
bool ok = true;
bool found = false;
while(doList || getline(configfile, line)) {
if(!doList) {
if(!stringSplit(line, " \t", keyw, data))
if(!stringSplit(line, keyw, data))
continue; // empty or comment lines
cout << line;
ok = false;
......@@ -296,8 +297,14 @@ void PreprocessingFilter::GetParameters(UInt_t *error_code)
}
KEND;
KPAR("CoreFromXtalk", "%f %f %f", "mat1Gain mat2Gain segHigEnergyThreshold");
ok = 3 == sscanf(data.c_str(), "%f %f %f", &fPrepXtalkMatGain1, &fPrepXtalkMatGain2, &fPrepXtalkEnerHigh);
KPAR("CoreFromXtalk", "%f %f %f %f %f", "mat1Gain mat2Gain segCountEmin wrTracesEmin wrTracesEmax");
//ok = 5 == stringCount(data);
//stringFirst(data, value); sscanf(value.c_str(), "%f", &fPrepXtalkMatGain1);
//stringFirst(data, value); sscanf(value.c_str(), "%f", &fPrepXtalkMatGain2);
//stringFirst(data, value); sscanf(value.c_str(), "%f", &fPrepXtalkEnerHigh);
//stringFirst(data, value); sscanf(value.c_str(), "%f", &fPrepXtalkWrEmin);
//stringFirst(data, value); sscanf(value.c_str(), "%f", &fPrepXtalkWrEmax);
ok = 5 == sscanf(data.c_str(), "%f %f %f %f %f", &fPrepXtalkMatGain1, &fPrepXtalkMatGain2, &fPrepXtalkEnerHigh, &fPrepXtalkWrEmin, &fPrepXtalkWrEmax);
KEND;
KPAR("EnergyGain", "%f", "scaling factor for binary energy spectra");
......
......@@ -83,6 +83,8 @@ protected:
Float_t fPrepXtalkMatGain1; // gain of 1st set of [eCore - eCoreFromXtalk] matrices
Float_t fPrepXtalkMatGain2; // gain of 2nd set of [eCore - eCoreFromXtalk] matrices
Float_t fPrepXtalkEnerHigh; // energy threshold count hit segments for the 2nd set of matrices
Float_t fPrepXtalkWrEmin; // minimum derived energy to call PreprocessingFilterPSA::WriteTraces()
Float_t fPrepXtalkWrEmax; // maximum derived energy to call PreprocessingFilterPSA::WriteTraces()
Int_t fCFD_CC_int, fCFD_CC_diff;
Int_t fCFD_CC_delay;
......
......@@ -61,6 +61,7 @@ private:
std::string fnPrepTraces;
FILE *fpPrepTraces;
bool doWriteTrace; // dynamic selection
#ifdef PPF_FromGRU
GNetServerRoot *PPNetworkRoot;
......@@ -146,12 +147,15 @@ public:
bool bBadCFD; // CDF could not produce timing
int fitChan1, fitChan2; // region used to fit the stright line
float xSegE[ADF::CrystalInterface::kNbSegments]; // in keV, before xTalk correction
float xTalkDir[ADF::CrystalInterface::kNbSegments][ADF::CrystalInterface::kNbSegments];
bool xTalkDirValid;
float xTalkAveraged;
float xTalkMatGain1;
float xTalkMatGain2;
float xTalkEnerHigh;
float xTalkEnergyCC;
bool ProcessEvent (int &smult, float &esum1, float &esum2);
float FindTriggerTime (float *pTS, float trigFract, int trigChans); // stright line of parabola
......
......@@ -1307,7 +1307,7 @@ void TrackingFilter::GetParameters(UInt_t *error_code)
while(doList || getline(configfile, line)) {
if(!doList) {
if(!stringSplit(line, " \t", keyw, data))
if(!stringSplit(line, keyw, data))
continue; // empty or comment lines
cout << line;
ok = false;
......@@ -1508,21 +1508,21 @@ void TrackingFilter::GetParameters(UInt_t *error_code)
ok = 2 == sscanf(data.c_str(), "%d %f", &fSizeMatr_gg2, &fGainMatr_gg2);
KEND;
KPAR("Details", "", "list input events in symbolic form (very slow and incompletee)")
KPAR("Details", "", "list input events in symbolic form (very slow and incompletee)");
fDetails = true;
ok = true;
KEND;
KPAR("EnergyGain", "%f", "scaling factor for binary energy spectra")
KPAR("EnergyGain", "%f", "scaling factor for binary energy spectra");
ok = 1 == sscanf(data.c_str(), "%f", &fEnergyGain);
KEND;
KPAR("NoMultiHist", "", "exclude flat binary spectra")
KPAR("NoMultiHist", "", "exclude flat binary spectra");
fUseMultiHist = false;
ok = true;
KEND;
KPAR("Verbose", "", "verbosity of printouts")
KPAR("Verbose", "", "verbosity of printouts");
fVerbose = true;
ok = true;
KEND;
......
......@@ -222,76 +222,76 @@ void AncillaryProducerTCP::GetParameters(uint32_t *error_code)
while(doList || getline(configfile, line)) {
if(!doList) {
if(!stringSplit(line, " \t", keyw, data))
if(!stringSplit(line, keyw, data))
continue; // empty or comment lines
cout << line;
ok = false;
found = false;
}
KPAR("ActualClass", "%s", "name of daughter class")
KPAR("ActualClass", "%s", "name of daughter class");
ok = data.size() > 0;
gActualClass = data;
}
KEND;
KPAR("ReadDataDir", "%s", "directory of raw data to replay")
KPAR("ReadDataDir", "%s", "directory of raw data to replay");
ok = data.size() > 0;
fIdirPrefix = data;
forceTailSlash(fIdirPrefix);
}
KEND;
KPAR("SaveDataDir", "%s", "where to write data and spectra")
KPAR("SaveDataDir", "%s", "where to write data and spectra");
ok = data.size() > 0;
fOdirPrefix = data;
forceTailSlash(fOdirPrefix);
}
KEND;
KPAR("KeyADF", "%s", "data:ranc0")
KPAR("KeyADF", "%s", "data:ranc0");
ok = data.size() > 0;
fKeyADF = data;
}
KEND;
KPAR("WriteDataMask", "%d", "write input raw data if (%d) != 0")
KPAR("WriteDataMask", "%d", "write input raw data if (%d) != 0");
ok = 1 == sscanf(data.c_str(), "%d", &fWriteDataMask);
}
KEND;
KPAR("DetectorID", "%d", "ID of detector (usually 99) for printouts")
KPAR("DetectorID", "%d", "ID of detector (usually 99) for printouts");
ok = 1 == sscanf(data.c_str(), "%d", &fDetectorID);
}
KEND;
KPAR("TcpPort", "%d", "tcp port (usually 999)")
KPAR("TcpPort", "%d", "tcp port (usually 999)");
ok = 1 == sscanf(data.c_str(), "%d", &fTcpPort);
}
KEND;
KPAR("TcpLittleEndian", "", "VME data transmitted in LittleEndian (default is BigEndian)")
KPAR("TcpLittleEndian", "", "VME data transmitted in LittleEndian (default is BigEndian)");
fBigEndian = false;
ok = true;
}
KEND;
KPAR("EndEventTag", "", "manage \"Nicola's\" data containing 0xFFFFFFFF end_of_event mark")
KPAR("EndEventTag", "", "manage \"Nicola's\" data containing 0xFFFFFFFF end_of_event mark");
fEndEventTag = 1;
ok = true;
}
KEND;
KPAR("InputDataFile", "%s", "raw data file to replay")
KPAR("InputDataFile", "%s", "raw data file to replay");
ok = data.size() > 0;
fInputDataFile = data;
}
KEND;
KPAR("RawXDaq", "%d", "replaying really-raw \"Nicola's\" data")
KPAR("RawXDaq", "%d", "replaying really-raw \"Nicola's\" data");
ok = 1 == sscanf(data.c_str(), "%d", &fRawXDaq);
if(fRawXDaq < 1) fRawXDaq = 1;
}
KEND;
KPAR("EventsPerBlock", "%d", "re-blocking for replaying really-raw \"Nicola's\" data")
KPAR("EventsPerBlock", "%d", "re-blocking for replaying really-raw \"Nicola's\" data");
ok = 1 == sscanf(data.c_str(), "%d", &fReBlock);
if(fReBlock < 1) fReBlock = 0;
}
KEND;
KPAR("Verbose", "", "verbosity of printouts")
KPAR("Verbose", "", "verbosity of printouts");
fVerbose = true;
ok = true;
}
KEND;
if(doList)
return;
......
......@@ -180,124 +180,124 @@ void CrystalProducer::GetParameters(UInt_t *error_code )
while(doList || getline(configfile, line)) {
if(!doList) {
if(!stringSplit(line, " \t", keyw, data))
if(!stringSplit(line, keyw, data))
continue; // empty or comment lines
cout << line;
ok = false;
found = false;
}
KPAR("ActualClass", "%s", "name of daughter class")
KPAR("ActualClass", "%s", "name of daughter class");
ok = data.size() > 0;
gActualClass = data;
}
KEND;
KPAR("ReadDataDir", "%s", "directory of raw data to replay")
KPAR("ReadDataDir", "%s", "directory of raw data to replay");
ok = data.size() > 0;
fIdirPrefix = data;
forceTailSlash(fIdirPrefix);
}
KEND;
KPAR("SaveDataDir", "%s", "where to write data and spectra")
KPAR("SaveDataDir", "%s", "where to write data and spectra");
ok = data.size() > 0;
fOdirPrefix = data;
forceTailSlash(fOdirPrefix);
}
KEND;
KPAR("TstampCorrection", "%lld", "modify timestamp of events")
KPAR("TstampCorrection", "%lld", "modify timestamp of events");
ok = 1 == sscanf(data.c_str(), "%lld", &fTstampCorr);
}
KEND;
KPAR("CrystalID", "%hu", "ID of crystal")
KPAR("CrystalID", "%hu", "ID of crystal");
ok = 1 == sscanf(data.c_str(), "%hu", &fCrystalID);
}
KEND;
KPAR("WriteDataMask", "%d", "0=none 1=input_mezzdata 2=event_mezzdata 4=event_mezzhead 8=event_energy 16=event_core 32=tstampdiff")
KPAR("WriteDataMask", "%d", "0=none 1=input_mezzdata 2=event_mezzdata 4=event_mezzhead 8=event_energy 16=event_core 32=tstampdiff");
ok = 1 == sscanf(data.c_str(), "%d", &fWriteDataMask);
}
KEND;
KPAR("DecimateMezzdata", "%d", "write out one every (%d) events")
KPAR("DecimateMezzdata", "%d", "write out one every (%d) events");
ok = 1 == sscanf(data.c_str(), "%d", &fDecimateMezzData);
}
KEND;
KPAR("DecimateMezzener", "%d", "write out one every (%d) events")
KPAR("DecimateMezzener", "%d", "write out one every (%d) events");
ok = 1 == sscanf(data.c_str(), "%d", &fDecimateMezzEner);
}
KEND;
KPAR("WriteCompressed", "", "event_mezzdata written in compressed format (default)")
KPAR("WriteCompressed", "", "event_mezzdata written in compressed format (default)");
fWriteCompressed = true;
ok = true;
}
KEND;
KPAR("WriteUnCompressed", "", "event_mezzdata written uncompressed")
KPAR("WriteUnCompressed", "", "event_mezzdata written uncompressed");