Hello, I replicated the results in this paper and now I want to compare my results to theirs, I got their data from this website.
The problem arises when I try to load their histograms, every time I try to apply any method to them like ->Draw() I get segmentation violation.
I suppose that the problem is loading the files, they have this structure: a root file with Table of class TDirectoryFile and inside that Table are the histograms.
I have tried GetObject, FindObject, Lists, Directories, I have tried using the constructors in all the ways I can think of, am at the end of my rope here.
This iteration of my code (apparently) fails when I try to apply a method to the histogram:
Holly shit!, thanks you so much!, I’ve been hours workign on this I never imagined a freaking space was the solution… but all that matters is there is a solution. Thank you and Linev so much
Edit: I fixed it, sorry, sorry, it was a very silly mistake. It should have been Table 2 when talking about ptz variables
Terminal says “Undeclared Identifier”. But there’s something that worries me more.
I starting adding things to the code now that it works, and there is no specific line that causes a segmentation violation, and it is a line virtually identical to the ones before.
I put a “#######################” before that line
#include <iostream>
using namespace std;
#include "Pythia8/Pythia.h"
#include "TROOT.h"
#include "TCanvas.h"
#include "TH1F.h"
#include "TF1.h"
#include "TFile.h"
#include "TList.h"
#include "TDirectoryFile.h"
#include "TGraphAsymmErrors.h"
using namespace Pythia8;
int main()
{
//obtener datos profesionales
TFile* proData1 = TFile::Open("/Users/Fer/Documents/Pythia/myhists/HEPData-ins1395253-v1-Table1.root");
TFile* proData2 = TFile::Open("/Users/Fer/Documents/Pythia/myhists/HEPData-ins1395253-v1-Table2.root");
//crear los histogramas con los datos profesionales
TH1F* proHist_eta_inel0= (TH1F*)proData1->Get("Table 1/Hist1D_y1");
TH1F* proHist_eta_inel= (TH1F*)proData1->Get("Table 1/Hist1D_y1");
//No confundir, la variable se llama igual pero la sacamos de proData2
TH1F* proHist_ptz_inel0= (TH1F*)proData2->Get("Table 1/Hist1D_y1");
//Obtenemos los datos de los histogramas para inicializar nuestros histogramas
int proBinNumber_eta_inel0 = proHist_eta_inel0->GetNbinsX();
int proBinNumber_eta_inel = proHist_eta_inel->GetNbinsX();
//####################### If the next line is commented there will be no segmentation violation
int proBinNumber_ptz_inel0 = proHist_ptz_inel0->GetNbinsX();
cout<<proBinNumber_eta_inel0<<endl;
return 0;
}