CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
SiPixelDetectorStatus Class Reference

#include <SiPixelDetectorStatus.h>

Public Member Functions

void addModule (int detid, int nrocs)
 
void addModule (int detid, SiPixelModuleStatus a)
 
std::map< int, SiPixelModuleStatus >::iterator begin ()
 
unsigned long int digiOccDET ()
 
void dumpToFile (std::ofstream &outFile)
 
std::map< int, SiPixelModuleStatus >::iterator end ()
 
void fillDIGI (int detid, int roc)
 
void fillFEDerror25 (int detid, PixelFEDChannel ch)
 
bool findModule (int detid)
 
std::map< int, SiPixelModuleStatusgetDetectorStatus ()
 
std::map< int, std::vector< int > > getFEDerror25Rocs ()
 
std::pair< int, int > getLSRange ()
 
SiPixelModuleStatusgetModule (int detid)
 
unsigned long int getNevents ()
 
std::pair< int, int > getRunRange ()
 
std::map< int, SiPixelModuleStatus >::iterator next ()
 
int nmodules ()
 
double perRocDigiOcc ()
 
double perRocDigiOccVar ()
 
void readFromFile (std::string filename)
 
void resetDetectorStatus ()
 
void setLSRange (int ls0, int ls1)
 
void setNevents (unsigned long int N)
 
void setRunRange (int run0, int run1)
 
 SiPixelDetectorStatus ()
 
void updateDetectorStatus (SiPixelDetectorStatus newData)
 
 ~SiPixelDetectorStatus ()
 

Private Attributes

unsigned long int fDetHits_
 
int fLS0_
 
int fLS1_
 
std::map< int, SiPixelModuleStatusfModules_
 
int fRun0_
 
int fRun1_
 
unsigned long int ftotalevents_
 

Detailed Description

Definition at line 11 of file SiPixelDetectorStatus.h.

Constructor & Destructor Documentation

◆ SiPixelDetectorStatus()

SiPixelDetectorStatus::SiPixelDetectorStatus ( )

Definition at line 14 of file SiPixelDetectorStatus.cc.

References fDetHits_, and ftotalevents_.

◆ ~SiPixelDetectorStatus()

SiPixelDetectorStatus::~SiPixelDetectorStatus ( )

Definition at line 20 of file SiPixelDetectorStatus.cc.

20 {}

Member Function Documentation

◆ addModule() [1/2]

void SiPixelDetectorStatus::addModule ( int  detid,
int  nrocs 
)

Definition at line 102 of file SiPixelDetectorStatus.cc.

References a, fModules_, and DeadROCCounter::nrocs.

Referenced by SiPixelStatusProducer::beginLuminosityBlock(), and readFromFile().

102  {
103  // only need to add NEW modules
104  if (fModules_.find(detid) == fModules_.end()) {
105  SiPixelModuleStatus a(detid, nrocs);
106  fModules_.insert(std::make_pair(detid, a));
107  }
108 }
std::map< int, SiPixelModuleStatus > fModules_
double a
Definition: hdecay.h:119

◆ addModule() [2/2]

void SiPixelDetectorStatus::addModule ( int  detid,
SiPixelModuleStatus  a 
)

Definition at line 111 of file SiPixelDetectorStatus.cc.

References a, and fModules_.

111 { fModules_.insert(std::make_pair(detid, a)); }
std::map< int, SiPixelModuleStatus > fModules_
double a
Definition: hdecay.h:119

◆ begin()

std::map< int, SiPixelModuleStatus >::iterator SiPixelDetectorStatus::begin ( )

Definition at line 150 of file SiPixelDetectorStatus.cc.

References fModules_.

Referenced by dumpToFile(), getFEDerror25Rocs(), perRocDigiOcc(), perRocDigiOccVar(), and updateDetectorStatus().

150 { return fModules_.begin(); }
std::map< int, SiPixelModuleStatus > fModules_

◆ digiOccDET()

unsigned long int SiPixelDetectorStatus::digiOccDET ( )
inline

Definition at line 45 of file SiPixelDetectorStatus.h.

References fDetHits_.

Referenced by SiPixelStatusManager::readLumi(), and updateDetectorStatus().

45 { return fDetHits_; }
unsigned long int fDetHits_

◆ dumpToFile()

void SiPixelDetectorStatus::dumpToFile ( std::ofstream &  outFile)

Definition at line 85 of file SiPixelDetectorStatus.cc.

References begin(), end(), fDetHits_, fLS0_, fLS1_, fRun0_, and fRun1_.

Referenced by SiPixelStatusProducer::globalEndLuminosityBlockProduce().

