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  for (int i = 0; i < fNrocs_; ++i) {
15  fRocs_.push_back(a);
16  }
17 };
18 
19 // ----------------------------------------------------------------------
21 
22 // ----------------------------------------------------------------------
24  if (iroc < fNrocs_)
25  fRocs_[iroc].fillDIGI();
26 }
27 // ----------------------------------------------------------------------
29  int roc_first = int(ch.roc_first);
30  int roc_last = int(ch.roc_last);
31  for (int iroc = 0; iroc < fNrocs_; iroc++) {
32  if (iroc >= roc_first && iroc <= roc_last) {
33  fRocs_[iroc].fillFEDerror25();
34  }
35  }
36 }
37 // ----------------------------------------------------------------------
39 // ----------------------------------------------------------------------
41 // ----------------------------------------------------------------------
43 // ----------------------------------------------------------------------
44 void SiPixelModuleStatus::setNrocs(int nRoc) { fNrocs_ = nRoc; }
45 
46 // ----------------------------------------------------------------------
47 void SiPixelModuleStatus::updateDIGI(int iroc, unsigned int nhit) {
48  if (iroc < fNrocs_)
49  fRocs_[iroc].updateDIGI(nhit);
50 }
51 // ----------------------------------------------------------------------
52 void SiPixelModuleStatus::updateFEDerror25(int iroc, bool fedError25) {
53  if (iroc < fNrocs_)
54  fRocs_[iroc].updateFEDerror25(fedError25);
55 }
56 
57 // ----------------------------------------------------------------------
58 unsigned int SiPixelModuleStatus::digiOccROC(int iroc) { return (iroc < fNrocs_ ? fRocs_[iroc].digiOccROC() : 0); }
59 // ----------------------------------------------------------------------
60 bool SiPixelModuleStatus::fedError25(int iroc) { return (iroc < fNrocs_ ? fRocs_[iroc].isFEDerror25() : false); }
61 // ----------------------------------------------------------------------
63  unsigned int count(0);
64  for (int iroc = 0; iroc < fNrocs_; ++iroc) {
65  count += digiOccROC(iroc);
66  }
67  return count;
68 }
69 
70 // ----------------------------------------------------------------------
72  unsigned int ave(0);
73  for (int iroc = 0; iroc < fNrocs_; ++iroc) {
74  unsigned int inc = digiOccROC(iroc);
75  ave += inc;
76  }
77  return (1.0 * ave) / fNrocs_;
78 }
79 
81  double fModAverage = SiPixelModuleStatus::perRocDigiOcc();
82 
83  double sig = 1.0;
84  for (int iroc = 0; iroc < fNrocs_; ++iroc) {
85  unsigned int inc = digiOccROC(iroc);
86  sig += (fModAverage - inc) * (fModAverage - inc);
87  }
88 
89  double fModSigma = sig / (fNrocs_ - 1);
90  return TMath::Sqrt(fModSigma);
91 }
92 
93 // ----------------------------------------------------------------------
94 // Return the address not the value of ROC status
95 SiPixelRocStatus* SiPixelModuleStatus::getRoc(int iroc) { return (iroc < fNrocs_ ? &fRocs_[iroc] : nullptr); }
96 
97 // ----------------------------------------------------------------------
98 void SiPixelModuleStatus::updateModuleDIGI(int iroc, unsigned int nhits) {
99  if (iroc < fNrocs_)
100  fRocs_[iroc].updateDIGI(nhits);
101 }
102 // ----------------------------------------------------------------------
104  bool isSameModule = true;
105  if (fDetid_ != newData.detid() || fNrocs_ != newData.nrocs()) {
106  isSameModule = false;
107  }
108 
109  if (isSameModule) {
110  for (int iroc = 0; iroc < fNrocs_; ++iroc) { // loop over rocs
111  //update occupancy
112  fRocs_[iroc].updateDIGI(newData.digiOccROC(iroc));
113  //update FEDerror25
114  fRocs_[iroc].updateFEDerror25(newData.fedError25(iroc));
115 
116  } // loop over rocs
117 
118  } // if same module
119 }
void updateModuleDIGI(int roc, unsigned int nhits)
combine new data to update(topup) module status
void fillDIGI(int iroc)
fill digi
void fillFEDerror25(PixelFEDChannel ch)
fill FEDerror25
std::vector< SiPixelRocStatus > fRocs_
int detid()
accessors and setters
bool fedError25(int iroc)
return ROC FEDerror25
unsigned int roc_last
void setDetId(int detid)
void updateFEDerror25(int iroc, bool FEDerror25)
update FEDerror25
void updateDIGI(int iroc, unsigned int nhit)
update digi (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:119
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