Differences between Histo and Ntuple [message #16539] |
Wed, 07 May 2014 16:11 |
Mamen
Messages: 55 Registered: January 2009 Location: Mainz
|
continuous participant |
From: *kph.uni-mainz.de
|
|
Dear all,
I'm trying to learn how to save data into a root file using both a histogram or an ntuple.
For the histogram I get reasonable plots, but for the ntuple I get strange events/particles plotted at -1000.
My code looks like follows:
TH1F *eppx = new TH1F ("eppx", "eppx (All)", 200, -2000, 5000.);
(.../...)
RhoTuple *ntp = new RhoTuple("RecoTuple","Reco_analysis");
(.../...)
PndAnalysis* theAnalysis = new PndAnalysis();
if (nevts==0) nevts= theAnalysis->GetEntries();
// *** RhoCandLists for the analysis
RhoCandList eplus;
(.../...)
while (theAnalysis->GetEvent() && i++<nevts)
{
if ((i%100)==0) cout<<"evt " << i << endl;
// *** Select with no PID info ('All'); type and mass are set
theAnalysis->FillList(chrg, "Charged");
theAnalysis->FillList(eplus, "ElectronAllPlus");
(.../...)
for (j=0;j<eplus.GetLength();++j)
{
eppx->Fill(eplus[j]->Px());
ntp->Column("eppx", (Float_t) eplus[j]->Px(), -999.0f);
ntp->DumpData();
}
(.../...)
}
out->cd();
eppx->Write();
out->Save();
ntp->GetInternalTree()->Write();
out->Close();
However, I get strange results when I open the output rootfile (see uploaded files).
Am I doing something wrong? Does somebody know where these events at -1000 in the ntuple saved data come from?
Thanks a lot in advance!
Best regards,
Mamen
|
|
|
|
|
Re: Differences between Histo and Ntuple [message #16547 is a reply to message #16539] |
Thu, 08 May 2014 17:25 |
Mamen
Messages: 55 Registered: January 2009 Location: Mainz
|
continuous participant |
From: *kph.uni-mainz.de
|
|
Hi again,
Thanks to both of you... after some time spent today I found out that this is not a bug... As Klaus said, it corresponds to the default value... So for instance, if I make a loop over the positive-candidates, and another over the negative-candidates and store info from both loops in an ntuple (for example px_pos and px_neg), it can be that for some common event-number, there is no negative entry for the corresponding positive entry, then the default value is filled in the negative-information branch (evt=X; px_pos=Value1; px_neg=-999.0(default_value)).
This bugs me a bit, because afterwards I would need to apply an extra cut "var>-999" to all plots... Is there any way to avoid that? I don't remember a behavior like that in the old Babar-like framework...
Thanks again for your help!
Cheers,
Mamen
|
|
|