CMS 3D CMS Logo

SiPixelModuleStatus.cc
Go to the documentation of this file.
1 #include <iostream>
2 #include <map>
3 #include <cmath>
4 #include <vector>
5 
6 #include <TMath.h>
7 #include <TH1.h>
8 
10 
11 using namespace std;
12 
13 // ----------------------------------------------------------------------
14 SiPixelModuleStatus::SiPixelModuleStatus(int detId, int nrocs): fDetid(detId), fNrocs(nrocs) {
15 
16  for (int i = 0; i < fNrocs; ++i) {
18  fRocs.push_back(a);
19  }
20 
21  fModAverage = fModSigma = 0.;
22 
23 };
24 
25 
26 // ----------------------------------------------------------------------
28 
29 
30 // ----------------------------------------------------------------------
31 void SiPixelModuleStatus::fillDIGI(int iroc, int idc) {
32 
33  if (iroc < fNrocs)
34  fRocs[iroc].fillDIGI(idc);
35 
36 }
37 
38 // ----------------------------------------------------------------------
39 void SiPixelModuleStatus::updateDIGI(int iroc, int idc, unsigned long int nhit) {
40 
41  if (iroc < fNrocs)
42  fRocs[iroc].updateDIGI(idc, nhit);
43 
44 }
45 
46 // ----------------------------------------------------------------------
48 
49  int fed = int(ch.fed);
50  int link = int(ch.link);
51  int roc_first = int(ch.roc_first); int roc_last = int(ch.roc_last);
52  for (int iroc = 0; iroc < fNrocs; iroc++){
53  if(iroc>=roc_first && iroc<=roc_last){
54  fRocs[iroc].fillStuckTBM(fed,link,time);
55  }
56  }
57 
58 }
59 
60 // ----------------------------------------------------------------------
61 unsigned long int SiPixelModuleStatus::digiOccDC(int iroc, int idc) {
62 
63  return (iroc < fNrocs ? fRocs[iroc].digiOccDC(idc) : -1);
64 
65 }
66 
67 
68 // ----------------------------------------------------------------------
69 unsigned long int SiPixelModuleStatus::digiOccROC(int iroc) {
70 
71  return (iroc < fNrocs ? fRocs[iroc].digiOccROC() : -1);
72 
73 }
74 
75 
76 // ----------------------------------------------------------------------
77 unsigned long int SiPixelModuleStatus::digiOccMOD() {
78 
79  unsigned long int count(0);
80  for (int iroc = 0; iroc < fNrocs; ++iroc) {
81  count += digiOccROC(iroc);
82  }
83  return count;
84 
85 }
86 
87 
88 // ----------------------------------------------------------------------
90 
91  return fDetid;
92 
93 }
94 
95 
96 // ----------------------------------------------------------------------
98  return fNrocs;
99 }
100 
101 // ----------------------------------------------------------------------
103  fNrocs = iroc;
104 }
105 
106 
107 // ----------------------------------------------------------------------
109  digiOccupancy();
110  return fModAverage;
111 }
112 
113 
114 // ----------------------------------------------------------------------
116 
117  digiOccupancy();
118  return fModSigma;
119 }
120 
121 // ----------------------------------------------------------------------
123 
124  fModAverage = fModSigma = 0.;
125  unsigned long int ave(0.), sig(0.);
126  for (int iroc = 0; iroc < fNrocs; ++iroc) {
127  unsigned long int inc = digiOccROC(iroc);
128  ave += inc;
129  }
130  fModAverage = (1.0*ave)/fNrocs;
131 
132  for (int iroc = 0; iroc < fNrocs; ++iroc) {
133  unsigned long int inc = digiOccROC(iroc);
134  sig += (fModAverage-inc)*(fModAverage-inc);
135  }
136 
137  fModSigma = sig/(fNrocs-1);
138  fModSigma = TMath::Sqrt(fModSigma);
139 
140 }
141 
142 
143 // ----------------------------------------------------------------------
144 // Be careful : return the address not the value of ROC status
146  return &fRocs[i];
147 }
148 
149 // ----------------------------------------------------------------------
150 void SiPixelModuleStatus::updateModuleDIGI(int iroc, int idc, unsigned long int nhits) {
151  fRocs[iroc].updateDIGI(idc,nhits);
152 }
153 
155 
156  bool isSameModule = true;
157  if( fDetid!=newData.detid() || fNrocs!=newData.nrocs()) {
158  isSameModule = false;
159  }
160 
161  if(isSameModule){
162 
163  for (int iroc = 0; iroc < fNrocs; ++iroc) {
164  int nDC = fRocs[iroc].nDC();
165  //update occupancy
166  for(int idc = 0; idc < nDC; ++idc) {
167  fRocs[iroc].updateDIGI(idc,newData.digiOccDC(iroc,idc));
168  }
169  //update stuckTBM
170  SiPixelRocStatus* rocStatus = newData.getRoc(iroc);
171  if(rocStatus->isStuckTBM()){
172  fRocs[iroc].updateStuckTBM(rocStatus->getBadFed(), rocStatus->getBadLink(),rocStatus->getStartBadTime(), rocStatus->getBadFreq());
173  }
174  }
175 
176  } // if same module
177 
178 }
void updateDIGI(int iroc, int idc, unsigned long nhit)
fill with online coordinates (nhit > 1)
unsigned int fed
int detid()
accessors and setters
void digiOccupancy()
calculate (averaged over this module&#39;s ROCs) mean hit number and its sigma
unsigned int link
unsigned int roc_last
void fillStuckTBM(PixelFEDChannel ch, std::time_t time)
fill stuck TBM
std::vector< SiPixelRocStatus > fRocs
void fillDIGI(int iroc, int idc)
fill with online coordinates
unsigned long int digiOccROC(int iroc)
return ROC status (= hits on ROC iroc)
void updateModuleDIGI(int roc, int dc, unsigned long int nhits)
combine new data to update(topup) module status
unsigned long int getBadFreq()
unsigned int getBadLink()
unsigned int getBadFed()
SiPixelModuleStatus(int det=0, int nrocs=16)
unsigned int roc_first
unsigned long int digiOccMOD()
return module status (= hits on module)
std::time_t getStartBadTime()
double a
Definition: hdecay.h:121
SiPixelRocStatus * getRoc(int i)
get a ROC
void updateModuleStatus(SiPixelModuleStatus newData)
unsigned long int digiOccDC(int iroc, int idc)
return DC status of a ROC (=hits on DC idc on ROC iroc)