Re: How to get an Histogram ?

From: Philippe Canal <pcanal_at_fnal.gov>
Date: Thu, 8 Sep 2011 09:40:39 -0500


Hi Jordi,

 > than looking at it in the root file.

What do you mean? What steps are you taking in that case?

Philippe.

On 9/8/11 8:46 AM, Jordi Nadal wrote:
> Hi Suvayu,
>
> Thanks again for your time.
>
> I just ran your macro.
>
> [jnadal_at_at305 JetFitter]$ root test.C
>
> Welcome to the ATLAS rootlogon.C
> root [0]
> Processing test.C...
> Info in<TCanvas::MakeDefCanvas>: created default TCanvas with name c1
> QCDnorm_corr_mu -0.157223
> QCDnorm_corr_mu_btag 0.106851
> root [1] .q
> [jnadal_at_at305 JetFitter]$ root PSE/JO_muon_PSE_RbFree/sumRootFile.root
>
> Welcome to the ATLAS rootlogon.C
> root [0]
> Attaching file PSE/JO_muon_PSE_RbFree/sumRootFile.root as _file0...
> root [1] HangingTree->Draw("QCDnorm_corr_mu_btag>>histo")
> Info in<TCanvas::MakeDefCanvas>: created default TCanvas with name c1
> root [2] histo->GetMean()
> (const Double_t)1.69030729412928876e-01
> root [3]
>
> My problem is that I don't get the same number using the macro for variable (QCDnorm_corr_mu_btag) than looking at it in the root file.
>
> Thanks,
> Jordi
>
>
> On Sep 8, 2011, at 2:46 PM, suvayu ali 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.
Received on Thu Sep 08 2011 - 16:41:21 CEST

This archive was generated by hypermail 2.2.0 : Thu Sep 08 2011 - 17:50:01 CEST