85  {
86  OD << "# SiPixelDetectorStatus START" << std::endl;
87  OD << "# SiPixelDetectorStatus for LS " << fLS0_ << " .. " << fLS1_ << std::endl;
88  OD << "# SiPixelDetectorStatus for run " << fRun0_ << " .. " << fRun1_ << std::endl;
89  OD << "# SiPixelDetectorStatus total hits = " << fDetHits_ << std::endl;
90 
91  for (std::map<int, SiPixelModuleStatus>::iterator it = SiPixelDetectorStatus::begin();
93  ++it) {
94  for (int iroc = 0; iroc < it->second.nrocs(); ++iroc) {
95  OD << Form("%10d %2d %3d", it->first, iroc, int(it->second.getRoc(iroc)->digiOccROC())) << std::endl;
96  }
97  }
98  OD << "# SiPixelDetectorStatus END" << std::endl;
99 }
unsigned long int fDetHits_
std::map< int, SiPixelModuleStatus >::iterator end()
std::map< int, SiPixelModuleStatus >::iterator begin()

◆ end()

std::map< int, SiPixelModuleStatus >::iterator SiPixelDetectorStatus::end ( )

◆ fillDIGI()

void SiPixelDetectorStatus::fillDIGI ( int  detid,
int  roc 
)

Definition at line 114 of file SiPixelDetectorStatus.cc.

References fDetHits_, fModules_, and PixelMapPlotter::roc.

Referenced by SiPixelStatusProducer::accumulate().

114  {
115  ++fDetHits_;
116  fModules_[detid].fillDIGI(roc);
117 }
unsigned long int fDetHits_
std::map< int, SiPixelModuleStatus > fModules_

◆ fillFEDerror25()

void SiPixelDetectorStatus::fillFEDerror25 ( int  detid,
PixelFEDChannel  ch 
)

Definition at line 120 of file SiPixelDetectorStatus.cc.

References fModules_.

Referenced by SiPixelStatusProducer::endLuminosityBlock().

120  {
121  if (fModules_.find(detid) != fModules_.end()) {
122  fModules_[detid].fillFEDerror25(ch);
123  }
124 }
std::map< int, SiPixelModuleStatus > fModules_

◆ findModule()

bool SiPixelDetectorStatus::findModule ( int  detid)

Definition at line 166 of file SiPixelDetectorStatus.cc.

References fModules_.

166  {
167  if (fModules_.find(detid) == fModules_.end())
168  return false;
169  else
170  return true;
171 }
std::map< int, SiPixelModuleStatus > fModules_

◆ getDetectorStatus()

std::map<int, SiPixelModuleStatus> SiPixelDetectorStatus::getDetectorStatus ( )
inline

Definition at line 41 of file SiPixelDetectorStatus.h.

References fModules_.

Referenced by SiPixelStatusHarvester::dqmEndRun(), and SiPixelStatusHarvester::perLayerRingAverage().

41 { return fModules_; }
std::map< int, SiPixelModuleStatus > fModules_

◆ getFEDerror25Rocs()

std::map< int, std::vector< int > > SiPixelDetectorStatus::getFEDerror25Rocs ( )

Definition at line 127 of file SiPixelDetectorStatus.cc.

References begin(), end(), SiPixelModuleStatus::getRoc(), SiPixelModuleStatus::nrocs(), and PixelMapPlotter::roc.

Referenced by SiPixelStatusManager::createFEDerror25().

127  {
128  std::map<int, std::vector<int>> badRocLists;
129 
130  for (std::map<int, SiPixelModuleStatus>::iterator itMod = SiPixelDetectorStatus::begin();
131  itMod != SiPixelDetectorStatus::end();
132  ++itMod) {
133  int detid = itMod->first;
134  // FEDerror25 effected ROCs in a given module
135  std::vector<int> list;
136  SiPixelModuleStatus modStatus = itMod->second;
137  for (int iroc = 0; iroc < modStatus.nrocs(); ++iroc) {
138  SiPixelRocStatus* roc = modStatus.getRoc(iroc);
139  if (roc->isFEDerror25()) {
140  list.push_back(iroc);
141  }
142  badRocLists[detid] = list;
143  }
144  }
145 
146  return badRocLists;
147 }
std::map< int, SiPixelModuleStatus >::iterator end()
std::map< int, SiPixelModuleStatus >::iterator begin()
SiPixelRocStatus * getRoc(int i)
get a ROC

◆ getLSRange()

std::pair<int, int> SiPixelDetectorStatus::getLSRange ( )
inline

Definition at line 67 of file SiPixelDetectorStatus.h.

References fLS0_, and fLS1_.

Referenced by SiPixelStatusManager::rankByLumi().

67 { return std::make_pair(fLS0_, fLS1_); }

◆ getModule()

SiPixelModuleStatus * SiPixelDetectorStatus::getModule ( int  detid)

Definition at line 159 of file SiPixelDetectorStatus.cc.

