CMS 3D CMS Logo

RPCCluster.cc
Go to the documentation of this file.
1 #include "RPCCluster.h"
2 #include <iostream>
3 #include <fstream>
4 #include <cmath>
5 
6 using namespace std;
7 
9  fstrip(0), lstrip(0), bunchx(0),
10  sumTime(0), sumTime2(0), nTime(0), sumY(0), sumY2(0), nY(0)
11 {
12 }
13 
14 RPCCluster::RPCCluster(int fs, int ls, int bx) :
15  fstrip(fs), lstrip(ls), bunchx(bx),
16  sumTime(0), sumTime2(0), nTime(0), sumY(0), sumY2(0), nY(0)
17 {
18 }
19 
21 
22 int RPCCluster::firstStrip() const { return fstrip; }
23 int RPCCluster::lastStrip() const { return lstrip; }
24 int RPCCluster::clusterSize() const { return lstrip-fstrip+1; }
25 int RPCCluster::bx() const { return bunchx; }
26 
27 bool RPCCluster::hasTime() const { return nTime > 0; }
28 float RPCCluster::time() const { return hasTime() ? sumTime/nTime : 0; }
29 float RPCCluster::timeRMS() const { return hasTime() ? sqrt(max(0.F, sumTime2*nTime - sumTime*sumTime))/nTime : -1; }
30 
31 bool RPCCluster::hasY() const { return nY > 0; }
32 float RPCCluster::y() const { return hasY() ? sumY/nY : 0; }
33 float RPCCluster::yRMS() const { return hasY() ? sqrt(max(0.F, sumY2*nY - sumY*sumY))/nY : -1; }
34 
36 {
37  return ((cl.firstStrip() == this->firstStrip()-1) &&
38  (cl.bx() == this->bx()));
39 }
40 
41 void RPCCluster::addTime(const float time)
42 {
43  ++nTime;
44  sumTime += time;
45  sumTime2 += time*time;
46 }
47 
48 void RPCCluster::addY(const float y)
49 {
50  ++nY;
51  sumY += y;
52  sumY2 += y*y;
53 }
54 
56 {
57  if ( !this->isAdjacent(cl) ) return;
58 
59  fstrip = cl.firstStrip();
60 
61  nTime += cl.nTime;
62  sumTime += cl.sumTime;
63  sumTime2 += cl.sumTime2;
64 
65  nY += cl.nY;
66  sumY += cl.sumY;
67  sumY2 += cl.sumY2;
68 }
69 
71 {
72  if(cl.bx() == this->bx()) return cl.firstStrip()<this->firstStrip();
73 
74  return cl.bx()<this->bx();
75 }
76 
78 {
79  return ( (this->clusterSize() == cl.clusterSize()) &&
80  (this->bx() == cl.bx()) &&
81  (this->firstStrip() == cl.firstStrip()) );
82 }
uint16_t nY
Definition: RPCCluster.h:40
uint16_t nTime
Definition: RPCCluster.h:37
void addY(const float y)
Definition: RPCCluster.cc:48
int16_t bunchx
Definition: RPCCluster.h:34
bool operator==(const RPCCluster &cl) const
Definition: RPCCluster.cc:77
float timeRMS() const
Definition: RPCCluster.cc:29
void merge(const RPCCluster &cl)
Definition: RPCCluster.cc:55
int clusterSize() const
Definition: RPCCluster.cc:24
float sumTime2
Definition: RPCCluster.h:36
bool hasTime() const
Definition: RPCCluster.cc:27
uint16_t lstrip
Definition: RPCCluster.h:33
float sumY2
Definition: RPCCluster.h:39
float yRMS() const
Definition: RPCCluster.cc:33
T sqrt(T t)
Definition: SSEVec.h:18
float sumTime
Definition: RPCCluster.h:36
bool operator<(const RPCCluster &cl) const
Definition: RPCCluster.cc:70
def ls(path, rec=False)
Definition: eostools.py:349
float sumY
Definition: RPCCluster.h:39
int bx() const
Definition: RPCCluster.cc:25
bool hasY() const
Definition: RPCCluster.cc:31
float y() const
Definition: RPCCluster.cc:32
void addTime(const float time)
Definition: RPCCluster.cc:41
int lastStrip() const
Definition: RPCCluster.cc:23
static uInt32 F(BLOWFISH_CTX *ctx, uInt32 x)
Definition: blowfish.cc:281
uint16_t fstrip
Definition: RPCCluster.h:32
int firstStrip() const
Definition: RPCCluster.cc:22
float time() const
Definition: RPCCluster.cc:28
bool isAdjacent(const RPCCluster &cl) const
Definition: RPCCluster.cc:35