g4tools  5.4.0
Public Types | Public Member Functions | Protected Types | Protected Member Functions | List of all members
tools::histo::base_histo< TC, TO, TN, TW, TH > Class Template Referenceabstract
Inheritance diagram for tools::histo::base_histo< TC, TO, TN, TW, TH >:
Inheritance graph
[legend]
Collaboration diagram for tools::histo::base_histo< TC, TO, TN, TW, TH >:
Collaboration graph
[legend]

Public Types

typedef histo_data< TC, TO, TN, TW > hd_t
 
typedef axis< TC, TO > axis_t
 
typedef axis_t::bn_t bn_t
 
typedef unsigned int dim_t
 
typedef TC coordinate_t
 
typedef TO offset_t
 
typedef TN num_entries_t
 
typedef TW weight_t
 
typedef TH height_t
 
typedef std::map< std::string, std::string > annotations_t
 

Public Member Functions

const hd_tdac () const
 
bool equals (const base_histo &a_from, const TW &a_prec, TW(*a_fabs)(TW)) const
 
const std::string & title () const
 
bool set_title (const std::string &a_title)
 
dim_t dimension () const
 
dim_t number_of_planes () const
 
TN entries () const
 
TN all_entries () const
 
TN extra_entries () const
 
TW equivalent_bin_entries () const
 
TH sum_bin_heights () const
 
TH sum_all_bin_heights () const
 
TH sum_extra_bin_heights () const
 
TH min_bin_height () const
 
TH max_bin_height () const
 
bool min_bin_height_with_entries (TH &a_value) const
 
bool max_bin_height_with_entries (TH &a_value) const
 
bool has_entries_per_bin () const
 
bool get_ith_axis_Sxw (dim_t a_axis, TC &a_value) const
 
bool get_ith_axis_Sx2w (dim_t a_axis, TC &a_value) const
 
TW get_in_range_Sw () const
 
TW get_in_range_Sw2 () const
 
void get_Sw_Sw2 (TW &a_sw, TW &a_sw2) const
 
void get_all_Sw_Sw2 (TW &a_sw, TW &a_sw2) const
 
const std::vector< TN > & bins_entries () const
 
const std::vector< TW > & bins_sum_w () const
 
const std::vector< TW > & bins_sum_w2 () const
 
const std::vector< std::vector< TC > > & bins_sum_xw () const
 
const std::vector< std::vector< TC > > & bins_sum_x2w () const
 
const std::vector< TC > & in_range_planes_xyw () const
 
const axis_tget_axis (int a_index) const
 
offset_t get_bins () const
 
const std::string & get_title () const
 
dim_t get_dimension () const
 
bool is_valid () const
 
const annotations_tannotations () const
 
annotations_t annotations ()
 
void add_annotation (const std::string &a_key, const std::string &a_value)
 
bool annotation (const std::string &a_key, std::string &a_value) const
 
void set_annotations (const annotations_t &a_annotations)
 
void hprint_annotations (std::ostream &a_out)
 

Protected Types

enum  { AxisX =0, AxisY =1, AxisZ =2 }
 
- Protected Types inherited from tools::histo::histo_data< TC, TO, TN, TW >
typedef axis< TC, TO > axis_t
 
typedef unsigned int dim_t
 
typedef std::map< std::string, std::string > annotations_t
 

Protected Member Functions

virtual TH get_bin_height (TO) const =0
 
void base_from_data (const hd_t &a_from)
 
hd_t base_get_data () const
 
 base_histo ()
 
virtual ~base_histo ()
 
 base_histo (const base_histo &a_from)
 
base_histooperator= (const base_histo &a_from)
 
bool configure (dim_t a_dim, const std::vector< bn_t > &aNumbers, const std::vector< TC > &aMins, const std::vector< TC > &aMaxs)
 
bool configure (dim_t a_dim, const std::vector< std::vector< TC > > &a_edges)
 
void base_reset ()
 
void base_allocate ()
 
bool is_compatible (const base_histo &a_histo)
 
void base_add (const base_histo &a_histo)
 
void base_subtract (const base_histo &a_histo)
 
bool base_multiply (const base_histo &a_histo)
 
bool base_divide (const base_histo &a_histo)
 
bool base_multiply (TW a_factor)
 
bool get_ith_axis_mean (dim_t a_axis, TC &a_value) const
 
bool get_ith_axis_rms (dim_t a_axis, TC &a_value) const
 
TN get_bin_entries (const std::vector< int > &aIs) const
 
- Protected Member Functions inherited from tools::histo::histo_data< TC, TO, TN, TW >
void reset_fast_getters ()
 
 histo_data ()
 
 histo_data (const histo_data &a_from)
 
histo_dataoperator= (const histo_data &a_from)
 
virtual ~histo_data ()
 
void update_fast_getters ()
 
bool equals (const histo_data &a_from, const TW &a_prec, TW(*a_fabs)(TW)) const
 
bool equals_TH (const histo_data &a_from, const TW &a_prec, TW(*a_fabs)(TW), bool a_cmp_bin_Sw2) const
 

Additional Inherited Members

- Protected Attributes inherited from tools::histo::histo_data< TC, TO, TN, TW >
std::string m_title
 
dim_t m_dimension
 
TO m_bin_number
 
std::vector< TN > m_bin_entries
 
std::vector< TW > m_bin_Sw
 
std::vector< TW > m_bin_Sw2
 
std::vector< std::vector< TC > > m_bin_Sxw
 
std::vector< std::vector< TC > > m_bin_Sx2w
 
std::vector< axis_tm_axes
 
std::vector< TC > m_in_range_plane_Sxyw
 
std::map< std::string, std::string > m_annotations
 
TN m_all_entries
 
TN m_in_range_entries
 
TW m_in_range_Sw
 
TW m_in_range_Sw2
 
std::vector< TC > m_in_range_Sxw
 
std::vector< TC > m_in_range_Sx2w
 

Detailed Description

template<class TC, class TO, class TN, class TW, class TH>
class tools::histo::base_histo< TC, TO, TN, TW, TH >

Definition at line 27 of file base_histo.

Member Typedef Documentation

◆ annotations_t