References fModules_.

Referenced by readFromFile(), and updateDetectorStatus().

159  {
160  if (fModules_.find(detid) == fModules_.end()) {
161  return nullptr;
162  }
163  return &(fModules_[detid]);
164 }
std::map< int, SiPixelModuleStatus > fModules_

◆ getNevents()

unsigned long int SiPixelDetectorStatus::getNevents ( )
inline

Definition at line 48 of file SiPixelDetectorStatus.h.

References ftotalevents_.

Referenced by updateDetectorStatus().

48 { return ftotalevents_; }
unsigned long int ftotalevents_

◆ getRunRange()

std::pair<int, int> SiPixelDetectorStatus::getRunRange ( )
inline

Definition at line 61 of file SiPixelDetectorStatus.h.

References fRun0_, and fRun1_.

◆ next()

std::map<int, SiPixelModuleStatus>::iterator SiPixelDetectorStatus::next ( )

◆ nmodules()

int SiPixelDetectorStatus::nmodules ( )

Definition at line 156 of file SiPixelDetectorStatus.cc.

References fModules_.

156 { return static_cast<int>(fModules_.size()); }
std::map< int, SiPixelModuleStatus > fModules_

◆ perRocDigiOcc()

double SiPixelDetectorStatus::perRocDigiOcc ( )

Definition at line 174 of file SiPixelDetectorStatus.cc.

References begin(), end(), and DeadROCCounter::nrocs.

Referenced by SiPixelStatusManager::createBadComponents(), SiPixelStatusHarvester::dqmEndRun(), and perRocDigiOccVar().

174  {
175  unsigned long int ave(0);
176  int nrocs(0);
177  for (std::map<int, SiPixelModuleStatus>::iterator it = SiPixelDetectorStatus::begin();
179  ++it) {
180  unsigned long int inc = it->second.digiOccMOD();
181  ave += inc;
182  nrocs += it->second.nrocs();
183  }
184  return (1.0 * ave) / nrocs;
185 }
std::map< int, SiPixelModuleStatus >::iterator end()
std::map< int, SiPixelModuleStatus >::iterator begin()

◆ perRocDigiOccVar()

double SiPixelDetectorStatus::perRocDigiOccVar ( )

Definition at line 187 of file SiPixelDetectorStatus.cc.

References begin(), end(), DeadROCCounter::nrocs, and perRocDigiOcc().

187  {
188  double fDetAverage = SiPixelDetectorStatus::perRocDigiOcc();
189 
190  double sig = 0.0;
191  int nrocs(0);
192  for (std::map<int, SiPixelModuleStatus>::iterator it = SiPixelDetectorStatus::begin();
194  ++it) {
195  unsigned long int inc = it->second.digiOccMOD();
196  sig += (fDetAverage - inc) * (fDetAverage - inc);
197  nrocs += it->second.nrocs();
198  }
199 
200  double fDetSigma = sig / (nrocs - 1);
201  return TMath::Sqrt(fDetSigma);
202 }
std::map< int, SiPixelModuleStatus >::iterator end()
std::map< int, SiPixelModuleStatus >::iterator begin()

◆ readFromFile()

void SiPixelDetectorStatus::readFromFile ( std::string  filename)

Definition at line 23 of file SiPixelDetectorStatus.cc.

References addModule(), fDetHits_, corrVsCorr::filename, fLS0_, fLS1_, fRun0_, fRun1_, getModule(), hfClusterShapes_cfi::hits, PixelMapPlotter::roc, SiPixelModuleStatus::setNrocs(), AlCaHLTBitMon_QueryRunRegistry::string, and SiPixelModuleStatus::updateModuleDIGI().

