GSI Forum
GSI Helmholtzzentrum für Schwerionenforschung

Home » PANDA » PandaRoot » Analysis » Differences between Histo and Ntuple
Differences between Histo and Ntuple [message #16539] Wed, 07 May 2014 16:11 Go to next message
Mamen is currently offline  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 #16541 is a reply to message #16539] Wed, 07 May 2014 17:37 Go to previous messageGo to next message
StefanoSpataro is currently offline  StefanoSpataro
Messages: 2736
Registered: June 2005
Location: Torino
first-grade participant

From: *to.infn.it
In theory the ntuple Write should come before the file Save. Try to invert them,
Re: Differences between Histo and Ntuple [message #16542 is a reply to message #16539] Wed, 07 May 2014 19:29 Go to previous messageGo to next message
Klaus Götzen is currently offline  Klaus Götzen
Messages: 293
Registered: June 2006
Location: GSI
first-grade participant
From: *adsl.alicedsl.de
Hi Mamen,


are the entries at -1000 or at -999? Because you see, that the default value of the column is -999.0:
ntp->Column("eppx",  (Float_t) eplus[j]->Px(), -999.0f);

In case you call ntp->DumpData() without filling in a value after the last DumpData, the default value will be stored. So you might check whether sometimes (perhaps somewhere else) ntp->DumpData() is called (accidently).


Best,
Klaus

Re: Differences between Histo and Ntuple [message #16547 is a reply to message #16539] Thu, 08 May 2014 17:25 Go to previous message
Mamen is currently offline  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
Previous Topic: Ideal PID in full simulation
Next Topic: hyperon fast simualtions
Goto Forum:
  


Current Time: Sun Apr 21 10:38:18 CEST 2024

Total time taken to generate the page: 0.01117 seconds