f.ls() showed all my histograms which I created. I’m creating them in the very beginning, before opening another file, so gDirectory->GetName() gives me name of my output file.
Also I checked where they belong to while filling and it’s also my output file.
Thank you so much for your reply! I’ll try to check the stuff and write a reproduce also this weekend. Although on a first sight, it’s not the first and the second issue because I’ve already checked these.
Hi Yuliia,
to be clear:
You find the histograms on the file but they are empty, correct?
This means you write them before filling or you clear them again
before writing.
What gives hist->Print() for the histos on the file?
What root version are you using, did you change from 5 -> 6
I ask because with Root5 ( CINT) all was on heap
You say you changed host country?
Otto
Recently I tried Print() method right after writing my file in the code and it gives me non-zero number of entries as it should be, but when I opened my file in ROOT both on server (version 5.34/38) or on my own computer (version 6.16/00) the same method gives 0. But if I comment the line with opening another file everything is ok.
Also I tried to create a histogram on the heap, result was the same.
I’m on holidays in Ukraine now, but previously I was in Poland when everything began.
I tried to write a reproduce (I’ve never done this before), but I can’t even compile it although the structure of code is like in my original code. I will really appreciate any help with it. It can be accessed via
/afs/cern.ch/user/y/yubalkov/Analysis/test.cc
I guess the second file, which is opened during the operating, can be whatever you like, but I specified the one I’ve tried to work with.
Hi Yullia,
I tried your test.cc and after some mods it works as
expected with root_6.18.00 (I dont expect a diff to 6.16.00),
histos are filled on the output file.
mods: make it a complete macro:
void test()
{
...
}
Changed filling, TH2 has not FillRandom(“gaus”).
I cannot run your DataAnalysis.cc , includes missing,
it is a main(), so Makefile needed and too lengthy
One thing I see:
in line 255
To run DataAnalysis.cc you need to set environment of SHINE experiment, and I don’t know if external users can do it. I just wanted to show that structure of code is exactly the same. The feature with tree was token from ROOT forum, so I assumed that it’ll work.
I tried to run corrected file and here what I’m talking about:
root [0] .L test.cc
root [1] test()
Warning in <TClass::TClass>: no dictionary for class ROOT::TIOFeatures is available
Error in <TClass::New>: cannot create object of class TH2
Error in <TClass::New>: cannot create object of class TH1
run-039390x000_.root:/
TFile** run-039390x000_.root
TFile* run-039390x000_.root
KEY: TTree t;1 tree
KEY: TH1F hADCS1sum;1 S1 ADC amplitude
KEY: TH1F hADCAdet;1 A_det ADC amplitude
KEY: TH1F hTDCS113;1 S11+S13 TDC amplitude
KEY: TH1F hTDCS124;1 S12+S14 TDC amplitude
KEY: TH1F hTDCS1sum;1 S1 TDC amplitude (sum)
KEY: TH1F hTDCS1diff;1 S1 TDC amplitude (diff)
KEY: TH1F hTDCAdet;1 A_det TDC amplitude
KEY: TH2F hADCcorr;1 S1 ADC amplitude vs A_det ADC amplitude
KEY: TH2F hTDCcorr;1 S1 TDC amplitude vs A_det TDC amplitude
KEY: TH2F hADCS1TDCall;1 S1 ADC amplitude vs overall TDC amplitude
test.root:/
TH1.Print Name = histo1, Entries= 5000, Total sum= 4978
TH1.Print Name = histo2, Entries= 5000, Total sum= 3782
TFile** test.root
TFile* test.root
OBJ: TH2D histo1 : 0 at: 0x141b8a0
OBJ: TH2D histo2 : 0 at: 0x141bf20
TH1.Print Name = histo1, Entries= 5000, Total sum= 4978
TH1.Print Name = histo2, Entries= 5000, Total sum= 3782
root [2] TFile *_file0 = TFile::Open("test.root")
root [3] histo1->Print()
TH1.Print Name = histo1, Entries= 0, Total sum= 0 <-----!!!
Do I understand correct that you don’t get such a result?
Hi Yullia,
you are obviously running root version 5 but your run-039390x000_.root
was made with: fVersion 61600 File format version.
Therefore you get:
Warning in <TClass::TClass>: no dictionary for class ROOT::TIOFeatures is available
If I run test.cc with 5.34.36 I get the same b a d result as you.
With 6.16.00 I dont get the Warnings, Errors and the histos
are as expected on the output file.
It seems that it’s a problem: in internal SHINE environment only 5.34 version is available for compilation, and as you wrote before all .root files were created with 6.16 version. It’s a pity, but the only solution I see here is to create all these files with 5.34, because it’ll be a problem now to switch all the environment to 6.16. I guess it’s impossible to make these versions compatible by ROOT itself.
Thank you so much for your time and help! If you see another solution, please, write it here.
@axel@pcanal It seems that opening a file produced by ROOT 6.14/06 or 6.16/00 (files from ROOT 6.12/06 and earlier releases and also ROOT 6.18/00 seem fine) in ROOT 5 is sufficient to screw the old ROOT 5 so that it is unable to properly save its newly created histograms in its newly created file (e.g. in ROOT 5.34/36 or the current “v5-34-00-patches” branch).
Here’s a simple standalone trial.cxx (987 Bytes) macro which reproduces this problem (it needs the standard “hsimple.root” file from ROOT 6.14/06 or 6.16/00).