23  {
24  std::ifstream INS;
25  std::string sline;
26  INS.open(filename.c_str());
27 
28  int oldDetId(-1);
29  int detid(0), roc(0), hits(0), nroc(0);
30  SiPixelModuleStatus* pMod(nullptr);
31  bool readOK(false);
32  while (std::getline(INS, sline)) {
33  if (std::string::npos != sline.find("# SiPixelDetectorStatus START")) {
34  readOK = true;
35  continue;
36  }
37  if (!readOK)
38  continue;
39 
40  if (std::string::npos != sline.find("# SiPixelDetectorStatus END")) {
41  pMod->setNrocs(nroc + 1);
42  break;
43  }
44 
45  if (sline.find("# SiPixelDetectorStatus for LS") != std::string::npos) {
46  std::sscanf(sline.c_str(), "# SiPixelDetectorStatus for LS %d .. %d", &fLS0_, &fLS1_);
47  continue;
48  }
49  if (sline.find("# SiPixelDetectorStatus for run") != std::string::npos) {
50  std::sscanf(sline.c_str(), "# SiPixelDetectorStatus for run %d .. %d", &fRun0_, &fRun1_);
51  continue;
52  }
53  if (sline.find("# SiPixelDetectorStatus total hits = ") != std::string::npos) {
54  std::sscanf(sline.c_str(), "# SiPixelDetectorStatus total hits = %ld", &fDetHits_);
55  continue;
56  }
57 
58  std::sscanf(sline.c_str(), "%d %d %d", &detid, &roc, &hits);
59  if (roc > nroc)
60  nroc = roc;
61  if (detid != oldDetId) {
62  if (pMod) {
63  pMod->setNrocs(nroc + 1); // roc ranges from 0, "+1" to get number of rocs per module
64  }
65 
66  oldDetId = detid;
67  if (getModule(detid) == nullptr) {
68  addModule(detid, nroc + 1); // roc ranges from 0, "+1" to get number of rocs per module
69  }
70 
71  pMod = getModule(detid);
72  nroc = 0;
73  }
74  // for existing module, update its content
75  if (pMod != nullptr) {
76  fDetHits_ += hits;
77  pMod->updateModuleDIGI(roc, hits);
78  }
79  }
80 
81  INS.close();
82 }
void addModule(int detid, int nrocs)
unsigned long int fDetHits_
SiPixelModuleStatus * getModule(int detid)

◆ resetDetectorStatus()

void SiPixelDetectorStatus::resetDetectorStatus ( )

Definition at line 223 of file SiPixelDetectorStatus.cc.

References fDetHits_, fLS0_, fLS1_, fModules_, fRun0_, fRun1_, and ftotalevents_.

223  {
224  fModules_.clear();
225  fDetHits_ = 0;
226  ftotalevents_ = 0;
227  fRun0_ = 99999999;
228  fRun1_ = 0;
229  fLS0_ = 99999999;
230  fLS1_ = 0;
231 }
unsigned long int fDetHits_
unsigned long int ftotalevents_
std::map< int, SiPixelModuleStatus > fModules_

◆ setLSRange()

void SiPixelDetectorStatus::setLSRange ( int  ls0,
int  ls1 
)
inline

◆ setNevents()

void SiPixelDetectorStatus::setNevents ( unsigned long int  N)
inline

Definition at line 47 of file SiPixelDetectorStatus.h.

References ftotalevents_, and N.

Referenced by SiPixelStatusProducer::endLuminosityBlock().

47 { ftotalevents_ = N; }
unsigned long int ftotalevents_
#define N
Definition: blowfish.cc:9

◆ setRunRange()

void SiPixelDetectorStatus::setRunRange ( int  run0,
int  run1 
)
inline

◆ updateDetectorStatus()

void SiPixelDetectorStatus::updateDetectorStatus ( SiPixelDetectorStatus  newData)

Definition at line 207 of file SiPixelDetectorStatus.cc.

References begin(), digiOccDET(), end(), fDetHits_, fModules_, ftotalevents_, getModule(), and getNevents().

Referenced by SiPixelStatusManager::createBadComponents(), and SiPixelStatusProducer::globalEndLuminosityBlockProduce().

207  {
208  // loop over new data status
209  for (std::map<int, SiPixelModuleStatus>::iterator it = newData.begin(); it != newData.end(); ++it) {
210  int detid = it->first;
211 
212  if (fModules_.find(detid) != fModules_.end()) { // if the detid is in the module lists
213  fModules_[detid].updateModuleStatus(*(newData.getModule(detid)));
214  } else { // if new module, add(insert) the module data
215  fModules_.insert(std::make_pair(detid, *(newData.getModule(detid))));
216  }
217  }
218 
219  fDetHits_ = fDetHits_ + newData.digiOccDET();
220  ftotalevents_ = ftotalevents_ + newData.getNevents();
221 }
unsigned long int digiOccDET()
unsigned long int fDetHits_
unsigned long int ftotalevents_
std::map< int, SiPixelModuleStatus >::iterator end()
std::map< int, SiPixelModuleStatus >::iterator begin()
std::map< int, SiPixelModuleStatus > fModules_
unsigned long int getNevents()
SiPixelModuleStatus * getModule(int detid)

Member Data Documentation

◆ fDetHits_

unsigned long int SiPixelDetectorStatus::fDetHits_
private

◆ fLS0_

int SiPixelDetectorStatus::fLS0_
private

◆ fLS1_

int SiPixelDetectorStatus::fLS1_
private

◆ fModules_

std::map<int, SiPixelModuleStatus> SiPixelDetectorStatus::fModules_
private

◆ fRun0_

int SiPixelDetectorStatus::fRun0_
private

◆ fRun1_

int SiPixelDetectorStatus::fRun1_
private

◆ ftotalevents_

unsigned long int SiPixelDetectorStatus::ftotalevents_
private