template<class TC , class TO , class TN , class TW , class TH >
typedef std::map<std::string,std::string> tools::histo::base_histo< TC, TO, TN, TW, TH >::annotations_t

Definition at line 442 of file base_histo.

◆ axis_t

template<class TC , class TO , class TN , class TW , class TH >
typedef axis<TC,TO> tools::histo::base_histo< TC, TO, TN, TW, TH >::axis_t

Definition at line 36 of file base_histo.

◆ bn_t

template<class TC , class TO , class TN , class TW , class TH >
typedef axis_t::bn_t tools::histo::base_histo< TC, TO, TN, TW, TH >::bn_t

Definition at line 37 of file base_histo.

◆ coordinate_t

template<class TC , class TO , class TN , class TW , class TH >
typedef TC tools::histo::base_histo< TC, TO, TN, TW, TH >::coordinate_t

Definition at line 39 of file base_histo.

◆ dim_t

template<class TC , class TO , class TN , class TW , class TH >
typedef unsigned int tools::histo::base_histo< TC, TO, TN, TW, TH >::dim_t

Definition at line 38 of file base_histo.

◆ hd_t

template<class TC , class TO , class TN , class TW , class TH >
typedef histo_data<TC,TO,TN,TW> tools::histo::base_histo< TC, TO, TN, TW, TH >::hd_t

Definition at line 35 of file base_histo.

◆ height_t

template<class TC , class TO , class TN , class TW , class TH >
typedef TH tools::histo::base_histo< TC, TO, TN, TW, TH >::height_t

Definition at line 43 of file base_histo.

◆ num_entries_t

template<class TC , class TO , class TN , class TW , class TH >
typedef TN tools::histo::base_histo< TC, TO, TN, TW, TH >::num_entries_t

Definition at line 41 of file base_histo.

◆ offset_t

template<class TC , class TO , class TN , class TW , class TH >
typedef TO tools::histo::base_histo< TC, TO, TN, TW, TH >::offset_t

Definition at line 40 of file base_histo.

◆ weight_t

template<class TC , class TO , class TN , class TW , class TH >
typedef TW tools::histo::base_histo< TC, TO, TN, TW, TH >::weight_t

Definition at line 42 of file base_histo.

Member Enumeration Documentation

◆ anonymous enum

template<class TC , class TO , class TN , class TW , class TH >
anonymous enum
protected
Enumerator
AxisX 
AxisY 
AxisZ 

Definition at line 291 of file base_histo.

291 {AxisX=0,AxisY=1,AxisZ=2};

Constructor & Destructor Documentation

◆ base_histo() [1/2]

template<class TC , class TO , class TN , class TW , class TH >
tools::histo::base_histo< TC, TO, TN, TW, TH >::base_histo ( )
inlineprotected

Definition at line 58 of file base_histo.

58  :parent() {
59 #ifdef TOOLS_MEM
60  mem::increment(s_class().c_str());
61 #endif
62  }

◆ ~base_histo()

template<class TC , class TO , class TN , class TW , class TH >
virtual tools::histo::base_histo< TC, TO, TN, TW, TH >::~base_histo ( )
inlineprotectedvirtual

Definition at line 64 of file base_histo.

64  {
65 #ifdef TOOLS_MEM
66  mem::decrement(s_class().c_str());
67 #endif
68  }

◆ base_histo() [2/2]

template<class TC , class TO , class TN , class TW , class TH >
tools::histo::base_histo< TC, TO, TN, TW, TH >::base_histo ( const base_histo< TC, TO, TN, TW, TH > &  a_from)
inlineprotected

Definition at line 70 of file base_histo.

70  :parent(a_from) {
71 #ifdef TOOLS_MEM
72  mem::increment(s_class().c_str());
73 #endif
74  }

Member Function Documentation

◆ add_annotation()

template<class TC , class TO , class TN , class TW , class TH >
void tools::histo::base_histo< TC, TO, TN, TW, TH >::add_annotation ( const std::string &  a_key,
const std::string &  a_value 
)
inline

Definition at line 446 of file base_histo.

446  {
447  parent::m_annotations[a_key] = a_value; //override if a_key already exists.
448  }

◆ all_entries()

template<class TC , class TO , class TN , class TW , class TH >
TN tools::histo::base_histo< TC, TO, TN, TW, TH >::all_entries ( ) const
inline

Definition at line 95 of file base_histo.

95  {
96  return parent::m_all_entries; //works also is reading histo from a CERN-ROOT file.
97  }

◆ annotation()

template<class TC , class TO , class TN , class TW , class TH >
bool tools::histo::base_histo< TC, TO, TN, TW, TH >::annotation ( const std::string &  a_key,
std::string &  a_value 
) const
inline

Definition at line 449 of file base_histo.

449  {
450  annotations_t::const_iterator it = parent::m_annotations.find(a_key);
451  if(it==parent::m_annotations.end()) {a_value.clear();return false;}
452  a_value = (*it).second;
453  return true;
454  }

◆ annotations() [1/2]

template<class TC , class TO , class TN , class TW , class TH >
annotations_t tools::histo::base_histo< TC, TO, TN, TW, TH >::annotations ( )
inline

Definition at line 444 of file base_histo.

444 {return parent::m_annotations;}

◆ annotations() [2/2]

template<class TC , class TO , class TN , class TW , class TH >
const annotations_t& tools::histo::base_histo< TC, TO, TN, TW, TH >::annotations ( ) const
inline

Definition at line 443 of file base_histo.

443 {return parent::m_annotations;}

◆ base_add()

template<class TC , class TO , class TN , class TW , class TH >
void tools::histo::base_histo< TC, TO, TN, TW, TH >::base_add ( const base_histo< TC, TO, TN, TW, TH > &  a_histo)
inlineprotected

Definition at line 476 of file base_histo.

