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.

14  : fLS0_(99999999), fLS1_(0), fRun0_(99999999), fRun1_(0) {
15  fDetHits_ = 0;
16  ftotalevents_ = 0;
17 }

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.

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 }

References a, fModules_, and DeadROCCounter::nrocs.

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

◆ addModule() [2/2]

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

Definition at line 111 of file SiPixelDetectorStatus.cc.

111 { fModules_.insert(std::make_pair(detid, a)); }

References a, and fModules_.

◆ begin()

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

Definition at line 150 of file SiPixelDetectorStatus.cc.

150 { return fModules_.begin(); }

References fModules_.

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

◆ digiOccDET()

unsigned long int SiPixelDetectorStatus::digiOccDET ( )
inline

Definition at line 45 of file SiPixelDetectorStatus.h.

45 { return fDetHits_; }

References fDetHits_.

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

◆ dumpToFile()

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

Definition at line 85 of file SiPixelDetectorStatus.cc.

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 }

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

Referenced by SiPixelStatusProducer::globalEndLuminosityBlockProduce().

◆ end()

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

◆ fillDIGI()

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

Definition at line 114 of file SiPixelDetectorStatus.cc.

114  {
115  ++fDetHits_;
116  fModules_[detid].fillDIGI(roc);
117 }

References fDetHits_, fModules_, and PixelMapPlotter::roc.

Referenced by SiPixelStatusProducer::accumulate().

◆ fillFEDerror25()

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

Definition at line 120 of file SiPixelDetectorStatus.cc.

120  {
121  if (fModules_.find(detid) != fModules_.end()) {
122  fModules_[detid].fillFEDerror25(ch);
123  }
124 }

References fModules_.

Referenced by SiPixelStatusProducer::endLuminosityBlock().

◆ findModule()

bool SiPixelDetectorStatus::findModule ( int  detid)

Definition at line 166 of file SiPixelDetectorStatus.cc.

166  {
167  if (fModules_.find(detid) == fModules_.end())
168  return false;
169  else
170  return true;
171 }

References fModules_.

◆ getDetectorStatus()

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

Definition at line 41 of file SiPixelDetectorStatus.h.

41 { return fModules_; }

References fModules_.

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

◆ getFEDerror25Rocs()

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

Definition at line 127 of file SiPixelDetectorStatus.cc.

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 }

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

Referenced by SiPixelStatusManager::createFEDerror25().

◆ getLSRange()

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

Definition at line 67 of file SiPixelDetectorStatus.h.

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

References fLS0_, and fLS1_.

Referenced by SiPixelStatusManager::rankByLumi().

◆ getModule()

SiPixelModuleStatus * SiPixelDetectorStatus::getModule ( int  detid)

Definition at line 159 of file SiPixelDetectorStatus.cc.

159  {
160  if (fModules_.find(detid) == fModules_.end()) {
161  return nullptr;
162  }
163  return &(fModules_[detid]);
164 }

References fModules_.

Referenced by readFromFile(), and updateDetectorStatus().

◆ getNevents()

unsigned long int SiPixelDetectorStatus::getNevents ( )
inline

Definition at line 48 of file SiPixelDetectorStatus.h.

48 { return ftotalevents_; }

References ftotalevents_.

Referenced by updateDetectorStatus().

◆ getRunRange()

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

Definition at line 61 of file SiPixelDetectorStatus.h.

61 { return std::make_pair(fRun0_, fRun1_); }

References fRun0_, and fRun1_.

◆ next()

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

◆ nmodules()

int SiPixelDetectorStatus::nmodules ( )

Definition at line 156 of file SiPixelDetectorStatus.cc.

156 { return static_cast<int>(fModules_.size()); }

References fModules_.

◆ perRocDigiOcc()

double SiPixelDetectorStatus::perRocDigiOcc ( )

Definition at line 174 of file SiPixelDetectorStatus.cc.

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 }

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

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

◆ perRocDigiOccVar()

double SiPixelDetectorStatus::perRocDigiOccVar ( )

Definition at line 187 of file SiPixelDetectorStatus.cc.

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 }

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

◆ readFromFile()

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

Definition at line 23 of file SiPixelDetectorStatus.cc.

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 }

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

◆ resetDetectorStatus()

void SiPixelDetectorStatus::resetDetectorStatus ( )

