Hi there!
I ask for your help to be able to include a library written by me in a root file
This is dataclass.h
#define DATACLASS
#include<cmath>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
class Dataset
{
public:
vector<double> asse_x;
vector<double> asse_y;
string description;
Dataset();
Dataset(string folder, string fname) { lettura(folder, fname); };
~Dataset();
int find_maximum(vector<double> &vec)
{
return max_element(vec.begin(), vec.end()) - vec.begin();
};
void erase_and_take(int del_sx, int del_dx,int take, vector<double> &asse_y_temp)
{
int max_y1;
int max_y2;
int max_y;
for (int i = 0; i < abs(del_sx); i++)
{
max_y1 = find_maximum(asse_y_temp);
asse_y_temp.erase(asse_y_temp.begin() + (max_y1 - 1));
}
for (int i = 0; i < abs(del_dx); i++)
{
max_y2 = find_maximum(asse_y_temp);
asse_y_temp.erase(asse_y_temp.begin() + (max_y2 + 1));
}
max_y = find_maximum(asse_y_temp);
asse_y_temp.erase(asse_y_temp.begin(),asse_y_temp.begin()+max_y-take);
max_y=find_maximum(asse_y_temp);
asse_y_temp.erase(asse_y_temp.begin()+max_y+take,asse_y_temp.begin()+asse_y_temp.size());
asse_y_temp.erase(asse_y_temp.begin() + max_y);
};
};
(The library is 100% functional because i tested it.)
And this is a simple .cxx file that request dataclass.h
#include "TH1.h"
#include "TMath.h"
#include "TF1.h"
#include "TLegend.h"
#include "TCanvas.h"
#include <fstream>
#include "TFitResult.h"
#include "TMatrixD.h"
#include "../Programmi/dataclass.h"
using namespace std;
void fit_for_max()
{
TCanvas *c1 = new TCanvas("c1", "Canvas", 200, 10, 1000, 700);
c1->SetGrid();
c1->SetFillColor(0);
Dataset *diff;
vector<double> asse_x_temp;
vector<double> asse_y_temp;
diff->lettura("../Dati", "/1f_10p_sgnbkg.xls");
diff->erase_and_take(10, 10, 8, asse_y_temp);
TVectorD root_asse_y_temp(asse_y_temp.size(), asse_y_temp.data());
root_asse_y_temp.Print();
vector<double> asse_x;
for (int i =0 ; i<16 ;i++){
asse_x[i]=i;
}
TVectorD root_asse_x(asse_x.size(), asse_x.data());
TGraph *grafico= new TGraph(root_asse_x, root_asse_y_temp);
grafico->Draw();
}
Root gives me this error when I run .x fit_for_max.cxx:
IncrementalExecutor::executeFunction: symbol āZStL19__constant_string_pIcEbPKTā unresolved while linking [cling interface function]!
You are probably missing the definition of bool std::__constant_string_p(char const*)
Maybe you need to load the corresponding shared library?
Is it possible to include a proprietary library in this way? I couldnāt interpret the root error. Thank you very much for your help.
Have a nice day .