Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:51:32

0001 #include "CondFormats/SiPixelObjects/interface/SiPixelCalibConfiguration.h"
0002 #include "CalibFormats/SiPixelObjects/interface/PixelCalibConfiguration.h"
0003 #include <cstdlib>
0004 
0005 short SiPixelCalibConfiguration::vcalIndexForEvent(const uint32_t &eventnumber) const {
0006   uint32_t relative_event = std::abs((int32_t)eventnumber - 1) % patternSize();
0007   short relative_pattern = relative_event / getNTriggers();
0008   return relative_pattern;
0009 }
0010 short SiPixelCalibConfiguration::vcalForEvent(const uint32_t &eventnumber) const {
0011   short result = fVCalValues[vcalIndexForEvent(eventnumber)];
0012   return result;
0013 }
0014 std::vector<short> SiPixelCalibConfiguration::columnPatternForEvent(const uint32_t &eventnumber) const {
0015   std::vector<short> result;
0016   uint32_t patternnumber = eventnumber / patternSize();
0017   uint32_t colpatternnumber = patternnumber % nColumnPatterns();
0018 
0019   uint32_t nminuscol = 0;
0020   for (size_t icol = 0; icol < fColumnPattern.size(); icol++) {
0021     if (fColumnPattern[icol] == -1)
0022       nminuscol++;
0023     else if (nminuscol > colpatternnumber)
0024       break;
0025     else if (nminuscol == colpatternnumber) {
0026       short val = fColumnPattern[icol];
0027       result.push_back(val);
0028     }
0029   }
0030   return result;
0031 }
0032 
0033 std::vector<short> SiPixelCalibConfiguration::rowPatternForEvent(const uint32_t &eventnumber) const {
0034   std::vector<short> result;
0035   uint32_t patternnumber = eventnumber / patternSize();
0036   uint32_t rowpatternnumber = patternnumber / nColumnPatterns();
0037 
0038   uint32_t nminusrow = 0;
0039   for (size_t irow = 0; irow < fRowPattern.size(); irow++) {
0040     if (fRowPattern[irow] == -1)
0041       nminusrow++;
0042     else if (nminusrow > rowpatternnumber)
0043       break;
0044     else if (nminusrow == rowpatternnumber) {
0045       short val = fRowPattern[irow];
0046       result.push_back(val);
0047     }
0048   }
0049   return result;
0050 }
0051 uint32_t SiPixelCalibConfiguration::nextPatternChangeForEvent(const uint32_t &eventnumber) const {
0052   uint32_t relative_event = eventnumber / patternSize();
0053   relative_event += 1;
0054   return relative_event * patternSize();
0055 }
0056 uint32_t SiPixelCalibConfiguration::expectedTotalEvents() const { return patternSize() * nPatterns(); }
0057 
0058 SiPixelCalibConfiguration::SiPixelCalibConfiguration(const pos::PixelCalibConfiguration &fancyConfig)
0059     : fNTriggers(0),
0060       fRowPattern(std::vector<short>(0)),
0061       fColumnPattern(std::vector<short>(0)),
0062       fVCalValues(std::vector<short>(0)),
0063       fMode("unknown")
0064 
0065 {  // copy constructor that uses the complex object
0066   fNTriggers = fancyConfig.nTriggersPerPattern();
0067   std::vector<int> vcalpoints(0);
0068   std::cout << "scan name = " << fancyConfig.scanName(0) << std::endl;
0069   std::vector<uint32_t> vcalpointsuint32 = fancyConfig.scanValues(fancyConfig.scanName(0));
0070   for (size_t ical = 0; ical < vcalpointsuint32.size(); ++ical) {
0071     short vcalinput = vcalpointsuint32[ical];
0072 
0073     std::cout << "Vcal value " << ical << " = " << vcalinput << std::endl;
0074     fVCalValues.push_back(vcalinput);
0075   }
0076   // copy row and column patterns
0077 
0078   std::vector<std::vector<uint32_t> > cols = fancyConfig.columnList();
0079   std::vector<std::vector<uint32_t> > rows = fancyConfig.rowList();
0080   for (uint32_t i = 0; i < cols.size(); ++i) {
0081     for (uint32_t j = 0; j < cols[i].size(); ++j) {
0082       short colval = cols[i][j];
0083       fColumnPattern.push_back(colval);
0084     }
0085     fColumnPattern.push_back(-1);
0086   }
0087   for (uint32_t i = 0; i < rows.size(); ++i) {
0088     for (uint32_t j = 0; j < rows[i].size(); ++j) {
0089       short rowval = rows[i][j];
0090       fRowPattern.push_back(rowval);
0091     }
0092     fRowPattern.push_back(-1);
0093   }
0094   fMode = fancyConfig.mode();
0095 }
0096 
0097 uint32_t SiPixelCalibConfiguration::nRowPatterns() const {
0098   uint32_t nrows = 0;
0099   for (std::vector<short>::const_iterator i = fRowPattern.begin(); i != fRowPattern.end(); ++i) {
0100     if (*i == -1)
0101       nrows++;
0102   }
0103   return nrows;
0104 }
0105 uint32_t SiPixelCalibConfiguration::nColumnPatterns() const {
0106   uint32_t ncols = 0;
0107 
0108   for (std::vector<short>::const_iterator i = fColumnPattern.begin(); i != fColumnPattern.end(); ++i) {
0109     if (*i == -1)
0110       ncols++;
0111   }
0112   return ncols;
0113 }