Hello!
I know this might not be linked necessarily to a root problem, but I have issues implementing this.
I am trying to check if there is an element in the array of X values from a TGraph. I do this with begin/end functions.
#include <algorithm> // for std::find
#include <iterator> // for std::begin, std::end
#include <iostream>
using namespace std;
int t()
{
TFile *IPRfile = new TFile(64080.IPR.root);
TGraphErrors* g = (TGraphErrors*)IPRfile->Get("IPRchargeTelType0");
const int n_iprg = g->GetN();
Double_t * arrx = g->GetX();
//here I tried retrieving the content of the array X into a type double
Double_t arr[n_iprg];
for (i=0; i<n_iprg; i++){
arr[i] = arrx[i];
}
bool exists = std::find(std::begin(arr), std::end(arr), target) != std::end(arr);
if (exists) {
std::cout << "Element found";
} else {
std::cout << "Element not found";
}
return 0;
}
But this gives me an error (error: no matching function for call to ‘end’), which is related to the type of variable that is being passed to the function. My question is: how can I get the array of X values from a TGraph in type double, so that I can pass it to this function?
Passing a simple double like double arr2[4] = {6, 7, 8.7, 4.5}; works fine.
64080.IPR.root (112.6 KB)