Public Member Functions | Protected Attributes | Static Protected Attributes | List of all members
caldp::LiteProfile Class Reference

Lightweight TProfile equivalent. More...

#include "/cvmfs/nova-development.opensciencegrid.org/novasoft/releases/N20-11-28/CalibrationDataProducts/AttenProfiles.h"

Public Member Functions

 LiteProfile ()
 
 LiteProfile (float w0, float w1)
 
void Fill (float x, float y)
 
LiteProfileoperator+= (LiteProfile const &rhs)
 
TH1F * ToTH1F () const
 
int TotalHits () const
 
int TotalEntries () const
 
std::vector< int > const & Count () const
 
std::vector< float > const & Sum () const
 
std::vector< float > const & SqSum () const
 

Protected Attributes

float fMinW
 
float fMaxW
 
std::vector< intfCount
 
std::vector< float > fSum
 
std::vector< float > fSqSum
 

Static Protected Attributes

static const size_t kNumBins = 100
 

Detailed Description

Lightweight TProfile equivalent.

Definition at line 24 of file AttenProfiles.h.

Constructor & Destructor Documentation

caldp::LiteProfile::LiteProfile ( )
inline

Definition at line 32 of file AttenProfiles.h.

References Count(), Fill(), operator+=(), SqSum(), Sum(), TotalEntries(), TotalHits(), ToTH1F(), submit_syst::x, and submit_syst::y.

33  : fMinW(-1)
34  , fMaxW(-1)
35  {}
caldp::LiteProfile::LiteProfile ( float  w0,
float  w1 
)

Definition at line 12 of file AttenProfiles.cxx.

13  : fMinW(w0)
14  , fMaxW(w1)
15  {
16  }

Member Function Documentation

std::vector< int > const & caldp::LiteProfile::Count ( ) const

Definition at line 118 of file AttenProfiles.cxx.

References fCount.

Referenced by LiteProfile(), and calib::AttenuationFit::writeResults().

119  {
120  return fCount;
121  }
std::vector< int > fCount
Definition: AttenProfiles.h:55
void caldp::LiteProfile::Fill ( float  x,
float  y 
)

Definition at line 19 of file AttenProfiles.cxx.

References ana::assert(), bin, fCount, fMaxW, fMinW, fSqSum, fSum, kNumBins, and submit_syst::y.

Referenced by calib::CosmicCalib::FillPathLengthInfo(), calib::MakeAttenuationProfiles::FillPathLengthInfo(), and LiteProfile().

20  {
21  const unsigned int bin = ((x-fMinW)*kNumBins)/(fMaxW-fMinW);
22  if(x < fMinW || bin > kNumBins) return; // Drop overflows
23 
24  assert(y >= 0);
25 
26  // only reserve the memory necessary for the
27  // the vectors when needed, not at construction
28  // assume if the fCount vector is not at the size
29  // of kNumBins, then none of them are
30  if(fCount.size() < kNumBins){
31  fCount.resize(kNumBins, 0 );
32  fSum .resize(kNumBins, 0.);
33  fSqSum.resize(kNumBins, 0.);
34  }
35 
36  ++fCount[bin];
37  fSum[bin] += y;
38  fSqSum[bin] += y*y;
39  }
std::vector< int > fCount
Definition: AttenProfiles.h:55
float bin[41]
Definition: plottest35.C:14
static const size_t kNumBins
Definition: AttenProfiles.h:53
std::vector< float > fSum
Definition: AttenProfiles.h:56
std::vector< float > fSqSum
Definition: AttenProfiles.h:57
assert(nhit_max >=nhit_nbins)
LiteProfile & caldp::LiteProfile::operator+= ( LiteProfile const &  rhs)

Definition at line 42 of file AttenProfiles.cxx.

References ana::assert(), fCount, fMaxW, fMinW, fSqSum, fSum, MECModelEnuComparisons::i, kNumBins, and LOG_DEBUG.

Referenced by caldp::AttenProfiles::AttenProfiles(), caldp::AttenProfilesMap::AttenProfilesMap(), and LiteProfile().

43  {
44  assert(rhs.fMinW == fMinW);
45  assert(rhs.fMaxW == fMaxW);
46 
47  // only reserve the memory necessary for the
48  // the vectors when needed, not at construction
49  // assume if the fCount vector is not at the size
50  // of kNumBins, then none of them are
51  if(fCount.size() < kNumBins){
52  fCount.resize(kNumBins, 0 );
53  fSum .resize(kNumBins, 0.);
54  fSqSum.resize(kNumBins, 0.);
55  }
56 
57  // only add the profiles if they have the same
58  // number of entried for each vector
59  if(fCount.size() == rhs.fCount.size() &&
60  fSum.size() == rhs.fSum.size() &&
61  fSqSum.size() == rhs.fSqSum.size() ){
62 
63  for(size_t i = 0; i < fCount.size(); ++i){
64  LOG_DEBUG("AttenProfiles") << i << " " << rhs.fCount[i] << " " << rhs.fSum[i] << " " << rhs.fSqSum[i];
65  fCount[i] += rhs.fCount[i];
66  fSum[i] += rhs.fSum[i];
67  fSqSum[i] += rhs.fSqSum[i];
68  }
69  }
70 
71  return *this;
72  }
#define LOG_DEBUG(stream)
Definition: Messenger.h:149
std::vector< int > fCount
Definition: AttenProfiles.h:55
static const size_t kNumBins
Definition: AttenProfiles.h:53
std::vector< float > fSum
Definition: AttenProfiles.h:56
std::vector< float > fSqSum
Definition: AttenProfiles.h:57
assert(nhit_max >=nhit_nbins)
std::vector< float > const & caldp::LiteProfile::SqSum ( ) const

