Hello Eduard,
I think you are complete right.
A delete histo; directly fails… so I am trying to set a different histo each iteration.
Thanks all again.
Cheers,
JOrdi
On Sep 8, 2011, at 4:43 PM, Eduard Avetisyan wrote:
>
>
> Hi Jordi,
>
> Your problem is that the histogram actually doesn't get overwritten in the
> subsequent calls. In your script, you first draw QCDnorm_corr_mu in
> histogram named "histo", and then you put the QCDnorm_corr_mu_btag into
> the SAME histogram. It's true, the contents is overwritten, but the
> histogram limits are not adjusted to the new variable. It doesn't happen
> if you wouldn't indicate the histogram name and use the default "htemp"
> which has the corresponding flag of resetting also the axis with the new
> data being filled.
>
> In short - if you would try in your interactive test the following
> sequence:
>
> root [1] HangingTree->Draw("QCDnorm_corr_mu>>histo")
> root [2] histo->GetMean()
> root [1] HangingTree->Draw("QCDnorm_corr_mu_btag>>histo")
> root [2] histo->GetMean()
>
> you would see the same results as your script produces.
> If you want CORRECT values for the mean, either use different names for
> the histograms, or take care to actually delete "histo" between fills.
>
> Hope this helps,
>
> Eduard
>
>
> On Thu, 8 Sep 2011, Jordi Nadal wrote:
>
>>> Hi Jordi,
>>>
>>> I am not sure about your issue as I don't know what exactly you are
>>> trying to achieve. However after simplifying your example macro I
>>> found two errors:
>>>
>>> {
>>> int N = 2;
>>> TString parnames[N] = { "QCDnorm_corr_mu", "QCDnorm_corr_mu_btag"};
>>>
>>>
>>> TFile *file = TFile::Open("PSE/JO_muon_PSE_RbFree/sumRootFile.root");
>>> TTree* HangingTree = (TTree*) file->Get("HangingTree");
>>>
>>> for(int i=0; i<N;i++){
>>> TString raw = parnames[i];
>>> // here the histograms get overwritten by subsequent calls to Draw()
>>> HangingTree->Draw(raw+">>histo");
>>> // this line does multiple declaration of h as the loop proceeds
>>> // this is not correct C++ but might be forgivable in CINT, not sure
>>> TH1D *h = (TH1D*) gROOT->FindObject("histo");
>>> std::cout << raw << " " << h->GetMean() << std::endl;
>>> }
>>> }
>>>
>>> I hope this helps.
>>>
>>> --
>>> Suvayu
>>>
>>> Open source is the future. It sets us free.
This archive was generated by hypermail 2.2.0 : Thu Sep 08 2011 - 23:50:01 CEST