change: class constructor or destructor

This commit is contained in:
liuyihui 2022-07-06 23:47:50 +08:00
parent 9e63b34088
commit 1e2b51abe3
8 changed files with 24 additions and 47 deletions

15
include/BindHandler.h Normal file
View File

@ -0,0 +1,15 @@
#pragma once
#ifndef bind_handler_h
#define bind_handler_h
#include "GaussFit.h"
#include "FileHandler.h"
class BindHandler {
public:
BindHandler();
~BindHandler() {};
};
#endif

View File

@ -3,17 +3,16 @@
#ifndef file_handler_h
#define file_handler_h
#include "GaussFit.h"
#include <TH1F.h>
#include "utils.h"
using std::string;
using std::to_string;
class FileHandler {
public:
FileHandler();
FileHandler() {};
FileHandler(string, int n_ = 6, int thMin_ = 800, int thMax_ = 4000);
~FileHandler();
~FileHandler() {};
public:
int n = 6, m = 8;
@ -22,14 +21,9 @@ public:
std::vector<int> adcValue[6][8][2];
public:
double getADC(TH1F hist);
void readData();
void save();
void save(string);
};
FileHandler::FileHandler() {}
FileHandler::FileHandler(string file_, int n_, int thMin_, int thMax_) {
file = file_;
n = n_;
@ -37,32 +31,6 @@ FileHandler::FileHandler(string file_, int n_, int thMin_, int thMax_) {
thMax = thMax_;
}
FileHandler::~FileHandler() {}
double FileHandler::getADC(TH1F hist) {
int n, cnt = 0;
double *parma = new double[3];
GaussFit GF = GaussFit();
for (int k = 10; k < CHANNEL_NUMBER; k++) {
n = hist.GetBinContent(k);
if (n == 0) continue;
GF.addData(hist.GetBinCenter(k), n);
}
parma = GF.fit();
if (DEBUG) GF.draw();
return parma[1];
}
void FileHandler::readData() { readROOTData(file.c_str(), adcValue, n, m, thMin, thMax); }
void FileHandler::save() {
string path = rmString(file, ".root") + ".csv";
save(path);
}
void FileHandler::save(string path) {
std::ofstream ofs(path);
}
#endif

View File

@ -27,8 +27,8 @@ double* GaussianJacobian(double x, double* p) {
class GaussFit {
public:
GaussFit();
~GaussFit();
GaussFit() {};
~GaussFit() {};
public:
void addData(double x, double y);
@ -42,10 +42,6 @@ public:
std::vector<Eigen::Vector2d> data;
};
GaussFit::GaussFit() {}
GaussFit::~GaussFit() {}
void GaussFit::addData(double x, double y) { data.push_back(Eigen::Vector2d(x, y)); }
double* GaussFit::fit(int type_) {

Binary file not shown.

Binary file not shown.

View File

@ -18,7 +18,7 @@ public:
SigmaClip(double sigma = 3, int maxiters = 5,
double (*cenF)(std::vector<Eigen::Vector2d> data) = nullptr,
double (*stdF)(std::vector<Eigen::Vector2d> data) = nullptr);
~SigmaClip();
~SigmaClip() {};
std::vector<Eigen::Vector2d> clip(std::vector<Eigen::Vector2d> data);
std::vector<Eigen::Vector2d> clipN(std::vector<Eigen::Vector2d> data);
@ -35,8 +35,6 @@ SigmaClip::SigmaClip(double sigma_, int maxiters_,
stdF = stdF_ == nullptr ? dataStd2D : stdF_;
}
SigmaClip::~SigmaClip() {}
void SigmaClip::computeBound(std::vector<Eigen::Vector2d> data) {
double std = (*stdF)(data);
double mean = (*cenF)(data);

View File

@ -15,7 +15,7 @@ using std::vector;
class CsvReader {
public:
CsvReader(string);
~CsvReader();
~CsvReader() {};
public:
string file;
@ -29,8 +29,6 @@ public:
CsvReader::CsvReader(string file_) { file = file_; }
CsvReader::~CsvReader() {}
int CsvReader::rows() { return strArray.size(); }
void CsvReader::readData() {

View File

@ -1,5 +1,7 @@
#include "BindHandler.h"
#include "CsvReader.h"
#include "FileHandler.h"
#include "utils.h"
#include <iostream>