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 // ----------------------------------------------------------------------
12 SiPixelModuleStatus::SiPixelModuleStatus(int detId, int nrocs): fDetid(detId), fNrocs(nrocs) {
13 
14  for (int i = 0; i < fNrocs; ++i) {
16  fRocs.push_back(a);
17  }
18 
19 };
20 
21 
22 // ----------------------------------------------------------------------
24 
25 
26 // ----------------------------------------------------------------------
28 
29  if (iroc < fNrocs)
30  fRocs[iroc].fillDIGI();
31 
32 }
33 
34 // ----------------------------------------------------------------------
35 void SiPixelModuleStatus::updateDIGI(int iroc, unsigned int nhit) {
36 
37  if (iroc < fNrocs)
38  fRocs[iroc].updateDIGI(nhit);
39 
40 }
41 
42 // ----------------------------------------------------------------------
44 
45  int roc_first = int(ch.roc_first); int roc_last = int(ch.roc_last);
46  for (int iroc = 0; iroc < fNrocs; iroc++){
47  if(iroc>=roc_first && iroc<=roc_last){
48  fRocs[iroc].fillFEDerror25();
49  }
50  }
51 
52 }
53 
54 // ----------------------------------------------------------------------
55 unsigned int SiPixelModuleStatus::digiOccROC(int iroc) {
56 
57  return (iroc < fNrocs ? fRocs[iroc].digiOccROC() : -1);
58 
59 }
60 
61 // ----------------------------------------------------------------------
63 
64  unsigned int count(0);
65  for (int iroc = 0; iroc < fNrocs; ++iroc) {
66  count += digiOccROC(iroc);
67  }
68  return count;
69 
70 }
71 
72 // ----------------------------------------------------------------------
74 
75  return fDetid;
76 
77 }
78 
79 // ----------------------------------------------------------------------
81 
82  return fNrocs;
83 
84 }
85 
86 // ----------------------------------------------------------------------
88 
89  fNrocs = iroc;
90 
91 }
92 
93 // ----------------------------------------------------------------------
95 
96  unsigned int ave(0);
97  for (int iroc = 0; iroc < fNrocs; ++iroc) {
98  unsigned int inc = digiOccROC(iroc);
99  ave += inc;
100  }
101  return (1.0*ave)/fNrocs;
102 
103 }
104 
106 
107  double fModAverage = SiPixelModuleStatus::perRocDigiOcc();
108 
109  double sig = 1.0;
110  for (int iroc = 0; iroc < fNrocs; ++iroc) {
111  unsigned int inc = digiOccROC(iroc);
112  sig += (fModAverage-inc)*(fModAverage-inc);
113  }
114 
115  double fModSigma = sig/(fNrocs-1);
116  return TMath::Sqrt(fModSigma);
117 
118 }
119 
120 // ----------------------------------------------------------------------
121 // Be careful : return the address not the value of ROC status
123 
124  return &fRocs[i];
125 
126 }
127 
128 // ----------------------------------------------------------------------
129 void SiPixelModuleStatus::updateModuleDIGI(int iroc, unsigned int nhits) {
130 
131  fRocs[iroc].updateDIGI(nhits);
132 
133 }
134 
136 
137  bool isSameModule = true;
138  if( fDetid!=newData.detid() || fNrocs!=newData.nrocs()) {
139  isSameModule = false;
140  }
141 
142  if(isSameModule){
143 
144  for (int iroc = 0; iroc < fNrocs; ++iroc) {
145  //update occupancy
146  fRocs[iroc].updateDIGI(newData.digiOccROC(iroc));
147  //update FEDerror25
148  SiPixelRocStatus* rocStatus = newData.getRoc(iroc);
149  if(rocStatus->isFEDerror25()){
150  fRocs[iroc].fillFEDerror25();
151  }
152  }
153 
154  } // if same module
155 
156 }
void updateModuleDIGI(int roc, unsigned int nhits)
combine new data to update(topup) module status
void fillDIGI(int iroc)
fill with online coordinates
void fillFEDerror25(PixelFEDChannel ch)
fill FEDerror25
int detid()
accessors and setters
unsigned int roc_last
std::vector< SiPixelRocStatus > fRocs
void updateDIGI(int iroc, unsigned int nhit)
fill with online coordinates (nhit > 1)
SiPixelModuleStatus(int det=0, int nrocs=16)
unsigned int roc_first
unsigned int digiOccMOD()
return module status (= hits on module)
double a
Definition: hdecay.h:121
SiPixelRocStatus * getRoc(int i)
get a ROC
void updateModuleStatus(SiPixelModuleStatus newData)
unsigned int digiOccROC(int iroc)
return ROC status (= hits on ROC iroc)
double perRocDigiOcc()
calculate (averaged over this module&#39;s ROCs) mean hit number and its sigma