can you help in this code please !
the attached file.txt (can be readed by Notepad or by Atom contain a result of spectrometer, (Count).
the file only show the count. the channels range from 0:8192.
how can i coded the calibration process for energy.
#include "TGraph.h"
#include "TPad.h"
#include <string>
#include <fstream>
#include <cstdlib>
TGraph *mca(const char *file = "file.mca") { // "MCA8000D PMCA SPECTRUM"
TGraph *g = new TGraph();
g->SetTitle("MCA8000D PMCA SPECTRUM;channel number;number of counts");
if ((!file) || (!file[0])) return g; // just a precaution
std::string line;
std::ifstream ifs(file, std::ifstream::in);
while (std::getline(ifs, line) && (line.find("<<DATA>>") != 0)) continue; // wait for "<<DATA>>"
while (std::getline(ifs, line)) {
if (line.find("<<END>>") == 0) break; // wait for "<<END>>"
double x = g->GetN(); // raw "channel number"
// x = 10. * x + 100.; // here you can implement some energy calibration formula
double y = atof(line.c_str()); // raw "number of counts"
// y = y / 100.; // here you can implement some count rate scaling
g->SetPoint(g->GetN(), x, y);
}
ifs.close();
if (g->GetN() > 0) g->Draw("APL");
return g;
}
1 Like
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.