Definition at line 130 of file AttenProfiles.cxx.

References fSqSum.

Referenced by LiteProfile().

131  {
132  return fSqSum;
133  }
std::vector< float > fSqSum
Definition: AttenProfiles.h:57
std::vector< float > const & caldp::LiteProfile::Sum ( ) const

Definition at line 124 of file AttenProfiles.cxx.

References fSum.

Referenced by LiteProfile(), and calib::AttenuationFit::writeResults().

125  {
126  return fSum;
127  }
std::vector< float > fSum
Definition: AttenProfiles.h:56
int caldp::LiteProfile::TotalEntries ( ) const

Definition at line 107 of file AttenProfiles.cxx.

References fCount, MECModelEnuComparisons::i, kNumBins, and runNovaSAM::ret.

Referenced by calib::AttenFit::endJob(), calib::AttenFit::GetBestHistogram(), calib::AttenuationFit::GetBestHistogram(), LiteProfile(), and calib::AttenuationFit::writeResults().

108  {
109  int ret =0;
110  for(size_t i = 0; i < kNumBins; ++i){
111  ret+=fCount[i];
112  }
113 
114  return ret;
115  }
std::vector< int > fCount
Definition: AttenProfiles.h:55
static const size_t kNumBins
Definition: AttenProfiles.h:53
int caldp::LiteProfile::TotalHits ( ) const

Definition at line 99 of file AttenProfiles.cxx.

References fSum, getGoodRuns4SAM::n, and runNovaSAM::ret.

Referenced by caldp::AttenProfilesMap::GetAllProfilesByPlaneAndCell(), and LiteProfile().

100  {
101  int ret = 0;
102  for(int n: fSum) ret += n;
103  return ret;
104  }
std::vector< float > fSum
Definition: AttenProfiles.h:56
TH1F * caldp::LiteProfile::ToTH1F ( ) const

Definition at line 75 of file AttenProfiles.cxx.

References fCount, fMaxW, fMinW, fSqSum, fSum, make_syst_table_plots::h, MECModelEnuComparisons::i, kNumBins, and std::sqrt().

Referenced by calib::AttenFit::endJob(), caldp::AttenProfilesMap::GetAllProfilesByPlaneAndCell(), LiteProfile(), and calib::AttenuationFit::writeResults().

76  {
77  TH1F* h = new TH1F("", "", kNumBins, fMinW, fMaxW);
78 
79  for(size_t i = 0; i < kNumBins; ++i){
80  const int N = fCount[i];
81  if(N < 1) continue;
82  h->SetEntries(h->GetEntries()+N);
83 
84  h->SetBinContent(i+1, fSum[i]/N);
85 
86  const float arg = fSqSum[i]-fSum[i]*fSum[i]/N;
87  if(arg >= 0){
88  h->SetBinError(i+1, std::sqrt(arg)/N);
89  }
90  else{
91  h->SetBinError(i+1, fSum[i]/N);
92  }
93  }
94 
95  return h;
96  }
std::vector< int > fCount
Definition: AttenProfiles.h:55
T sqrt(T number)
Definition: d0nt_math.hpp:156
static const size_t kNumBins
Definition: AttenProfiles.h:53
std::vector< float > fSum
Definition: AttenProfiles.h:56
std::vector< float > fSqSum
Definition: AttenProfiles.h:57

Member Data Documentation

std::vector<int> caldp::LiteProfile::fCount
protected

Definition at line 55 of file AttenProfiles.h.

Referenced by Count(), Fill(), operator+=(), TotalEntries(), and ToTH1F().

float caldp::LiteProfile::fMaxW
protected

Definition at line 51 of file AttenProfiles.h.

Referenced by Fill(), caldp::AttenProfilesMap::MaxW(), operator+=(), and ToTH1F().

float caldp::LiteProfile::fMinW
protected

Definition at line 51 of file AttenProfiles.h.

Referenced by Fill(), caldp::AttenProfilesMap::MinW(), operator+=(), and ToTH1F().

std::vector<float> caldp::LiteProfile::fSqSum
protected

Definition at line 57 of file AttenProfiles.h.

Referenced by Fill(), operator+=(), SqSum(), and ToTH1F().

std::vector<float> caldp::LiteProfile::fSum
protected

Definition at line 56 of file AttenProfiles.h.

Referenced by Fill(), operator+=(), Sum(), TotalHits(), and ToTH1F().

const size_t caldp::LiteProfile::kNumBins = 100
staticprotected

Definition at line 53 of file AttenProfiles.h.

Referenced by Fill(), operator+=(), TotalEntries(), and ToTH1F().


The documentation for this class was generated from the following files: