Hello I am trying to fill a histogram in what I believe is a very simple way, using selectors, my Analyze.C file:
#define Analyze_cxx
#include "Analyze.h"
#include <TH2.h>
#include <TStyle.h>
//********** Definition Section ************
TH1* chi2Hist = NULL;
void Analyze::Begin(TTree * /*tree*/)
{
TString option = GetOption();
chi2Hist = new TH1D("chi2", "Histogram of Chi2", 100, 0, 20);
//********* Initialization section *********
}
void Analyze::SlaveBegin(TTree * /*tree*/) {}
Bool_t Analyze::Process(Long64_t entry)
{
//********* Loop Section *********
tree1->GetEntry(entry);
chi2Hist->Fill(chi2);
return kTRUE;
}
void Analyze::SlaveTerminate(){}
void Analyze::Terminate()
{
chi2Hist->Draw();
//********* Wrap-up section ********
}
The header was generated automatically and I did not touch it.
I then run:
TFile myFile(“experiment.root”)
tree1->Process(“Analyze.C”)
But I get the error:
error: no matching member function for call to 'Fill'
chi2Hist->Fill(chi2);
~~~~~~~~~~^~~~
/opt/local/libexec/root6/include/root/TH1.h:220:21: note: candidate function not viable: no known conversion from
'TTreeReaderValue<Float_t>' to 'Double_t' (aka 'double') for 1st argument
virtual Int_t Fill(Double_t x);
^
/opt/local/libexec/root6/include/root/TH1.h:221:21: note: candidate function not viable: requires 2 arguments, but 1 was provided
virtual Int_t Fill(Double_t x, Double_t w);
^
/opt/local/libexec/root6/include/root/TH1.h:222:21: note: candidate function not viable: requires 2 arguments, but 1 was provided
virtual Int_t Fill(const char *name, Double_t w);
So it seems that the member function of TH1, Fill(), only takes doubles as arguments. Is it correct that I should need to convert from TTreeReaderValue<Float_t> to Double_t manually somehow? If so, how?