Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 11:59:37

0001 #include <iostream>
0002 #include <map>
0003 #include <cmath>
0004 #include <vector>
0005 
0006 #include <TMath.h>
0007 #include <TH1.h>
0008 
0009 #include "CalibTracker/SiPixelQuality/interface/SiPixelModuleStatus.h"
0010 
0011 // ----------------------------------------------------------------------
0012 SiPixelModuleStatus::SiPixelModuleStatus(int detId, int nrocs) : fDetid_(detId), fNrocs_(nrocs) {
0013   for (int i = 0; i < fNrocs_; ++i) {
0014     SiPixelRocStatus a;
0015     fRocs_.push_back(a);
0016   }
0017 };
0018 
0019 // ----------------------------------------------------------------------
0020 SiPixelModuleStatus::~SiPixelModuleStatus(){};
0021 
0022 // ----------------------------------------------------------------------
0023 void SiPixelModuleStatus::fillDIGI(int iroc) {
0024   if (iroc < fNrocs_)
0025     fRocs_[iroc].fillDIGI();
0026 }
0027 // ----------------------------------------------------------------------
0028 void SiPixelModuleStatus::fillFEDerror25(PixelFEDChannel ch) {
0029   int roc_first = int(ch.roc_first);
0030   int roc_last = int(ch.roc_last);
0031   for (int iroc = 0; iroc < fNrocs_; iroc++) {
0032     if (iroc >= roc_first && iroc <= roc_last) {
0033       fRocs_[iroc].fillFEDerror25();
0034     }
0035   }
0036 }
0037 // ----------------------------------------------------------------------
0038 int SiPixelModuleStatus::detid() { return fDetid_; }
0039 // ----------------------------------------------------------------------
0040 int SiPixelModuleStatus::nrocs() { return fNrocs_; }
0041 // ----------------------------------------------------------------------
0042 void SiPixelModuleStatus::setDetId(int detid) { fDetid_ = detid; }
0043 // ----------------------------------------------------------------------
0044 void SiPixelModuleStatus::setNrocs(int nRoc) { fNrocs_ = nRoc; }
0045 
0046 // ----------------------------------------------------------------------
0047 void SiPixelModuleStatus::updateDIGI(int iroc, unsigned int nhit) {
0048   if (iroc < fNrocs_)
0049     fRocs_[iroc].updateDIGI(nhit);
0050 }
0051 // ----------------------------------------------------------------------
0052 void SiPixelModuleStatus::updateFEDerror25(int iroc, bool fedError25) {
0053   if (iroc < fNrocs_)
0054     fRocs_[iroc].updateFEDerror25(fedError25);
0055 }
0056 
0057 // ----------------------------------------------------------------------
0058 unsigned int SiPixelModuleStatus::digiOccROC(int iroc) { return (iroc < fNrocs_ ? fRocs_[iroc].digiOccROC() : 0); }
0059 // ----------------------------------------------------------------------
0060 bool SiPixelModuleStatus::fedError25(int iroc) { return (iroc < fNrocs_ ? fRocs_[iroc].isFEDerror25() : false); }
0061 // ----------------------------------------------------------------------
0062 unsigned int SiPixelModuleStatus::digiOccMOD() {
0063   unsigned int count(0);
0064   for (int iroc = 0; iroc < fNrocs_; ++iroc) {
0065     count += digiOccROC(iroc);
0066   }
0067   return count;
0068 }
0069 
0070 // ----------------------------------------------------------------------
0071 double SiPixelModuleStatus::perRocDigiOcc() {
0072   unsigned int ave(0);
0073   for (int iroc = 0; iroc < fNrocs_; ++iroc) {
0074     unsigned int inc = digiOccROC(iroc);
0075     ave += inc;
0076   }
0077   return (1.0 * ave) / fNrocs_;
0078 }
0079 
0080 double SiPixelModuleStatus::perRocDigiOccVar() {
0081   double fModAverage = SiPixelModuleStatus::perRocDigiOcc();
0082 
0083   double sig = 1.0;
0084   for (int iroc = 0; iroc < fNrocs_; ++iroc) {
0085     unsigned int inc = digiOccROC(iroc);
0086     sig += (fModAverage - inc) * (fModAverage - inc);
0087   }
0088 
0089   double fModSigma = sig / (fNrocs_ - 1);
0090   return TMath::Sqrt(fModSigma);
0091 }
0092 
0093 // ----------------------------------------------------------------------
0094 // Return the address not the value of ROC status
0095 SiPixelRocStatus* SiPixelModuleStatus::getRoc(int iroc) { return (iroc < fNrocs_ ? &fRocs_[iroc] : nullptr); }
0096 
0097 // ----------------------------------------------------------------------
0098 void SiPixelModuleStatus::updateModuleDIGI(int iroc, unsigned int nhits) {
0099   if (iroc < fNrocs_)
0100     fRocs_[iroc].updateDIGI(nhits);
0101 }
0102 // ----------------------------------------------------------------------
0103 void SiPixelModuleStatus::updateModuleStatus(SiPixelModuleStatus newData) {
0104   bool isSameModule = true;
0105   if (fDetid_ != newData.detid() || fNrocs_ != newData.nrocs()) {
0106     isSameModule = false;
0107   }
0108 
0109   if (isSameModule) {
0110     for (int iroc = 0; iroc < fNrocs_; ++iroc) {  // loop over rocs
0111       //update occupancy
0112       fRocs_[iroc].updateDIGI(newData.digiOccROC(iroc));
0113       //update FEDerror25
0114       fRocs_[iroc].updateFEDerror25(newData.fedError25(iroc));
0115 
0116     }  // loop over rocs
0117 
0118   }  // if same module
0119 }