Re: Problems to draw a weighted sum of histograms (corrected message)

From: Antonio Augusto Alves Junior <aalvesju_at_cern.ch>
Date: Tue, 26 Aug 2008 10:38:36 -0300


Hi Rene,

When I was studying the code for write the requested script, I saw that the bug was not in the sum and drawing of the histograms. My script was mixing the data sources before fill the histograms. I fixed this bug and now it is all running fine!

Thank you very much, and very sorry by the mistake!

Augusto

Rene Brun escreveu:
> Could you send the shortest possible RUNNING script (and data file)
> reproducing the problem?
>
> Rene Brun
>
> Antonio Augusto Alves Junior wrote:
>> Hi all,
>>
>> Please, can you help me?
>> I am using the TH1::Add(const TH1* , Double_t ) to add two histograms.
>> I build the histogram h = c1*h1 + c2*h2, doing this
>>
>> h->Reset();
>> h->Add( h1, c1);
>> h->Add(h2,c2);
>>
>> here the h, h1 and h2 are TH1F objects, then I draw the histogram
>>
>> h->Draw();
>>
>> The problem: in the generated graph, is still possible see
>> contributions from h1 histogram when c1 is null!
>> By other side, the histogram's parameters, like h->Integral(),
>> h->GetEntries() etc, has the correct values.
>>
>> Some hint? Is it a bug in the Draw() method?
>> The piece of code is below.
>>
>> Best regards
>> Augusto
>>
>> vector.front()->chain->Draw(draw_opt, filter, "goff" );
>> TH1F *h = (TH1F*) (gDirectory->Get( histo_name ))->Clone("h");
>> h->Reset(); Int_t h_nr=0;
>> for( ChainVector::const_iterator it_vector = vector.begin();
>> it_vector != vector.end(); it_vector++ )
>> {
>> TString h_name("histo_");
>> h_name += h_nr;
>> h_nr++;
>> (*it_vector)->chain->Draw(draw_opt, filter, "goff" );
>> TH1F *h1 = (TH1F*)(gDirectory->Get( histo_name ) )
>> h->Add(h1, (*it_vector)->weight );
>> delete h1; }
>> h->Draw();
>>
>
Received on Tue Aug 26 2008 - 15:38:49 CEST

This archive was generated by hypermail 2.2.0 : Thu Aug 28 2008 - 17:50:02 CEST