CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
RPCLinkSynchroStat::SynchroCounts Class Reference

#include <RPCLinkSynchroStat.h>

Public Member Functions

const std::vector< unsigned int > & counts () const
 
unsigned int firstHit () const
 
void increment (unsigned int bxDiff)
 
double mean () const
 
SynchroCountsoperator+= (const SynchroCounts &rhs)
 
bool operator== (const SynchroCounts &) const
 
std::string print () const
 
double rms () const
 
void set (unsigned int bxDiff)
 
unsigned int sum () const
 
 SynchroCounts ()
 
 SynchroCounts (const unsigned int *hits)
 

Private Member Functions

unsigned int mom0 () const
 
double mom1 () const
 

Private Attributes

std::vector< unsigned int > theCounts
 

Detailed Description

Definition at line 45 of file RPCLinkSynchroStat.h.

Constructor & Destructor Documentation

◆ SynchroCounts() [1/2]

RPCLinkSynchroStat::SynchroCounts::SynchroCounts ( )
inline

Definition at line 47 of file RPCLinkSynchroStat.h.

47 : theCounts(std::vector<unsigned int>(8, 0)) {}

◆ SynchroCounts() [2/2]

RPCLinkSynchroStat::SynchroCounts::SynchroCounts ( const unsigned int *  hits)
inline

Definition at line 48 of file RPCLinkSynchroStat.h.

48 : theCounts(std::vector<unsigned int>(hits, hits + 8)) {}

Member Function Documentation

◆ counts()

const std::vector<unsigned int>& RPCLinkSynchroStat::SynchroCounts::counts ( ) const
inline

Definition at line 59 of file RPCLinkSynchroStat.h.

59 { return theCounts; }

References theCounts.

◆ firstHit()

unsigned int RPCLinkSynchroStat::SynchroCounts::firstHit ( ) const

Definition at line 47 of file RPCLinkSynchroStat.cc.

47  {
48  for (unsigned int i = 0; i < 8; ++i)
49  if (theCounts[i])
50  return i;
51  return 8;
52 }

References mps_fire::i.

◆ increment()

void RPCLinkSynchroStat::SynchroCounts::increment ( unsigned int  bxDiff)

Definition at line 59 of file RPCLinkSynchroStat.cc.

59  {
60  if (bxDiff < 8)
61  theCounts[bxDiff]++;
62 }

◆ mean()

double RPCLinkSynchroStat::SynchroCounts::mean ( ) const

Definition at line 84 of file RPCLinkSynchroStat.cc.

84  {
85  unsigned int sum = mom0();
86  return sum == 0 ? 0. : mom1() / sum;
87 }

◆ mom0()

unsigned int RPCLinkSynchroStat::SynchroCounts::mom0 ( ) const
private

Definition at line 70 of file RPCLinkSynchroStat.cc.

70  {
71  unsigned int result = 0;
72  for (unsigned int i = 0; i < 8; ++i)
73  result += theCounts[i];
74  return result;
75 }

References mps_fire::i, and mps_fire::result.

Referenced by sum().

◆ mom1()

double RPCLinkSynchroStat::SynchroCounts::mom1 ( ) const
private

Definition at line 77 of file RPCLinkSynchroStat.cc.

77  {
78  double result = 0.;
79  for (unsigned int i = 0; i < 8; ++i)
80  result += i * theCounts[i];
81  return result;
82 }

References mps_fire::i, and mps_fire::result.

◆ operator+=()

RPCLinkSynchroStat::SynchroCounts & RPCLinkSynchroStat::SynchroCounts::operator+= ( const SynchroCounts rhs)

Definition at line 64 of file RPCLinkSynchroStat.cc.

64  {
65  for (unsigned int i = 0; i < 8; ++i)
66  theCounts[i] += rhs.theCounts[i];
67  return *this;
68 }

References mps_fire::i, and theCounts.

◆ operator==()

bool RPCLinkSynchroStat::SynchroCounts::operator== ( const SynchroCounts o) const

Definition at line 111 of file RPCLinkSynchroStat.cc.

111  {
112  for (unsigned int idx = 0; idx < 8; ++idx)
113  if (theCounts[idx] != o.theCounts[idx])
114  return false;
115  return true;
116 }

References training_settings::idx, and EcalTangentSkim_cfg::o.

◆ print()

std::string RPCLinkSynchroStat::SynchroCounts::print ( void  ) const

Definition at line 101 of file RPCLinkSynchroStat.cc.

101  {
102  std::ostringstream str;
103  str << " mean: " << std::setw(8) << mean();
104  str << " rms: " << std::setw(8) << rms();
105  str << " counts:";
106  for (int i = 0; i < 8; ++i)
107  str << " " << std::setw(4) << theCounts[i];
108  return str.str();
109 }

References mps_fire::i, SiStripPI::mean, SiStripPI::rms, and str.

◆ rms()

double RPCLinkSynchroStat::SynchroCounts::rms ( ) const

Definition at line 89 of file RPCLinkSynchroStat.cc.

89  {
90  double result = 0.;
91  int sum = mom0();
92  if (sum == 0)
93  return 0.;
94  double mean = mom1() / sum;
95  for (int i = 0; i < 8; ++i)
96  result += theCounts[i] * (mean - i) * (mean - i);
97  result /= sum;
98  return sqrt(result);
99 }

References mps_fire::i, SiStripPI::mean, mps_fire::result, and mathSSE::sqrt().

◆ set()

void RPCLinkSynchroStat::SynchroCounts::set ( unsigned int  bxDiff)

Definition at line 54 of file RPCLinkSynchroStat.cc.

54  {
55  if (bxDiff < 8)
56  theCounts[bxDiff] = 1;
57 }

◆ sum()

unsigned int RPCLinkSynchroStat::SynchroCounts::sum ( ) const
inline

Definition at line 56 of file RPCLinkSynchroStat.h.

56 { return mom0(); }

References mom0().

Member Data Documentation

◆ theCounts

std::vector<unsigned int> RPCLinkSynchroStat::SynchroCounts::theCounts
private

Definition at line 66 of file RPCLinkSynchroStat.h.

Referenced by counts(), and operator+=().

mps_fire.i
i
Definition: mps_fire.py:355
hfClusterShapes_cfi.hits
hits
Definition: hfClusterShapes_cfi.py:5
training_settings.idx
idx
Definition: training_settings.py:16
EcalTangentSkim_cfg.o
o
Definition: EcalTangentSkim_cfg.py:36
RPCLinkSynchroStat::SynchroCounts::mom1
double mom1() const
Definition: RPCLinkSynchroStat.cc:77
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
RPCLinkSynchroStat::SynchroCounts::rms
double rms() const
Definition: RPCLinkSynchroStat.cc:89
str
#define str(s)
Definition: TestProcessor.cc:48
RPCLinkSynchroStat::SynchroCounts::sum
unsigned int sum() const
Definition: RPCLinkSynchroStat.h:56
RPCLinkSynchroStat::SynchroCounts::mean
double mean() const
Definition: RPCLinkSynchroStat.cc:84
mps_fire.result
result
Definition: mps_fire.py:303
RPCLinkSynchroStat::SynchroCounts::mom0
unsigned int mom0() const
Definition: RPCLinkSynchroStat.cc:70
RPCLinkSynchroStat::SynchroCounts::theCounts
std::vector< unsigned int > theCounts
Definition: RPCLinkSynchroStat.h:66