CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes
SiPixelStatusManager Class Reference

#include <SiPixelStatusManager.h>

Public Types

typedef std::map< edm::LuminosityBlockNumber_t, std::map< int, std::vector< int > > >::iterator FEDerror25Map_iterator
 
typedef std::map< edm::LuminosityBlockNumber_t, SiPixelDetectorStatus >::iterator siPixelStatusMap_iterator
 
typedef std::vector< SiPixelDetectorStatus >::iterator siPixelStatusVtr_iterator
 

Public Member Functions

void createPayloads ()
 
const std::map< edm::LuminosityBlockNumber_t, SiPixelDetectorStatus > & getBadComponents ()
 
const std::map< edm::LuminosityBlockNumber_t, std::map< int, std::vector< int > > > & getFEDerror25Rocs ()
 
void readLumi (const edm::LuminosityBlock &)
 
void reset ()
 
 SiPixelStatusManager ()
 
 SiPixelStatusManager (const edm::ParameterSet &, edm::ConsumesCollector &&)
 
virtual ~SiPixelStatusManager ()
 

Private Member Functions

void createBadComponents ()
 
void createFEDerror25 ()
 

Static Private Member Functions

static bool rankByLumi (SiPixelDetectorStatus status1, SiPixelDetectorStatus status2)
 

Private Attributes

int aveDigiOcc_
 
std::map< edm::LuminosityBlockNumber_t, std::map< int, std::vector< int > > > FEDerror25Map_
 
std::string label_
 
std::string moduleName_
 
int nLumi_
 
std::string outputBase_
 
std::map< edm::LuminosityBlockNumber_t, SiPixelDetectorStatussiPixelStatusMap_
 
edm::EDGetTokenT< SiPixelDetectorStatussiPixelStatusToken_
 
std::vector< SiPixelDetectorStatussiPixelStatusVtr_
 

Detailed Description

Author

helper class that set up IOV strcutre of SiPixelDetectorStatus

Author

Definition at line 24 of file SiPixelStatusManager.h.

Member Typedef Documentation

◆ FEDerror25Map_iterator

typedef std::map<edm::LuminosityBlockNumber_t, std::map<int, std::vector<int> > >::iterator SiPixelStatusManager::FEDerror25Map_iterator

Definition at line 41 of file SiPixelStatusManager.h.

◆ siPixelStatusMap_iterator

Definition at line 40 of file SiPixelStatusManager.h.

◆ siPixelStatusVtr_iterator

Definition at line 42 of file SiPixelStatusManager.h.

Constructor & Destructor Documentation

◆ SiPixelStatusManager() [1/2]

SiPixelStatusManager::SiPixelStatusManager ( )

Definition at line 21 of file SiPixelStatusManager.cc.

21 {}

◆ SiPixelStatusManager() [2/2]

SiPixelStatusManager::SiPixelStatusManager ( const edm::ParameterSet iConfig,
edm::ConsumesCollector &&  iC 
)

Definition at line 24 of file SiPixelStatusManager.cc.

25  : outputBase_(iConfig.getParameter<ParameterSet>("SiPixelStatusManagerParameters")
26  .getUntrackedParameter<std::string>("outputBase")),
27  aveDigiOcc_(iConfig.getParameter<edm::ParameterSet>("SiPixelStatusManagerParameters")
28  .getUntrackedParameter<int>("aveDigiOcc")),
29  nLumi_(iConfig.getParameter<edm::ParameterSet>("SiPixelStatusManagerParameters")
30  .getUntrackedParameter<int>("resetEveryNLumi")),
31  moduleName_(iConfig.getParameter<ParameterSet>("SiPixelStatusManagerParameters")
32  .getUntrackedParameter<std::string>("moduleName")),
33  label_(iConfig.getParameter<ParameterSet>("SiPixelStatusManagerParameters")
35  edm::InputTag siPixelStatusTag_(moduleName_, label_);
37 
38  LogInfo("SiPixelStatusManager") << "Output base: " << outputBase_ << std::endl;
39  reset();
40 }

References edm::InLumi, label_, moduleName_, outputBase_, reset(), and siPixelStatusToken_.

