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

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

Definition at line 40 of file SiPixelStatusManager.h.

Definition at line 39 of file SiPixelStatusManager.h.

Definition at line 41 of file SiPixelStatusManager.h.

Constructor & Destructor Documentation

SiPixelStatusManager::SiPixelStatusManager ( )

Definition at line 21 of file SiPixelStatusManager.cc.

21  {
22 }
SiPixelStatusManager::SiPixelStatusManager ( const edm::ParameterSet iConfig,
edm::ConsumesCollector &&  iC 
)

Definition at line 25 of file SiPixelStatusManager.cc.

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

25  :
26  outputBase_(iConfig.getParameter<ParameterSet>("SiPixelStatusManagerParameters").getUntrackedParameter<std::string>("outputBase")),
27  aveDigiOcc_(iConfig.getParameter<edm::ParameterSet>("SiPixelStatusManagerParameters").getUntrackedParameter<int>("aveDigiOcc")),
28  nLumi_(iConfig.getParameter<edm::ParameterSet>("SiPixelStatusManagerParameters").getUntrackedParameter<int>("resetEveryNLumi")),
29  moduleName_(iConfig.getParameter<ParameterSet>("SiPixelStatusManagerParameters").getUntrackedParameter<std::string>("moduleName")),
30  label_ (iConfig.getParameter<ParameterSet>("SiPixelStatusManagerParameters").getUntrackedParameter<std::string>("label"))
31 {
32 
33  edm::InputTag siPixelStatusTag_(moduleName_, label_);
35 
36  LogInfo("SiPixelStatusManager")
37  << "Output base: " << outputBase_
38  << std::endl;
39  reset();
40 }
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
edm::EDGetTokenT< SiPixelDetectorStatus > siPixelStatusToken_
SiPixelStatusManager::~SiPixelStatusManager ( )
virtual

Definition at line 43 of file SiPixelStatusManager.cc.

43  {
44 }

Member Function Documentation

void SiPixelStatusManager::createBadComponents ( )
private

Definition at line 93 of file SiPixelStatusManager.cc.

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

Referenced by createPayloads().

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

Definition at line 241 of file SiPixelStatusManager.cc.

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

Referenced by createPayloads().

241  {
242 
243  // initialize the first IOV and SiPixelDetector status (in the first IOV)
244  siPixelStatusVtr_iterator firstStatus = siPixelStatusVtr_.begin();
245  edm::LuminosityBlockNumber_t firstLumi = edm::LuminosityBlockNumber_t(firstStatus->getLSRange().first);
246  SiPixelDetectorStatus firstFEDerror25 = (*firstStatus);
247  FEDerror25Map_[firstLumi] = firstFEDerror25.getFEDerror25Rocs();
248 
249  siPixelStatusVtr_iterator lastStatus = siPixelStatusVtr_.end();
250 
252  bool sameAsLastIOV = true;
253  edm::LuminosityBlockNumber_t previousLumi = firstLumi;
254 
255  siPixelStatusVtr_iterator secondStatus = std::next(siPixelStatusVtr_.begin());
256  for (siPixelStatusVtr_iterator it = secondStatus; it != lastStatus; it++) {
257  // init for each lumi section (iterator)
258  edm::LuminosityBlockNumber_t tmpLumi = edm::LuminosityBlockNumber_t(it->getLSRange().first);
259  SiPixelDetectorStatus tmpFEDerror25 = (*it);
260 
261  std::map<int,std::vector<int> >tmpBadRocLists = tmpFEDerror25.getFEDerror25Rocs();
262 
263  std::map<int, SiPixelModuleStatus>::iterator itModEnd = tmpFEDerror25.end();
264  for (std::map<int, SiPixelModuleStatus>::iterator itMod = tmpFEDerror25.begin(); itMod != itModEnd; ++itMod)
265  {
266  int detid = itMod->first;
267  // if the badroc list differs for any detid, update the payload
268  if(tmpBadRocLists[detid]!=(FEDerror25Map_[previousLumi])[detid]){
269  sameAsLastIOV = false;
270  break; // jump out of the loop once a new payload is found
271  }
272  }
273 
274  if(sameAsLastIOV==false){
275  //only write new IOV when this Lumi's FEDerror25 ROC list is not equal to the previous one
276  FEDerror25Map_[tmpLumi] = tmpBadRocLists;
277  // and reset
278  previousLumi = tmpLumi;
279  sameAsLastIOV = true;
280 
281  }
282 
283  }
284 
285 }
std::map< int, std::vector< int > > getFEDerror25Rocs()
unsigned int LuminosityBlockNumber_t
std::vector< SiPixelDetectorStatus >::iterator siPixelStatusVtr_iterator
std::map< edm::LuminosityBlockNumber_t, std::map< int, std::vector< int > > > FEDerror25Map_
std::vector< SiPixelDetectorStatus > siPixelStatusVtr_
void SiPixelStatusManager::createPayloads ( )

Definition at line 56 of file SiPixelStatusManager.cc.

References createBadComponents(), createFEDerror25(), rankByLumi(), siPixelStatusVtr_, and jetUpdater_cfi::sort.

