Message: Re: Not Logged In (login)
 Next-in-Thread Next-in-Thread
 Next-in-Forum Next-in-Forum

None Re:  

Forum: Analysis
Re: Question "Sumw2" for histograms in G4AnalysisManager (Geng)
Date: 14 Sep, 2015
From: Guy Barrand <Guy Barrand>

  Hi Changran

 When having a ref (or a pointer) to a tools:::histo::h1d :
   tools::histo::h1d& h = <get some histo ref through the G4AnalysisManager>

 you can have all infos on bins with :
   const std::vector<unsigned int>& _entries = h.bins_entries();
   const std::vector<double>& _bins_sum_w = h.bins_sum_w();
   const std::vector<double>& _bins_sum_w2 = h.bins_sum_w2();
   const std::vector< std::vector<double> >& _bins_sum_xw = h.bins_sum_xw();
   const std::vector< std::vector<double> >& _bins_sum_x2w = h.bins_sum_x2w();

for example to  dump bin 50 of an histo (assuming some 100 bins histo)  :
   std::cout << "entries[50] = " << _entries[50] << std::endl;
   std::cout << "  sum_w[50] = " << _bins_sum_w[50] << std::endl;
   std::cout << " sum_w2[50] = " << _bins_sum_w2[50] << std::endl;
   std::cout << " sum_xw[50] = " << _bins_sum_xw[50][0] << std::endl;   //0 = xaxis
   std::cout << "sum_x2w[50] = " << _bins_sum_x2w[50][0] << std::endl;  //0 = xaxis

 (Take care that the [0] entries in the upper vectors are for the "underflow bin" and
 the last one is for the "overflow bin").

 Note that you can also get all internal data of an histo through the "histo_data" :
   const tools::histo::h1d::hd_t& hdata = h.dac();  //dac=data access.

and then find back the bins infos with :
   const std::vector<unsigned int>& _entries = hdata.m_bin_entries;
   const std::vector<double>& _bins_sum_w = hdata.m_bin_Sw;
   const std::vector<double>& _bins_sum_w2 = hdata.m_bin_Sw2;
   const std::vector< std::vector<double> >& _bins_sum_xw = hdata.m_bin_Sxw;
   const std::vector< std::vector<double> >& _bins_sum_x2w = hdata.m_bin_Sx2w;
   // dump bin 50 :
   std::cout << "entries[50] = " << _entries[50] << std::endl;
   std::cout << "  sum_w[50] = " << _bins_sum_w[50] << std::endl;
   std::cout << " sum_w2[50] = " << _bins_sum_w2[50] << std::endl;
   std::cout << " sum_xw[50] = " << _bins_sum_xw[50][0] << std::endl;   //0 = xaxis
   std::cout << "sum_x2w[50] = " << _bins_sum_x2w[50][0] << std::endl;  //0 = xaxis

(see the tools/histo/histo_data class for all internal fields).

 Not clear to me what you mean by "Sumw2 like the way in root", but the h.bins_sum_w2() seems to be what you look for.

   Cheers. Guy

 Add Message Add Message
to: "Re: "

 Subscribe Subscribe

This site runs SLAC HyperNews version 1.11-slac-98, derived from the original HyperNews


[ Geant 4 Home | Geant 4 HyperNews | Search | Request New Forum | Feedback ]