◆ ~SiPixelStatusManager()

SiPixelStatusManager::~SiPixelStatusManager ( )
virtual

Definition at line 43 of file SiPixelStatusManager.cc.

43 {}

Member Function Documentation

◆ createBadComponents()

void SiPixelStatusManager::createBadComponents ( )
private

Definition at line 88 of file SiPixelStatusManager.cc.

88  {
89  siPixelStatusVtr_iterator firstStatus = siPixelStatusVtr_.begin();
91 
92  siPixelStatusMap_.clear();
93 
94  // doesn't work for nLumi_=1 cos any integer can be completely divided by 1
95  if (outputBase_ == "nLumibased" && nLumi_ > 1) {
96  // if the total number of Lumi Blocks can't be completely divided by nLumi_,
97  // the residual Lumi Blocks will be as the last IOV
98  int iterationLumi = 0;
99 
100  LuminosityBlockNumber_t tmpLumi;
101  SiPixelDetectorStatus tmpSiPixelStatus;
102  for (siPixelStatusVtr_iterator it = firstStatus; it != lastStatus; it++) {
103  // this is the begining of an IOV
104  if (iterationLumi % nLumi_ == 0) {
105  tmpLumi = edm::LuminosityBlockNumber_t(it->getLSRange().first);
106  tmpSiPixelStatus = (*it);
107  }
108 
109  // keep update detector status up to nLumi_ lumi sections
110  if (iterationLumi % nLumi_ > 0) {
111  tmpSiPixelStatus.updateDetectorStatus((*it));
112  tmpSiPixelStatus.setLSRange(int(tmpLumi), (*it).getLSRange().second);
113  }
114 
115  siPixelStatusVtr_iterator currentIt = it;
116  siPixelStatusVtr_iterator nextIt = std::next(currentIt);
117  // wirte out if current lumi is the last lumi-section in the IOV
118  if (iterationLumi % nLumi_ == nLumi_ - 1 || nextIt == lastStatus) {
119  // fill it into a new map (with IOV structured)
120  siPixelStatusMap_[tmpLumi] = tmpSiPixelStatus;
121  }
122 
123  iterationLumi = iterationLumi + 1;
124  }
125 
126  // check whether there is not enough number of Lumi in the last IOV
127  // (only when siPixelStatusVtr_.size() > nLumi_ or equivalently current siPixelStatusMap_.size()>1
128  // (otherwise there will be only one IOV, and not previous IOV before the last IOV)
129  // and the number of lumi can not be completely divided by the nLumi_.
130  // (then the number of lumis in the last IOV is equal to the residual, which is less than nLumi_)
131  // if it is, combine last IOV with the IOV before it
132  if (siPixelStatusVtr_.size() % nLumi_ != 0 && siPixelStatusMap_.size() > 1) {
133  // start from the iterator of the end of std::map
135  // the last IOV
136  siPixelStatusMap_iterator iterLastIOV = std::prev(iterEnd);
137  // the IOV before the last IOV
138  siPixelStatusMap_iterator iterBeforeLastIOV = std::prev(iterLastIOV);
139 
140  // combine the last IOV data to the IOV before the last IOV
141  (iterBeforeLastIOV->second).updateDetectorStatus(iterLastIOV->second);
142  (iterBeforeLastIOV->second)
143  .setLSRange((iterBeforeLastIOV->second).getLSRange().first, (iterLastIOV->second).getLSRange().second);
144 
145  // delete the last IOV, so the IOV before the last IOV becomes the new last IOV
146  siPixelStatusMap_.erase(iterLastIOV);
147  }
148 
149  } else if (outputBase_ == "dynamicLumibased") {
150  double aveDigiOcc = 1.0 * aveDigiOcc_;
151 
153  SiPixelDetectorStatus tmpSiPixelStatus;
154  bool isNewIOV = true;
155 
156  int counter = 0;
157  for (siPixelStatusVtr_iterator it = firstStatus; it != lastStatus; it++) {
158  if (isNewIOV) { // if it is new IOV, init with the current data
159  tmpLumi = edm::LuminosityBlockNumber_t(it->getLSRange().first);
160  tmpSiPixelStatus = (*it);
161  } else { // if it is not new IOV, append current data
162  tmpSiPixelStatus.updateDetectorStatus((*it));
163  tmpSiPixelStatus.setLSRange(int(tmpLumi), (*it).getLSRange().second);
164  }
165 
166  // if reaching the end of data, write the last IOV to the map whatsoevec
167  siPixelStatusVtr_iterator currentIt = it;
168  siPixelStatusVtr_iterator nextIt = std::next(currentIt);
169  if (tmpSiPixelStatus.perRocDigiOcc() < aveDigiOcc && nextIt != lastStatus) {
170  isNewIOV = false; // if digi occ is not enough, next data will not belong to new IOV
171  } else { // if (accunumated) digi occ is enough, write the data to the map
172  isNewIOV = true;
173  siPixelStatusMap_[tmpLumi] = tmpSiPixelStatus;
174  // so next loop is the begining of a new IOV
175  }
176  counter++;
177 
178  } // end of siPixelStatusMap
179 
180  // check whether last IOV has enough statistics
181  // (ONLY when there are more than oneIOV(otherwise there is NO previous IOV before the last IOV) )
182  // if not, combine with previous IOV
183  if (siPixelStatusMap_.size() > 1) {
184  // start from the end iterator of the std::map
186  // the last IOV
187  siPixelStatusMap_iterator iterLastIOV = std::prev(iterEnd);
188  // if the statistics of the last IOV is not enough
189  if ((iterLastIOV->second).perRocDigiOcc() < aveDigiOcc) {
190  // the IOV before the last IOV of the map
191  siPixelStatusMap_iterator iterBeforeLastIOV = std::prev(iterLastIOV);
192  // combine the last IOV data to the IOV before the last IOV
193  (iterBeforeLastIOV->second).updateDetectorStatus(iterLastIOV->second);
194  (iterBeforeLastIOV->second)
195  .setLSRange((iterBeforeLastIOV->second).getLSRange().first, (iterLastIOV->second).getLSRange().second);
196  // erase the last IOV, so the IOV before the last IOV becomes the new last IOV
197  siPixelStatusMap_.erase(iterLastIOV);
198  }
199  }
200 
201  } else if (outputBase_ == "runbased" || ((int(siPixelStatusVtr_.size()) <= nLumi_ && outputBase_ == "nLumibased"))) {
202  edm::LuminosityBlockNumber_t tmpLumi = edm::LuminosityBlockNumber_t(firstStatus->getLSRange().first);
203  SiPixelDetectorStatus tmpSiPixelStatus = (*firstStatus);
204 
205  siPixelStatusVtr_iterator nextStatus = ++siPixelStatusVtr_.begin();
206  for (siPixelStatusVtr_iterator it = nextStatus; it != lastStatus; it++) {
207  tmpSiPixelStatus.updateDetectorStatus((*it));
208  tmpSiPixelStatus.setLSRange(int(tmpLumi), (*it).getLSRange().second);
209  }
210 
211  siPixelStatusMap_[tmpLumi] = tmpSiPixelStatus;
212 
213  } else {
214  LogInfo("SiPixelStatusManager") << "Unrecognized payload outputBase parameter: " << outputBase_ << endl;
215  }
216 }

References AlCaHarvesting_cff::aveDigiOcc, aveDigiOcc_, GetRecoTauVFromDQM_MC_cff::next, nLumi_, outputBase_, SiPixelDetectorStatus::perRocDigiOcc(), SiPixelDetectorStatus::setLSRange(), siPixelStatusMap_, siPixelStatusVtr_, and SiPixelDetectorStatus::updateDetectorStatus().

Referenced by createPayloads().

◆ createFEDerror25()

void SiPixelStatusManager::createFEDerror25 ( )
private

Definition at line 218 of file SiPixelStatusManager.cc.

218  {
219  // initialize the first IOV and SiPixelDetector status (in the first IOV)
220  siPixelStatusVtr_iterator firstStatus = siPixelStatusVtr_.begin();
221  edm::LuminosityBlockNumber_t firstLumi = edm::LuminosityBlockNumber_t(firstStatus->getLSRange().first);
222  SiPixelDetectorStatus firstFEDerror25 = (*firstStatus);
223  FEDerror25Map_[firstLumi] = firstFEDerror25.getFEDerror25Rocs();
224 
225  siPixelStatusVtr_iterator lastStatus = siPixelStatusVtr_.end();
226 
228  bool sameAsLastIOV = true;
229  edm::LuminosityBlockNumber_t previousLumi = firstLumi;
230 
231  siPixelStatusVtr_iterator secondStatus = std::next(siPixelStatusVtr_.begin());
232  for (siPixelStatusVtr_iterator it = secondStatus; it != lastStatus; it++) {
233  // init for each lumi section (iterator)
234  edm::LuminosityBlockNumber_t tmpLumi = edm::LuminosityBlockNumber_t(it->getLSRange().first);
235  SiPixelDetectorStatus tmpFEDerror25 = (*it);
236 
237  std::map<int, std::vector<int> > tmpBadRocLists = tmpFEDerror25.getFEDerror25Rocs();
238 
239  std::map<int, SiPixelModuleStatus>::iterator itModEnd = tmpFEDerror25.end();
240  for (std::map<int, SiPixelModuleStatus>::iterator itMod = tmpFEDerror25.begin(); itMod != itModEnd; ++itMod) {
241  int detid = itMod->first;
242  // if the badroc list differs for any detid, update the payload
243  if (tmpBadRocLists[detid] != (FEDerror25Map_[previousLumi])[detid]) {
244  sameAsLastIOV = false;
245  break; // jump out of the loop once a new payload is found
246  }
247  }
248 
249  if (sameAsLastIOV == false) {
250  //only write new IOV when this Lumi's FEDerror25 ROC list is not equal to the previous one
251  FEDerror25Map_[tmpLumi] = tmpBadRocLists;
252  // and reset
253  previousLumi = tmpLumi;
254  sameAsLastIOV = true;
255  }
256  }
257 }

