Commit 7766edd2 authored by dino's avatar dino
Browse files

Refactoring


git-svn-id: svn://gal-serv.lnl.infn.it/agata/trunk/narval_emulator@1203 170316e4-aea8-4b27-aad4-0380ec0519c9
parent bdf154b5
......@@ -4,7 +4,7 @@
#include <sstream>
#include <memory.h>
#include "misc.h"
#include "Misc.h"
#include "ConfReader.h"
using namespace std;
......
#include "misc.h"
#include <iostream>
#include <iomanip>
#include <fstream>
#include <sstream>
#include <algorithm>
#include "Misc.h"
using namespace std;
void stringTrim(std::string &str)
......@@ -91,7 +91,7 @@ void stringRemove(std::string &str, const std::string rem, bool by_char) {
bool stringFirst(std::string &line, std::string &keyw, const std::string sep)
{
stringTrim(line, "#");
if(line.size() == 0)
if(line.empty())
return false;
size_t npos1 = line.find_first_not_of(sep, 0);
size_t npos2 = line.find_first_of(sep, npos1);
......@@ -105,7 +105,7 @@ bool stringFirst(std::string &line, std::string &keyw, const std::string sep)
bool stringSplit(std::string &line, std::string &keyw, std::string &data, const std::string sep)
{
stringTrim(line, "#");
if(line.size() == 0)
if(line.empty())
return false;
const char cc[2] = {'\'', '"'}; // if grouped as '' or ""
......@@ -141,7 +141,7 @@ bool stringSplit(std::string &line, std::string &keyw, std::string &data, const
int stringCount(std::string &line, const std::string sep)
{
stringTrim(line, "#");
if(line.size() == 0)
if(line.empty())
return 0;
int count = 1;
......@@ -284,7 +284,7 @@ int stringWhere(const std::string &s1, const std::string &s2, bool ignorecase) {
int stringLocate(const std::string &s1, const std::vector<std::string> &sv, bool ignorecase, bool partial)
{
if(sv.size() < 1)
if(sv.empty())
return -1;
string line(s1), sLow1, rest;
......
......@@ -3,8 +3,6 @@
#include <string>
#include <vector>
//#include <memory.h>
//#include <ctime>
void stringTrim(std::string &str);
bool stringTrim(std::string &str, const std::string& cmt);
......@@ -35,16 +33,31 @@ bool InvertMatrix2 (const double m[ 4], double invOut[ 4]);
bool InvertMatrix3 (const double m[ 9], double invOut[ 9]);
bool InvertMatrix4 (const double m[16], double invOut[16]);
//// bit values used in various places
//enum kretValue {
// kEvNormal = 0,
// kEvNewBuffer = 1,
// kEvNewFile = 2,
// kEvFinish = 4,
// kEvSkip = 8,
// kEvAgain = 16,
// kEvReturn = 32
//};
template <typename T>
inline T AverageValue(T* data, int nchan)
{
if(nchan < 1)
return 0;
T vv = 0;
for(int nn = 0; nn < nchan; nn++)
vv += data[nn];
return vv/nchan;
}
template <typename T>
inline T AverageVariance(T* data, int nchan, T meanval = 0)
{
if(nchan < 1)
return 0;
T vv = 0;
for(int nn = 0; nn < nchan; nn++) {
float vt = data[nn]-meanval;
vv += vt*vt;
}
return vv/nchan;
}
//template<class T>
//class median
......
#include "TextReader.h"
#include <iostream>
#include <iomanip>
#include <fstream>
#include <sstream>
#include <algorithm>
#include "misc.h"
#include "TextReader.h"
#include "Misc.h"
using namespace std;
......
#include "TstampFilter.h"
#include <iostream>
#include <stdio.h>
#include <iomanip>
#include "TstampFilter.h"
using namespace std;
TstampFilter::TstampFilter()
......
#include "adetParams.h"
#include "commonDefs.h"
#include "misc.h"
#include <iostream>
#include <fstream>
#include <sstream>
......@@ -9,6 +5,10 @@
#include <cmath>
#include <algorithm>
#include "adetParams.h"
#include "commonDefs.h"
#include "Misc.h"
using namespace std;
// This file contains the calibration coefficients for energies and traces,
......
......@@ -236,7 +236,7 @@ const int defTriggerSample = 10; // 60-10=50 samples passed to the PSA
defined(GLF_MULTIHIST) ||\
defined(TRF_MULTIHIST) ||\
defined(EVB_MULTIHIST)
# define MULTIHIST_SPECTRA // needed by cycleServer if any individual one is enabled
# define MULTIHIST_SPECTRA // needed by CycleServer if any individual one is enabled
#endif
//////////////////////////////////////////////////////////////
......
......@@ -2,7 +2,7 @@
#include <fstream>
#include <iomanip>
#include "cycleServer.h"
#include "CycleServer.h"
#if OS_TYPE != OS_WINDOWS
# include <unistd.h>
......@@ -10,7 +10,7 @@
using namespace std;
void cycleServer::Start(std::string name, unsigned int cycleMin, unsigned int cycleMax)
void CycleServer::Start(std::string name, unsigned int cycleMin, unsigned int cycleMax)
{
SetPrompt(name);
secMinStep = cycleMin;
......@@ -22,7 +22,7 @@ void cycleServer::Start(std::string name, unsigned int cycleMin, unsigned int cy
}
// check if it exists and remove if requested (and possible)
bool cycleServer::CheckComFile(bool remove)
bool CycleServer::CheckComFile(bool remove)
{
if( comFile.empty() )
return false;
......@@ -39,7 +39,7 @@ bool cycleServer::CheckComFile(bool remove)
return true;
}
bool cycleServer::CheckComFile(bool &erase, bool remove)
bool CycleServer::CheckComFile(bool &erase, bool remove)
{
erase = false;
if( comFile.empty() )
......@@ -63,7 +63,7 @@ bool cycleServer::CheckComFile(bool &erase, bool remove)
return true;
}
bool cycleServer::RemoveComFile()
bool CycleServer::RemoveComFile()
{
#if OS_TYPE == OS_WINDOWS
int done = _unlink(comFile.c_str());
......@@ -73,7 +73,7 @@ bool cycleServer::RemoveComFile()
return (done == 0);
}
void cycleServer::SetPrompt(std::string name)
void CycleServer::SetPrompt(std::string name)
{
myName = "-" + name + ":";
//size_t ln = myName.length();
......@@ -82,7 +82,7 @@ void cycleServer::SetPrompt(std::string name)
//ln = myName.length();
}
unsigned int cycleServer::Prompt(int id, unsigned int nevs, unsigned int bsize, bool isAll)
unsigned int CycleServer::Prompt(int id, unsigned int nevs, unsigned int bsize, bool isAll)
{
//if(mCount > sCount) {
// Check(); // only if new events
......@@ -104,7 +104,7 @@ unsigned int cycleServer::Prompt(int id, unsigned int nevs, unsigned int bsize,
return irate;
}
unsigned int cycleServer::ExecLong(bool newStep)
unsigned int CycleServer::ExecLong(bool newStep)
{
unsigned int actions = 0;
......
......@@ -7,7 +7,7 @@
#include <ctime>
#include "commonDefs.h"
#include "misc.h"
#include "Misc.h"
#ifdef MULTIHIST_SPECTRA
# include "MultiHist.h"
#endif
......@@ -64,7 +64,7 @@ public:
}
};
class cycleServer
class CycleServer
{
unsigned long long tstStart; // value of the first timestamp
unsigned long long tstCheck; // timestamp for the NEXT check == tstNow + tst1second*secMinStep;
......@@ -93,7 +93,7 @@ class cycleServer
}
public:
cycleServer(unsigned int cycleMin = defaultMinCycleTime, unsigned int cycleMax = defaultMaxCycleTime) :
CycleServer(unsigned int cycleMin = defaultMinCycleTime, unsigned int cycleMax = defaultMaxCycleTime) :
mCount(0), sCount(0),
tstStart(0), tstCheck(0), tstWrite(0), tstThis(0), tstStep(0),
secMinStep(cycleMin), secMaxStep(cycleMax), lastWrite(0)
......
......@@ -7,7 +7,6 @@
#include <fstream>
#include <memory.h>
template <typename T>
class sAppend
{
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment