Overlap root files

Hi everyone,

I have a problem with a macro.
I want to open two root files and fill them in one histo.

But it gives this error:

Error: illegal pointer to class object Get(“h_JetEta”) 0x0 58 JetPlot.C:55:

also this is ss:

here is my macro:

could anyone tell me what is wrong with it?

Thank you so much.

In the file listing there is no histogram h_JetEta

could you explain it more please ?
I am new on root…
@couet

you try to get the histogram h_JetEta … and it seems you do the listing of the file supposing containing it before doing the Get … but in the listing there is not just name … just look at the screen dump you sent…

i am sorry.
This is my first experience with the overlap method so i have no idea how can i solve the problem.
I understood your sentence but still cant find the problem.
Because i am really stranger to listing the file, get method etc.
@couet

i changed the order:

TFile *fRecHitNZS=new TFile(cFileNameNZS);
EventProfile->cd();
TH1F E1_NZS=(TH1F)gDirectory->Get(“h_JetEta”)->Clone(“E1_NZS”);
gDirectory->ls();

now, there is no KEY: TprocessID…
Only gives illegal pointer to class object…

I do not have the root file you are trying to read… so it is hard to help further …
Your macro looks quite complex and is not at the beginner level you claimed to be.
So it might be that you took it from a colleague ? … if so you might ask her/him to help you ?

i see.
yes my colleague gave me but he wants me to solve. So, i cannot ask him for now.
I want to compare pythia6 and pythia8 data’s for ATLAS detector.
is there a simpler method to open two root files and get jet-eta in one histo ?

Can you try:

TFile f("Wplus1Jet_PYTHIA6_ATLAS_cteq6l1_delphes_events_all.root");
f.ls()

and post the output you get ?

I think warnings because of delphes library. but it’s ok.
and there is no error with your f.ls() method.

f.ls() lists the contain of the file. As you see it does not show any histogram nor any subdirectories.
That’s why the Get(0 method is not able to find the histogram ‘h_JetEta’ (it is not listed) … So either your file is somehow corrupted or you do not have the right file. I guess you should go back to your colleague and ask him …

Okey thank yo so much.
I will ask him.

Hi again @couet

I took your time too much. I am really sorry.
I have another question.

Today i tried to list this file with f.ls(); method.
Not in macro, on root.
And as you said i saw all directories under Delphes.

also, I checked it with TBrowser.

As you see the file is ok i think.

So my new questions is:

when i try to access with::
f.cd(“Delphes”);
it says, “unknown directory Delphes”

What is wrong with it.
Should i write something else?
Why i cannot go to Delphes Directory.
So probably the problem with the macro is same.
if i solve it on root probably i can also solve macro.

Thank you so much.

Delphes is not a directory . it is a TTree. what you see are the variables in the tree. try for instance

Delphes->Draw("Particle");

I guess your colleague can instruct you which variables in this tree are interesting for your study

Thank you so much @couet
I solved it.
It’s about the root file as you said.
First, i used a macro which stores all histograms in a root file.
Then, i used this root file.
Thank you again.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.