References FEDerror25Map_, SiPixelDetectorStatus::getFEDerror25Rocs(), GetRecoTauVFromDQM_MC_cff::next, and siPixelStatusVtr_.

Referenced by createPayloads().

◆ createPayloads()

void SiPixelStatusManager::createPayloads ( )

Definition at line 56 of file SiPixelStatusManager.cc.

56  {
57  //only create std::map payloads when the number of non-zero DIGI lumi sections is greater than ZERO otherwise segmentation fault
58  if (!siPixelStatusVtr_.empty()) {
59  // sort the vector according to lumi
61 
62  // create FEDerror25 ROCs and bad ROCs from PCL
65 
66  // realse the cost of siPixelStatusVtr_ since it is not needed anymore
67  siPixelStatusVtr_.clear();
68  }
69 }

References createBadComponents(), createFEDerror25(), rankByLumi(), and siPixelStatusVtr_.

Referenced by SiPixelStatusHarvester::dqmEndRun().

◆ getBadComponents()

const std::map<edm::LuminosityBlockNumber_t, SiPixelDetectorStatus>& SiPixelStatusManager::getBadComponents ( )
inline

Definition at line 35 of file SiPixelStatusManager.h.

35 { return siPixelStatusMap_; }

References siPixelStatusMap_.

Referenced by SiPixelStatusHarvester::dqmEndRun().

◆ getFEDerror25Rocs()

const std::map<edm::LuminosityBlockNumber_t, std::map<int, std::vector<int> > >& SiPixelStatusManager::getFEDerror25Rocs ( )
inline

Definition at line 36 of file SiPixelStatusManager.h.

36  {
37  return FEDerror25Map_;
38  }

References FEDerror25Map_.

Referenced by SiPixelStatusHarvester::dqmEndRun().

◆ rankByLumi()

bool SiPixelStatusManager::rankByLumi ( SiPixelDetectorStatus  status1,
SiPixelDetectorStatus  status2 
)
staticprivate

Definition at line 52 of file SiPixelStatusManager.cc.

52  {
53  return (status1.getLSRange().first < status2.getLSRange().first);
54 }