476  {
477  // The only histogram operation that makes sense.
478  for(TO ibin=0;ibin<parent::m_bin_number;ibin++) {
479  parent::m_bin_entries[ibin] += a_histo.m_bin_entries[ibin];
480  parent::m_bin_Sw[ibin] += a_histo.m_bin_Sw[ibin];
481  parent::m_bin_Sw2[ibin] += a_histo.m_bin_Sw2[ibin];
482  for(dim_t iaxis=0;iaxis<parent::m_dimension;iaxis++) {
483  parent::m_bin_Sxw[ibin][iaxis] += a_histo.m_bin_Sxw[ibin][iaxis];
484  parent::m_bin_Sx2w[ibin][iaxis] += a_histo.m_bin_Sx2w[ibin][iaxis];
485  }
486  }
487  {size_t nplane = parent::m_in_range_plane_Sxyw.size();
488  for(size_t iplane=0;iplane<nplane;iplane++)
489  parent::m_in_range_plane_Sxyw[iplane] += a_histo.m_in_range_plane_Sxyw[iplane];}
491  }

◆ base_allocate()

template<class TC , class TO , class TN , class TW , class TH >
void tools::histo::base_histo< TC, TO, TN, TW, TH >::base_allocate ( )
inlineprotected

Definition at line 398 of file base_histo.

398  {
399  dim_t iaxis;
400  // Add two bins for the [under,out]flow data.
401  TO n_bin = 1;
402  for(iaxis=0;iaxis<parent::m_dimension;iaxis++) {
403  n_bin *= (parent::m_axes[iaxis].bins() + 2);
404  }
405 
406  parent::m_bin_entries.resize(n_bin,0);
407  parent::m_bin_Sw.resize(n_bin,0);
408  parent::m_bin_Sw2.resize(n_bin,0);
409 
410  std::vector<TC> empty;
411  empty.resize(parent::m_dimension,0);
412  parent::m_bin_Sxw.resize(n_bin,empty);
413  parent::m_bin_Sx2w.resize(n_bin,empty);
414 
415  parent::m_bin_number = n_bin; // All bins : [in-range, underflow, outflow] bins.
416 
417  parent::m_axes[0].m_offset = 1;
418  for(iaxis=1;iaxis<parent::m_dimension;iaxis++) {
419  parent::m_axes[iaxis].m_offset = parent::m_axes[iaxis-1].m_offset * (parent::m_axes[iaxis-1].bins()+2);
420  }
421 
423  }

◆ base_divide()

template<class TC , class TO , class TN , class TW , class TH >
bool tools::histo::base_histo< TC, TO, TN, TW, TH >::base_divide ( const base_histo< TC, TO, TN, TW, TH > &  a_histo)
inlineprotected

Definition at line 547 of file base_histo.

547  {
548  //ill-defined operation. We keep that because of the "ill-defined past".
549 
550  // We build a new histo with one entry in each bin of weight :
551  // this.w / a_histo.w
552  // The current histo is overriden with this new histo.
553  // The m_bin_Sw2 computation is consistent with FreeHEP and ROOT.
554 
555  if(!is_compatible(a_histo)) return false;
556 
557  std::vector<int> is(parent::m_dimension);
558  for(TO ibin=0;ibin<parent::m_bin_number;ibin++) {
560  TW swa = parent::m_bin_Sw[ibin];
561  TW swb = a_histo.m_bin_Sw[ibin];
562  TW sw2a = parent::m_bin_Sw2[ibin];
563  TW sw2b = a_histo.m_bin_Sw2[ibin];
564  if(swb!=0) {
565  parent::m_bin_entries[ibin] = 1;
566  TW sw = swa / swb;
567  parent::m_bin_Sw[ibin] = sw;
568  TW swb2 = swb * swb;
569  parent::m_bin_Sw2[ibin] = sw2a / swb2 + sw2b * swa * swa /(swb2*swb2);
570  for(dim_t iaxis=0;iaxis<parent::m_dimension;iaxis++) {
571  TC x = parent::m_axes[iaxis].bin_center(is[iaxis]);
572  parent::m_bin_Sxw[ibin][iaxis] = x * sw;
573  parent::m_bin_Sx2w[ibin][iaxis] = x * x * sw;
574  }
575  } else {
576  parent::m_bin_entries[ibin] = 0;
577  parent::m_bin_Sw[ibin] = 0;
578  parent::m_bin_Sw2[ibin] = 0;
579  for(dim_t iaxis=0;iaxis<parent::m_dimension;iaxis++) {
580  parent::m_bin_Sxw[ibin][iaxis] = 0;
581  parent::m_bin_Sx2w[ibin][iaxis] = 0;
582  }
583  }
584  }
585 
586  //{for(dim_t iplane=0;iplane<nplane;iplane++) parent::m_in_range_plane_Sxyw[iplane] ??? a_histo.m_in_range_plane_Sxyw[iplane];}
587 
589  return true;
590  }

◆ base_from_data()

template<class TC , class TO , class TN , class TW , class TH >
void tools::histo::base_histo< TC, TO, TN, TW, TH >::base_from_data ( const hd_t a_from)
inlineprotected

Definition at line 47 of file base_histo.

47 {parent::operator=(a_from);}

◆ base_get_data()

template<class TC , class TO , class TN , class TW , class TH >
hd_t tools::histo::base_histo< TC, TO, TN, TW, TH >::base_get_data ( ) const
inlineprotected

Definition at line 49 of file base_histo.

49  {
50  hd_t hd;
51  hd = *this;
52  return hd;
53  }

◆ base_multiply() [1/2]

template<class TC , class TO , class TN , class TW , class TH >
bool tools::histo::base_histo< TC, TO, TN, TW, TH >::base_multiply ( const base_histo< TC, TO, TN, TW, TH > &  a_histo)
inlineprotected

Definition at line 513 of file base_histo.

