Thanks to the replies
I will make a better description of the problem.
The code that i have now is:
void MakeHisto(){
std::unique_ptr<TFile> file( TFile::Open("myrootfileroot") );
if (!file || file->IsZombie()){
std::cerr << "Error opening file" << endl;
exit(-1);
}
file->ls();
gDirectory->cd("path/to/the/folder/that/contein/theTH1Pthistogram/");
file->ls();
TH1 *h;
h = static_cast<TH1*>(file->Get("Pt"));
if (!h) printf("No TH1 with such name exists in the file!\n");
h->Draw();
}
and the output is
5. Listing inside of subfolders.
Declare the h hsito as TH1
Copy the histogram!
No TH1 with such name exists in the file!
Generating stack trace...
0x00007f568ef985b4 in <unknown function>
0x00007f568ef98053 in <unknown function>
0x00007f5689a59698 in <unknown> from /snap/root-framework/412/usr/local/lib/libCling.so
0x00007f56899c2557 in <unknown> from /snap/root-framework/412/usr/local/lib/libCling.so
0x00007f56899c2cc9 in <unknown> from /snap/root-framework/412/usr/local/lib/libCling.so
0x00007f5689ad0ea5 in <unknown> from /snap/root-framework/412/usr/local/lib/libCling.so
0x00007f5689adf4b5 in <unknown> from /snap/root-framework/412/usr/local/lib/libCling.so
0x00007f5689ae08e6 in <unknown> from /snap/root-framework/412/usr/local/lib/libCling.so
0x00007f5689ac9e39 in <unknown> from /snap/root-framework/412/usr/local/lib/libCling.so
0x00007f56897d5fa9 in <unknown> from /snap/root-framework/412/usr/local/lib/libCling.so
0x00007f56897d6a3f in TCling::ProcessLine(char const*, TInterpreter::EErrorCode*) + 0x8e3 from /snap/root-framework/412/usr/local/lib/libCling.so
0x00007f56897da5ae in TCling::ProcessLineSynch(char const*, TInterpreter::EErrorCode*) + 0xa6 from /snap/root-framework/412/usr/local/lib/libCling.so
0x00007f568f2904a2 in TApplication::ExecuteFile(char const*, int*, bool) at TApplication.cxx:? from /snap/root-framework/412/usr/local/lib/libCore.so
0x00007f568f28fc00 in TApplication::ProcessFile(char const*, int*, bool) + 0x34 from /snap/root-framework/412/usr/local/lib/libCore.so
0x00007f568f28f9eb in TApplication::ProcessLine(char const*, bool, int*) + 0xda9 from /snap/root-framework/412/usr/local/lib/libCore.so
0x00007f568f64e8fb in TRint::ProcessLineNr(char const*, char const*, int*) + 0x24d from /snap/root-framework/412/usr/local/lib/libRint.so
0x00007f568f64d10a in TRint::Run(bool) + 0x6b2 from /snap/root-framework/412/usr/local/lib/libRint.so
0x00005618841db241 in main + 0x78 from /snap/root-framework/412/usr/local/bin/root.exe
0x00007f568ebcb0b3 in __libc_start_main + 0xf3 from /lib/x86_64-linux-gnu/libc.so.6
0x00005618841db10e in _start + 0x2e from /snap/root-framework/412/usr/local/bin/root.exe
Error in <HandleInterpreterException>: Trying to dereference null pointer or trying to call routine taking non-null arguments.
Execution of your code was aborted.
In file included from input_line_8:1:
/home/sergio/Documents/QualificationTask/Programming/Macros/MakeHisto.cpp:97:5: warning: null passed to a callee that requires a non-null argument [-Wnonnull]
h->Draw();
^