References SiPixelDetectorStatus::getLSRange().

Referenced by createPayloads().

◆ readLumi()

void SiPixelStatusManager::readLumi ( const edm::LuminosityBlock iLumi)

Definition at line 72 of file SiPixelStatusManager.cc.

72  {
73  edm::Handle<SiPixelDetectorStatus> siPixelStatusHandle;
74  iLumi.getByToken(siPixelStatusToken_, siPixelStatusHandle);
75 
76  if (siPixelStatusHandle.isValid()) { // check the product
77  SiPixelDetectorStatus tmpStatus = (*siPixelStatusHandle);
78  if (tmpStatus.digiOccDET() > 0) { // only put in SiPixelDetectorStatus with non zero digi (pixel hit)
79  siPixelStatusVtr_.push_back(tmpStatus);
80  }
81  } else {
82  edm::LogWarning("SiPixelStatusManager") << " SiPixelDetectorStatus is not valid for run " << iLumi.run() << " lumi "
83  << iLumi.luminosityBlock() << std::endl;
84  }
85 }

References SiPixelDetectorStatus::digiOccDET(), edm::LuminosityBlock::getByToken(), edm::HandleBase::isValid(), edm::LuminosityBlockBase::luminosityBlock(), edm::LuminosityBlockBase::run(), siPixelStatusToken_, and siPixelStatusVtr_.

Referenced by SiPixelStatusHarvester::endLuminosityBlock().

◆ reset()

void SiPixelStatusManager::reset ( void  )

Member Data Documentation

◆ aveDigiOcc_

int SiPixelStatusManager::aveDigiOcc_
private

Definition at line 54 of file SiPixelStatusManager.h.

Referenced by createBadComponents().

◆ FEDerror25Map_

std::map<edm::LuminosityBlockNumber_t, std::map<int, std::vector<int> > > SiPixelStatusManager::FEDerror25Map_
private

Definition at line 51 of file SiPixelStatusManager.h.

Referenced by createFEDerror25(), and getFEDerror25Rocs().

◆ label_

std::string SiPixelStatusManager::label_
private

◆ moduleName_

std::string SiPixelStatusManager::moduleName_
private

Definition at line 56 of file SiPixelStatusManager.h.

Referenced by SiPixelStatusManager().

◆ nLumi_

int SiPixelStatusManager::nLumi_
private

Definition at line 55 of file SiPixelStatusManager.h.

Referenced by createBadComponents().

◆ outputBase_

std::string SiPixelStatusManager::outputBase_
private

Definition at line 53 of file SiPixelStatusManager.h.

Referenced by createBadComponents(), and SiPixelStatusManager().

◆ siPixelStatusMap_

std::map<edm::LuminosityBlockNumber_t, SiPixelDetectorStatus> SiPixelStatusManager::siPixelStatusMap_
private

Definition at line 50 of file SiPixelStatusManager.h.

Referenced by createBadComponents(), getBadComponents(), and reset().

◆ siPixelStatusToken_

edm::EDGetTokenT<SiPixelDetectorStatus> SiPixelStatusManager::siPixelStatusToken_
private

Definition at line 59 of file SiPixelStatusManager.h.

Referenced by readLumi(), and SiPixelStatusManager().

◆ siPixelStatusVtr_