513  {
514  //ill-defined operation. We keep that because of the "ill-defined past".
515 
516  // We build a new histo with one entry in each bin of weight :
517  // this.w * a_histo.w
518  // The current histo is overriden with this new histo.
519  // The m_bin_Sw2 computation is consistent with FreeHEP and CERN-ROOT.
520 
521  if(!is_compatible(a_histo)) return false;
522 
523  std::vector<int> is(parent::m_dimension);
524  for(TO ibin=0;ibin<parent::m_bin_number;ibin++) {
525  TW swa = parent::m_bin_Sw[ibin];
526  TW sw2a = parent::m_bin_Sw2[ibin];
527  TW swb = a_histo.m_bin_Sw[ibin];
528  TW sw2b = a_histo.m_bin_Sw2[ibin];
529  TW sw = swa * swb;
530  parent::m_bin_entries[ibin] = 1;
531  parent::m_bin_Sw[ibin] = sw;
532  parent::m_bin_Sw2[ibin] = sw2a * swb * swb + sw2b * swa * swa;
534  for(dim_t iaxis=0;iaxis<parent::m_dimension;iaxis++) {
535  TC x = parent::m_axes[iaxis].bin_center(is[iaxis]);
536  parent::m_bin_Sxw[ibin][iaxis] = x * sw;
537  parent::m_bin_Sx2w[ibin][iaxis] = x * x * sw;
538  }
539  }
540 
541  //{for(dim_t iplane=0;iplane<nplane;iplane++) parent::m_in_range_plane_Sxyw[iplane] ??? a_histo.m_in_range_plane_Sxyw[iplane];}
542 
544  return true;
545  }

◆ base_multiply() [2/2]

template<class TC , class TO , class TN , class TW , class TH >
bool tools::histo::base_histo< TC, TO, TN, TW, TH >::base_multiply ( TW  a_factor)
inlineprotected

Definition at line 592 of file base_histo.

592  {
593  if(a_factor<0) return false;
594  TW factor2 = a_factor * a_factor;
595  for(TO ibin=0;ibin<parent::m_bin_number;ibin++) {
596  parent::m_bin_Sw[ibin] *= a_factor;
597  parent::m_bin_Sw2[ibin] *= factor2;
598  for(dim_t iaxis=0;iaxis<parent::m_dimension;iaxis++) {
599  parent::m_bin_Sxw[ibin][iaxis] *= a_factor;
600  parent::m_bin_Sx2w[ibin][iaxis] *= a_factor;
601  }
602  }
603  {size_t nplane = parent::m_in_range_plane_Sxyw.size();
604  for(size_t iplane=0;iplane<nplane;iplane++) parent::m_in_range_plane_Sxyw[iplane] *= a_factor;}
606  return true;
607  }

◆ base_reset()

template<class TC , class TO , class TN , class TW , class TH >
void tools::histo::base_histo< TC, TO, TN, TW, TH >::base_reset ( )
inlineprotected

Definition at line 381 of file base_histo.

381  {
382  // Reset content (different of clear that deallocate all internal things).
383  for(TO ibin=0;ibin<parent::m_bin_number;ibin++) {
384  parent::m_bin_entries[ibin] = 0;
385  parent::m_bin_Sw[ibin] = 0;
386  parent::m_bin_Sw2[ibin] = 0;
387  for(dim_t iaxis=0;iaxis<parent::m_dimension;iaxis++) {
388  parent::m_bin_Sxw[ibin][iaxis] = 0;
389  parent::m_bin_Sx2w[ibin][iaxis] = 0;
390  }
391  }
393  //profile not done here.
395  }

◆ base_subtract()

template<class TC , class TO , class TN , class TW , class TH >
void tools::histo::base_histo< TC, TO, TN, TW, TH >::base_subtract ( const base_histo< TC, TO, TN, TW, TH > &  a_histo)
inlineprotected

Definition at line 493 of file base_histo.

493  {
494  //ill-defined operation. We keep that because of the "ill-defined past".
495  // We build a new histo with one entry in each bin.
496  for(TO ibin=0;ibin<parent::m_bin_number;ibin++) {
497  parent::m_bin_entries[ibin] = 1;
498 
499  parent::m_bin_Sw[ibin] -= a_histo.m_bin_Sw[ibin];
500  // Yes, it is a += in the below.
501  parent::m_bin_Sw2[ibin] += a_histo.m_bin_Sw2[ibin];
502  for(dim_t iaxis=0;iaxis<parent::m_dimension;iaxis++) {
503  parent::m_bin_Sxw[ibin][iaxis] -= a_histo.m_bin_Sxw[ibin][iaxis];
504  parent::m_bin_Sx2w[ibin][iaxis] -= a_histo.m_bin_Sx2w[ibin][iaxis];
505  }
506  }
507 
508  //{for(dim_t iplane=0;iplane<nplane;iplane++) parent::m_in_range_plane_Sxyw[iplane] ??? a_histo.m_in_range_plane_Sxyw[iplane];}
509 
511  }

◆ bins_entries()

template<class TC , class TO , class TN , class TW , class TH >
const std::vector<TN>& tools::histo::base_histo< TC, TO, TN, TW, TH >::bins_entries ( ) const
inline

Definition at line 427 of file base_histo.

427 {return parent::m_bin_entries;}

◆ bins_sum_w()

template<class TC , class TO , class TN , class TW , class TH >
const std::vector<TW>& tools::histo::base_histo< TC, TO, TN, TW, TH >::bins_sum_w ( ) const
inline

Definition at line 428 of file base_histo.

428 {return parent::m_bin_Sw;}

◆ bins_sum_w2()

template<class TC , class TO , class TN , class TW , class TH >
const std::vector<TW>& tools::histo::base_histo< TC, TO, TN, TW, TH >::bins_sum_w2 ( ) const
inline

Definition at line 429 of file base_histo.

429 {return parent::m_bin_Sw2;}

◆ bins_sum_x2w()

template<class TC , class TO , class TN , class TW , class TH >
const std::vector< std::vector<TC> >& tools::histo::base_histo< TC, TO, TN, TW, TH >::bins_sum_x2w ( ) const
inline

Definition at line 431 of file base_histo.

431 {return parent::m_bin_Sx2w;}

◆ bins_sum_xw()

template<class TC , class TO , class TN , class TW , class TH >
const std::vector< std::vector<TC> >& tools::histo::base_histo< TC, TO, TN, TW, TH >::bins_sum_xw ( ) const
inline

Definition at line 430 of file base_histo.

430 {return parent::m_bin_Sxw;}

◆ configure() [1/2]

template<class TC , class TO , class TN , class TW , class TH >
bool tools::histo::base_histo< TC, TO, TN, TW, TH >::configure ( dim_t  a_dim,
const std::vector< bn_t > &  aNumbers,
const std::vector< TC > &  aMins,
const std::vector< TC > &  aMaxs 
)
inlineprotected

Definition at line 293 of file base_histo.

