CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_6_2_5/src/CondFormats/SiPixelObjects/src/SiPixelCalibConfiguration.cc

Go to the documentation of this file.
00001 #include "CondFormats/SiPixelObjects/interface/SiPixelCalibConfiguration.h"
00002 #include "CalibFormats/SiPixelObjects/interface/PixelCalibConfiguration.h"
00003 #include <cstdlib>
00004 
00005 short SiPixelCalibConfiguration::vcalIndexForEvent(const uint32_t & eventnumber) const{
00006   uint32_t relative_event = abs(eventnumber-1)%patternSize();
00007   short relative_pattern = relative_event/getNTriggers();
00008   return relative_pattern; 
00009 }
00010 short SiPixelCalibConfiguration::vcalForEvent(const uint32_t & eventnumber) const{
00011   short result = fVCalValues[vcalIndexForEvent(eventnumber)];
00012   return result;
00013 }
00014 std::vector<short> SiPixelCalibConfiguration::columnPatternForEvent(const uint32_t & eventnumber) const{
00015   std::vector<short> result;
00016   uint32_t patternnumber = eventnumber/patternSize();
00017   uint32_t colpatternnumber = patternnumber%nColumnPatterns();
00018 
00019   uint32_t nminuscol=0;
00020   for(size_t icol=0; icol<fColumnPattern.size(); icol++){
00021     if(fColumnPattern[icol]==-1)
00022       nminuscol++;
00023     else if(nminuscol>colpatternnumber)
00024       break;
00025     else if(nminuscol==colpatternnumber){
00026       short val = fColumnPattern[icol];
00027       result.push_back(val);
00028     }
00029   }
00030   return result;
00031 }
00032 
00033 std::vector<short> SiPixelCalibConfiguration::rowPatternForEvent(const uint32_t & eventnumber) const {
00034   std::vector<short> result;
00035   uint32_t patternnumber = eventnumber/patternSize();
00036   uint32_t rowpatternnumber = patternnumber/nColumnPatterns();
00037 
00038   uint32_t nminusrow=0;
00039   for(size_t irow=0; irow<fRowPattern.size(); irow++){
00040     if(fRowPattern[irow]==-1)
00041       nminusrow++;
00042     else if(nminusrow>rowpatternnumber)
00043       break;
00044     else if(nminusrow==rowpatternnumber){
00045       short val = fRowPattern[irow];
00046       result.push_back(val);
00047     }
00048   }
00049   return result;
00050 }
00051 uint32_t SiPixelCalibConfiguration::nextPatternChangeForEvent(const uint32_t & eventnumber) const {
00052   uint32_t relative_event = eventnumber/patternSize();
00053   relative_event+=1;
00054   return relative_event*patternSize();
00055 }
00056 uint32_t SiPixelCalibConfiguration::expectedTotalEvents() const {
00057   return patternSize()*nPatterns();
00058 }
00059 
00060 SiPixelCalibConfiguration::SiPixelCalibConfiguration(const pos::PixelCalibConfiguration &fancyConfig):
00061   fNTriggers(0),
00062   fRowPattern(std::vector<short>(0)),
00063   fColumnPattern(std::vector<short>(0)),
00064   fVCalValues(std::vector<short>(0)),
00065   fMode("unknown")
00066 
00067 { // copy constructor that uses the complex object
00068   fNTriggers = fancyConfig.nTriggersPerPattern();
00069   std::vector<int> vcalpoints(0);
00070   std::cout << "scan name = " << fancyConfig.scanName(0) << std::endl;
00071   std::vector<uint32_t> vcalpointsuint32 = fancyConfig.scanValues(fancyConfig.scanName(0));
00072   for(size_t ical=0; ical<vcalpointsuint32.size(); ++ical){
00073     short vcalinput = vcalpointsuint32[ical];
00074   
00075     std::cout << "Vcal value " << ical << " = " << vcalinput << std::endl;
00076     fVCalValues.push_back(vcalinput);
00077   }
00078   // copy row and column patterns
00079 
00080   std::vector<std::vector<uint32_t> > cols=fancyConfig.columnList();
00081   std::vector<std::vector<uint32_t> > rows= fancyConfig.rowList();
00082   for(uint32_t i=0; i<cols.size(); ++i){
00083     for(uint32_t j=0; j<cols[i].size(); ++j){
00084       short colval = cols[i][j];
00085       fColumnPattern.push_back(colval);
00086     }
00087     fColumnPattern.push_back(-1);
00088   }
00089   for(uint32_t i=0; i<rows.size(); ++i){
00090     for(uint32_t j=0; j<rows[i].size(); ++j){
00091       short rowval = rows[i][j];
00092       fRowPattern.push_back(rowval);
00093     }
00094     fRowPattern.push_back(-1);
00095   }
00096   fMode = fancyConfig.mode();
00097 }
00098 
00099 uint32_t SiPixelCalibConfiguration::nRowPatterns() const{
00100  uint32_t nrows = 0;
00101  for(std::vector<short>::const_iterator i=fRowPattern.begin();i!=fRowPattern.end();++i){
00102    if(*i == -1)
00103     nrows++;
00104   }
00105   return nrows;
00106 }
00107 uint32_t SiPixelCalibConfiguration::nColumnPatterns() const{
00108   uint32_t ncols = 0;
00109   
00110   for(std::vector<short>::const_iterator i=fColumnPattern.begin();i!=fColumnPattern.end();++i){
00111     if(*i == -1)
00112     ncols++;
00113   }
00114   return ncols;
00115 }
00116