ROOT Version: 6.20/00
Platform: ubuntu 20.04
Compiler: g++ 9.3.0
Hi,
In my macro, I am writing a function that should copy the content of one branch to the histogram.
Part of my code that involved in this:
#include <TFile.h>
#include <TRandom3.h>
#include <TTree.h>
#include <TStopwatch.h>
#include <TH1.h>
#include <TF1.h>
#include <TCanvas.h>
#include <TCut.h>
#include <TStyle.h>
#include <TPaveStats.h>
#include <TMath.h>
#include <string.h>
using namespace std;
vector<double> FindROI(const TFile* fTracks_ideal, const double& mu_potential){
vector<double> roi;
auto t_ana_uncut = fTracks_ideal->Get<TTree>("AnalysisTree");
TH1F *hspectrum_uncut = new TH1F("hspectrum_uncut", "Energy spectrum of a reconstructed events without cut strips.", 100,1800,2620);
//filling the histogram
t_ana_uncut->Project("hspectrum_uncut", "tckAna_trackEnergy");
~~~
The rest of my code
~~~
return roi;
}
void cut_ROI_Xe136()
{
Double_t xpeak = 2420.;
TFile *f_tracks2 = new TFile("my_file.root");
vector<double> ROI_vec = FindROI(f_tracks2, xpeak);
return 0;
}
When I execute my code I receive such an error:
cut_ROI_Xe136.C:55:39: error: no matching member function for call to 'Get'
auto t_ana_uncut = fTracks_ideal->Get<TTree>("AnalysisTree");
~~~~~~~~~~~~~~~^~~~~~~~~~
note: candidate function not viable: no known conversion from 'const TFile' to 'TDirectoryFile' for object argument
template <class T> inline T* Get(const char* namecycle)
^
Which is confusing as if I am just adding a line TTree *t_ana_uncut = (TTree*)f_tracks2->Get("AnalysisTree");
in my main macro after opening my file and not using FindROI function, everything is working fine.
Do you have an idea what am I doing wrong?
Thanks in advance.