296  {
297  // Clear :
298  parent::m_bin_entries.clear();
299  parent::m_bin_Sw.clear();
300  parent::m_bin_Sw2.clear();
301  parent::m_bin_Sxw.clear();
302  parent::m_bin_Sx2w.clear();
303  parent::m_in_range_Sxw.clear();
304  parent::m_in_range_Sx2w.clear();
305  parent::m_axes.clear();
307  parent::m_annotations.clear();
308 
315  parent::m_in_range_Sxw.resize(a_dim,0);
316  parent::m_in_range_Sx2w.resize(a_dim,0);
317 
318  // Some checks :
319  if(!a_dim) return false;
320  parent::m_axes.resize(a_dim);
321  // Setup axes :
322  for(dim_t iaxis=0;iaxis<a_dim;iaxis++) {
323  if(!parent::m_axes[iaxis].configure(aNumbers[iaxis],aMins[iaxis],aMaxs[iaxis])) {
324  // do not do :
325  // m_axes.clear()
326  // so that :
327  // b1::axis(),b2::axis_[x,y]()
328  // do not crash in case of a bad booking.
329  //m_axes.clear();
330  return false;
331  }
332  }
333 
334  parent::m_dimension = a_dim;
335 
336  base_allocate(); //set m_bin_number.
337 
338  return true;
339  }

◆ configure() [2/2]

template<class TC , class TO , class TN , class TW , class TH >
bool tools::histo::base_histo< TC, TO, TN, TW, TH >::configure ( dim_t  a_dim,
const std::vector< std::vector< TC > > &  a_edges 
)
inlineprotected

Definition at line 341 of file base_histo.

341  {
342  // Clear :
343  parent::m_bin_entries.clear();
344  parent::m_bin_Sw.clear();
345  parent::m_bin_Sw2.clear();
346  parent::m_bin_Sxw.clear();
347  parent::m_bin_Sx2w.clear();
348  parent::m_in_range_Sxw.clear();
349  parent::m_in_range_Sx2w.clear();
350  parent::m_axes.clear();
352  parent::m_annotations.clear();
353 
360  parent::m_in_range_Sxw.resize(a_dim,0);
361  parent::m_in_range_Sx2w.resize(a_dim,0);
362 
363  // Some checks :
364  if(!a_dim) return false;
365  parent::m_axes.resize(a_dim);
366  // Setup axes :
367  for(dim_t iaxis=0;iaxis<a_dim;iaxis++) {
368  if(!parent::m_axes[iaxis].configure(a_edges[iaxis])) {
369  //m_axes.clear();
370  return false;
371  }
372  }
373 
374  parent::m_dimension = a_dim;
375 
376  base_allocate(); //set m_bin_number.
377 
378  return true;
379  }

◆ dac()

template<class TC , class TO , class TN , class TW , class TH >
const hd_t& tools::histo::base_histo< TC, TO, TN, TW, TH >::dac ( ) const
inline

Definition at line 56 of file base_histo.

56 {return *this;} //data accessor.

◆ dimension()

template<class TC , class TO , class TN , class TW , class TH >
dim_t tools::histo::base_histo< TC, TO, TN, TW, TH >::dimension ( ) const
inline

Definition at line 89 of file base_histo.

89 {return parent::m_dimension;}

◆ entries()

template<class TC , class TO , class TN , class TW , class TH >
TN tools::histo::base_histo< TC, TO, TN, TW, TH >::entries ( ) const
inline

Definition at line 92 of file base_histo.

92  {
93  return parent::m_in_range_entries; //not set if reading a TH from a CERN-ROOT file.
94  }

◆ equals()

template<class TC , class TO , class TN , class TW , class TH >
bool tools::histo::base_histo< TC, TO, TN, TW, TH >::equals ( const base_histo< TC, TO, TN, TW, TH > &  a_from,
const TW &  a_prec,
TW(*)(TW)  a_fabs 
) const
inline

Definition at line 83 of file base_histo.

83  {
84  return parent::equals(a_from,a_prec,a_fabs);
85  }

◆ equivalent_bin_entries()

template<class TC , class TO , class TN , class TW , class TH >
TW tools::histo::base_histo< TC, TO, TN, TW, TH >::equivalent_bin_entries ( ) const
inline

Definition at line 102 of file base_histo.

102  {
103  TW sw = 0;
104  TW sw2 = 0;
105  for(TO ibin=0;ibin<parent::m_bin_number;ibin++) {
106  if(!histo::is_out(parent::m_axes,ibin)) {
107  sw += parent::m_bin_Sw[ibin];
108  sw2 += parent::m_bin_Sw2[ibin];
109  }
110  }
111  if(sw2==0) return 0;
112  return (sw * sw)/sw2;
113  }

◆ extra_entries()

template<class TC , class TO , class TN , class TW , class TH >
TN tools::histo::base_histo< TC, TO, TN, TW, TH >::extra_entries ( ) const
inline

Definition at line 99 of file base_histo.

99  {
100  return parent::m_all_entries-parent::m_in_range_entries; //works also is reading histo from a CERN-ROOT file.
101  }

◆ get_all_Sw_Sw2()

template<class TC , class TO , class TN , class TW , class TH >
void tools::histo::base_histo< TC, TO, TN, TW, TH >::get_all_Sw_Sw2 ( TW &  a_sw,
TW &  a_sw2 
) const
inline

Definition at line 256 of file base_histo.

256  {
257  a_sw = 0;
258  a_sw2 = 0;
259  for(TO ibin=0;ibin<parent::m_bin_number;ibin++) {
260  a_sw += parent::m_bin_Sw[ibin];
261  a_sw2 += parent::m_bin_Sw2[ibin];
262  }
263  }

◆ get_axis()

template<class TC , class TO , class TN , class TW , class TH >
const axis_t& tools::histo::base_histo< TC, TO, TN, TW, TH >::get_axis ( int  a_index) const
inline

Definition at line 435 of file base_histo.

435 {return parent::m_axes[a_index];}

◆ get_bin_entries()

template<class TC , class TO , class TN , class TW , class TH >
TN tools::histo::base_histo< TC, TO, TN, TW, TH >::get_bin_entries ( const std::vector< int > &  aIs) const
inlineprotected

Definition at line 644 of file base_histo.

