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

From: Antonio Augusto Alves Junior <aalvesju_at_cern.ch>
Date: Tue, 26 Aug 2008 01:30:00 -0300


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 - 06:30:09 CEST

This archive was generated by hypermail 2.2.0 : Tue Aug 26 2008 - 11:50:01 CEST