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 
28 // ----------------------------------------------------------------------
29 void SiPixelModuleStatus::updateDIGI(int iroc, unsigned int nhit) {
30  if (iroc < fNrocs)
31  fRocs[iroc].updateDIGI(nhit);
32 }
33 
34 // ----------------------------------------------------------------------
36  int roc_first = int(ch.roc_first);
37  int roc_last = int(ch.roc_last);
38  for (int iroc = 0; iroc < fNrocs; iroc++) {
39  if (iroc >= roc_first && iroc <= roc_last) {
40  fRocs[iroc].fillFEDerror25();
41  }
42  }
43 }
44 
45 // ----------------------------------------------------------------------
46 unsigned int SiPixelModuleStatus::digiOccROC(int iroc) { return (iroc < fNrocs ? fRocs[iroc].digiOccROC() : -1); }
47 
48 // ----------------------------------------------------------------------
50  unsigned int count(0);
51  for (int iroc = 0; iroc < fNrocs; ++iroc) {
52  count += digiOccROC(iroc);
53  }
54  return count;
55 }
56 
57 // ----------------------------------------------------------------------
59 
60 // ----------------------------------------------------------------------
62 
63 // ----------------------------------------------------------------------
64 void SiPixelModuleStatus::setNrocs(int iroc) { fNrocs = iroc; }
65 
66 // ----------------------------------------------------------------------
68  unsigned int ave(0);
69  for (int iroc = 0; iroc < fNrocs; ++iroc) {
70  unsigned int inc = digiOccROC(iroc);
71  ave += inc;
72  }
73  return (1.0 * ave) / fNrocs;
74 }
75 
77  double fModAverage = SiPixelModuleStatus::perRocDigiOcc();
78 
79  double sig = 1.0;
80  for (int iroc = 0; iroc < fNrocs; ++iroc) {
81  unsigned int inc = digiOccROC(iroc);
82  sig += (fModAverage - inc) * (fModAverage - inc);
83  }
84 
85  double fModSigma = sig / (fNrocs - 1);
86  return TMath::Sqrt(fModSigma);
87 }
88 
89 // ----------------------------------------------------------------------
90 // Be careful : return the address not the value of ROC status
92 
93 // ----------------------------------------------------------------------
94 void SiPixelModuleStatus::updateModuleDIGI(int iroc, unsigned int nhits) { fRocs[iroc].updateDIGI(nhits); }
95 
97  bool isSameModule = true;
98  if (fDetid != newData.detid() || fNrocs != newData.nrocs()) {
99  isSameModule = false;
100  }
101 
102  if (isSameModule) {
103  for (int iroc = 0; iroc < fNrocs; ++iroc) {
104  //update occupancy
105  fRocs[iroc].updateDIGI(newData.digiOccROC(iroc));
106  //update FEDerror25
107  SiPixelRocStatus* rocStatus = newData.getRoc(iroc);
108  if (rocStatus->isFEDerror25()) {
109  fRocs[iroc].fillFEDerror25();
110  }
111  }
112 
113  } // if same module
114 }
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: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