644  {
645  if(parent::m_bin_number==0) return 0;
646  TO offset;
647  if(!histo::get_offset(parent::m_axes,aIs,offset)) return 0;
648  return parent::m_bin_entries[offset];
649  }

◆ get_bin_height()

template<class TC , class TO , class TN , class TW , class TH >
virtual TH tools::histo::base_histo< TC, TO, TN, TW, TH >::get_bin_height ( TO  ) const
protectedpure virtual

◆ get_bins()

template<class TC , class TO , class TN , class TW , class TH >
offset_t tools::histo::base_histo< TC, TO, TN, TW, TH >::get_bins ( ) const
inline

Definition at line 436 of file base_histo.

436 {return parent::m_bin_number;}

◆ get_dimension()

template<class TC , class TO , class TN , class TW , class TH >
dim_t tools::histo::base_histo< TC, TO, TN, TW, TH >::get_dimension ( ) const
inline

Definition at line 438 of file base_histo.

438 {return parent::m_dimension;}

◆ get_in_range_Sw()

template<class TC , class TO , class TN , class TW , class TH >
TW tools::histo::base_histo< TC, TO, TN, TW, TH >::get_in_range_Sw ( ) const
inline

Definition at line 243 of file base_histo.

243 {return parent::m_in_range_Sw;} //for CERN-ROOT file writing.

◆ get_in_range_Sw2()

template<class TC , class TO , class TN , class TW , class TH >
TW tools::histo::base_histo< TC, TO, TN, TW, TH >::get_in_range_Sw2 ( ) const
inline

Definition at line 244 of file base_histo.

244 {return parent::m_in_range_Sw2;} //for CERN-ROOT file writing.

◆ get_ith_axis_mean()

template<class TC , class TO , class TN , class TW , class TH >
bool tools::histo::base_histo< TC, TO, TN, TW, TH >::get_ith_axis_mean ( dim_t  a_axis,
TC &  a_value 
) const
inlineprotected

Definition at line 609 of file base_histo.

609  {
610  a_value = 0;
611  if(a_axis>=parent::m_dimension) return false;
612  TW sw = 0;
613  TC sxw = 0;
614  for(TO ibin=0;ibin<parent::m_bin_number;ibin++) {
615  if(!histo::is_out(parent::m_axes,ibin)) {
616  sw += parent::m_bin_Sw[ibin];
617  sxw += parent::m_bin_Sxw[ibin][a_axis];
618  }
619  }
620  if(sw==0) return false;
621  a_value = sxw/sw;
622  return true;
623  }

◆ get_ith_axis_rms()

template<class TC , class TO , class TN , class TW , class TH >
bool tools::histo::base_histo< TC, TO, TN, TW, TH >::get_ith_axis_rms ( dim_t  a_axis,
TC &  a_value 
) const
inlineprotected

Definition at line 625 of file base_histo.

625  {
626  a_value = 0;
627  if(a_axis>=parent::m_dimension) return false;
628  TW sw = 0;
629  TC sxw = 0;
630  TC sx2w = 0;
631  for(TO ibin=0;ibin<parent::m_bin_number;ibin++) {
632  if(!histo::is_out(parent::m_axes,ibin)) {
633  sw += parent::m_bin_Sw[ibin];
634  sxw += parent::m_bin_Sxw[ibin][a_axis];
635  sx2w += parent::m_bin_Sx2w[ibin][a_axis];
636  }
637  }
638  if(sw==0) return false;
639  TC mean = sxw/sw;
640  a_value = ::sqrt(::fabs((sx2w / sw) - mean * mean));
641  return true;
642  }

◆ get_ith_axis_Sx2w()

template<class TC , class TO , class TN , class TW , class TH >
bool tools::histo::base_histo< TC, TO, TN, TW, TH >::get_ith_axis_Sx2w ( dim_t  a_axis,
TC &  a_value 
) const
inline

Definition at line 232 of file base_histo.

232  {
233  a_value = 0;
234  if(a_axis>=parent::m_dimension) return false;
235  for(TO ibin=0;ibin<parent::m_bin_number;ibin++) {
236  if(!histo::is_out(parent::m_axes,ibin)) {
237  a_value += parent::m_bin_Sx2w[ibin][a_axis];
238  }
239  }
240  return true;
241  }

◆ get_ith_axis_Sxw()

template<class TC , class TO , class TN , class TW , class TH >
bool tools::histo::base_histo< TC, TO, TN, TW, TH >::get_ith_axis_Sxw ( dim_t  a_axis,
TC &  a_value 
) const
inline

Definition at line 221 of file base_histo.

221  {
222  a_value = 0;
223  if(a_axis>=parent::m_dimension) return false;
224  for(TO ibin=0;ibin<parent::m_bin_number;ibin++) {
225  if(!histo::is_out(parent::m_axes,ibin)) {
226  a_value += parent::m_bin_Sxw[ibin][a_axis];
227  }
228  }
229  return true;
230  }

◆ get_Sw_Sw2()

template<class TC , class TO , class TN , class TW , class TH >
void tools::histo::base_histo< TC, TO, TN, TW, TH >::get_Sw_Sw2 ( TW &  a_sw,
TW &  a_sw2 
) const
inline

Definition at line 246 of file base_histo.

246  {
247  a_sw = 0;
248  a_sw2 = 0;
249  for(TO ibin=0;ibin<parent::m_bin_number;ibin++) {
250  if(!histo::is_out(parent::m_axes,ibin)) {
251  a_sw += parent::m_bin_Sw[ibin];
252  a_sw2 += parent::m_bin_Sw2[ibin];
253  }
254  }
255  }

◆ get_title()

template<class TC , class TO , class TN , class TW , class TH >
const std::string& tools::histo::base_histo< TC, TO, TN, TW, TH >::get_title ( ) const
inline

Definition at line 437 of file base_histo.

437 {return parent::m_title;}

◆ has_entries_per_bin()

template<class TC , class TO , class TN , class TW , class TH >
bool tools::histo::base_histo< TC, TO, TN, TW, TH >::has_entries_per_bin ( ) const
inline

Definition at line 211 of file base_histo.

