Q3D-Calibration/include/FileHandler.h

69 lines
1.3 KiB
C
Raw Normal View History

#pragma once
#ifndef file_handler_h
#define file_handler_h
#include "GaussFit.h"
#include <TH1F.h>
using std::string;
using std::to_string;
class FileHandler {
public:
FileHandler();
FileHandler(string, int n_ = 6, int thMin_ = 800, int thMax_ = 4000);
~FileHandler();
public:
int n = 6, m = 8;
int thMin, thMax, pX;
string file;
2022-07-06 23:42:52 +08:00
std::vector<int> adcValue[6][8][2];
public:
double getADC(TH1F hist);
2022-07-06 23:42:52 +08:00
void readData();
void save();
void save(string);
};
FileHandler::FileHandler() {}
FileHandler::FileHandler(string file_, int n_, int thMin_, int thMax_) {
file = file_;
n = n_;
thMin = thMin_;
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];
}
2022-07-06 23:42:52 +08:00
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