std::vector<SiPixelDetectorStatus> SiPixelStatusManager::siPixelStatusVtr_
private
SiPixelStatusManager::siPixelStatusToken_
edm::EDGetTokenT< SiPixelDetectorStatus > siPixelStatusToken_
Definition: SiPixelStatusManager.h:59
counter
Definition: counter.py:1
SiPixelStatusManager::reset
void reset()
Definition: SiPixelStatusManager.cc:46
SiPixelStatusManager::rankByLumi
static bool rankByLumi(SiPixelDetectorStatus status1, SiPixelDetectorStatus status2)
Definition: SiPixelStatusManager.cc:52
SiPixelDetectorStatus::getFEDerror25Rocs
std::map< int, std::vector< int > > getFEDerror25Rocs()
Definition: SiPixelDetectorStatus.cc:127
SiPixelStatusManager::siPixelStatusVtr_iterator
std::vector< SiPixelDetectorStatus >::iterator siPixelStatusVtr_iterator
Definition: SiPixelStatusManager.h:42
edm::ParameterSet::getUntrackedParameter
T getUntrackedParameter(std::string const &, T const &) const
SiPixelDetectorStatus::setLSRange
void setLSRange(int ls0, int ls1)
Definition: SiPixelDetectorStatus.h:63
edm::LuminosityBlockBase::run
RunNumber_t run() const
Definition: LuminosityBlockBase.h:42
edm::LogInfo
Log< level::Info, false > LogInfo
Definition: MessageLogger.h:125
SiPixelStatusManager::aveDigiOcc_
int aveDigiOcc_
Definition: SiPixelStatusManager.h:54
edm::Handle
Definition: AssociativeIterator.h:50
edm::LuminosityBlockNumber_t
unsigned int LuminosityBlockNumber_t
Definition: RunLumiEventNumber.h:13
edm::LogWarning
Log< level::Warning, false > LogWarning
Definition: MessageLogger.h:122
SiPixelStatusManager::siPixelStatusMap_iterator
std::map< edm::LuminosityBlockNumber_t, SiPixelDetectorStatus >::iterator siPixelStatusMap_iterator
Definition: SiPixelStatusManager.h:40
SiPixelStatusManager::siPixelStatusVtr_
std::vector< SiPixelDetectorStatus > siPixelStatusVtr_
Definition: SiPixelStatusManager.h:49
SiPixelDetectorStatus
Definition: SiPixelDetectorStatus.h:11
edm::LuminosityBlock::getByToken
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: LuminosityBlock.h:319
AlCaHarvesting_cff.aveDigiOcc
aveDigiOcc
Definition: AlCaHarvesting_cff.py:179
SiPixelStatusManager::nLumi_
int nLumi_
Definition: SiPixelStatusManager.h:55
edm::LuminosityBlockBase::luminosityBlock
LuminosityBlockNumber_t luminosityBlock() const
Definition: LuminosityBlockBase.h:40
SiPixelDetectorStatus::getLSRange
std::pair< int, int > getLSRange()
Definition: SiPixelDetectorStatus.h:67
SiPixelStatusManager::createBadComponents
void createBadComponents()
Definition: SiPixelStatusManager.cc:88
edm::ConsumesCollector::consumes
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
Definition: ConsumesCollector.h:55
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
SiPixelStatusManager::label_
std::string label_
Definition: SiPixelStatusManager.h:57
edm::ParameterSet
Definition: ParameterSet.h:47
edm::InLumi
Definition: BranchType.h:11
SiPixelStatusManager::FEDerror25Map_
std::map< edm::LuminosityBlockNumber_t, std::map< int, std::vector< int > > > FEDerror25Map_
Definition: SiPixelStatusManager.h:51
SiPixelDetectorStatus::updateDetectorStatus
void updateDetectorStatus(SiPixelDetectorStatus newData)
Definition: SiPixelDetectorStatus.cc:207
SiPixelStatusManager::createFEDerror25
void createFEDerror25()
Definition: SiPixelStatusManager.cc:218
SiPixelStatusManager::outputBase_
std::string outputBase_
Definition: SiPixelStatusManager.h:53
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
SiPixelDetectorStatus::perRocDigiOcc
double perRocDigiOcc()
Definition: SiPixelDetectorStatus.cc:174
SiPixelStatusManager::siPixelStatusMap_
std::map< edm::LuminosityBlockNumber_t, SiPixelDetectorStatus > siPixelStatusMap_
Definition: SiPixelStatusManager.h:50
SiPixelDetectorStatus::digiOccDET
unsigned long int digiOccDET()
Definition: SiPixelDetectorStatus.h:45
edm::HandleBase::isValid
bool isValid() const
Definition: HandleBase.h:70
edm::InputTag
Definition: InputTag.h:15
GetRecoTauVFromDQM_MC_cff.next
next
Definition: GetRecoTauVFromDQM_MC_cff.py:31
SiPixelStatusManager::moduleName_
std::string moduleName_
Definition: SiPixelStatusManager.h:56