211  { //to detect histos coming from TH streaming out of a root file.
212  // it assumes that update_fast_getters() had been applied.
213  if(parent::m_in_range_entries) return true;
214  // may be a from-root histo :
215  if(parent::m_in_range_Sw) return false;
216  // no in range entries and weight :
217  return true; //for exa not filled = ok.
218  }

◆ hprint_annotations()

template<class TC , class TO , class TN , class TW , class TH >
void tools::histo::base_histo< TC, TO, TN, TW, TH >::hprint_annotations ( std::ostream &  a_out)
inline

Definition at line 458 of file base_histo.

458  {
459  a_out << " * ANNOTATIONS :" << std::endl;
460  annotations_t::const_iterator it;
461  for(it=parent::m_annotations.begin();it!=parent::m_annotations.end();++it) {
462  //out << " * (" << index << ") "
463  a_out << " * " << (*it).first << " = " << (*it).second << std::endl;
464  }
465  }

◆ in_range_planes_xyw()

template<class TC , class TO , class TN , class TW , class TH >
const std::vector<TC>& tools::histo::base_histo< TC, TO, TN, TW, TH >::in_range_planes_xyw ( ) const
inline

Definition at line 432 of file base_histo.

◆ is_compatible()

template<class TC , class TO , class TN , class TW , class TH >
bool tools::histo::base_histo< TC, TO, TN, TW, TH >::is_compatible ( const base_histo< TC, TO, TN, TW, TH > &  a_histo)
inlineprotected

Definition at line 468 of file base_histo.

468  {
469  if(parent::m_dimension!=a_histo.m_dimension) return false;
470  for(dim_t iaxis=0;iaxis<parent::m_dimension;iaxis++) {
471  if(!parent::m_axes[iaxis].is_compatible(a_histo.m_axes[iaxis])) return false;
472  }
473  return true;
474  }

◆ is_valid()

template<class TC , class TO , class TN , class TW , class TH >
bool tools::histo::base_histo< TC, TO, TN, TW, TH >::is_valid ( ) const
inline

Definition at line 439 of file base_histo.

439 {return (parent::m_dimension?true:false);}

◆ max_bin_height()

template<class TC , class TO , class TN , class TW , class TH >
TH tools::histo::base_histo< TC, TO, TN, TW, TH >::max_bin_height ( ) const
inline

Definition at line 158 of file base_histo.

158  {
159  TH value = 0;
160  bool first = true;
161  for(TO ibin=0;ibin<parent::m_bin_number;ibin++) {
162  if(!histo::is_out(parent::m_axes,ibin)) {
163  TH vbin = get_bin_height(ibin);
164  if(first) {
165  first = false;
166  value = vbin;
167  } else {
168  if(vbin>=value) value = vbin;
169  }
170  }
171  }
172  return value;
173  }

◆ max_bin_height_with_entries()

template<class TC , class TO , class TN , class TW , class TH >
bool tools::histo::base_histo< TC, TO, TN, TW, TH >::max_bin_height_with_entries ( TH &  a_value) const
inline

Definition at line 193 of file base_histo.

193  {
194  TH value = 0;
195  bool first = true;
196  for(TO ibin=0;ibin<parent::m_bin_number;ibin++) {
197  if(!histo::is_out(parent::m_axes,ibin) && (parent::m_bin_entries[ibin]>0) ) {
198  TH vbin = get_bin_height(ibin);
199  if(first) {
200  first = false;
201  value = vbin;
202  } else {
203  if(vbin>=value) value = vbin;
204  }
205  }
206  }
207  a_value = value;
208  return first?false:true; //return true if at least one bin with entries processed.
209  }

◆ min_bin_height()

template<class TC , class TO , class TN , class TW , class TH >
TH tools::histo::base_histo< TC, TO, TN, TW, TH >::min_bin_height ( ) const
inline

Definition at line 141 of file base_histo.

141  {
142  TH value = 0;
143  bool first = true;
144  for(TO ibin=0;ibin<parent::m_bin_number;ibin++) {
145  if(!histo::is_out(parent::m_axes,ibin)) {
146  TH vbin = get_bin_height(ibin);
147  if(first) {
148  first = false;
149  value = vbin;
150  } else {
151  if(vbin<=value) value = vbin;
152  }
153  }
154  }
155  return value;
156  }

◆ min_bin_height_with_entries()

template<class TC , class TO , class TN , class TW , class TH >
bool tools::histo::base_histo< TC, TO, TN, TW, TH >::min_bin_height_with_entries ( TH &  a_value) const
inline

Definition at line 175 of file base_histo.

175  {
176  TH value = 0;
177  bool first = true;
178  for(TO ibin=0;ibin<parent::m_bin_number;ibin++) {
179  if(!histo::is_out(parent::m_axes,ibin) && (parent::m_bin_entries[ibin]>0) ) {
180  TH vbin = get_bin_height(ibin);
181  if(first) {
182  first = false;
183  value = vbin;
184  } else {
185  if(vbin<=value) value = vbin;
186  }
187  }
188  }
189  a_value = value;
190  return first?false:true; //return true if at least one bin with entries processed.
191  }

◆ number_of_planes()

template<class TC , class TO , class TN , class TW , class TH >
dim_t tools::histo::base_histo< TC, TO, TN, TW, TH >::number_of_planes ( ) const
inline

Definition at line 90 of file base_histo.

◆ operator=()

template<class TC , class TO , class TN , class TW , class TH >
base_histo& tools::histo::base_histo< TC, TO, TN, TW, TH >::operator= ( const base_histo< TC, TO, TN, TW, TH > &  a_from)
inlineprotected

Definition at line 76 of file base_histo.

76  {
77  if(&a_from==this) return *this;
78  parent::operator=(a_from);
79  return *this;
80  }

◆ set_annotations()

template<class TC , class TO , class TN , class TW , class TH >
void tools::histo::base_histo< TC, TO, TN, TW, TH >::set_annotations ( const annotations_t a_annotations)
inline

Definition at line 456 of file base_histo.

456 {parent::m_annotations = a_annotations;}

◆ set_title()

template<class TC , class TO , class TN , class TW , class TH >
bool tools::histo::base_histo< TC, TO, TN, TW, TH >::set_title ( const std::string &  a_title)
inline

