Commit 68e5eb38 authored by dino's avatar dino
Browse files

femul - -k to get a list of the keywords accepted by most of the actors

PostPsaFilter can modify crystal_id  (keyword NewCrystalID val) 

git-svn-id: svn://gal-serv.lnl.infn.it/agata/trunk/narval_emulator@1121 170316e4-aea8-4b27-aad4-0380ec0519c9
parent 18c328e4
...@@ -122,6 +122,8 @@ int nSIGINT = 0; // count number of SIGINT (CTRL_C) ...@@ -122,6 +122,8 @@ int nSIGINT = 0; // count number of SIGINT (CTRL_C)
bool stopSig = false; // used to check StopFile bool stopSig = false; // used to check StopFile
bool killSig = false; // used to check KillFile bool killSig = false; // used to check KillFile
bool listKeys = false; // rudimentary help
time_t ttstart; time_t ttstart;
time_t ttpresent; time_t ttpresent;
...@@ -143,6 +145,7 @@ vector<builder_t *> theBuilders; ...@@ -143,6 +145,7 @@ vector<builder_t *> theBuilders;
void getparams(int, char **); void getparams(int, char **);
void numparams(char *, int); void numparams(char *, int);
void listKeysAndExit(); // call GetParameters() and exit
bool checkADFpath(); // check presence of ADF.conf bool checkADFpath(); // check presence of ADF.conf
int eventLoop1(); // non-threaded int eventLoop1(); // non-threaded
int eventLoop2(); // threaded int eventLoop2(); // threaded
...@@ -188,6 +191,9 @@ int main(int argc, char **argv) ...@@ -188,6 +191,9 @@ int main(int argc, char **argv)
getparams(argc, argv); getparams(argc, argv);
if(listKeys)
listKeysAndExit();
ok = topologyRead(topologyFile); ok = topologyRead(topologyFile);
if(!ok) if(!ok)
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
...@@ -211,6 +217,7 @@ int main(int argc, char **argv) ...@@ -211,6 +217,7 @@ int main(int argc, char **argv)
if(!ok) if(!ok)
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
topologyPrint(); topologyPrint();
ok = topologyInit(); ok = topologyInit();
if(!ok) if(!ok)
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
...@@ -308,6 +315,9 @@ void getparams(int argc, char *argv[]) ...@@ -308,6 +315,9 @@ void getparams(int argc, char *argv[])
if(argc < 2 ) { if(argc < 2 ) {
ok = -1; ok = -1;
} }
else if(!strcmp(argv[1], "-h")|| !strcmp(argv[1], "--help")) {
ok = -1;
}
else { else {
topologyFile = argv[1]; topologyFile = argv[1];
ok = (argc > 1) ? 1 : 0; ok = (argc > 1) ? 1 : 0;
...@@ -336,6 +346,9 @@ void getparams(int argc, char *argv[]) ...@@ -336,6 +346,9 @@ void getparams(int argc, char *argv[])
numparams(cmd, argc-argn-1); numparams(cmd, argc-argn-1);
adfVerbose = abs(atoi(argv[argn++])); adfVerbose = abs(atoi(argv[argn++]));
} }
else if(!strcmp(cmd, "-k") || !strcmp(cmd, "-keys")) {
listKeys = true;
}
else { else {
ok = 0; ok = 0;
} }
...@@ -344,9 +357,10 @@ void getparams(int argc, char *argv[]) ...@@ -344,9 +357,10 @@ void getparams(int argc, char *argv[])
if(ok < 1) { if(ok < 1) {
if(ok == 0 && argc > 2) cout << "\nInvalid switch " << argv[argn-1] << endl; if(ok == 0 && argc > 2) cout << "\nInvalid switch " << argv[argn-1] << endl;
cout << "\nUsage: " << argv[0] << " topology_file [OPTION]..." << endl; cout << "\nUsage: " << argv[0] << " TopologyFile [OPTION]..." << endl;
cout << " -h print this list" << endl ; cout << " -h print this list and exit" << endl ;
cout << " -k print the list of keywords accepted by the actors and exit" << endl ;
cout << " -conf conf_dir name of configuration directory [Conf]" << endl ; cout << " -conf conf_dir name of configuration directory [Conf]" << endl ;
cout << " -turns nn limit analysis to nn turns (unlimited if <=0) [0]" << endl ; cout << " -turns nn limit analysis to nn turns (unlimited if <=0) [0]" << endl ;
#ifdef WCT_THREADED #ifdef WCT_THREADED
...@@ -479,7 +493,7 @@ bool topologyRead(string topo) ...@@ -479,7 +493,7 @@ bool topologyRead(string topo)
if(!stringSplit(line, " \t", keyw, data)) if(!stringSplit(line, " \t", keyw, data))
continue; // empty or comment lines continue; // empty or comment lines
cout << line << endl; cout << line << endl;
if(stringEq(keyw, "EndLoop") ) { if( stringEq(keyw, "EndLoop") || stringEq(keyw, "End_Loop") ) {
hasEndLoop = true; hasEndLoop = true;
break; break;
} }
...@@ -657,6 +671,46 @@ void topologyPrint(int nchains) ...@@ -657,6 +671,46 @@ void topologyPrint(int nchains)
} }
} }
// Call GetParameters() for the relevant classes to get the list of accepted keys
// Creation of the objects is done on the stack to avoid coredumps in the destructors
// which happen due to the fact that to properly setup things we should call process_init
// This is an acceptable way to proceed as we exit immediately (otherwise it is just wasted memory).
void listKeysAndExit()
{
// get rid of the adf messages
CentralLog::theCentralLog()->GetCurrentLogCollector()->SetLevelFiltering(LogMessage::kError, (unsigned short)(0));
AncillaryProducerTCP *pa1 = new AncillaryProducerTCP;
pa1->GetParameters();
AncillaryFilter *pa2 = new AncillaryFilter;
pa2->GetParameters();
CrystalProducer *pp1 = new CrystalProducer;
pp1->GetParameters();
PreprocessingFilter *pp2 = new PreprocessingFilter;
pp2->GetParameters();
PSAFilter *pp3 = new PSAFilter;
pp3->GetParameters();
PostPSAFilter *pp4 = new PostPSAFilter;
pp4->GetParameters();
EventBuilder *pp5 = new EventBuilder("EventBuilder");
pp5->GetParameters();
// not really developed and used
//GlobalFilter *pp6 = new GlobalFilter;
//pp6->GetParameters();
TrackingFilter *pp7 = new TrackingFilter;
pp7->GetParameters();
exit(EXIT_SUCCESS);
}
// process_config + generation of objects // process_config + generation of objects
bool topologyConfNew() bool topologyConfNew()
{ {
......
...@@ -569,39 +569,69 @@ bool EventBuilder::InitBuilder() ...@@ -569,39 +569,69 @@ bool EventBuilder::InitBuilder()
return true; return true;
} }
void EventBuilder::GetParameters()
{
printInfo("\nKEYWORDS ACCEPTED BY EventBuilder");
UInt_t errcode = 0xFFFFFFFF;
GetParameters(&errcode);
}
void EventBuilder::GetParameters(UInt_t *error_code) void EventBuilder::GetParameters(UInt_t *error_code)
{ {
bool doList = *error_code == 0xFFFFFFFF;
*error_code = 0; *error_code = 0;
string configFileName = GetConfPath() + fActualClass + ".conf"; string configFileName = GetConfPath() + gMotherClass + ".conf";
ifstream configfile( configFileName.c_str() ); ifstream configfile( configFileName.c_str() );
if( !configfile.good() ) {
cout << endl << "Error opening " << configFileName << endl; if(!doList) {
*error_code = 102; if(!configfile.good()) {
return; cout << endl << "Error opening " << configFileName << endl;
*error_code = 102;
return;
}
cout << endl << gMotherClass + "::GetParameters() reading from --> " << configFileName << endl;
} }
cout << endl << fActualClass + "::GetParameters() reading from --> " << configFileName << endl;
string line, keyw, data, value; string kcmd, line, keyw, data, value;
bool ok = true; bool ok = true;
while(getline(configfile, line)) { bool found = false;
if(!stringSplit(line, " \t", keyw, data)) while(doList || getline(configfile, line)) {
continue; // empty or comment lines
if(!doList) {
cout << line; if(!stringSplit(line, " \t", keyw, data))
ok = false; continue; // empty or comment lines
cout << line;
if( stringEq(keyw, "ActualClass") ) { ok = false;
found = false;
}
kcmd = "ActualClass";
if(doList)
printInfo(kcmd, "%s", "name of daughter class");
else if( !found && stringEq(kcmd, keyw) ) {
found = true;
ok = data.size() > 0; ok = data.size() > 0;
gActualClass = data; gActualClass = data;
//fActualClass = gActualClass = data; //fActualClass = gActualClass = data;
} }
else if( stringEq(keyw, "SaveDataDir") || stringEq(keyw, "WriteDataDir") || stringEq(keyw, "WriteDataPrefix") ) {
kcmd = "SaveDataDir";
if(doList)
printInfo(kcmd, "%s", "where to write data and spectra");
else if( !found && stringEq(kcmd, keyw) ) {
found = true;
ok = data.size() > 0; ok = data.size() > 0;
fOdirPrefix = data; fOdirPrefix = data;
forceTailSlash(fOdirPrefix); forceTailSlash(fOdirPrefix);
} }
else if( stringEq(keyw, "BuilderType") ) {
kcmd = "BuilderType";
if(doList)
printInfo(kcmd, "%s", "builder type (TimeStamp | EventNumber)");
else if( !found && stringEq(kcmd, keyw) ) {
found = true;
stringSplit(data, " \t", keyw, value); stringSplit(data, " \t", keyw, value);
if( stringEq(keyw, "TimeStamp") ) { if( stringEq(keyw, "TimeStamp") ) {
useEventNumber = false; useEventNumber = false;
...@@ -620,18 +650,38 @@ void EventBuilder::GetParameters(UInt_t *error_code) ...@@ -620,18 +650,38 @@ void EventBuilder::GetParameters(UInt_t *error_code)
ok = false; ok = false;
} }
} }
else if( stringEq(keyw, "KeyIn") ) {
kcmd = "KeyIn";
if(doList)
printInfo(kcmd, "%s", "symbolic_name (e.g. data:psa)");
else if( !found && stringEq(kcmd, keyw) ) {
found = true;
ok = (data.length() > 1); ok = (data.length() > 1);
sKeyIn.push_back(data); sKeyIn.push_back(data);
} }
else if( stringEq(keyw, "KeyOut") ) {
kcmd = "KeyOut";
if(doList)
printInfo(kcmd, "%s", "symbolic_name (e.g. event:data:psa)");
else if( !found && stringEq(kcmd, keyw) ) {
found = true;
ok = (data.length() > 1); ok = (data.length() > 1);
sKeyOut = data; sKeyOut = data;
} }
else if( stringEq(keyw, "MinFold") ) {
kcmd = "MinFold";
if(doList)
printInfo(kcmd, "%d", "minimum number of detectors for valid events");
else if( !found && stringEq(kcmd, keyw) ) {
found = true;
ok = 1 == sscanf(data.c_str(), "%d", &minFold); ok = 1 == sscanf(data.c_str(), "%d", &minFold);
} }
else if( stringEq(keyw, "TimestampCorrect") ) {
kcmd = "TimestampCorrect";
if(doList)
printInfo(kcmd, "%d %d", "Queue Value");
else if( !found && stringEq(kcmd, keyw) ) {
found = true;
UInt_t ind(nchains); UInt_t ind(nchains);
Int_t val(0); Int_t val(0);
ok = 2 == sscanf(data.c_str(), "%d %d", &ind, &val); ok = 2 == sscanf(data.c_str(), "%d %d", &ind, &val);
...@@ -639,7 +689,12 @@ void EventBuilder::GetParameters(UInt_t *error_code) ...@@ -639,7 +689,12 @@ void EventBuilder::GetParameters(UInt_t *error_code)
vCorrection[ind] = val; vCorrection[ind] = val;
} }
} }
else if( stringEq(keyw, "TimestampFixBug24") ) {
kcmd = "TimestampFixBug24";
if(doList)
printInfo(kcmd, "%d", "Queue");
else if( !found && stringEq(kcmd, keyw) ) {
found = true;
UInt_t ind(nchains); UInt_t ind(nchains);
Int_t val(0); Int_t val(0);
ok = 1 == sscanf(data.c_str(), "%d", &ind); ok = 1 == sscanf(data.c_str(), "%d", &ind);
...@@ -647,24 +702,48 @@ void EventBuilder::GetParameters(UInt_t *error_code) ...@@ -647,24 +702,48 @@ void EventBuilder::GetParameters(UInt_t *error_code)
vCorrection[ind] = 0x7FFFFFFF; vCorrection[ind] = 0x7FFFFFFF;
} }
} }
else if( stringEq(keyw, "NoMultiHist") || stringEq(keyw, "NoLocalSpectra") ) {
kcmd = "NoMultiHist";
if(doList)
printInfo(kcmd, "", "exclude flat binary spectra");
else if( !found && stringEq(kcmd, keyw) ) {
found = true;
fUseMultiHist = false; fUseMultiHist = false;
ok = true; ok = true;
} }
else if( stringEq(keyw, "Verbose") ) {
kcmd = "Details";
if(doList)
printInfo(kcmd, "%d", "b1=tstamp_snapshot for all events b2=tstamp_diff for all input queues");
else if( !found && stringEq(kcmd, keyw) ) {
found = true;
ok = 1 == sscanf(data.c_str(), "%d", &details);
}
kcmd = "Verbose";
if(doList)
printInfo(kcmd, "", "verbosity of printouts");
else if( !found && stringEq(kcmd, keyw) ) {
found = true;
verbose = true; verbose = true;
ok = true; ok = true;
} }
else if( stringEq(keyw, "Details") ) {
ok = 1 == sscanf(data.c_str(), "%d", &details); if(doList)
} return;
else {
if(!found) {
cout << " --> ignored"; cout << " --> ignored";
cout << endl;
GetParameters();
ok = true; ok = true;
} }
if(!ok) { if(!ok) {
cout << " --> error reading argument(s)" << endl; cout << " --> error reading argument(s)" << endl;
cout << endl;
GetParameters();
cout << endl;
*error_code = 103; *error_code = 103;
return; return;
} }
......
...@@ -168,9 +168,14 @@ public: ...@@ -168,9 +168,14 @@ public:
#endif #endif
private: private:
void GetParameters(UInt_t *error_code);
bool InitBuilder(); bool InitBuilder();
bool InitKeys(unsigned int nv); bool InitKeys(unsigned int nv);
private:
void GetParameters(UInt_t *error_code);
public:
void GetParameters();
}; };
#endif // EVENTBUILDER_H_INCLUDED #endif // EVENTBUILDER_H_INCLUDED
...@@ -409,6 +409,7 @@ bool adetParams::ReadXtalkCoeffs(std::string cname, bool verbose) ...@@ -409,6 +409,7 @@ bool adetParams::ReadXtalkCoeffs(std::string cname, bool verbose)
return true; return true;
} }
//
void adetParams::CalcDifferentialXtalk(float xfactor) void adetParams::CalcDifferentialXtalk(float xfactor)
{ {
// average of non neighbours; we could recover a few more // average of non neighbours; we could recover a few more
...@@ -421,8 +422,8 @@ void adetParams::CalcDifferentialXtalk(float xfactor) ...@@ -421,8 +422,8 @@ void adetParams::CalcDifferentialXtalk(float xfactor)
for(int n2 = 0; n2 < nSG; n2++) { for(int n2 = 0; n2 < nSG; n2++) {
int sector2 = n2/NSLI; int sector2 = n2/NSLI;
//int slice2 = n2%NSLI; //int slice2 = n2%NSLI;
int secdist = (sector2+NSEC-sector1)%NSEC; int secdist = (sector2>sector1) ? (sector2-sector1) : (sector1-sector2);
if( secdist==0 || secdist==1 || secdist==NSEC-1) if( secdist==0 || secdist==1 || secdist==(NSEC-1) )
continue; continue;
if(!xTalkProp[n2][n2]) if(!xTalkProp[n2][n2])
continue; // exclude broken segments continue; // exclude broken segments
......
...@@ -42,7 +42,7 @@ static const int NSEC = 6; // number of sectors (slower index) ...@@ -42,7 +42,7 @@ static const int NSEC = 6; // number of sectors (slower index)
public: public:
adetParams() : vtrig(-1000.f), itrig(0), nCC(NCC), nSG(NSG), adetParams() : vtrig(-1000.f), itrig(0), nCC(NCC), nSG(NSG),
doecalF2(false), bSegEmin(false), vSegEmin(0), doecalF2(false), bSegEmin(false), vSegEmin(0),
tntFactor(2097152.f) { tntFactor(2097152.f) { // 2^21
for(int nn = 0; nn < nCC; nn++) for(int nn = 0; nn < nCC; nn++)
pCC[nn].myID = nn; pCC[nn].myID = nn;
for(int nn = 0; nn < nSG; nn++) for(int nn = 0; nn < nSG; nn++)
......
...@@ -250,3 +250,37 @@ bool fileExists(std::string fname) ...@@ -250,3 +250,37 @@ bool fileExists(std::string fname)
} }
return false; return false;
} }
void printInfo(const std::string &s1) {
cout << s1 << endl;
}
void printInfo(const std::string &s1, const std::string &s2) {
const int p2 = 23;
cout << s1;
int n1 = p2-int(s1.size());
for(int ii = 0; ii < n1; ii++)
cout << " ";
cout << s2 << endl;
}
void printInfo(const std::string &s1, const std::string &s2, const std::string &s3) {
const int p2 = 23;
const int p3 = 45;
cout << s1;
int n1 = p2 - int(s1.size());
if(n1 < 0) n1 = 0;
for(int ii = 0; ii < n1; ii++)
std::cout << " ";
cout << s2;
int n2 = p3 - (int(s1.size()) + n1 + int(s2.size()));
if(n2 < 0) n2 = 0;
for(int ii = 0; ii < n2; ii++)
cout << " ";
cout << s3 << endl;
}
...@@ -19,6 +19,10 @@ int getKeyFromFile(const std::string filename, const std::string theKey, std:: ...@@ -19,6 +19,10 @@ int getKeyFromFile(const std::string filename, const std::string theKey, std::
void forceTailSlash(std::string &dr); void forceTailSlash(std::string &dr);
bool fileExists(std::string fname); bool fileExists(std::string fname);
void printInfo(const std::string &s1);
void printInfo(const std::string &s1, const std::string &s2);
void printInfo(const std::string &s1, const std::string &s2, const std::string &s3);
//// bit values used in various places //// bit values used in various places
//enum retValue { //enum retValue {
// EvNormal = 0, // EvNormal = 0,
......
...@@ -212,49 +212,95 @@ void AncillaryFilter::process_initialise ( UInt_t *error_code ) ...@@ -212,49 +212,95 @@ void AncillaryFilter::process_initialise ( UInt_t *error_code )
Log << dolog; Log << dolog;
} }
void AncillaryFilter::GetParameters(UInt_t *error_code) void AncillaryFilter::GetParameters()
{ {
*error_code = 0; printInfo("\nKEYWORDS ACCEPTED BY AncillaryFilter");
string configFileName = GetConfPath() + gMotherClass + ".conf"; UInt_t errcode = 0xFFFFFFFF;
ifstream configfile( configFileName.c_str() ); GetParameters(&errcode);
if( !configfile.good() ) { }
cout << endl << "Error opening " << configFileName << endl;
*error_code = 102;
return;
}
cout << endl << gMotherClass + "::GetParameters() reading from --> " << configFileName << endl;
string line, keyw, data; void AncillaryFilter::GetParameters(UInt_t *error_code)
{
bool doList = *error_code == 0xFFFFFFFF;
*error_code = 0;
string configFileName = GetConfPath() + gMotherClass + ".conf";
ifstream configfile( configFileName.c_str() );
if(!doList) {
if(!configfile.good()) {
cout << endl << "Error opening " << configFileName << endl;
*error_code = 102;
return;
}
cout << endl << gMotherClass + "::GetParameters() reading from --> " << configFileName << endl;
}
string kcmd, line, keyw, data;
bool ok = true; bool ok = true;
while(getline(configfile, line)) { bool found = false;
if(!stringSplit(line, " \t", keyw, data)) while(doList || getline(configfile, line)) {
continue; // empty or comment lines
if(!doList) {
cout << line; if(!stringSplit(line, " \t", keyw, data))
ok = false; continue; // empty or comment lines
if( stringEq(keyw, "ActualClass") ) { cout << line;
ok = false;
found = false;
}
kcmd = "ActualClass";
if(doList)
printInfo(kcmd, "%s", "name of daughter class");
else if( !found && stringEq(kcmd, keyw) ) {
found = true;
ok = data.size() > 0; ok = data.size() > 0;
gActualClass = data; gActualClass = data;
} }
else if( stringEq(keyw, "SaveDataDir") || stringEq(keyw, "WriteDataDir") || stringEq(keyw, "WriteDataPrefix") ) {