Commit 438b0f20 authored by Guillaume Baulieu's avatar Guillaume Baulieu
Browse files

Removes unused variables

Pass string as const reference instead of value
parent 6af511da
......@@ -169,7 +169,7 @@ vector<ChainOfActors *> theChains;
// this part used only during setup
struct builder_t {
builder_t(std::string name) : pEventBuilder(NULL), theName(name), numInputs(0), indChain(-1) {}
builder_t(const std::string& name) : pEventBuilder(NULL), theName(name), numInputs(0), indChain(-1) {}
EventBuilder *pEventBuilder;
std::string theName;
int numInputs;
......
......@@ -24,7 +24,7 @@ const int rQueuesStep = 1000000; // 10 ms steps
bool stopSig;
#endif
EventBuilder::EventBuilder(std::string name, unsigned int nque) :
EventBuilder::EventBuilder(const std::string& name, unsigned int nque) :
nQueues(0), nevCount(0), oevCount(0),
evQue(NULL), evQueEvts(NULL), isGood(NULL), minTstamp(0), oldTstamp(0), minChain(0),
inQueLocker(NULL), statKeys(NULL),
......@@ -697,7 +697,7 @@ bool EventBuilder::InitBuilder()
UInt_t EventBuilder::GetParameters(const std::string& confFile, Bool_t doList)
{
string bType; int btV1(0), btV2(0);
int btV1(0), btV2(0);
string inpKey;
string MandatoryinpKey;
UInt_t ind1(0); int val1(0);
......@@ -708,8 +708,6 @@ UInt_t EventBuilder::GetParameters(const std::string& confFile, Bool_t doList)
, &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).SetRequired(2);
conf.Add("KeyIn", "symbolic_name (e.g. data:psa) of the input frames"
, &inpKey);
conf.Add("KeyOut", "symbolic_name (e.g. event:data:psa) of \"\". 'None' to avoid the surrounding frame"
......@@ -897,7 +895,7 @@ bool EventBuilder::InitKeys(unsigned int nv)
return (nerrors == 0);
}
void EventBuilder::PrintDFAgentKeys(std::string str)
void EventBuilder::PrintDFAgentKeys(const std::string& str)
{
return;
......
......@@ -110,7 +110,7 @@ public:
public:
EventBuilder(std::string name, unsigned int nque = 1);
EventBuilder(const std::string& name, unsigned int nque = 1);
const std::string &GetConfPath() {
return fConfPath;
......@@ -153,7 +153,7 @@ public:
}
void PrintStat();
void PrintDFAgentKeys(std::string str);
void PrintDFAgentKeys(const std::string& str);
void CheckEvent_Tstamp();
......
......@@ -64,10 +64,7 @@ class ConfReader
std::vector<Par *> vpar;
std::vector<char *> saved;
Com() : keyCount(0), parCount(0), Required(-1), Disabled(false), HasError(false) {}
Com(const std::string &keyw, const std::string &help) : keyCount(0), parCount(0), Required(-1), Disabled(false), HasError(false) {
Keyw = keyw;
KeyLow = keyw;
Help = help;
Com(const std::string &keyw, const std::string &help) : keyCount(0), parCount(0), Required(-1), Disabled(false), HasError(false), Keyw(keyw), KeyLow(keyw), Help(help) {
transform(KeyLow.begin(), KeyLow.end(), KeyLow.begin(), ::tolower);
}
int GetData(std::string data, bool verbose);
......
......@@ -84,7 +84,7 @@ private:
public:
CycleServer(int cycleMin = defaultMinCycleTime, int cycleMax = defaultMaxCycleTime);
virtual ~CycleServer() {}
void SetCommandFile(std::string name) { comFile = name; }
void SetCommandFile(const std::string& name) { comFile = name; }
void Start(const std::string &name, int pprompt = 1, int cycleMin = defaultMinCycleTime, int cycleMax = defaultMaxCycleTime);
void Exec(uint64_t tstNew, int nevts);
void Save(bool erase = false);
......
......@@ -44,7 +44,7 @@ public:
void AddToBuffer ( unsigned short int *, int );
public:
void SetPrefix (std::string pfx) {filePrefix = pfx;}
void SetPrefix (const std::string& pfx) {filePrefix = pfx;}
void BeginOfRun ( int );
void EndOfRun ();
......
......@@ -71,7 +71,7 @@ bool stringTrim(std::string& str, const std::string& cmt)
return false;
}
void stringRemove(std::string &str, const std::string rem, bool by_char) {
void stringRemove(std::string &str, const std::string& rem, bool by_char) {
if(by_char) {
size_t nn = str.find_first_of(rem);
while(nn != string::npos) {
......@@ -88,7 +88,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)
bool stringFirst(std::string &line, std::string &keyw, const std::string& sep)
{
stringTrim(line, "#");
if(line.empty())
......@@ -102,7 +102,7 @@ bool stringFirst(std::string &line, std::string &keyw, const std::string sep)
return true;
}
bool stringSplit(std::string &line, std::string &keyw, std::string &data, const std::string sep)
bool stringSplit(std::string &line, std::string &keyw, std::string &data, const std::string& sep)
{
stringTrim(line, "#");
if(line.empty())
......@@ -138,7 +138,7 @@ bool stringSplit(std::string &line, std::string &keyw, std::string &data, const
return true;
}
int stringCount(std::string &line, const std::string sep)
int stringCount(std::string &line, const std::string& sep)
{
stringTrim(line, "#");
if(line.empty())
......@@ -231,7 +231,7 @@ bool stringIncrement(std::string &str, int count)
return true;
}
bool stringIncrement(std::string &str, const std::string sep, int count)
bool stringIncrement(std::string &str, const std::string& sep, int count)
{
if(count == 0)
return false;
......@@ -323,7 +323,7 @@ int stringLocate(const std::string &s1, const std::vector<std::string> &sv, bool
}
int getKeyFromFile(const std::string filename, const std::string theKey, std::string &theValue, bool verbose)
int getKeyFromFile(const std::string& filename, const std::string& theKey, std::string &theValue, bool verbose)
{
ifstream configfile( filename.c_str() );
if(!configfile.good()) {
......
......@@ -21,18 +21,18 @@ inline double get_wall_time() {
void stringTrim(std::string &str);
bool 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 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 stringIncrement(std::string &str, const std::string& sep, int count = 1);
bool stringEq (const std::string &s1, const std::string &s2, bool ignorecase = true);
bool stringHas (const std::string &s1, const std::string &s2, bool ignorecase = true);
int stringWhere (const std::string &s1, const std::string &s2, bool ignorecase = true);
int stringLocate(const std::string &s1, const std::vector<std::string> &s2, bool ignorecase = true, bool partial = true);
void stringRemove(std::string &str, const std::string rem, bool by_char = true);
void stringRemove(std::string &str, const std::string& rem, bool by_char = true);
int getKeyFromFile(const std::string filename, const std::string theKey, std::string &theValue, bool verbose = false);
int getKeyFromFile(const std::string& filename, const std::string& theKey, std::string &theValue, bool verbose = false);
void forceTailSlash(std::string &dr);
bool forceExtension(std::string &fn, const std::string &type);
bool fileExists(const std::string &fname);
......
......@@ -48,7 +48,7 @@ class MultiHist_t
format = tnm;
}
void setFileName(const std::string fn) {
void setFileName(const std::string& fn) {
size_t special = fn.find_first_of("?");
if (special != std::string::npos) {
std::string fn1 = fn.substr(0, special);
......@@ -71,7 +71,7 @@ class MultiHist_t
return fname;
}
void setComment(const std::string comm, const std::string lpfx = "") {
void setComment(const std::string& comm, const std::string& lpfx = "") {
comment = comm;
lstart = lpfx;
}
......@@ -189,7 +189,9 @@ public:
#ifdef MHIST_LMBUFF_ENABLE
virtual bool setupSwapper(int num = 1, int len = MHIST_LMBUFF_MINLEN) = 0;
#endif
virtual ~MultiHist_t() {}
virtual ~MultiHist_t() {
delete myIO;
}
void setEnable(bool val) {
enabled = val;
......@@ -197,13 +199,13 @@ public:
bool getEnable() const {
return (enabled ? true : false);
}
void setFileName(const std::string fn) {
void setFileName(const std::string& fn) {
myIO->setFileName(fn);
}
std::string getFileName() const {
return myIO->getFileName();
}
void setComment(const std::string comm, const std::string lpfx = "") {
void setComment(const std::string& comm, const std::string& lpfx = "") {
myIO->setComment(comm, lpfx);
}
std::string getComment() const {
......
......@@ -139,7 +139,7 @@ bool TextReader::BuildMetaLines()
return true;
}
void TextReader::PrintMetaLines(const std::string fname)
void TextReader::PrintMetaLines(const std::string& fname)
{
cout << " File " << fname << " decoded according to the following format:" << endl;
if(theKeys.size()) {
......@@ -149,7 +149,7 @@ void TextReader::PrintMetaLines(const std::string fname)
}
}
int TextReader::LocateKey(const std::string kname)
int TextReader::LocateKey(const std::string& kname)
{
for(size_t nk = 0; nk < theKeys.size(); nk++) {
if( stringEq(kname, theKeys[nk].keyword) )
......@@ -158,7 +158,7 @@ int TextReader::LocateKey(const std::string kname)
return -1;
}
int TextReader::LocateData(size_t whichKey, const std::string dname)
int TextReader::LocateData(size_t whichKey, const std::string& dname)
{
if( whichKey >= theKeys.size() )
return -1;
......@@ -205,14 +205,14 @@ int TextReader::DecodeLine(size_t whichKey, int occurrence)
return -2;
}
int TextReader::DecodeText(size_t whichKey, const std::string text)
int TextReader::DecodeText(size_t whichKey, const std::string& text)
{
if(whichKey >= theKeys.size() || text.size()==0 )
return 0;
return theKeys[whichKey].DecodeText(text);
}
int TextReader::KeyItem::LocateData(const std::string dname)
int TextReader::KeyItem::LocateData(const std::string& dname)
{
for(size_t nn = 0; nn<vdat.size(); nn++) {
if(vdat[nn].name == dname)
......@@ -221,7 +221,7 @@ int TextReader::KeyItem::LocateData(const std::string dname)
return -1;
}
int TextReader::KeyItem::DecodeText(const std::string text)
int TextReader::KeyItem::DecodeText(const std::string& text)
{
size_t found = 0;
string ltext = text;
......
......@@ -8,7 +8,7 @@ class TextReader
{
public:
struct DataItem {
DataItem(char type=0, const std::string name="") : dtype(type), name(name), ivalue(0), fvalue(0) {}
DataItem(char type=0, const std::string& name="") : dtype(type), name(name), ivalue(0), fvalue(0) {}
std::string name;
int dtype; // d f s
int ivalue;
......@@ -26,12 +26,12 @@ public:
bool GetData(size_t nn, double &rr) {if(nn>=vdat.size()) return false; rr= vdat[nn].fvalue; return true;}
bool GetData(size_t nn, std::string &rr) {if(nn>=vdat.size()) return false; rr= vdat[nn].svalue; return true;}
// get vdat by name
bool GetData(const std::string name, int &rr) {int nn=LocateData(name); if(nn<0) return false; rr= vdat[nn].ivalue; return true;}
bool GetData(const std::string name, float &rr) {int nn=LocateData(name); if(nn<0) return false; rr=float(vdat[nn].fvalue); return true;}
bool GetData(const std::string name, double &rr) {int nn=LocateData(name); if(nn<0) return false; rr= vdat[nn].fvalue; return true;}
bool GetData(const std::string name, std::string &rr) {int nn=LocateData(name); if(nn<0) return false; rr= vdat[nn].svalue; return true;}
int DecodeText(const std::string line);
int LocateData(const std::string vname);
bool GetData(const std::string& name, int &rr) {int nn=LocateData(name); if(nn<0) return false; rr= vdat[nn].ivalue; return true;}
bool GetData(const std::string& name, float &rr) {int nn=LocateData(name); if(nn<0) return false; rr=float(vdat[nn].fvalue); return true;}
bool GetData(const std::string& name, double &rr) {int nn=LocateData(name); if(nn<0) return false; rr= vdat[nn].fvalue; return true;}
bool GetData(const std::string& name, std::string &rr) {int nn=LocateData(name); if(nn<0) return false; rr= vdat[nn].svalue; return true;}
int DecodeText(const std::string& line);
int LocateData(const std::string& vname);
size_t NumVariables() {return vdat.size();}
void Reset() {keyword.clear(); format.clear(); vdat.clear();}
};
......@@ -48,11 +48,11 @@ public:
bool ImportFile(std::string setupFile, bool doMeta = true, bool verbose=false);
void FetchMetaLines();
bool BuildMetaLines();
void PrintMetaLines(const std::string fname);
int LocateKey(const std::string kname);
int LocateData(size_t whichKey, const std::string dname);
void PrintMetaLines(const std::string& fname);
int LocateKey(const std::string& kname);
int LocateData(size_t whichKey, const std::string& dname);
int DecodeLine(size_t whichKey, int occurrence = 0);
int DecodeText(size_t whichKey, const std::string text);
int DecodeText(size_t whichKey, const std::string& text);
int CountLines(size_t whichKey);
private:
std::vector<std::string> theLines;
......
......@@ -11,7 +11,7 @@ TstampFilter::TstampFilter()
}
TstampFilter::TstampFilter(std::string tstampFile, int tolerance, int id)
TstampFilter::TstampFilter(const std::string& tstampFile, int tolerance, int id)
{
Reset();
Initialize(tstampFile, tolerance, id);
......
......@@ -22,7 +22,7 @@ public:
//UInt_t fStats[1000];
TstampFilter();
TstampFilter(std::string tstampFile, int tolerance, int id = -1);
TstampFilter(const std::string& tstampFile, int tolerance, int id = -1);
virtual ~TstampFilter();
void Reset();
bool Initialize(std::string tstampFile, int tolerance, int id = -1);
......
......@@ -355,7 +355,7 @@ bool AncillaryFilterATCA::presortDante()
unsigned int tsampCC;
float fractCC;
mwd->MWtimingCFD(fTracesCC[iTR], tsampCC, fractCC);
if(tsampCC <= 0)
if(tsampCC == 0)
return false; // no trigger on CC
float tRefCC = tsampCC + fractCC;
......
#include "Converter.h"
bool Converter_t::Setup(std::string name, EModule type, UInt_t crate, UInt_t slot, UInt_t nchan)
bool Converter_t::Setup(const std::string& name, EModule type, UInt_t crate, UInt_t slot, UInt_t nchan)
{
Name = name;
Type = type;
......
......@@ -18,7 +18,7 @@ public:
if(Offset) delete [] Offset;
if(Gain) delete [] Gain;
}
bool Setup(std::string name, EModule type, UInt_t crate, UInt_t slot, UInt_t nchan);
bool Setup(const std::string& name, EModule type, UInt_t crate, UInt_t slot, UInt_t nchan);
void Clear() { if(NumChan) memset(Value, 0, NumChan*sizeof(Float_t)); }
bool SetValue(UInt_t chan, Float_t val) {
if(chan >= NumChan)
......
......@@ -2790,7 +2790,7 @@ bool PSAFilterGridSearch::WriteBasisVoxels()
return true;
}
bool PSAFilterGridSearch::WriteBasisFull(std::string ext)
bool PSAFilterGridSearch::WriteBasisFull(const std::string& ext)
{
#ifdef PSA_MULTIHIST
// Write the complete basis as a <short> spectrum. 2 mm packed. Normalization is 30000.
......@@ -2966,7 +2966,7 @@ bool PSAFilterGridSearch::WriteBasisSlopes()
return true;
}
bool PSAFilterGridSearch::WriteBasisSegAverage(float scale, std::string ext)
bool PSAFilterGridSearch::WriteBasisSegAverage(float scale, const std::string& ext)
{
const int totSamp = 60; // 56
const int offSamp = 8; // 0
......
......@@ -175,9 +175,9 @@ private:
float CalcChi2Residue(pointFull &PF);
float CalcChi2GridPts(int segNum, int pdNum, pointFull &PF);
bool WriteBasisVoxels();
bool WriteBasisFull(std::string ext);
bool WriteBasisFull(const std::string& ext);
bool WriteBasisSegments(int first, int last = -1);
bool WriteBasisSegAverage(float scale, std::string ext);
bool WriteBasisSegAverage(float scale, const std::string& ext);
bool WriteBasisSegSum();
bool WriteBasisSlopes();
bool WriteBasisPoint(pointPsa &pt, float scale, FILE *FP, int totSamp, int offSamp, int numSamp, int totSegs);
......
......@@ -2385,9 +2385,11 @@ restEnerCe(point **qq, int np)
void
testphotoL(clust *pcl)
{
return;
/*
double dist, xx;
int nn, iegam;
return;
if(pcl->npoints != 1) return;
nn = pcl->ppc[0]->ind;
......@@ -2405,17 +2407,20 @@ return;
// pcl->egamma *= recoil.gamma * (1. - recoil.beta * costhrec(pcl->ppc[0]) );
//}
}
*/
}
void
testpair1L(clust *pcl)
{
return;
/*
int npc, ii, jj, kk, j1, j2, j3, iene;
double eclust, epair, dpair, ej1, ej2, em0c2, dm0c2;
double dist;
char *pch, tch;
point **ppc, *ppt;
return;
npc = pcl->npoints;
if(npc < 3) return;
......@@ -2487,6 +2492,7 @@ OK:
// pcl->egamma *= recoil.gamma * (1. - recoil.beta * costhrec(pcl->ppc[0]) );
//}
return;
*/
}
void
......
......@@ -86,7 +86,6 @@ int read_data(uint32_t bytes_to_get) {
int send_data(uint32_t bytes_to_send) {
int i;
int bytes_sent;
//printf ( "Sending %d bytes...\n", bytes_to_send);
......@@ -162,16 +161,11 @@ void reset_connection() {
int main ( int argc, char *argv[] ) {
struct timeval tv;
fd_set readset;
int to = 5000; //select timeout in milliseconds
int iof = -1;
int i;
int result;
int bytes_read;
int bytes_to_send;
uint32_t bytes_to_get = 0;
int keep_connection_alive = 1;
FILE *fp;
if (start_tcp_client() < 0) {
......@@ -180,7 +174,7 @@ int main ( int argc, char *argv[] ) {
fp = fopen("aa_0.dat", "rb");
while (keep_connection_alive) {
while (true) {
//FD_ZERO(&readset);
//FD_SET(sockfd, &readset);
// Initialize time out struct
......
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