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 44 of file RPCLinkSynchroStat.h.

Constructor & Destructor Documentation

◆ SynchroCounts() [1/2]

RPCLinkSynchroStat::SynchroCounts::SynchroCounts ( )
inline

Definition at line 46 of file RPCLinkSynchroStat.h.

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

◆ SynchroCounts() [2/2]

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

Definition at line 47 of file RPCLinkSynchroStat.h.

47 : 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 58 of file RPCLinkSynchroStat.h.

58 { return theCounts; }

References theCounts.

◆ firstHit()

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

Definition at line 45 of file RPCLinkSynchroStat.cc.

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

References mps_fire::i.

◆ increment()

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

Definition at line 57 of file RPCLinkSynchroStat.cc.

57  {
58  if (bxDiff < 8)
59  theCounts[bxDiff]++;
60 }

◆ mean()

double RPCLinkSynchroStat::SynchroCounts::mean ( ) const

Definition at line 82 of file RPCLinkSynchroStat.cc.

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

◆ mom0()

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

Definition at line 68 of file RPCLinkSynchroStat.cc.

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

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

Referenced by sum().

◆ mom1()

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

Definition at line 75 of file RPCLinkSynchroStat.cc.

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

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

◆ operator+=()

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

Definition at line 62 of file RPCLinkSynchroStat.cc.

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

References mps_fire::i, and theCounts.

◆ operator==()

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

Definition at line 109 of file RPCLinkSynchroStat.cc.

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

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

◆ print()

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

Definition at line 99 of file RPCLinkSynchroStat.cc.

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

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

◆ rms()

double RPCLinkSynchroStat::SynchroCounts::rms ( ) const

Definition at line 87 of file RPCLinkSynchroStat.cc.

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

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

◆ set()

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

Definition at line 52 of file RPCLinkSynchroStat.cc.

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

◆ sum()

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

Definition at line 55 of file RPCLinkSynchroStat.h.

55 { return mom0(); }

References mom0().

Member Data Documentation

◆ theCounts

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

Definition at line 65 of file RPCLinkSynchroStat.h.

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

mps_fire.i
i
Definition: mps_fire.py:428
hfClusterShapes_cfi.hits
hits
Definition: hfClusterShapes_cfi.py:5
EcalTangentSkim_cfg.o
o
Definition: EcalTangentSkim_cfg.py:42
heavyIonCSV_trainingSettings.idx
idx
Definition: heavyIonCSV_trainingSettings.py:5
RPCLinkSynchroStat::SynchroCounts::mom1
double mom1() const
Definition: RPCLinkSynchroStat.cc:75
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
RPCLinkSynchroStat::SynchroCounts::rms
double rms() const
Definition: RPCLinkSynchroStat.cc:87
str
#define str(s)
Definition: TestProcessor.cc:53
RPCLinkSynchroStat::SynchroCounts::sum
unsigned int sum() const
Definition: RPCLinkSynchroStat.h:55
RPCLinkSynchroStat::SynchroCounts::mean
double mean() const
Definition: RPCLinkSynchroStat.cc:82
mps_fire.result
result
Definition: mps_fire.py:311
RPCLinkSynchroStat::SynchroCounts::mom0
unsigned int mom0() const
Definition: RPCLinkSynchroStat.cc:68
RPCLinkSynchroStat::SynchroCounts::theCounts
std::vector< unsigned int > theCounts
Definition: RPCLinkSynchroStat.h:65