Definition at line 88 of file base_histo.

88 {parent::m_title = a_title;return true;}

◆ sum_all_bin_heights()

template<class TC , class TO , class TN , class TW , class TH >
TH tools::histo::base_histo< TC, TO, TN, TW, TH >::sum_all_bin_heights ( ) const
inline

Definition at line 123 of file base_histo.

123  {
124  TH sh = 0;
125  for(TO ibin=0;ibin<parent::m_bin_number;ibin++) {
126  sh += get_bin_height(ibin);
127  }
128  return sh;
129  }

◆ sum_bin_heights()

template<class TC , class TO , class TN , class TW , class TH >
TH tools::histo::base_histo< TC, TO, TN, TW, TH >::sum_bin_heights ( ) const
inline

Definition at line 114 of file base_histo.

114  {
115  TH sh = 0;
116  for(TO ibin=0;ibin<parent::m_bin_number;ibin++) {
117  if(!histo::is_out(parent::m_axes,ibin)) {
118  sh += get_bin_height(ibin);
119  }
120  }
121  return sh;
122  }

◆ sum_extra_bin_heights()

template<class TC , class TO , class TN , class TW , class TH >
TH tools::histo::base_histo< TC, TO, TN, TW, TH >::sum_extra_bin_heights ( ) const
inline

Definition at line 131 of file base_histo.

131  {
132  TH sh = 0;
133  for(TO ibin=0;ibin<parent::m_bin_number;ibin++) {
134  if(histo::is_out(parent::m_axes,ibin)) {
135  sh += get_bin_height(ibin);
136  }
137  }
138  return sh;
139  }

◆ title()

template<class TC , class TO , class TN , class TW , class TH >
const std::string& tools::histo::base_histo< TC, TO, TN, TW, TH >::title ( ) const
inline

Definition at line 87 of file base_histo.

87 {return parent::m_title;}

The documentation for this class was generated from the following file:
tools::jpeg::is
bool is(const std::string &a_file)
Definition: jpeg:216
tools::histo::histo_data::m_in_range_Sw2
TW m_in_range_Sw2
Definition: histo_data:189
tools::histo::base_histo::AxisX
@ AxisX
Definition: base_histo:291
tools::histo::base_histo::base_allocate
void base_allocate()
Definition: base_histo:398
tools::histo::histo_data::m_annotations
std::map< std::string, std::string > m_annotations
Definition: histo_data:184
tools::histo::histo_data::update_fast_getters
void update_fast_getters()
Definition: histo_data:103
tools::histo::histo_data::m_bin_Sx2w
std::vector< std::vector< TC > > m_bin_Sx2w
Definition: histo_data:179
tools::histo::get_offset
bool get_offset(const std::vector< axis< TC, TO > > &a_axes, const std::vector< int > &a_is, TO &a_offset)
Definition: axes:50
tools::histo::histo_data::m_in_range_Sxw
std::vector< TC > m_in_range_Sxw
Definition: histo_data:190
tools::histo::histo_data::equals
bool equals(const histo_data &a_from, const TW &a_prec, TW(*a_fabs)(TW)) const
Definition: histo_data:119
tools::histo::histo_data::m_bin_entries
std::vector< TN > m_bin_entries
Definition: histo_data:175
tools::histo::base_histo::is_compatible
bool is_compatible(const base_histo &a_histo)
Definition: base_histo:468
tools::histo::histo_data::m_bin_Sw
std::vector< TW > m_bin_Sw
Definition: histo_data:176
tools::waxml::begin
void begin(std::ostream &a_writer)
Definition: begend:15
tools::histo::histo_data::m_in_range_entries
TN m_in_range_entries
Definition: histo_data:187
tools::histo::base_histo::get_bin_height
virtual TH get_bin_height(TO) const =0
tools::histo::histo_data::m_in_range_Sx2w
std::vector< TC > m_in_range_Sx2w
Definition: histo_data:191
tools::histo::base_histo::AxisY
@ AxisY
Definition: base_histo:291
tools::histo::histo_data::m_title
std::string m_title
Definition: histo_data:171
tools::histo::base_histo::AxisZ
@ AxisZ
Definition: base_histo:291
tools::histo::is_out
bool is_out(const std::vector< axis< TC, TO > > &a_axes, TO a_offset)
Definition: axes:16
tools::histo::dim_planes
unsigned int dim_planes(unsigned int a_dim)
Definition: histo_data:17
tools::histo::histo_data::operator=
histo_data & operator=(const histo_data &a_from)
Definition: histo_data:69
tools::histo::get_indices
void get_indices(const std::vector< axis< TC, TO > > &a_axes, TO a_offset, std::vector< int > &a_is)
Definition: axes:30
tools::histo::histo_data::m_bin_Sxw
std::vector< std::vector< TC > > m_bin_Sxw
Definition: histo_data:178
tools::histo::histo_data::reset_fast_getters
void reset_fast_getters()
Definition: histo_data:93
tools::histo::histo_data::m_axes
std::vector< axis_t > m_axes
Definition: histo_data:181
tools::histo::base_histo::dim_t
unsigned int dim_t
Definition: base_histo:38
tools::histo::base_histo::configure
bool configure(dim_t a_dim, const std::vector< bn_t > &aNumbers, const std::vector< TC > &aMins, const std::vector< TC > &aMaxs)
Definition: base_histo:293
tools::waxml::end
void end(std::ostream &a_writer)
Definition: begend:31
tools::histo::histo_data::m_bin_Sw2
std::vector< TW > m_bin_Sw2
Definition: histo_data:177
tools::histo::histo_data::m_all_entries
TN m_all_entries
Definition: histo_data:186
tools::histo::histo_data::m_in_range_Sw
TW m_in_range_Sw
Definition: histo_data:188
tools::histo::base_histo::hd_t
histo_data< TC, TO, TN, TW > hd_t
Definition: base_histo:35
tools::histo::histo_data::m_bin_number
TO m_bin_number
Definition: histo_data:174
tools::histo::histo_data::m_in_range_plane_Sxyw
std::vector< TC > m_in_range_plane_Sxyw
Definition: histo_data:183
tools::histo::histo_data::m_dimension
dim_t m_dimension
Definition: histo_data:172