Referenced by SiPixelStatusHarvester::endRunProduce().

56  {
57  if(!siPixelStatusVtr_.empty()){ //only create std::map payloads when the number of non-zero DIGI lumi sections is greater than ZERO otherwise segmentation fault
58 
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  }
70 
71 }
std::vector< SiPixelDetectorStatus > siPixelStatusVtr_
static bool rankByLumi(SiPixelDetectorStatus status1, SiPixelDetectorStatus status2)
const std::map<edm::LuminosityBlockNumber_t,SiPixelDetectorStatus>& SiPixelStatusManager::getBadComponents ( )
inline

Definition at line 36 of file SiPixelStatusManager.h.

References siPixelStatusMap_.

Referenced by SiPixelStatusHarvester::endRunProduce().

36 {return siPixelStatusMap_; }
std::map< edm::LuminosityBlockNumber_t, SiPixelDetectorStatus > siPixelStatusMap_
const std::map<edm::LuminosityBlockNumber_t,std::map<int, std::vector<int> > >& SiPixelStatusManager::getFEDerror25Rocs ( )
inline

Definition at line 37 of file SiPixelStatusManager.h.

References FEDerror25Map_.

Referenced by SiPixelStatusHarvester::endRunProduce().

37 {return FEDerror25Map_;}
std::map< edm::LuminosityBlockNumber_t, std::map< int, std::vector< int > > > FEDerror25Map_
bool SiPixelStatusManager::rankByLumi ( SiPixelDetectorStatus  status1,
SiPixelDetectorStatus  status2 
)
staticprivate

Definition at line 53 of file SiPixelStatusManager.cc.

References SiPixelDetectorStatus::getLSRange().

Referenced by createPayloads().

54 { return (status1.getLSRange().first < status2.getLSRange().first); }
std::pair< int, int > getLSRange()
void SiPixelStatusManager::readLumi ( const edm::LuminosityBlock iLumi)

Definition at line 74 of file SiPixelStatusManager.cc.

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

Referenced by SiPixelStatusHarvester::endLuminosityBlock().

74  {
75 
76  edm::Handle<SiPixelDetectorStatus> siPixelStatusHandle;
77  iLumi.getByToken(siPixelStatusToken_, siPixelStatusHandle);
78 
79  if(siPixelStatusHandle.isValid()) { // check the product
80  SiPixelDetectorStatus tmpStatus = (*siPixelStatusHandle);
81  if(tmpStatus.digiOccDET()>0){ // only put in SiPixelDetectorStatus with non zero digi (pixel hit)
82  siPixelStatusVtr_.push_back(tmpStatus);
83  }
84  }
85  else {
86  edm::LogWarning("SiPixelStatusManager")
87  << " SiPixelDetectorStatus is not valid for run "<<iLumi.run()<<" lumi "<<iLumi.luminosityBlock()<< std::endl;
88  }
89 
90 }
bool getByToken(EDGetToken token, Handle< PROD > &result) const
unsigned long int digiOccDET()
edm::EDGetTokenT< SiPixelDetectorStatus > siPixelStatusToken_
LuminosityBlockNumber_t luminosityBlock() const
RunNumber_t run() const
bool isValid() const
Definition: HandleBase.h:74
std::vector< SiPixelDetectorStatus > siPixelStatusVtr_
void SiPixelStatusManager::reset ( void  )

Definition at line 47 of file SiPixelStatusManager.cc.

References siPixelStatusMap_, and siPixelStatusVtr_.

Referenced by MatrixReader.MatrixReader::__init__(), data_sources.json_list::next(), MatrixReader.MatrixReader::showRaw(), SiPixelStatusHarvester::SiPixelStatusHarvester(), and SiPixelStatusManager().

47  {
48  siPixelStatusMap_.clear();
49  siPixelStatusVtr_.clear();
50 }
std::vector< SiPixelDetectorStatus > siPixelStatusVtr_
std::map< edm::LuminosityBlockNumber_t, SiPixelDetectorStatus > siPixelStatusMap_

Member Data Documentation

int SiPixelStatusManager::aveDigiOcc_
private

Definition at line 54 of file SiPixelStatusManager.h.

Referenced by createBadComponents().

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().

std::string SiPixelStatusManager::label_
private
std::string SiPixelStatusManager::moduleName_
private

Definition at line 56 of file SiPixelStatusManager.h.

Referenced by SiPixelStatusManager().

int SiPixelStatusManager::nLumi_
private

Definition at line 55 of file SiPixelStatusManager.h.

Referenced by createBadComponents().

std::string SiPixelStatusManager::outputBase_
private

Definition at line 53 of file SiPixelStatusManager.h.

Referenced by createBadComponents(), and SiPixelStatusManager().

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

Definition at line 50 of file SiPixelStatusManager.h.

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

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

Definition at line 59 of file SiPixelStatusManager.h.

Referenced by readLumi(), and SiPixelStatusManager().

std::vector<SiPixelDetectorStatus> SiPixelStatusManager::siPixelStatusVtr_
private