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)
bool stopSig = false; // used to check StopFile
bool killSig = false; // used to check KillFile
bool listKeys = false; // rudimentary help
time_t ttstart;
time_t ttpresent;
......@@ -143,6 +145,7 @@ vector<builder_t *> theBuilders;
void getparams(int, char **);
void numparams(char *, int);
void listKeysAndExit(); // call GetParameters() and exit
bool checkADFpath(); // check presence of ADF.conf
int eventLoop1(); // non-threaded
int eventLoop2(); // threaded
......@@ -188,6 +191,9 @@ int main(int argc, char **argv)
getparams(argc, argv);
if(listKeys)
listKeysAndExit();
ok = topologyRead(topologyFile);
if(!ok)
exit(EXIT_FAILURE);
......@@ -211,6 +217,7 @@ int main(int argc, char **argv)
if(!ok)
exit(EXIT_FAILURE);
topologyPrint();
ok = topologyInit();
if(!ok)
exit(EXIT_FAILURE);
......@@ -308,6 +315,9 @@ void getparams(int argc, char *argv[])
if(argc < 2 ) {
ok = -1;
}
else if(!strcmp(argv[1], "-h")|| !strcmp(argv[1], "--help")) {
ok = -1;
}
else {
topologyFile = argv[1];
ok = (argc > 1) ? 1 : 0;
......@@ -336,6 +346,9 @@ void getparams(int argc, char *argv[])
numparams(cmd, argc-argn-1);
adfVerbose = abs(atoi(argv[argn++]));
}
else if(!strcmp(cmd, "-k") || !strcmp(cmd, "-keys")) {
listKeys = true;
}
else {
ok = 0;
}
......@@ -344,9 +357,10 @@ void getparams(int argc, char *argv[])
if(ok < 1) {
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 << " -turns nn limit analysis to nn turns (unlimited if <=0) [0]" << endl ;
#ifdef WCT_THREADED
......@@ -479,7 +493,7 @@ bool topologyRead(string topo)
if(!stringSplit(line, " \t", keyw, data))
continue; // empty or comment lines
cout << line << endl;
if(stringEq(keyw, "EndLoop") ) {
if( stringEq(keyw, "EndLoop") || stringEq(keyw, "End_Loop") ) {
hasEndLoop = true;
break;
}
......@@ -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
bool topologyConfNew()
{
......
......@@ -569,39 +569,69 @@ bool EventBuilder::InitBuilder()
return true;
}
void EventBuilder::GetParameters()
{
printInfo("\nKEYWORDS ACCEPTED BY EventBuilder");
UInt_t errcode = 0xFFFFFFFF;
GetParameters(&errcode);
}
void EventBuilder::GetParameters(UInt_t *error_code)
{
bool doList = *error_code == 0xFFFFFFFF;
*error_code = 0;
string configFileName = GetConfPath() + fActualClass + ".conf";
string configFileName = GetConfPath() + gMotherClass + ".conf";
ifstream configfile( configFileName.c_str() );
if( !configfile.good() ) {
if(!doList) {
if(!configfile.good()) {
cout << endl << "Error opening " << configFileName << endl;
*error_code = 102;
return;
}
cout << endl << fActualClass + "::GetParameters() reading from --> " << configFileName << endl;
cout << endl << gMotherClass + "::GetParameters() reading from --> " << configFileName << endl;
}
string line, keyw, data, value;
string kcmd, line, keyw, data, value;
bool ok = true;
while(getline(configfile, line)) {
bool found = false;
while(doList || getline(configfile, line)) {
if(!doList) {
if(!stringSplit(line, " \t", keyw, data))
continue; // empty or comment lines
cout << line;
ok = false;
found = false;
}
if( stringEq(keyw, "ActualClass") ) {
kcmd = "ActualClass";
if(doList)
printInfo(kcmd, "%s", "name of daughter class");
else if( !found && stringEq(kcmd, keyw) ) {
found = true;
ok = data.size() > 0;
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;
fOdirPrefix = data;
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);
if( stringEq(keyw, "TimeStamp") ) {
useEventNumber = false;
......@@ -620,18 +650,38 @@ void EventBuilder::GetParameters(UInt_t *error_code)
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);
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);
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);
}
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);
Int_t val(0);
ok = 2 == sscanf(data.c_str(), "%d %d", &ind, &val);
......@@ -639,7 +689,12 @@ void EventBuilder::GetParameters(UInt_t *error_code)
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);
Int_t val(0);
ok = 1 == sscanf(data.c_str(), "%d", &ind);
......@@ -647,24 +702,48 @@ void EventBuilder::GetParameters(UInt_t *error_code)
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;
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;
ok = true;
}
else if( stringEq(keyw, "Details") ) {
ok = 1 == sscanf(data.c_str(), "%d", &details);
}
else {
if(doList)
return;
if(!found) {
cout << " --> ignored";
cout << endl;
GetParameters();
ok = true;
}
if(!ok) {
cout << " --> error reading argument(s)" << endl;
cout << endl;
GetParameters();
cout << endl;
*error_code = 103;
return;
}
......
......@@ -168,9 +168,14 @@ public:
#endif
private:
void GetParameters(UInt_t *error_code);
bool InitBuilder();
bool InitKeys(unsigned int nv);
private:
void GetParameters(UInt_t *error_code);
public:
void GetParameters();
};
#endif // EVENTBUILDER_H_INCLUDED
......@@ -409,6 +409,7 @@ bool adetParams::ReadXtalkCoeffs(std::string cname, bool verbose)
return true;
}
//
void adetParams::CalcDifferentialXtalk(float xfactor)
{
// average of non neighbours; we could recover a few more
......@@ -421,8 +422,8 @@ void adetParams::CalcDifferentialXtalk(float xfactor)
for(int n2 = 0; n2 < nSG; n2++) {
int sector2 = n2/NSLI;
//int slice2 = n2%NSLI;
int secdist = (sector2+NSEC-sector1)%NSEC;
if( secdist==0 || secdist==1 || secdist==NSEC-1)
int secdist = (sector2>sector1) ? (sector2-sector1) : (sector1-sector2);
if( secdist==0 || secdist==1 || secdist==(NSEC-1) )
continue;
if(!xTalkProp[n2][n2])
continue; // exclude broken segments
......
......@@ -42,7 +42,7 @@ static const int NSEC = 6; // number of sectors (slower index)
public:
adetParams() : vtrig(-1000.f), itrig(0), nCC(NCC), nSG(NSG),
doecalF2(false), bSegEmin(false), vSegEmin(0),
tntFactor(2097152.f) {
tntFactor(2097152.f) { // 2^21
for(int nn = 0; nn < nCC; nn++)
pCC[nn].myID = nn;
for(int nn = 0; nn < nSG; nn++)
......
......@@ -250,3 +250,37 @@ bool fileExists(std::string fname)
}
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::
void forceTailSlash(std::string &dr);
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
//enum retValue {
// EvNormal = 0,
......
......@@ -212,49 +212,95 @@ void AncillaryFilter::process_initialise ( UInt_t *error_code )
Log << dolog;
}
void AncillaryFilter::GetParameters()
{
printInfo("\nKEYWORDS ACCEPTED BY AncillaryFilter");
UInt_t errcode = 0xFFFFFFFF;
GetParameters(&errcode);
}
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( !configfile.good() ) {
if(!doList) {
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;
string kcmd, line, keyw, data;
bool ok = true;
while(getline(configfile, line)) {
bool found = false;
while(doList || getline(configfile, line)) {
if(!doList) {
if(!stringSplit(line, " \t", keyw, data))
continue; // empty or comment lines
cout << line;
ok = false;
if( stringEq(keyw, "ActualClass") ) {
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;
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;
fOdirPrefix = data;
forceTailSlash(fOdirPrefix);
}
else if( stringEq(keyw, "AllPairsMat") ) {
kcmd = "AllPairsMat";
if(doList)
printInfo(kcmd, "", "generate matrix of all pairs of parameters");
else if( !found && stringEq(kcmd, keyw) ) {
found = true;
fAllPairsMat = true;
ok = true;
}
else if( stringEq(keyw, "PRISMALUTFile") ) {
kcmd = "PRISMALUTFile";
if(doList)
printInfo(kcmd, "%s", "lookup table for PRISMA");
else if( !found && stringEq(kcmd, keyw) ) {
found = true;
ok = data.size() > 0;
fPRISMALUTFile = data;
}
else if( stringEq(keyw, "PRISMAManager") ) {
kcmd = "PRISMAManager";
if(doList)
printInfo(kcmd, "%s", "configuration file for the PRISMA manager");
else if( !found && stringEq(kcmd, keyw) ) {
found = true;
ok = data.size() > 0;
fPRISMAManager = data;
}
else if( stringEq(keyw, "WriteRootTree") ) {
kcmd = "WriteRootTree";
if(doList)
printInfo(kcmd, "", "produce root-tree of ancillary data");
else if( !found && stringEq(kcmd, keyw) ) {
found = true;
#ifdef ANF_ROOTTREE
fWriteRootTree = true;
#else
......@@ -262,7 +308,12 @@ void AncillaryFilter::GetParameters(UInt_t *error_code)
#endif
ok = true;
}
else if( stringEq(keyw, "TstampFile") ) {
kcmd = "TstampFile";
if(doList)
printInfo(kcmd, "%s %d", "File_with_timestams_to_selct Width_of_selection");
else if( !found && stringEq(kcmd, keyw) ) {
found = true;
ok = data.size() > 0;
string value1, value2;
stringSplit(data, " \t", value1, value2);
......@@ -270,48 +321,107 @@ void AncillaryFilter::GetParameters(UInt_t *error_code)
if(value2.size())
fTolerance = atoi(value2.c_str());
}
else if( stringEq(keyw, "DanteChan") ) {
ok = 3 == sscanf(data.c_str(), "%d %d %d ", &fDanteChT, &fDanteChX, &fDanteChY);
kcmd = "DanteChan";
if(doList)
printInfo(kcmd, "%d %d %d", "T X Y channels of DANTE data");
else if( !found && stringEq(kcmd, keyw) ) {
found = true;
ok = 3 == sscanf(data.c_str(), "%d %d %d", &fDanteChT, &fDanteChX, &fDanteChY);
}
else if( stringEq(keyw, "DantePos") ) {
kcmd = "DantePos";
if(doList)
printInfo(kcmd, "%f %f %f %f %f", "DanteDz DanteRz, DanteRy DanteRz2 DanteRx (positioning Dante)");
else if( !found && stringEq(kcmd, keyw) ) {
found = true;
ok = 5 == sscanf(data.c_str(), "%f %f %f %f %f", &fDanteDz, &fDanteRz1, &fDanteRy, &fDanteRz2, &fDanteRx);
}
else if( stringEq(keyw, "DanteBeta") ) {
kcmd = "DanteBeta";
if(doList)
printInfo(kcmd, "%f", "recoil v/c");
else if( !found && stringEq(kcmd, keyw) ) {
found = true;
ok = 1 == sscanf(data.c_str(), "%f", &fDanteVc);
}
else if( stringEq(keyw, "DanteCalX") ) {
kcmd = "DanteCalX";
if(doList)
printInfo(kcmd, "%f %f", "x-calibration (offset, gain)");
else if( !found && stringEq(kcmd, keyw) ) {
found = true;
ok = 2 == sscanf(data.c_str(), "%f %f", &fDanteChXcal0, &fDanteChXcal1);
}
else if( stringEq(keyw, "DanteCalY") ) {
kcmd = "DanteCalY";
if(doList)
printInfo(kcmd, "%f %f", "y-calibration (offset, gain)");
else if( !found && stringEq(kcmd, keyw) ) {
found = true;
ok = 2 == sscanf(data.c_str(), "%f %f", &fDanteChYcal0, &fDanteChYcal1);
}
else if( stringEq(keyw, "ReferenceTDC") ) {
kcmd = "ReferenceTDC";
if(doList)
printInfo(kcmd, "%d %d %f", "TDCModule, TDCIndex, TDCOffset for subsample interpolation");
else if( !found && stringEq(kcmd, keyw) ) {
found = true;
ok = 3 == sscanf(data.c_str(), "%d %d %f", &fRefTDCModule, &fRefTDCIndex, &fRefTDCOffset);
if(ok) fRefTDC = true;
}
else if( stringEq(keyw, "DanteTDC") ) {
kcmd = "DanteTDC";
if(doList)
printInfo(kcmd, "%d %d %d %d", "DanteTDCModule DanteTDCIndex DanteTDCMin DanteTDCMax");
else if( !found && stringEq(kcmd, keyw) ) {
found = true;
ok = 4 == sscanf(data.c_str(), "%d %d %d %d", &fDanteTDCModule, &fDanteTDCIndex, &fDanteTDCMin, &fDanteTDCMax);
if(ok) fDanteTDC = true;
}
else if( stringEq(keyw, "PrismaTDC") ) {
kcmd = "PrismaTDC";
if(doList)
printInfo(kcmd, "%d %d %d %d", "PrismaTDCModule PrismaTDCIndex PrismaTDCMin PrismaTDCMax");