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)) {}
std::vector< unsigned int > theCounts

◆ 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)) {}
std::vector< unsigned int > theCounts

Member Function Documentation

◆ counts()

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

Definition at line 58 of file RPCLinkSynchroStat.h.

References theCounts.

58 { return theCounts; }
std::vector< unsigned int > theCounts

◆ firstHit()

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

Definition at line 45 of file RPCLinkSynchroStat.cc.

References mps_fire::i.

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

◆ 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 }
std::vector< unsigned int > theCounts

◆ 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.

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

Referenced by sum().

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

◆ mom1()

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

Definition at line 75 of file RPCLinkSynchroStat.cc.

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

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

◆ operator+=()

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

Definition at line 62 of file RPCLinkSynchroStat.cc.

References mps_fire::i, and theCounts.

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

◆ operator==()

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

Definition at line 109 of file RPCLinkSynchroStat.cc.

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

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

◆ print()

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

Definition at line 99 of file RPCLinkSynchroStat.cc.

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

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 }
std::vector< unsigned int > theCounts
#define str(s)

◆ rms()

double RPCLinkSynchroStat::SynchroCounts::rms ( ) const

Definition at line 87 of file RPCLinkSynchroStat.cc.

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

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 }
T sqrt(T t)
Definition: SSEVec.h:19
std::vector< unsigned int > theCounts

◆ 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 }
std::vector< unsigned int > theCounts

◆ sum()

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

Definition at line 55 of file RPCLinkSynchroStat.h.

References mom0().

55 { return 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+=().