Definition at line 223 of file SiPixelDetectorStatus.cc.

223  {
224  fModules_.clear();
225  fDetHits_ = 0;
226  ftotalevents_ = 0;
227  fRun0_ = 99999999;
228  fRun1_ = 0;
229  fLS0_ = 99999999;
230  fLS1_ = 0;
231 }

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

◆ setLSRange()

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

Definition at line 63 of file SiPixelDetectorStatus.h.

63  {
64  fLS0_ = ls0;
65  fLS1_ = ls1;
66  }

References fLS0_, and fLS1_.

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

◆ setNevents()

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

Definition at line 47 of file SiPixelDetectorStatus.h.

47 { ftotalevents_ = N; }

References ftotalevents_, and N.

Referenced by SiPixelStatusProducer::endLuminosityBlock().

◆ setRunRange()

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

Definition at line 57 of file SiPixelDetectorStatus.h.

57  {
58  fRun0_ = run0;
59  fRun1_ = run1;
60  }

References fRun0_, fRun1_, ntuplemaker::run0, and ntuplemaker::run1.

Referenced by SiPixelStatusProducer::globalEndLuminosityBlockProduce().

◆ updateDetectorStatus()

void SiPixelDetectorStatus::updateDetectorStatus ( SiPixelDetectorStatus  newData)

Definition at line 207 of file SiPixelDetectorStatus.cc.

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 }

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

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

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
SiPixelDetectorStatus::fDetHits_
unsigned long int fDetHits_
Definition: SiPixelDetectorStatus.h:86
SiPixelDetectorStatus::fLS1_
int fLS1_
Definition: SiPixelDetectorStatus.h:78
SiPixelDetectorStatus::fLS0_
int fLS0_
Definition: SiPixelDetectorStatus.h:78
hfClusterShapes_cfi.hits
hits
Definition: hfClusterShapes_cfi.py:5
SiPixelDetectorStatus::getModule
SiPixelModuleStatus * getModule(int detid)
Definition: SiPixelDetectorStatus.cc:159
SiPixelDetectorStatus::begin
std::map< int, SiPixelModuleStatus >::iterator begin()
Definition: SiPixelDetectorStatus.cc:150
SiPixelRocStatus
Definition: SiPixelRocStatus.h:5
SiPixelDetectorStatus::addModule
void addModule(int detid, int nrocs)
Definition: SiPixelDetectorStatus.cc:102
ntuplemaker.run1
run1
Definition: ntuplemaker.py:85
N
#define N
Definition: blowfish.cc:9
corrVsCorr.filename
filename
Definition: corrVsCorr.py:123
SiPixelModuleStatus
Definition: SiPixelModuleStatus.h:10
ntuplemaker.run0
run0
Definition: ntuplemaker.py:84
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
SiPixelDetectorStatus::getNevents
unsigned long int getNevents()
Definition: SiPixelDetectorStatus.h:48
a
double a
Definition: hdecay.h:119
SiPixelModuleStatus::getRoc
SiPixelRocStatus * getRoc(int i)
get a ROC
Definition: SiPixelModuleStatus.cc:95
SiPixelDetectorStatus::end
std::map< int, SiPixelModuleStatus >::iterator end()
Definition: SiPixelDetectorStatus.cc:153
SiPixelDetectorStatus::ftotalevents_
unsigned long int ftotalevents_
Definition: SiPixelDetectorStatus.h:83
SiPixelDetectorStatus::fModules_
std::map< int, SiPixelModuleStatus > fModules_
Definition: SiPixelDetectorStatus.h:75
SiPixelDetectorStatus::fRun0_
int fRun0_
Definition: SiPixelDetectorStatus.h:80
DeadROCCounter.nrocs
nrocs
Definition: DeadROCCounter.py:57
PixelMapPlotter.roc
roc
Definition: PixelMapPlotter.py:498
SiPixelDetectorStatus::perRocDigiOcc
double perRocDigiOcc()
Definition: SiPixelDetectorStatus.cc:174
SiPixelDetectorStatus::fRun1_
int fRun1_
Definition: SiPixelDetectorStatus.h:80
SiPixelModuleStatus::nrocs
int nrocs()
Definition: SiPixelModuleStatus.cc:40
SiPixelDetectorStatus::digiOccDET
unsigned long int digiOccDET()
Definition: SiPixelDetectorStatus.h:45